xz-clib (empty) → 5.6.3
raw patch · 178 files changed
+81603/−0 lines, 178 filessetup-changed
Files
- Changelog.md +7/−0
- Setup.hs +2/−0
- build/autoconf/config.guess +1807/−0
- build/autoconf/config.rpath +684/−0
- build/autoconf/config.sub +1960/−0
- build/autoconf/install-sh +541/−0
- build/autoconf/ltmain.sh +11436/−0
- cbits/LICENSE +11/−0
- cbits/common/mythread.h +548/−0
- cbits/common/sysdefs.h +199/−0
- cbits/common/tuklib_common.h +90/−0
- cbits/common/tuklib_config.h +12/−0
- cbits/common/tuklib_cpucores.c +108/−0
- cbits/common/tuklib_cpucores.h +22/−0
- cbits/common/tuklib_exit.c +57/−0
- cbits/common/tuklib_exit.h +24/−0
- cbits/common/tuklib_gettext.h +43/−0
- cbits/common/tuklib_integer.h +954/−0
- cbits/common/tuklib_mbstr.h +65/−0
- cbits/common/tuklib_mbstr_fw.c +30/−0
- cbits/common/tuklib_mbstr_width.c +64/−0
- cbits/common/tuklib_open_stdxxx.c +56/−0
- cbits/common/tuklib_open_stdxxx.h +22/−0
- cbits/common/tuklib_physmem.c +231/−0
- cbits/common/tuklib_physmem.h +27/−0
- cbits/common/tuklib_progname.c +49/−0
- cbits/common/tuklib_progname.h +31/−0
- cbits/config.h.in +625/−0
- cbits/liblzma/api/lzma.h +327/−0
- cbits/liblzma/api/lzma/base.h +747/−0
- cbits/liblzma/api/lzma/bcj.h +98/−0
- cbits/liblzma/api/lzma/block.h +694/−0
- cbits/liblzma/api/lzma/check.h +163/−0
- cbits/liblzma/api/lzma/container.h +995/−0
- cbits/liblzma/api/lzma/delta.h +95/−0
- cbits/liblzma/api/lzma/filter.h +769/−0
- cbits/liblzma/api/lzma/hardware.h +62/−0
- cbits/liblzma/api/lzma/index.h +882/−0
- cbits/liblzma/api/lzma/index_hash.h +123/−0
- cbits/liblzma/api/lzma/lzma12.h +568/−0
- cbits/liblzma/api/lzma/stream_flags.h +265/−0
- cbits/liblzma/api/lzma/version.h +134/−0
- cbits/liblzma/api/lzma/vli.h +166/−0
- cbits/liblzma/check/check.c +173/−0
- cbits/liblzma/check/check.h +174/−0
- cbits/liblzma/check/crc32_arm64.h +122/−0
- cbits/liblzma/check/crc32_fast.c +204/−0
- cbits/liblzma/check/crc32_small.c +67/−0
- cbits/liblzma/check/crc32_table.c +42/−0
- cbits/liblzma/check/crc32_table_be.h +527/−0
- cbits/liblzma/check/crc32_table_le.h +527/−0
- cbits/liblzma/check/crc32_tablegen.c +120/−0
- cbits/liblzma/check/crc64_fast.c +156/−0
- cbits/liblzma/check/crc64_small.c +57/−0
- cbits/liblzma/check/crc64_table.c +37/−0
- cbits/liblzma/check/crc64_table_be.h +523/−0
- cbits/liblzma/check/crc64_table_le.h +523/−0
- cbits/liblzma/check/crc64_tablegen.c +89/−0
- cbits/liblzma/check/crc_common.h +137/−0
- cbits/liblzma/check/crc_x86_clmul.h +432/−0
- cbits/liblzma/check/sha256.c +189/−0
- cbits/liblzma/common/alone_decoder.c +248/−0
- cbits/liblzma/common/alone_decoder.h +22/−0
- cbits/liblzma/common/alone_encoder.c +151/−0
- cbits/liblzma/common/auto_decoder.c +205/−0
- cbits/liblzma/common/block_buffer_decoder.c +79/−0
- cbits/liblzma/common/block_buffer_encoder.c +354/−0
- cbits/liblzma/common/block_buffer_encoder.h +23/−0
- cbits/liblzma/common/block_decoder.c +288/−0
- cbits/liblzma/common/block_decoder.h +21/−0
- cbits/liblzma/common/block_encoder.c +226/−0
- cbits/liblzma/common/block_encoder.h +46/−0
- cbits/liblzma/common/block_header_decoder.c +114/−0
- cbits/liblzma/common/block_header_encoder.c +131/−0
- cbits/liblzma/common/block_util.c +89/−0
- cbits/liblzma/common/common.c +480/−0
- cbits/liblzma/common/common.h +412/−0
- cbits/liblzma/common/easy_buffer_encoder.c +26/−0
- cbits/liblzma/common/easy_decoder_memusage.c +23/−0
- cbits/liblzma/common/easy_encoder.c +23/−0
- cbits/liblzma/common/easy_encoder_memusage.c +23/−0
- cbits/liblzma/common/easy_preset.c +26/−0
- cbits/liblzma/common/easy_preset.h +36/−0
- cbits/liblzma/common/file_info.c +854/−0
- cbits/liblzma/common/filter_buffer_decoder.c +87/−0
- cbits/liblzma/common/filter_buffer_encoder.c +54/−0
- cbits/liblzma/common/filter_common.c +393/−0
- cbits/liblzma/common/filter_common.h +50/−0
- cbits/liblzma/common/filter_decoder.c +214/−0
- cbits/liblzma/common/filter_decoder.h +22/−0
- cbits/liblzma/common/filter_encoder.c +330/−0
- cbits/liblzma/common/filter_encoder.h +22/−0
- cbits/liblzma/common/filter_flags_decoder.c +45/−0
- cbits/liblzma/common/filter_flags_encoder.c +55/−0
- cbits/liblzma/common/hardware_cputhreads.c +33/−0
- cbits/liblzma/common/hardware_physmem.c +24/−0
- cbits/liblzma/common/index.c +1268/−0
- cbits/liblzma/common/index.h +80/−0
- cbits/liblzma/common/index_decoder.c +372/−0
- cbits/liblzma/common/index_decoder.h +24/−0
- cbits/liblzma/common/index_encoder.c +262/−0
- cbits/liblzma/common/index_encoder.h +22/−0
- cbits/liblzma/common/index_hash.c +342/−0
- cbits/liblzma/common/lzip_decoder.c +417/−0
- cbits/liblzma/common/lzip_decoder.h +21/−0
- cbits/liblzma/common/memcmplen.h +188/−0
- cbits/liblzma/common/microlzma_decoder.c +220/−0
- cbits/liblzma/common/microlzma_encoder.c +140/−0
- cbits/liblzma/common/outqueue.c +286/−0
- cbits/liblzma/common/outqueue.h +258/−0
- cbits/liblzma/common/stream_buffer_decoder.c +90/−0
- cbits/liblzma/common/stream_buffer_encoder.c +141/−0
- cbits/liblzma/common/stream_decoder.c +473/−0
- cbits/liblzma/common/stream_decoder.h +21/−0
- cbits/liblzma/common/stream_decoder_mt.c +2017/−0
- cbits/liblzma/common/stream_encoder.c +354/−0
- cbits/liblzma/common/stream_encoder_mt.c +1280/−0
- cbits/liblzma/common/stream_flags_common.c +46/−0
- cbits/liblzma/common/stream_flags_common.h +35/−0
- cbits/liblzma/common/stream_flags_decoder.c +87/−0
- cbits/liblzma/common/stream_flags_encoder.c +85/−0
- cbits/liblzma/common/string_conversion.c +1338/−0
- cbits/liblzma/common/vli_decoder.c +85/−0
- cbits/liblzma/common/vli_encoder.c +68/−0
- cbits/liblzma/common/vli_size.c +29/−0
- cbits/liblzma/delta/delta_common.c +72/−0
- cbits/liblzma/delta/delta_common.h +19/−0
- cbits/liblzma/delta/delta_decoder.c +87/−0
- cbits/liblzma/delta/delta_decoder.h +25/−0
- cbits/liblzma/delta/delta_encoder.c +132/−0
- cbits/liblzma/delta/delta_encoder.h +23/−0
- cbits/liblzma/delta/delta_private.h +36/−0
- cbits/liblzma/lz/lz_decoder.c +324/−0
- cbits/liblzma/lz/lz_decoder.h +250/−0
- cbits/liblzma/lz/lz_encoder.c +632/−0
- cbits/liblzma/lz/lz_encoder.h +352/−0
- cbits/liblzma/lz/lz_encoder_hash.h +108/−0
- cbits/liblzma/lz/lz_encoder_hash_table.h +70/−0
- cbits/liblzma/lz/lz_encoder_mf.c +744/−0
- cbits/liblzma/lzma/fastpos.h +141/−0
- cbits/liblzma/lzma/fastpos_table.c +521/−0
- cbits/liblzma/lzma/fastpos_tablegen.c +58/−0
- cbits/liblzma/lzma/lzma2_decoder.c +310/−0
- cbits/liblzma/lzma/lzma2_decoder.h +28/−0
- cbits/liblzma/lzma/lzma2_encoder.c +416/−0
- cbits/liblzma/lzma/lzma2_encoder.h +42/−0
- cbits/liblzma/lzma/lzma_common.h +240/−0
- cbits/liblzma/lzma/lzma_decoder.c +1263/−0
- cbits/liblzma/lzma/lzma_decoder.h +52/−0
- cbits/liblzma/lzma/lzma_encoder.c +786/−0
- cbits/liblzma/lzma/lzma_encoder.h +58/−0
- cbits/liblzma/lzma/lzma_encoder_optimum_fast.c +169/−0
- cbits/liblzma/lzma/lzma_encoder_optimum_normal.c +858/−0
- cbits/liblzma/lzma/lzma_encoder_presets.c +63/−0
- cbits/liblzma/lzma/lzma_encoder_private.h +161/−0
- cbits/liblzma/rangecoder/price.h +92/−0
- cbits/liblzma/rangecoder/price_table.c +24/−0
- cbits/liblzma/rangecoder/price_tablegen.c +93/−0
- cbits/liblzma/rangecoder/range_common.h +77/−0
- cbits/liblzma/rangecoder/range_decoder.h +966/−0
- cbits/liblzma/rangecoder/range_encoder.h +349/−0
- cbits/liblzma/simple/arm.c +74/−0
- cbits/liblzma/simple/arm64.c +136/−0
- cbits/liblzma/simple/armthumb.c +79/−0
- cbits/liblzma/simple/ia64.c +115/−0
- cbits/liblzma/simple/powerpc.c +79/−0
- cbits/liblzma/simple/riscv.c +755/−0
- cbits/liblzma/simple/simple_coder.c +291/−0
- cbits/liblzma/simple/simple_coder.h +89/−0
- cbits/liblzma/simple/simple_decoder.c +39/−0
- cbits/liblzma/simple/simple_decoder.h +21/−0
- cbits/liblzma/simple/simple_encoder.c +37/−0
- cbits/liblzma/simple/simple_encoder.h +22/−0
- cbits/liblzma/simple/simple_private.h +73/−0
- cbits/liblzma/simple/sparc.c +86/−0
- cbits/liblzma/simple/x86.c +157/−0
- configure +24571/−0
- xz-clib.cabal +168/−0
+ Changelog.md view
@@ -0,0 +1,7 @@+## 5.6.3++* Update to 5.6.3 upstream sources++## 5.2.5++* Fork cbits from `lzma-static`
+ Setup.hs view
@@ -0,0 +1,2 @@+import Distribution.Simple+main = defaultMainWithHooks autoconfUserHooks
+ build/autoconf/config.guess view
@@ -0,0 +1,1807 @@+#! /bin/sh+# Attempt to guess a canonical system name.+# Copyright 1992-2023 Free Software Foundation, Inc.++# shellcheck disable=SC2006,SC2268 # see below for rationale++timestamp='2023-08-22'++# This file 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 to the GNU General Public License, if you+# distribute this file as part of a program that contains a+# configuration script generated by Autoconf, you may include it under+# the same distribution terms that you use for the rest of that+# program. This Exception is an additional permission under section 7+# of the GNU General Public License, version 3 ("GPLv3").+#+# Originally written by Per Bothner; maintained since 2000 by Ben Elliston.+#+# You can get the latest version of this script from:+# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess+#+# Please send patches to <config-patches@gnu.org>.+++# The "shellcheck disable" line above the timestamp inhibits complaints+# about features and limitations of the classic Bourne shell that were+# superseded or lifted in POSIX. However, this script identifies a wide+# variety of pre-POSIX systems that do not have POSIX shells at all, and+# even some reasonably current systems (Solaris 10 as case-in-point) still+# have a pre-POSIX /bin/sh.+++me=`echo "$0" | sed -e 's,.*/,,'`++usage="\+Usage: $0 [OPTION]++Output the configuration name of the system '$me' is run on.++Options:+ -h, --help print this help, then exit+ -t, --time-stamp print date of last modification, then exit+ -v, --version print version number, then exit++Report bugs and patches to <config-patches@gnu.org>."++version="\+GNU config.guess ($timestamp)++Originally written by Per Bothner.+Copyright 1992-2023 Free Software Foundation, Inc.++This is free software; see the source for copying conditions. There is NO+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."++help="+Try '$me --help' for more information."++# Parse command line+while test $# -gt 0 ; do+ case $1 in+ --time-stamp | --time* | -t )+ echo "$timestamp" ; exit ;;+ --version | -v )+ echo "$version" ; exit ;;+ --help | --h* | -h )+ echo "$usage"; exit ;;+ -- ) # Stop option processing+ shift; break ;;+ - ) # Use stdin as input.+ break ;;+ -* )+ echo "$me: invalid option $1$help" >&2+ exit 1 ;;+ * )+ break ;;+ esac+done++if test $# != 0; then+ echo "$me: too many arguments$help" >&2+ exit 1+fi++# Just in case it came from the environment.+GUESS=++# CC_FOR_BUILD -- compiler used by this script. Note that the use of a+# compiler to aid in system detection is discouraged as it requires+# temporary files to be created and, as you can see below, it is a+# headache to deal with in a portable fashion.++# Historically, 'CC_FOR_BUILD' used to be named 'HOST_CC'. We still+# use 'HOST_CC' if defined, but it is deprecated.++# Portable tmp directory creation inspired by the Autoconf team.++tmp=+# shellcheck disable=SC2172+trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15++set_cc_for_build() {+ # prevent multiple calls if $tmp is already set+ test "$tmp" && return 0+ : "${TMPDIR=/tmp}"+ # shellcheck disable=SC2039,SC3028+ { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir "$tmp" 2>/dev/null) ; } ||+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir "$tmp" 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; }+ dummy=$tmp/dummy+ case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in+ ,,) echo "int x;" > "$dummy.c"+ for driver in cc gcc c89 c99 ; do+ if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then+ CC_FOR_BUILD=$driver+ break+ fi+ done+ if test x"$CC_FOR_BUILD" = x ; then+ CC_FOR_BUILD=no_compiler_found+ fi+ ;;+ ,,*) CC_FOR_BUILD=$CC ;;+ ,*,*) CC_FOR_BUILD=$HOST_CC ;;+ esac+}++# This is needed to find uname on a Pyramid OSx when run in the BSD universe.+# (ghazi@noc.rutgers.edu 1994-08-24)+if test -f /.attbin/uname ; then+ PATH=$PATH:/.attbin ; export PATH+fi++UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown+UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown++case $UNAME_SYSTEM in+Linux|GNU|GNU/*)+ LIBC=unknown++ set_cc_for_build+ cat <<-EOF > "$dummy.c"+ #if defined(__ANDROID__)+ LIBC=android+ #else+ #include <features.h>+ #if defined(__UCLIBC__)+ LIBC=uclibc+ #elif defined(__dietlibc__)+ LIBC=dietlibc+ #elif defined(__GLIBC__)+ LIBC=gnu+ #else+ #include <stdarg.h>+ /* First heuristic to detect musl libc. */+ #ifdef __DEFINED_va_list+ LIBC=musl+ #endif+ #endif+ #endif+ EOF+ cc_set_libc=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`+ eval "$cc_set_libc"++ # Second heuristic to detect musl libc.+ if [ "$LIBC" = unknown ] &&+ command -v ldd >/dev/null &&+ ldd --version 2>&1 | grep -q ^musl; then+ LIBC=musl+ fi++ # If the system lacks a compiler, then just pick glibc.+ # We could probably try harder.+ if [ "$LIBC" = unknown ]; then+ LIBC=gnu+ fi+ ;;+esac++# Note: order is significant - the case branches are not exclusive.++case $UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION in+ *:NetBSD:*:*)+ # NetBSD (nbsd) targets should (where applicable) match one or+ # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,+ # *-*-netbsdecoff* and *-*-netbsd*. For targets that recently+ # switched to ELF, *-*-netbsd* would select the old+ # object file format. This provides both forward+ # compatibility and a consistent mechanism for selecting the+ # object file format.+ #+ # Note: NetBSD doesn't particularly care about the vendor+ # portion of the name. We always set it to "unknown".+ UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \+ /sbin/sysctl -n hw.machine_arch 2>/dev/null || \+ /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \+ echo unknown)`+ case $UNAME_MACHINE_ARCH in+ aarch64eb) machine=aarch64_be-unknown ;;+ armeb) machine=armeb-unknown ;;+ arm*) machine=arm-unknown ;;+ sh3el) machine=shl-unknown ;;+ sh3eb) machine=sh-unknown ;;+ sh5el) machine=sh5le-unknown ;;+ earmv*)+ arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`+ endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`+ machine=${arch}${endian}-unknown+ ;;+ *) machine=$UNAME_MACHINE_ARCH-unknown ;;+ esac+ # The Operating System including object format, if it has switched+ # to ELF recently (or will in the future) and ABI.+ case $UNAME_MACHINE_ARCH in+ earm*)+ os=netbsdelf+ ;;+ arm*|i386|m68k|ns32k|sh3*|sparc|vax)+ set_cc_for_build+ if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \+ | grep -q __ELF__+ then+ # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).+ # Return netbsd for either. FIX?+ os=netbsd+ else+ os=netbsdelf+ fi+ ;;+ *)+ os=netbsd+ ;;+ esac+ # Determine ABI tags.+ case $UNAME_MACHINE_ARCH in+ earm*)+ expr='s/^earmv[0-9]/-eabi/;s/eb$//'+ abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`+ ;;+ esac+ # The OS release+ # Debian GNU/NetBSD machines have a different userland, and+ # thus, need a distinct triplet. However, they do not need+ # kernel version information, so it can be replaced with a+ # suitable tag, in the style of linux-gnu.+ case $UNAME_VERSION in+ Debian*)+ release='-gnu'+ ;;+ *)+ release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`+ ;;+ esac+ # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:+ # contains redundant information, the shorter form:+ # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.+ GUESS=$machine-${os}${release}${abi-}+ ;;+ *:Bitrig:*:*)+ UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`+ GUESS=$UNAME_MACHINE_ARCH-unknown-bitrig$UNAME_RELEASE+ ;;+ *:OpenBSD:*:*)+ UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`+ GUESS=$UNAME_MACHINE_ARCH-unknown-openbsd$UNAME_RELEASE+ ;;+ *:SecBSD:*:*)+ UNAME_MACHINE_ARCH=`arch | sed 's/SecBSD.//'`+ GUESS=$UNAME_MACHINE_ARCH-unknown-secbsd$UNAME_RELEASE+ ;;+ *:LibertyBSD:*:*)+ UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`+ GUESS=$UNAME_MACHINE_ARCH-unknown-libertybsd$UNAME_RELEASE+ ;;+ *:MidnightBSD:*:*)+ GUESS=$UNAME_MACHINE-unknown-midnightbsd$UNAME_RELEASE+ ;;+ *:ekkoBSD:*:*)+ GUESS=$UNAME_MACHINE-unknown-ekkobsd$UNAME_RELEASE+ ;;+ *:SolidBSD:*:*)+ GUESS=$UNAME_MACHINE-unknown-solidbsd$UNAME_RELEASE+ ;;+ *:OS108:*:*)+ GUESS=$UNAME_MACHINE-unknown-os108_$UNAME_RELEASE+ ;;+ macppc:MirBSD:*:*)+ GUESS=powerpc-unknown-mirbsd$UNAME_RELEASE+ ;;+ *:MirBSD:*:*)+ GUESS=$UNAME_MACHINE-unknown-mirbsd$UNAME_RELEASE+ ;;+ *:Sortix:*:*)+ GUESS=$UNAME_MACHINE-unknown-sortix+ ;;+ *:Twizzler:*:*)+ GUESS=$UNAME_MACHINE-unknown-twizzler+ ;;+ *:Redox:*:*)+ GUESS=$UNAME_MACHINE-unknown-redox+ ;;+ mips:OSF1:*.*)+ GUESS=mips-dec-osf1+ ;;+ alpha:OSF1:*:*)+ # Reset EXIT trap before exiting to avoid spurious non-zero exit code.+ trap '' 0+ case $UNAME_RELEASE in+ *4.0)+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`+ ;;+ *5.*)+ UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`+ ;;+ esac+ # According to Compaq, /usr/sbin/psrinfo has been available on+ # OSF/1 and Tru64 systems produced since 1995. I hope that+ # covers most systems running today. This code pipes the CPU+ # types through head -n 1, so we only detect the type of CPU 0.+ ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1`+ case $ALPHA_CPU_TYPE in+ "EV4 (21064)")+ UNAME_MACHINE=alpha ;;+ "EV4.5 (21064)")+ UNAME_MACHINE=alpha ;;+ "LCA4 (21066/21068)")+ UNAME_MACHINE=alpha ;;+ "EV5 (21164)")+ UNAME_MACHINE=alphaev5 ;;+ "EV5.6 (21164A)")+ UNAME_MACHINE=alphaev56 ;;+ "EV5.6 (21164PC)")+ UNAME_MACHINE=alphapca56 ;;+ "EV5.7 (21164PC)")+ UNAME_MACHINE=alphapca57 ;;+ "EV6 (21264)")+ UNAME_MACHINE=alphaev6 ;;+ "EV6.7 (21264A)")+ UNAME_MACHINE=alphaev67 ;;+ "EV6.8CB (21264C)")+ UNAME_MACHINE=alphaev68 ;;+ "EV6.8AL (21264B)")+ UNAME_MACHINE=alphaev68 ;;+ "EV6.8CX (21264D)")+ UNAME_MACHINE=alphaev68 ;;+ "EV6.9A (21264/EV69A)")+ UNAME_MACHINE=alphaev69 ;;+ "EV7 (21364)")+ UNAME_MACHINE=alphaev7 ;;+ "EV7.9 (21364A)")+ UNAME_MACHINE=alphaev79 ;;+ esac+ # A Pn.n version is a patched version.+ # A Vn.n version is a released version.+ # A Tn.n version is a released field test version.+ # A Xn.n version is an unreleased experimental baselevel.+ # 1.2 uses "1.2" for uname -r.+ OSF_REL=`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`+ GUESS=$UNAME_MACHINE-dec-osf$OSF_REL+ ;;+ Amiga*:UNIX_System_V:4.0:*)+ GUESS=m68k-unknown-sysv4+ ;;+ *:[Aa]miga[Oo][Ss]:*:*)+ GUESS=$UNAME_MACHINE-unknown-amigaos+ ;;+ *:[Mm]orph[Oo][Ss]:*:*)+ GUESS=$UNAME_MACHINE-unknown-morphos+ ;;+ *:OS/390:*:*)+ GUESS=i370-ibm-openedition+ ;;+ *:z/VM:*:*)+ GUESS=s390-ibm-zvmoe+ ;;+ *:OS400:*:*)+ GUESS=powerpc-ibm-os400+ ;;+ arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)+ GUESS=arm-acorn-riscix$UNAME_RELEASE+ ;;+ arm*:riscos:*:*|arm*:RISCOS:*:*)+ GUESS=arm-unknown-riscos+ ;;+ SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)+ GUESS=hppa1.1-hitachi-hiuxmpp+ ;;+ Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)+ # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.+ case `(/bin/universe) 2>/dev/null` in+ att) GUESS=pyramid-pyramid-sysv3 ;;+ *) GUESS=pyramid-pyramid-bsd ;;+ esac+ ;;+ NILE*:*:*:dcosx)+ GUESS=pyramid-pyramid-svr4+ ;;+ DRS?6000:unix:4.0:6*)+ GUESS=sparc-icl-nx6+ ;;+ DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)+ case `/usr/bin/uname -p` in+ sparc) GUESS=sparc-icl-nx7 ;;+ esac+ ;;+ s390x:SunOS:*:*)+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`+ GUESS=$UNAME_MACHINE-ibm-solaris2$SUN_REL+ ;;+ sun4H:SunOS:5.*:*)+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`+ GUESS=sparc-hal-solaris2$SUN_REL+ ;;+ sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`+ GUESS=sparc-sun-solaris2$SUN_REL+ ;;+ i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)+ GUESS=i386-pc-auroraux$UNAME_RELEASE+ ;;+ i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)+ set_cc_for_build+ SUN_ARCH=i386+ # If there is a compiler, see if it is configured for 64-bit objects.+ # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.+ # This test works for both compilers.+ if test "$CC_FOR_BUILD" != no_compiler_found; then+ if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \+ (CCOPTS="" $CC_FOR_BUILD -m64 -E - 2>/dev/null) | \+ grep IS_64BIT_ARCH >/dev/null+ then+ SUN_ARCH=x86_64+ fi+ fi+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`+ GUESS=$SUN_ARCH-pc-solaris2$SUN_REL+ ;;+ sun4*:SunOS:6*:*)+ # According to config.sub, this is the proper way to canonicalize+ # SunOS6. Hard to guess exactly what SunOS6 will be like, but+ # it's likely to be more like Solaris than SunOS4.+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`+ GUESS=sparc-sun-solaris3$SUN_REL+ ;;+ sun4*:SunOS:*:*)+ case `/usr/bin/arch -k` in+ Series*|S4*)+ UNAME_RELEASE=`uname -v`+ ;;+ esac+ # Japanese Language versions have a version number like '4.1.3-JL'.+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/'`+ GUESS=sparc-sun-sunos$SUN_REL+ ;;+ sun3*:SunOS:*:*)+ GUESS=m68k-sun-sunos$UNAME_RELEASE+ ;;+ sun*:*:4.2BSD:*)+ UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`+ test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3+ case `/bin/arch` in+ sun3)+ GUESS=m68k-sun-sunos$UNAME_RELEASE+ ;;+ sun4)+ GUESS=sparc-sun-sunos$UNAME_RELEASE+ ;;+ esac+ ;;+ aushp:SunOS:*:*)+ GUESS=sparc-auspex-sunos$UNAME_RELEASE+ ;;+ # The situation for MiNT is a little confusing. The machine name+ # can be virtually everything (everything which is not+ # "atarist" or "atariste" at least should have a processor+ # > m68000). The system name ranges from "MiNT" over "FreeMiNT"+ # to the lowercase version "mint" (or "freemint"). Finally+ # the system name "TOS" denotes a system which is actually not+ # MiNT. But MiNT is downward compatible to TOS, so this should+ # be no problem.+ atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)+ GUESS=m68k-atari-mint$UNAME_RELEASE+ ;;+ atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)+ GUESS=m68k-atari-mint$UNAME_RELEASE+ ;;+ *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)+ GUESS=m68k-atari-mint$UNAME_RELEASE+ ;;+ milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)+ GUESS=m68k-milan-mint$UNAME_RELEASE+ ;;+ hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)+ GUESS=m68k-hades-mint$UNAME_RELEASE+ ;;+ *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)+ GUESS=m68k-unknown-mint$UNAME_RELEASE+ ;;+ m68k:machten:*:*)+ GUESS=m68k-apple-machten$UNAME_RELEASE+ ;;+ powerpc:machten:*:*)+ GUESS=powerpc-apple-machten$UNAME_RELEASE+ ;;+ RISC*:Mach:*:*)+ GUESS=mips-dec-mach_bsd4.3+ ;;+ RISC*:ULTRIX:*:*)+ GUESS=mips-dec-ultrix$UNAME_RELEASE+ ;;+ VAX*:ULTRIX*:*:*)+ GUESS=vax-dec-ultrix$UNAME_RELEASE+ ;;+ 2020:CLIX:*:* | 2430:CLIX:*:*)+ GUESS=clipper-intergraph-clix$UNAME_RELEASE+ ;;+ mips:*:*:UMIPS | mips:*:*:RISCos)+ set_cc_for_build+ sed 's/^ //' << EOF > "$dummy.c"+#ifdef __cplusplus+#include <stdio.h> /* for printf() prototype */+ int main (int argc, char *argv[]) {+#else+ int main (argc, argv) int argc; char *argv[]; {+#endif+ #if defined (host_mips) && defined (MIPSEB)+ #if defined (SYSTYPE_SYSV)+ printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);+ #endif+ #if defined (SYSTYPE_SVR4)+ printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);+ #endif+ #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)+ printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);+ #endif+ #endif+ exit (-1);+ }+EOF+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" &&+ dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&+ SYSTEM_NAME=`"$dummy" "$dummyarg"` &&+ { echo "$SYSTEM_NAME"; exit; }+ GUESS=mips-mips-riscos$UNAME_RELEASE+ ;;+ Motorola:PowerMAX_OS:*:*)+ GUESS=powerpc-motorola-powermax+ ;;+ Motorola:*:4.3:PL8-*)+ GUESS=powerpc-harris-powermax+ ;;+ Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)+ GUESS=powerpc-harris-powermax+ ;;+ Night_Hawk:Power_UNIX:*:*)+ GUESS=powerpc-harris-powerunix+ ;;+ m88k:CX/UX:7*:*)+ GUESS=m88k-harris-cxux7+ ;;+ m88k:*:4*:R4*)+ GUESS=m88k-motorola-sysv4+ ;;+ m88k:*:3*:R3*)+ GUESS=m88k-motorola-sysv3+ ;;+ AViiON:dgux:*:*)+ # DG/UX returns AViiON for all architectures+ UNAME_PROCESSOR=`/usr/bin/uname -p`+ if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110+ then+ if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \+ test "$TARGET_BINARY_INTERFACE"x = x+ then+ GUESS=m88k-dg-dgux$UNAME_RELEASE+ else+ GUESS=m88k-dg-dguxbcs$UNAME_RELEASE+ fi+ else+ GUESS=i586-dg-dgux$UNAME_RELEASE+ fi+ ;;+ M88*:DolphinOS:*:*) # DolphinOS (SVR3)+ GUESS=m88k-dolphin-sysv3+ ;;+ M88*:*:R3*:*)+ # Delta 88k system running SVR3+ GUESS=m88k-motorola-sysv3+ ;;+ XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)+ GUESS=m88k-tektronix-sysv3+ ;;+ Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)+ GUESS=m68k-tektronix-bsd+ ;;+ *:IRIX*:*:*)+ IRIX_REL=`echo "$UNAME_RELEASE" | sed -e 's/-/_/g'`+ GUESS=mips-sgi-irix$IRIX_REL+ ;;+ ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.+ GUESS=romp-ibm-aix # uname -m gives an 8 hex-code CPU id+ ;; # Note that: echo "'`uname -s`'" gives 'AIX '+ i*86:AIX:*:*)+ GUESS=i386-ibm-aix+ ;;+ ia64:AIX:*:*)+ if test -x /usr/bin/oslevel ; then+ IBM_REV=`/usr/bin/oslevel`+ else+ IBM_REV=$UNAME_VERSION.$UNAME_RELEASE+ fi+ GUESS=$UNAME_MACHINE-ibm-aix$IBM_REV+ ;;+ *:AIX:2:3)+ if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then+ set_cc_for_build+ sed 's/^ //' << EOF > "$dummy.c"+ #include <sys/systemcfg.h>++ main()+ {+ if (!__power_pc())+ exit(1);+ puts("powerpc-ibm-aix3.2.5");+ exit(0);+ }+EOF+ if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`+ then+ GUESS=$SYSTEM_NAME+ else+ GUESS=rs6000-ibm-aix3.2.5+ fi+ elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then+ GUESS=rs6000-ibm-aix3.2.4+ else+ GUESS=rs6000-ibm-aix3.2+ fi+ ;;+ *:AIX:*:[4567])+ IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`+ if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then+ IBM_ARCH=rs6000+ else+ IBM_ARCH=powerpc+ fi+ if test -x /usr/bin/lslpp ; then+ IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | \+ awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`+ else+ IBM_REV=$UNAME_VERSION.$UNAME_RELEASE+ fi+ GUESS=$IBM_ARCH-ibm-aix$IBM_REV+ ;;+ *:AIX:*:*)+ GUESS=rs6000-ibm-aix+ ;;+ ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)+ GUESS=romp-ibm-bsd4.4+ ;;+ ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC BSD and+ GUESS=romp-ibm-bsd$UNAME_RELEASE # 4.3 with uname added to+ ;; # report: romp-ibm BSD 4.3+ *:BOSX:*:*)+ GUESS=rs6000-bull-bosx+ ;;+ DPX/2?00:B.O.S.:*:*)+ GUESS=m68k-bull-sysv3+ ;;+ 9000/[34]??:4.3bsd:1.*:*)+ GUESS=m68k-hp-bsd+ ;;+ hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)+ GUESS=m68k-hp-bsd4.4+ ;;+ 9000/[34678]??:HP-UX:*:*)+ HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`+ case $UNAME_MACHINE in+ 9000/31?) HP_ARCH=m68000 ;;+ 9000/[34]??) HP_ARCH=m68k ;;+ 9000/[678][0-9][0-9])+ if test -x /usr/bin/getconf; then+ sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`+ sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`+ case $sc_cpu_version in+ 523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0+ 528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1+ 532) # CPU_PA_RISC2_0+ case $sc_kernel_bits in+ 32) HP_ARCH=hppa2.0n ;;+ 64) HP_ARCH=hppa2.0w ;;+ '') HP_ARCH=hppa2.0 ;; # HP-UX 10.20+ esac ;;+ esac+ fi+ if test "$HP_ARCH" = ""; then+ set_cc_for_build+ sed 's/^ //' << EOF > "$dummy.c"++ #define _HPUX_SOURCE+ #include <stdlib.h>+ #include <unistd.h>++ int main ()+ {+ #if defined(_SC_KERNEL_BITS)+ long bits = sysconf(_SC_KERNEL_BITS);+ #endif+ long cpu = sysconf (_SC_CPU_VERSION);++ switch (cpu)+ {+ case CPU_PA_RISC1_0: puts ("hppa1.0"); break;+ case CPU_PA_RISC1_1: puts ("hppa1.1"); break;+ case CPU_PA_RISC2_0:+ #if defined(_SC_KERNEL_BITS)+ switch (bits)+ {+ case 64: puts ("hppa2.0w"); break;+ case 32: puts ("hppa2.0n"); break;+ default: puts ("hppa2.0"); break;+ } break;+ #else /* !defined(_SC_KERNEL_BITS) */+ puts ("hppa2.0"); break;+ #endif+ default: puts ("hppa1.0"); break;+ }+ exit (0);+ }+EOF+ (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`+ test -z "$HP_ARCH" && HP_ARCH=hppa+ fi ;;+ esac+ if test "$HP_ARCH" = hppa2.0w+ then+ set_cc_for_build++ # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating+ # 32-bit code. hppa64-hp-hpux* has the same kernel and a compiler+ # generating 64-bit code. GNU and HP use different nomenclature:+ #+ # $ CC_FOR_BUILD=cc ./config.guess+ # => hppa2.0w-hp-hpux11.23+ # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess+ # => hppa64-hp-hpux11.23++ if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |+ grep -q __LP64__+ then+ HP_ARCH=hppa2.0w+ else+ HP_ARCH=hppa64+ fi+ fi+ GUESS=$HP_ARCH-hp-hpux$HPUX_REV+ ;;+ ia64:HP-UX:*:*)+ HPUX_REV=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*.[0B]*//'`+ GUESS=ia64-hp-hpux$HPUX_REV+ ;;+ 3050*:HI-UX:*:*)+ set_cc_for_build+ sed 's/^ //' << EOF > "$dummy.c"+ #include <unistd.h>+ int+ main ()+ {+ long cpu = sysconf (_SC_CPU_VERSION);+ /* The order matters, because CPU_IS_HP_MC68K erroneously returns+ true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct+ results, however. */+ if (CPU_IS_PA_RISC (cpu))+ {+ switch (cpu)+ {+ case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;+ case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;+ case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;+ default: puts ("hppa-hitachi-hiuxwe2"); break;+ }+ }+ else if (CPU_IS_HP_MC68K (cpu))+ puts ("m68k-hitachi-hiuxwe2");+ else puts ("unknown-hitachi-hiuxwe2");+ exit (0);+ }+EOF+ $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&+ { echo "$SYSTEM_NAME"; exit; }+ GUESS=unknown-hitachi-hiuxwe2+ ;;+ 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)+ GUESS=hppa1.1-hp-bsd+ ;;+ 9000/8??:4.3bsd:*:*)+ GUESS=hppa1.0-hp-bsd+ ;;+ *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)+ GUESS=hppa1.0-hp-mpeix+ ;;+ hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)+ GUESS=hppa1.1-hp-osf+ ;;+ hp8??:OSF1:*:*)+ GUESS=hppa1.0-hp-osf+ ;;+ i*86:OSF1:*:*)+ if test -x /usr/sbin/sysversion ; then+ GUESS=$UNAME_MACHINE-unknown-osf1mk+ else+ GUESS=$UNAME_MACHINE-unknown-osf1+ fi+ ;;+ parisc*:Lites*:*:*)+ GUESS=hppa1.1-hp-lites+ ;;+ C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)+ GUESS=c1-convex-bsd+ ;;+ C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)+ if getsysinfo -f scalar_acc+ then echo c32-convex-bsd+ else echo c2-convex-bsd+ fi+ exit ;;+ C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)+ GUESS=c34-convex-bsd+ ;;+ C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)+ GUESS=c38-convex-bsd+ ;;+ C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)+ GUESS=c4-convex-bsd+ ;;+ CRAY*Y-MP:*:*:*)+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`+ GUESS=ymp-cray-unicos$CRAY_REL+ ;;+ CRAY*[A-Z]90:*:*:*)+ echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \+ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \+ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \+ -e 's/\.[^.]*$/.X/'+ exit ;;+ CRAY*TS:*:*:*)+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`+ GUESS=t90-cray-unicos$CRAY_REL+ ;;+ CRAY*T3E:*:*:*)+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`+ GUESS=alphaev5-cray-unicosmk$CRAY_REL+ ;;+ CRAY*SV1:*:*:*)+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`+ GUESS=sv1-cray-unicos$CRAY_REL+ ;;+ *:UNICOS/mp:*:*)+ CRAY_REL=`echo "$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'`+ GUESS=craynv-cray-unicosmp$CRAY_REL+ ;;+ F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)+ FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`+ FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`+ FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`+ GUESS=${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}+ ;;+ 5000:UNIX_System_V:4.*:*)+ FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`+ FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`+ GUESS=sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}+ ;;+ i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)+ GUESS=$UNAME_MACHINE-pc-bsdi$UNAME_RELEASE+ ;;+ sparc*:BSD/OS:*:*)+ GUESS=sparc-unknown-bsdi$UNAME_RELEASE+ ;;+ *:BSD/OS:*:*)+ GUESS=$UNAME_MACHINE-unknown-bsdi$UNAME_RELEASE+ ;;+ arm:FreeBSD:*:*)+ UNAME_PROCESSOR=`uname -p`+ set_cc_for_build+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \+ | grep -q __ARM_PCS_VFP+ then+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabi+ else+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL-gnueabihf+ fi+ ;;+ *:FreeBSD:*:*)+ UNAME_PROCESSOR=`uname -p`+ case $UNAME_PROCESSOR in+ amd64)+ UNAME_PROCESSOR=x86_64 ;;+ i386)+ UNAME_PROCESSOR=i586 ;;+ esac+ FREEBSD_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`+ GUESS=$UNAME_PROCESSOR-unknown-freebsd$FREEBSD_REL+ ;;+ i*:CYGWIN*:*)+ GUESS=$UNAME_MACHINE-pc-cygwin+ ;;+ *:MINGW64*:*)+ GUESS=$UNAME_MACHINE-pc-mingw64+ ;;+ *:MINGW*:*)+ GUESS=$UNAME_MACHINE-pc-mingw32+ ;;+ *:MSYS*:*)+ GUESS=$UNAME_MACHINE-pc-msys+ ;;+ i*:PW*:*)+ GUESS=$UNAME_MACHINE-pc-pw32+ ;;+ *:SerenityOS:*:*)+ GUESS=$UNAME_MACHINE-pc-serenity+ ;;+ *:Interix*:*)+ case $UNAME_MACHINE in+ x86)+ GUESS=i586-pc-interix$UNAME_RELEASE+ ;;+ authenticamd | genuineintel | EM64T)+ GUESS=x86_64-unknown-interix$UNAME_RELEASE+ ;;+ IA64)+ GUESS=ia64-unknown-interix$UNAME_RELEASE+ ;;+ esac ;;+ i*:UWIN*:*)+ GUESS=$UNAME_MACHINE-pc-uwin+ ;;+ amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)+ GUESS=x86_64-pc-cygwin+ ;;+ prep*:SunOS:5.*:*)+ SUN_REL=`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`+ GUESS=powerpcle-unknown-solaris2$SUN_REL+ ;;+ *:GNU:*:*)+ # the GNU system+ GNU_ARCH=`echo "$UNAME_MACHINE" | sed -e 's,[-/].*$,,'`+ GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's,/.*$,,'`+ GUESS=$GNU_ARCH-unknown-$LIBC$GNU_REL+ ;;+ *:GNU/*:*:*)+ # other systems with GNU libc and userland+ GNU_SYS=`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"`+ GNU_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`+ GUESS=$UNAME_MACHINE-unknown-$GNU_SYS$GNU_REL-$LIBC+ ;;+ x86_64:[Mm]anagarm:*:*|i?86:[Mm]anagarm:*:*)+ GUESS="$UNAME_MACHINE-pc-managarm-mlibc"+ ;;+ *:[Mm]anagarm:*:*)+ GUESS="$UNAME_MACHINE-unknown-managarm-mlibc"+ ;;+ *:Minix:*:*)+ GUESS=$UNAME_MACHINE-unknown-minix+ ;;+ aarch64:Linux:*:*)+ set_cc_for_build+ CPU=$UNAME_MACHINE+ LIBCABI=$LIBC+ if test "$CC_FOR_BUILD" != no_compiler_found; then+ ABI=64+ sed 's/^ //' << EOF > "$dummy.c"+ #ifdef __ARM_EABI__+ #ifdef __ARM_PCS_VFP+ ABI=eabihf+ #else+ ABI=eabi+ #endif+ #endif+EOF+ cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`+ eval "$cc_set_abi"+ case $ABI in+ eabi | eabihf) CPU=armv8l; LIBCABI=$LIBC$ABI ;;+ esac+ fi+ GUESS=$CPU-unknown-linux-$LIBCABI+ ;;+ aarch64_be:Linux:*:*)+ UNAME_MACHINE=aarch64_be+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ alpha:Linux:*:*)+ case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null` in+ EV5) UNAME_MACHINE=alphaev5 ;;+ EV56) UNAME_MACHINE=alphaev56 ;;+ PCA56) UNAME_MACHINE=alphapca56 ;;+ PCA57) UNAME_MACHINE=alphapca56 ;;+ EV6) UNAME_MACHINE=alphaev6 ;;+ EV67) UNAME_MACHINE=alphaev67 ;;+ EV68*) UNAME_MACHINE=alphaev68 ;;+ esac+ objdump --private-headers /bin/sh | grep -q ld.so.1+ if test "$?" = 0 ; then LIBC=gnulibc1 ; fi+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ arc:Linux:*:* | arceb:Linux:*:* | arc32:Linux:*:* | arc64:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ arm*:Linux:*:*)+ set_cc_for_build+ if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \+ | grep -q __ARM_EABI__+ then+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ else+ if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \+ | grep -q __ARM_PCS_VFP+ then+ GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabi+ else+ GUESS=$UNAME_MACHINE-unknown-linux-${LIBC}eabihf+ fi+ fi+ ;;+ avr32*:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ cris:Linux:*:*)+ GUESS=$UNAME_MACHINE-axis-linux-$LIBC+ ;;+ crisv32:Linux:*:*)+ GUESS=$UNAME_MACHINE-axis-linux-$LIBC+ ;;+ e2k:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ frv:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ hexagon:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ i*86:Linux:*:*)+ GUESS=$UNAME_MACHINE-pc-linux-$LIBC+ ;;+ ia64:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ k1om:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ kvx:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ kvx:cos:*:*)+ GUESS=$UNAME_MACHINE-unknown-cos+ ;;+ kvx:mbr:*:*)+ GUESS=$UNAME_MACHINE-unknown-mbr+ ;;+ loongarch32:Linux:*:* | loongarch64:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ m32r*:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ m68*:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ mips:Linux:*:* | mips64:Linux:*:*)+ set_cc_for_build+ IS_GLIBC=0+ test x"${LIBC}" = xgnu && IS_GLIBC=1+ sed 's/^ //' << EOF > "$dummy.c"+ #undef CPU+ #undef mips+ #undef mipsel+ #undef mips64+ #undef mips64el+ #if ${IS_GLIBC} && defined(_ABI64)+ LIBCABI=gnuabi64+ #else+ #if ${IS_GLIBC} && defined(_ABIN32)+ LIBCABI=gnuabin32+ #else+ LIBCABI=${LIBC}+ #endif+ #endif++ #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6+ CPU=mipsisa64r6+ #else+ #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6+ CPU=mipsisa32r6+ #else+ #if defined(__mips64)+ CPU=mips64+ #else+ CPU=mips+ #endif+ #endif+ #endif++ #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)+ MIPS_ENDIAN=el+ #else+ #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)+ MIPS_ENDIAN=+ #else+ MIPS_ENDIAN=+ #endif+ #endif+EOF+ cc_set_vars=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU\|^MIPS_ENDIAN\|^LIBCABI'`+ eval "$cc_set_vars"+ test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; }+ ;;+ mips64el:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ openrisc*:Linux:*:*)+ GUESS=or1k-unknown-linux-$LIBC+ ;;+ or32:Linux:*:* | or1k*:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ padre:Linux:*:*)+ GUESS=sparc-unknown-linux-$LIBC+ ;;+ parisc64:Linux:*:* | hppa64:Linux:*:*)+ GUESS=hppa64-unknown-linux-$LIBC+ ;;+ parisc:Linux:*:* | hppa:Linux:*:*)+ # Look for CPU level+ case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in+ PA7*) GUESS=hppa1.1-unknown-linux-$LIBC ;;+ PA8*) GUESS=hppa2.0-unknown-linux-$LIBC ;;+ *) GUESS=hppa-unknown-linux-$LIBC ;;+ esac+ ;;+ ppc64:Linux:*:*)+ GUESS=powerpc64-unknown-linux-$LIBC+ ;;+ ppc:Linux:*:*)+ GUESS=powerpc-unknown-linux-$LIBC+ ;;+ ppc64le:Linux:*:*)+ GUESS=powerpc64le-unknown-linux-$LIBC+ ;;+ ppcle:Linux:*:*)+ GUESS=powerpcle-unknown-linux-$LIBC+ ;;+ riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ s390:Linux:*:* | s390x:Linux:*:*)+ GUESS=$UNAME_MACHINE-ibm-linux-$LIBC+ ;;+ sh64*:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ sh*:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ sparc:Linux:*:* | sparc64:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ tile*:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ vax:Linux:*:*)+ GUESS=$UNAME_MACHINE-dec-linux-$LIBC+ ;;+ x86_64:Linux:*:*)+ set_cc_for_build+ CPU=$UNAME_MACHINE+ LIBCABI=$LIBC+ if test "$CC_FOR_BUILD" != no_compiler_found; then+ ABI=64+ sed 's/^ //' << EOF > "$dummy.c"+ #ifdef __i386__+ ABI=x86+ #else+ #ifdef __ILP32__+ ABI=x32+ #endif+ #endif+EOF+ cc_set_abi=`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^ABI' | sed 's, ,,g'`+ eval "$cc_set_abi"+ case $ABI in+ x86) CPU=i686 ;;+ x32) LIBCABI=${LIBC}x32 ;;+ esac+ fi+ GUESS=$CPU-pc-linux-$LIBCABI+ ;;+ xtensa*:Linux:*:*)+ GUESS=$UNAME_MACHINE-unknown-linux-$LIBC+ ;;+ i*86:DYNIX/ptx:4*:*)+ # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.+ # earlier versions are messed up and put the nodename in both+ # sysname and nodename.+ GUESS=i386-sequent-sysv4+ ;;+ i*86:UNIX_SV:4.2MP:2.*)+ # Unixware is an offshoot of SVR4, but it has its own version+ # number series starting with 2...+ # I am not positive that other SVR4 systems won't match this,+ # I just have to hope. -- rms.+ # Use sysv4.2uw... so that sysv4* matches it.+ GUESS=$UNAME_MACHINE-pc-sysv4.2uw$UNAME_VERSION+ ;;+ i*86:OS/2:*:*)+ # If we were able to find 'uname', then EMX Unix compatibility+ # is probably installed.+ GUESS=$UNAME_MACHINE-pc-os2-emx+ ;;+ i*86:XTS-300:*:STOP)+ GUESS=$UNAME_MACHINE-unknown-stop+ ;;+ i*86:atheos:*:*)+ GUESS=$UNAME_MACHINE-unknown-atheos+ ;;+ i*86:syllable:*:*)+ GUESS=$UNAME_MACHINE-pc-syllable+ ;;+ i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)+ GUESS=i386-unknown-lynxos$UNAME_RELEASE+ ;;+ i*86:*DOS:*:*)+ GUESS=$UNAME_MACHINE-pc-msdosdjgpp+ ;;+ i*86:*:4.*:*)+ UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`+ if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then+ GUESS=$UNAME_MACHINE-univel-sysv$UNAME_REL+ else+ GUESS=$UNAME_MACHINE-pc-sysv$UNAME_REL+ fi+ ;;+ i*86:*:5:[678]*)+ # UnixWare 7.x, OpenUNIX and OpenServer 6.+ case `/bin/uname -X | grep "^Machine"` in+ *486*) UNAME_MACHINE=i486 ;;+ *Pentium) UNAME_MACHINE=i586 ;;+ *Pent*|*Celeron) UNAME_MACHINE=i686 ;;+ esac+ GUESS=$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}+ ;;+ i*86:*:3.2:*)+ if test -f /usr/options/cb.name; then+ UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`+ GUESS=$UNAME_MACHINE-pc-isc$UNAME_REL+ elif /bin/uname -X 2>/dev/null >/dev/null ; then+ UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`+ (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486+ (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \+ && UNAME_MACHINE=i586+ (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \+ && UNAME_MACHINE=i686+ (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \+ && UNAME_MACHINE=i686+ GUESS=$UNAME_MACHINE-pc-sco$UNAME_REL+ else+ GUESS=$UNAME_MACHINE-pc-sysv32+ fi+ ;;+ pc:*:*:*)+ # Left here for compatibility:+ # uname -m prints for DJGPP always 'pc', but it prints nothing about+ # the processor, so we play safe by assuming i586.+ # Note: whatever this is, it MUST be the same as what config.sub+ # prints for the "djgpp" host, or else GDB configure will decide that+ # this is a cross-build.+ GUESS=i586-pc-msdosdjgpp+ ;;+ Intel:Mach:3*:*)+ GUESS=i386-pc-mach3+ ;;+ paragon:*:*:*)+ GUESS=i860-intel-osf1+ ;;+ i860:*:4.*:*) # i860-SVR4+ if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then+ GUESS=i860-stardent-sysv$UNAME_RELEASE # Stardent Vistra i860-SVR4+ else # Add other i860-SVR4 vendors below as they are discovered.+ GUESS=i860-unknown-sysv$UNAME_RELEASE # Unknown i860-SVR4+ fi+ ;;+ mini*:CTIX:SYS*5:*)+ # "miniframe"+ GUESS=m68010-convergent-sysv+ ;;+ mc68k:UNIX:SYSTEM5:3.51m)+ GUESS=m68k-convergent-sysv+ ;;+ M680?0:D-NIX:5.3:*)+ GUESS=m68k-diab-dnix+ ;;+ M68*:*:R3V[5678]*:*)+ test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;+ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)+ OS_REL=''+ test -r /etc/.relid \+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;+ 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \+ && { echo i486-ncr-sysv4; exit; } ;;+ NCR*:*:4.2:* | MPRAS*:*:4.2:*)+ OS_REL='.3'+ test -r /etc/.relid \+ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`+ /bin/uname -p 2>/dev/null | grep 86 >/dev/null \+ && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }+ /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }+ /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \+ && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;+ m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)+ GUESS=m68k-unknown-lynxos$UNAME_RELEASE+ ;;+ mc68030:UNIX_System_V:4.*:*)+ GUESS=m68k-atari-sysv4+ ;;+ TSUNAMI:LynxOS:2.*:*)+ GUESS=sparc-unknown-lynxos$UNAME_RELEASE+ ;;+ rs6000:LynxOS:2.*:*)+ GUESS=rs6000-unknown-lynxos$UNAME_RELEASE+ ;;+ PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)+ GUESS=powerpc-unknown-lynxos$UNAME_RELEASE+ ;;+ SM[BE]S:UNIX_SV:*:*)+ GUESS=mips-dde-sysv$UNAME_RELEASE+ ;;+ RM*:ReliantUNIX-*:*:*)+ GUESS=mips-sni-sysv4+ ;;+ RM*:SINIX-*:*:*)+ GUESS=mips-sni-sysv4+ ;;+ *:SINIX-*:*:*)+ if uname -p 2>/dev/null >/dev/null ; then+ UNAME_MACHINE=`(uname -p) 2>/dev/null`+ GUESS=$UNAME_MACHINE-sni-sysv4+ else+ GUESS=ns32k-sni-sysv+ fi+ ;;+ PENTIUM:*:4.0*:*) # Unisys 'ClearPath HMP IX 4000' SVR4/MP effort+ # says <Richard.M.Bartel@ccMail.Census.GOV>+ GUESS=i586-unisys-sysv4+ ;;+ *:UNIX_System_V:4*:FTX*)+ # From Gerald Hewes <hewes@openmarket.com>.+ # How about differentiating between stratus architectures? -djm+ GUESS=hppa1.1-stratus-sysv4+ ;;+ *:*:*:FTX*)+ # From seanf@swdc.stratus.com.+ GUESS=i860-stratus-sysv4+ ;;+ i*86:VOS:*:*)+ # From Paul.Green@stratus.com.+ GUESS=$UNAME_MACHINE-stratus-vos+ ;;+ *:VOS:*:*)+ # From Paul.Green@stratus.com.+ GUESS=hppa1.1-stratus-vos+ ;;+ mc68*:A/UX:*:*)+ GUESS=m68k-apple-aux$UNAME_RELEASE+ ;;+ news*:NEWS-OS:6*:*)+ GUESS=mips-sony-newsos6+ ;;+ R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)+ if test -d /usr/nec; then+ GUESS=mips-nec-sysv$UNAME_RELEASE+ else+ GUESS=mips-unknown-sysv$UNAME_RELEASE+ fi+ ;;+ BeBox:BeOS:*:*) # BeOS running on hardware made by Be, PPC only.+ GUESS=powerpc-be-beos+ ;;+ BeMac:BeOS:*:*) # BeOS running on Mac or Mac clone, PPC only.+ GUESS=powerpc-apple-beos+ ;;+ BePC:BeOS:*:*) # BeOS running on Intel PC compatible.+ GUESS=i586-pc-beos+ ;;+ BePC:Haiku:*:*) # Haiku running on Intel PC compatible.+ GUESS=i586-pc-haiku+ ;;+ ppc:Haiku:*:*) # Haiku running on Apple PowerPC+ GUESS=powerpc-apple-haiku+ ;;+ *:Haiku:*:*) # Haiku modern gcc (not bound by BeOS compat)+ GUESS=$UNAME_MACHINE-unknown-haiku+ ;;+ SX-4:SUPER-UX:*:*)+ GUESS=sx4-nec-superux$UNAME_RELEASE+ ;;+ SX-5:SUPER-UX:*:*)+ GUESS=sx5-nec-superux$UNAME_RELEASE+ ;;+ SX-6:SUPER-UX:*:*)+ GUESS=sx6-nec-superux$UNAME_RELEASE+ ;;+ SX-7:SUPER-UX:*:*)+ GUESS=sx7-nec-superux$UNAME_RELEASE+ ;;+ SX-8:SUPER-UX:*:*)+ GUESS=sx8-nec-superux$UNAME_RELEASE+ ;;+ SX-8R:SUPER-UX:*:*)+ GUESS=sx8r-nec-superux$UNAME_RELEASE+ ;;+ SX-ACE:SUPER-UX:*:*)+ GUESS=sxace-nec-superux$UNAME_RELEASE+ ;;+ Power*:Rhapsody:*:*)+ GUESS=powerpc-apple-rhapsody$UNAME_RELEASE+ ;;+ *:Rhapsody:*:*)+ GUESS=$UNAME_MACHINE-apple-rhapsody$UNAME_RELEASE+ ;;+ arm64:Darwin:*:*)+ GUESS=aarch64-apple-darwin$UNAME_RELEASE+ ;;+ *:Darwin:*:*)+ UNAME_PROCESSOR=`uname -p`+ case $UNAME_PROCESSOR in+ unknown) UNAME_PROCESSOR=powerpc ;;+ esac+ if command -v xcode-select > /dev/null 2> /dev/null && \+ ! xcode-select --print-path > /dev/null 2> /dev/null ; then+ # Avoid executing cc if there is no toolchain installed as+ # cc will be a stub that puts up a graphical alert+ # prompting the user to install developer tools.+ CC_FOR_BUILD=no_compiler_found+ else+ set_cc_for_build+ fi+ if test "$CC_FOR_BUILD" != no_compiler_found; then+ if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \+ grep IS_64BIT_ARCH >/dev/null+ then+ case $UNAME_PROCESSOR in+ i386) UNAME_PROCESSOR=x86_64 ;;+ powerpc) UNAME_PROCESSOR=powerpc64 ;;+ esac+ fi+ # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc+ if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \+ (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \+ grep IS_PPC >/dev/null+ then+ UNAME_PROCESSOR=powerpc+ fi+ elif test "$UNAME_PROCESSOR" = i386 ; then+ # uname -m returns i386 or x86_64+ UNAME_PROCESSOR=$UNAME_MACHINE+ fi+ GUESS=$UNAME_PROCESSOR-apple-darwin$UNAME_RELEASE+ ;;+ *:procnto*:*:* | *:QNX:[0123456789]*:*)+ UNAME_PROCESSOR=`uname -p`+ if test "$UNAME_PROCESSOR" = x86; then+ UNAME_PROCESSOR=i386+ UNAME_MACHINE=pc+ fi+ GUESS=$UNAME_PROCESSOR-$UNAME_MACHINE-nto-qnx$UNAME_RELEASE+ ;;+ *:QNX:*:4*)+ GUESS=i386-pc-qnx+ ;;+ NEO-*:NONSTOP_KERNEL:*:*)+ GUESS=neo-tandem-nsk$UNAME_RELEASE+ ;;+ NSE-*:NONSTOP_KERNEL:*:*)+ GUESS=nse-tandem-nsk$UNAME_RELEASE+ ;;+ NSR-*:NONSTOP_KERNEL:*:*)+ GUESS=nsr-tandem-nsk$UNAME_RELEASE+ ;;+ NSV-*:NONSTOP_KERNEL:*:*)+ GUESS=nsv-tandem-nsk$UNAME_RELEASE+ ;;+ NSX-*:NONSTOP_KERNEL:*:*)+ GUESS=nsx-tandem-nsk$UNAME_RELEASE+ ;;+ *:NonStop-UX:*:*)+ GUESS=mips-compaq-nonstopux+ ;;+ BS2000:POSIX*:*:*)+ GUESS=bs2000-siemens-sysv+ ;;+ DS/*:UNIX_System_V:*:*)+ GUESS=$UNAME_MACHINE-$UNAME_SYSTEM-$UNAME_RELEASE+ ;;+ *:Plan9:*:*)+ # "uname -m" is not consistent, so use $cputype instead. 386+ # is converted to i386 for consistency with other x86+ # operating systems.+ if test "${cputype-}" = 386; then+ UNAME_MACHINE=i386+ elif test "x${cputype-}" != x; then+ UNAME_MACHINE=$cputype+ fi+ GUESS=$UNAME_MACHINE-unknown-plan9+ ;;+ *:TOPS-10:*:*)+ GUESS=pdp10-unknown-tops10+ ;;+ *:TENEX:*:*)+ GUESS=pdp10-unknown-tenex+ ;;+ KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)+ GUESS=pdp10-dec-tops20+ ;;+ XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)+ GUESS=pdp10-xkl-tops20+ ;;+ *:TOPS-20:*:*)+ GUESS=pdp10-unknown-tops20+ ;;+ *:ITS:*:*)+ GUESS=pdp10-unknown-its+ ;;+ SEI:*:*:SEIUX)+ GUESS=mips-sei-seiux$UNAME_RELEASE+ ;;+ *:DragonFly:*:*)+ DRAGONFLY_REL=`echo "$UNAME_RELEASE" | sed -e 's/[-(].*//'`+ GUESS=$UNAME_MACHINE-unknown-dragonfly$DRAGONFLY_REL+ ;;+ *:*VMS:*:*)+ UNAME_MACHINE=`(uname -p) 2>/dev/null`+ case $UNAME_MACHINE in+ A*) GUESS=alpha-dec-vms ;;+ I*) GUESS=ia64-dec-vms ;;+ V*) GUESS=vax-dec-vms ;;+ esac ;;+ *:XENIX:*:SysV)+ GUESS=i386-pc-xenix+ ;;+ i*86:skyos:*:*)+ SKYOS_REL=`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`+ GUESS=$UNAME_MACHINE-pc-skyos$SKYOS_REL+ ;;+ i*86:rdos:*:*)+ GUESS=$UNAME_MACHINE-pc-rdos+ ;;+ i*86:Fiwix:*:*)+ GUESS=$UNAME_MACHINE-pc-fiwix+ ;;+ *:AROS:*:*)+ GUESS=$UNAME_MACHINE-unknown-aros+ ;;+ x86_64:VMkernel:*:*)+ GUESS=$UNAME_MACHINE-unknown-esx+ ;;+ amd64:Isilon\ OneFS:*:*)+ GUESS=x86_64-unknown-onefs+ ;;+ *:Unleashed:*:*)+ GUESS=$UNAME_MACHINE-unknown-unleashed$UNAME_RELEASE+ ;;+esac++# Do we have a guess based on uname results?+if test "x$GUESS" != x; then+ echo "$GUESS"+ exit+fi++# No uname command or uname output not recognized.+set_cc_for_build+cat > "$dummy.c" <<EOF+#ifdef _SEQUENT_+#include <sys/types.h>+#include <sys/utsname.h>+#endif+#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)+#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)+#include <signal.h>+#if defined(_SIZE_T_) || defined(SIGLOST)+#include <sys/utsname.h>+#endif+#endif+#endif+main ()+{+#if defined (sony)+#if defined (MIPSEB)+ /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed,+ I don't know.... */+ printf ("mips-sony-bsd\n"); exit (0);+#else+#include <sys/param.h>+ printf ("m68k-sony-newsos%s\n",+#ifdef NEWSOS4+ "4"+#else+ ""+#endif+ ); exit (0);+#endif+#endif++#if defined (NeXT)+#if !defined (__ARCHITECTURE__)+#define __ARCHITECTURE__ "m68k"+#endif+ int version;+ version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;+ if (version < 4)+ printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);+ else+ printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);+ exit (0);+#endif++#if defined (MULTIMAX) || defined (n16)+#if defined (UMAXV)+ printf ("ns32k-encore-sysv\n"); exit (0);+#else+#if defined (CMU)+ printf ("ns32k-encore-mach\n"); exit (0);+#else+ printf ("ns32k-encore-bsd\n"); exit (0);+#endif+#endif+#endif++#if defined (__386BSD__)+ printf ("i386-pc-bsd\n"); exit (0);+#endif++#if defined (sequent)+#if defined (i386)+ printf ("i386-sequent-dynix\n"); exit (0);+#endif+#if defined (ns32000)+ printf ("ns32k-sequent-dynix\n"); exit (0);+#endif+#endif++#if defined (_SEQUENT_)+ struct utsname un;++ uname(&un);+ if (strncmp(un.version, "V2", 2) == 0) {+ printf ("i386-sequent-ptx2\n"); exit (0);+ }+ if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */+ printf ("i386-sequent-ptx1\n"); exit (0);+ }+ printf ("i386-sequent-ptx\n"); exit (0);+#endif++#if defined (vax)+#if !defined (ultrix)+#include <sys/param.h>+#if defined (BSD)+#if BSD == 43+ printf ("vax-dec-bsd4.3\n"); exit (0);+#else+#if BSD == 199006+ printf ("vax-dec-bsd4.3reno\n"); exit (0);+#else+ printf ("vax-dec-bsd\n"); exit (0);+#endif+#endif+#else+ printf ("vax-dec-bsd\n"); exit (0);+#endif+#else+#if defined(_SIZE_T_) || defined(SIGLOST)+ struct utsname un;+ uname (&un);+ printf ("vax-dec-ultrix%s\n", un.release); exit (0);+#else+ printf ("vax-dec-ultrix\n"); exit (0);+#endif+#endif+#endif+#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__)+#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__)+#if defined(_SIZE_T_) || defined(SIGLOST)+ struct utsname *un;+ uname (&un);+ printf ("mips-dec-ultrix%s\n", un.release); exit (0);+#else+ printf ("mips-dec-ultrix\n"); exit (0);+#endif+#endif+#endif++#if defined (alliant) && defined (i860)+ printf ("i860-alliant-bsd\n"); exit (0);+#endif++ exit (1);+}+EOF++$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=`"$dummy"` &&+ { echo "$SYSTEM_NAME"; exit; }++# Apollos put the system type in the environment.+test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; }++echo "$0: unable to guess system type" >&2++case $UNAME_MACHINE:$UNAME_SYSTEM in+ mips:Linux | mips64:Linux)+ # If we got here on MIPS GNU/Linux, output extra information.+ cat >&2 <<EOF++NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize+the system type. Please install a C compiler and try again.+EOF+ ;;+esac++cat >&2 <<EOF++This script (version $timestamp), has failed to recognize the+operating system you are using. If your script is old, overwrite *all*+copies of config.guess and config.sub with the latest versions from:++ https://git.savannah.gnu.org/cgit/config.git/plain/config.guess+and+ https://git.savannah.gnu.org/cgit/config.git/plain/config.sub+EOF++our_year=`echo $timestamp | sed 's,-.*,,'`+thisyear=`date +%Y`+# shellcheck disable=SC2003+script_age=`expr "$thisyear" - "$our_year"`+if test "$script_age" -lt 3 ; then+ cat >&2 <<EOF++If $0 has already been updated, send the following data and any+information you think might be pertinent to config-patches@gnu.org to+provide the necessary information to handle your system.++config.guess timestamp = $timestamp++uname -m = `(uname -m) 2>/dev/null || echo unknown`+uname -r = `(uname -r) 2>/dev/null || echo unknown`+uname -s = `(uname -s) 2>/dev/null || echo unknown`+uname -v = `(uname -v) 2>/dev/null || echo unknown`++/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`+/bin/uname -X = `(/bin/uname -X) 2>/dev/null`++hostinfo = `(hostinfo) 2>/dev/null`+/bin/universe = `(/bin/universe) 2>/dev/null`+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null`+/bin/arch = `(/bin/arch) 2>/dev/null`+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null`+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`++UNAME_MACHINE = "$UNAME_MACHINE"+UNAME_RELEASE = "$UNAME_RELEASE"+UNAME_SYSTEM = "$UNAME_SYSTEM"+UNAME_VERSION = "$UNAME_VERSION"+EOF+fi++exit 1++# Local variables:+# eval: (add-hook 'before-save-hook 'time-stamp)+# time-stamp-start: "timestamp='"+# time-stamp-format: "%:y-%02m-%02d"+# time-stamp-end: "'"+# End:
+ build/autoconf/config.rpath view
@@ -0,0 +1,684 @@+#! /bin/sh+# Output a system dependent set of variables, describing how to set the+# run time search path of shared libraries in an executable.+#+# Copyright 1996-2024 Free Software Foundation, Inc.+# Taken from GNU libtool, 2001+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996+#+# This file is free software; the Free Software Foundation gives+# unlimited permission to copy and/or distribute it, with or without+# modifications, as long as this notice is preserved.+#+# The first argument passed to this file is the canonical host specification,+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM+# or+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM+# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld+# should be set by the caller.+#+# The set of defined variables is at the end of this script.++# Known limitations:+# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer+# than 256 bytes, otherwise the compiler driver will dump core. The only+# known workaround is to choose shorter directory names for the build+# directory and/or the installation directory.++# All known linkers require a '.a' archive for static linking (except MSVC,+# which needs '.lib').+libext=a+shrext=.so++host="$1"+host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`+host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`+host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`++# Code taken from libtool.m4's _LT_CC_BASENAME.++for cc_temp in $CC""; do+ case $cc_temp in+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;+ \-*) ;;+ *) break;;+ esac+done+cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`++# Code taken from libtool.m4's _LT_COMPILER_PIC.++wl=+if test "$GCC" = yes; then+ wl='-Wl,'+else+ case "$host_os" in+ aix*)+ wl='-Wl,'+ ;;+ mingw* | cygwin* | pw32* | os2* | cegcc*)+ ;;+ hpux9* | hpux10* | hpux11*)+ wl='-Wl,'+ ;;+ irix5* | irix6* | nonstopux*)+ wl='-Wl,'+ ;;+ linux* | k*bsd*-gnu | kopensolaris*-gnu)+ case $cc_basename in+ ecc*)+ wl='-Wl,'+ ;;+ icc* | ifort*)+ wl='-Wl,'+ ;;+ lf95*)+ wl='-Wl,'+ ;;+ nagfor*)+ wl='-Wl,-Wl,,'+ ;;+ pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)+ wl='-Wl,'+ ;;+ ccc*)+ wl='-Wl,'+ ;;+ xl* | bgxl* | bgf* | mpixl*)+ wl='-Wl,'+ ;;+ como)+ wl='-lopt='+ ;;+ *)+ case `$CC -V 2>&1 | sed 5q` in+ *Sun\ F* | *Sun*Fortran*)+ wl=+ ;;+ *Sun\ C*)+ wl='-Wl,'+ ;;+ esac+ ;;+ esac+ ;;+ newsos6)+ ;;+ *nto* | *qnx*)+ ;;+ osf3* | osf4* | osf5*)+ wl='-Wl,'+ ;;+ rdos*)+ ;;+ solaris*)+ case $cc_basename in+ f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)+ wl='-Qoption ld '+ ;;+ *)+ wl='-Wl,'+ ;;+ esac+ ;;+ sunos4*)+ wl='-Qoption ld '+ ;;+ sysv4 | sysv4.2uw2* | sysv4.3*)+ wl='-Wl,'+ ;;+ sysv4*MP*)+ ;;+ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)+ wl='-Wl,'+ ;;+ unicos*)+ wl='-Wl,'+ ;;+ uts4*)+ ;;+ esac+fi++# Code taken from libtool.m4's _LT_LINKER_SHLIBS.++hardcode_libdir_flag_spec=+hardcode_libdir_separator=+hardcode_direct=no+hardcode_minus_L=no++case "$host_os" in+ cygwin* | mingw* | pw32* | cegcc*)+ # FIXME: the MSVC++ port hasn't been tested in a loooong time+ # When not using gcc, we currently assume that we are using+ # Microsoft Visual C++.+ if test "$GCC" != yes; then+ with_gnu_ld=no+ fi+ ;;+ interix*)+ # we just hope/assume this is gcc and not c89 (= MSVC++)+ with_gnu_ld=yes+ ;;+ openbsd*)+ with_gnu_ld=no+ ;;+esac++ld_shlibs=yes+if test "$with_gnu_ld" = yes; then+ # Set some defaults for GNU ld with shared library support. These+ # are reset later if shared libraries are not supported. Putting them+ # here allows them to be overridden if necessary.+ # Unlike libtool, we use -rpath here, not --rpath, since the documented+ # option of GNU ld is called -rpath, not --rpath.+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'+ case "$host_os" in+ aix[3-9]*)+ # On AIX/PPC, the GNU linker is very broken+ if test "$host_cpu" != ia64; then+ ld_shlibs=no+ fi+ ;;+ amigaos*)+ case "$host_cpu" in+ powerpc)+ ;;+ m68k)+ hardcode_libdir_flag_spec='-L$libdir'+ hardcode_minus_L=yes+ ;;+ esac+ ;;+ beos*)+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then+ :+ else+ ld_shlibs=no+ fi+ ;;+ cygwin* | mingw* | pw32* | cegcc*)+ # hardcode_libdir_flag_spec is actually meaningless, as there is+ # no search path for DLLs.+ hardcode_libdir_flag_spec='-L$libdir'+ if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then+ :+ else+ ld_shlibs=no+ fi+ ;;+ haiku*)+ ;;+ interix[3-9]*)+ hardcode_direct=no+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'+ ;;+ gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then+ :+ else+ ld_shlibs=no+ fi+ ;;+ netbsd*)+ ;;+ solaris*)+ if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then+ ld_shlibs=no+ elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then+ :+ else+ ld_shlibs=no+ fi+ ;;+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)+ case `$LD -v 2>&1` in+ *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)+ ld_shlibs=no+ ;;+ *)+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then+ hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'+ else+ ld_shlibs=no+ fi+ ;;+ esac+ ;;+ sunos4*)+ hardcode_direct=yes+ ;;+ *)+ if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then+ :+ else+ ld_shlibs=no+ fi+ ;;+ esac+ if test "$ld_shlibs" = no; then+ hardcode_libdir_flag_spec=+ fi+else+ case "$host_os" in+ aix3*)+ # Note: this linker hardcodes the directories in LIBPATH if there+ # are no directories specified by -L.+ hardcode_minus_L=yes+ if test "$GCC" = yes; then+ # Neither direct hardcoding nor static linking is supported with a+ # broken collect2.+ hardcode_direct=unsupported+ fi+ ;;+ aix[4-9]*)+ if test "$host_cpu" = ia64; then+ # On IA64, the linker does run time linking by default, so we don't+ # have to do anything special.+ aix_use_runtimelinking=no+ else+ aix_use_runtimelinking=no+ # Test if we are trying to use run time linking or normal+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we+ # need to do runtime linking.+ case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)+ for ld_flag in $LDFLAGS; do+ if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then+ aix_use_runtimelinking=yes+ break+ fi+ done+ ;;+ esac+ fi+ hardcode_direct=yes+ hardcode_libdir_separator=':'+ if test "$GCC" = yes; then+ case $host_os in aix4.[012]|aix4.[012].*)+ collect2name=`${CC} -print-prog-name=collect2`+ if test -f "$collect2name" && \+ strings "$collect2name" | grep resolve_lib_name >/dev/null+ then+ # We have reworked collect2+ :+ else+ # We have old collect2+ hardcode_direct=unsupported+ hardcode_minus_L=yes+ hardcode_libdir_flag_spec='-L$libdir'+ hardcode_libdir_separator=+ fi+ ;;+ esac+ fi+ # Begin _LT_AC_SYS_LIBPATH_AIX.+ echo 'int main () { return 0; }' > conftest.c+ ${CC} ${LDFLAGS} conftest.c -o conftest+ aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }+}'`+ if test -z "$aix_libpath"; then+ aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }+}'`+ fi+ if test -z "$aix_libpath"; then+ aix_libpath="/usr/lib:/lib"+ fi+ rm -f conftest.c conftest+ # End _LT_AC_SYS_LIBPATH_AIX.+ if test "$aix_use_runtimelinking" = yes; then+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"+ else+ if test "$host_cpu" = ia64; then+ hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'+ else+ hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"+ fi+ fi+ ;;+ amigaos*)+ case "$host_cpu" in+ powerpc)+ ;;+ m68k)+ hardcode_libdir_flag_spec='-L$libdir'+ hardcode_minus_L=yes+ ;;+ esac+ ;;+ bsdi[45]*)+ ;;+ cygwin* | mingw* | pw32* | cegcc*)+ # When not using gcc, we currently assume that we are using+ # Microsoft Visual C++.+ # hardcode_libdir_flag_spec is actually meaningless, as there is+ # no search path for DLLs.+ hardcode_libdir_flag_spec=' '+ libext=lib+ ;;+ darwin* | rhapsody*)+ hardcode_direct=no+ if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then+ :+ else+ ld_shlibs=no+ fi+ ;;+ dgux*)+ hardcode_libdir_flag_spec='-L$libdir'+ ;;+ freebsd2.[01]*)+ hardcode_direct=yes+ hardcode_minus_L=yes+ ;;+ freebsd* | dragonfly* | midnightbsd*)+ hardcode_libdir_flag_spec='-R$libdir'+ hardcode_direct=yes+ ;;+ hpux9*)+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'+ hardcode_libdir_separator=:+ hardcode_direct=yes+ # hardcode_minus_L: Not really in the search PATH,+ # but as the default location of the library.+ hardcode_minus_L=yes+ ;;+ hpux10*)+ if test "$with_gnu_ld" = no; then+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'+ hardcode_libdir_separator=:+ hardcode_direct=yes+ # hardcode_minus_L: Not really in the search PATH,+ # but as the default location of the library.+ hardcode_minus_L=yes+ fi+ ;;+ hpux11*)+ if test "$with_gnu_ld" = no; then+ hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'+ hardcode_libdir_separator=:+ case $host_cpu in+ hppa*64*|ia64*)+ hardcode_direct=no+ ;;+ *)+ hardcode_direct=yes+ # hardcode_minus_L: Not really in the search PATH,+ # but as the default location of the library.+ hardcode_minus_L=yes+ ;;+ esac+ fi+ ;;+ irix5* | irix6* | nonstopux*)+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'+ hardcode_libdir_separator=:+ ;;+ netbsd*)+ hardcode_libdir_flag_spec='-R$libdir'+ hardcode_direct=yes+ ;;+ newsos6)+ hardcode_direct=yes+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'+ hardcode_libdir_separator=:+ ;;+ *nto* | *qnx*)+ ;;+ openbsd*)+ if test -f /usr/libexec/ld.so; then+ hardcode_direct=yes+ if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'+ else+ case "$host_os" in+ openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)+ hardcode_libdir_flag_spec='-R$libdir'+ ;;+ *)+ hardcode_libdir_flag_spec='${wl}-rpath,$libdir'+ ;;+ esac+ fi+ else+ ld_shlibs=no+ fi+ ;;+ os2*)+ hardcode_libdir_flag_spec='-L$libdir'+ hardcode_minus_L=yes+ ;;+ osf3*)+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'+ hardcode_libdir_separator=:+ ;;+ osf4* | osf5*)+ if test "$GCC" = yes; then+ hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'+ else+ # Both cc and cxx compiler support -rpath directly+ hardcode_libdir_flag_spec='-rpath $libdir'+ fi+ hardcode_libdir_separator=:+ ;;+ solaris*)+ hardcode_libdir_flag_spec='-R$libdir'+ ;;+ sunos4*)+ hardcode_libdir_flag_spec='-L$libdir'+ hardcode_direct=yes+ hardcode_minus_L=yes+ ;;+ sysv4)+ case $host_vendor in+ sni)+ hardcode_direct=yes # is this really true???+ ;;+ siemens)+ hardcode_direct=no+ ;;+ motorola)+ hardcode_direct=no #Motorola manual says yes, but my tests say they lie+ ;;+ esac+ ;;+ sysv4.3*)+ ;;+ sysv4*MP*)+ if test -d /usr/nec; then+ ld_shlibs=yes+ fi+ ;;+ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)+ ;;+ sysv5* | sco3.2v5* | sco5v6*)+ hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'+ hardcode_libdir_separator=':'+ ;;+ uts4*)+ hardcode_libdir_flag_spec='-L$libdir'+ ;;+ *)+ ld_shlibs=no+ ;;+ esac+fi++# Check dynamic linker characteristics+# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER.+# Unlike libtool.m4, here we don't care about _all_ names of the library, but+# only about the one the linker finds when passed -lNAME. This is the last+# element of library_names_spec in libtool.m4, or possibly two of them if the+# linker has special search rules.+library_names_spec= # the last element of library_names_spec in libtool.m4+libname_spec='lib$name'+case "$host_os" in+ aix3*)+ library_names_spec='$libname.a'+ ;;+ aix[4-9]*)+ library_names_spec='$libname$shrext'+ ;;+ amigaos*)+ case "$host_cpu" in+ powerpc*)+ library_names_spec='$libname$shrext' ;;+ m68k)+ library_names_spec='$libname.a' ;;+ esac+ ;;+ beos*)+ library_names_spec='$libname$shrext'+ ;;+ bsdi[45]*)+ library_names_spec='$libname$shrext'+ ;;+ cygwin* | mingw* | pw32* | cegcc*)+ shrext=.dll+ library_names_spec='$libname.dll.a $libname.lib'+ ;;+ darwin* | rhapsody*)+ shrext=.dylib+ library_names_spec='$libname$shrext'+ ;;+ dgux*)+ library_names_spec='$libname$shrext'+ ;;+ freebsd[23].*)+ library_names_spec='$libname$shrext$versuffix'+ ;;+ freebsd* | dragonfly* | midnightbsd*)+ library_names_spec='$libname$shrext'+ ;;+ gnu*)+ library_names_spec='$libname$shrext'+ ;;+ haiku*)+ library_names_spec='$libname$shrext'+ ;;+ hpux9* | hpux10* | hpux11*)+ case $host_cpu in+ ia64*)+ shrext=.so+ ;;+ hppa*64*)+ shrext=.sl+ ;;+ *)+ shrext=.sl+ ;;+ esac+ library_names_spec='$libname$shrext'+ ;;+ interix[3-9]*)+ library_names_spec='$libname$shrext'+ ;;+ irix5* | irix6* | nonstopux*)+ library_names_spec='$libname$shrext'+ case "$host_os" in+ irix5* | nonstopux*)+ libsuff= shlibsuff=+ ;;+ *)+ case $LD in+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;+ *) libsuff= shlibsuff= ;;+ esac+ ;;+ esac+ ;;+ linux*oldld* | linux*aout* | linux*coff*)+ ;;+ linux* | k*bsd*-gnu | kopensolaris*-gnu)+ library_names_spec='$libname$shrext'+ ;;+ knetbsd*-gnu)+ library_names_spec='$libname$shrext'+ ;;+ netbsd*)+ library_names_spec='$libname$shrext'+ ;;+ newsos6)+ library_names_spec='$libname$shrext'+ ;;+ *nto* | *qnx*)+ library_names_spec='$libname$shrext'+ ;;+ openbsd*)+ library_names_spec='$libname$shrext$versuffix'+ ;;+ os2*)+ libname_spec='$name'+ shrext=.dll+ library_names_spec='$libname.a'+ ;;+ osf3* | osf4* | osf5*)+ library_names_spec='$libname$shrext'+ ;;+ rdos*)+ ;;+ solaris*)+ library_names_spec='$libname$shrext'+ ;;+ sunos4*)+ library_names_spec='$libname$shrext$versuffix'+ ;;+ sysv4 | sysv4.3*)+ library_names_spec='$libname$shrext'+ ;;+ sysv4*MP*)+ library_names_spec='$libname$shrext'+ ;;+ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)+ library_names_spec='$libname$shrext'+ ;;+ tpf*)+ library_names_spec='$libname$shrext'+ ;;+ uts4*)+ library_names_spec='$libname$shrext'+ ;;+esac++sed_quote_subst='s/\(["`$\\]\)/\\\1/g'+escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`+shlibext=`echo "$shrext" | sed -e 's,^\.,,'`+escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`+escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`+escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`++LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF++# How to pass a linker flag through the compiler.+wl="$escaped_wl"++# Static library suffix (normally "a").+libext="$libext"++# Shared library suffix (normally "so").+shlibext="$shlibext"++# Format of library name prefix.+libname_spec="$escaped_libname_spec"++# Library names that the linker finds when passed -lNAME.+library_names_spec="$escaped_library_names_spec"++# Flag to hardcode \$libdir into a binary during linking.+# This must work even if \$libdir does not exist.+hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"++# Whether we need a single -rpath flag with a separated argument.+hardcode_libdir_separator="$hardcode_libdir_separator"++# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the+# resulting binary.+hardcode_direct="$hardcode_direct"++# Set to yes if using the -LDIR flag during linking hardcodes DIR into the+# resulting binary.+hardcode_minus_L="$hardcode_minus_L"++EOF
+ build/autoconf/config.sub view
@@ -0,0 +1,1960 @@+#! /bin/sh+# Configuration validation subroutine script.+# Copyright 1992-2023 Free Software Foundation, Inc.++# shellcheck disable=SC2006,SC2268 # see below for rationale++timestamp='2023-09-19'++# This file 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 to the GNU General Public License, if you+# distribute this file as part of a program that contains a+# configuration script generated by Autoconf, you may include it under+# the same distribution terms that you use for the rest of that+# program. This Exception is an additional permission under section 7+# of the GNU General Public License, version 3 ("GPLv3").+++# Please send patches to <config-patches@gnu.org>.+#+# Configuration subroutine to validate and canonicalize a configuration type.+# Supply the specified configuration type as an argument.+# If it is invalid, we print an error message on stderr and exit with code 1.+# Otherwise, we print the canonical config type on stdout and succeed.++# You can get the latest version of this script from:+# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub++# This file is supposed to be the same for all GNU packages+# and recognize all the CPU types, system types and aliases+# that are meaningful with *any* GNU software.+# Each package is responsible for reporting which valid configurations+# it does not support. The user should be able to distinguish+# a failure to support a valid configuration from a meaningless+# configuration.++# The goal of this file is to map all the various variations of a given+# machine specification into a single specification in the form:+# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM+# or in some cases, the newer four-part form:+# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM+# It is wrong to echo any other type of specification.++# The "shellcheck disable" line above the timestamp inhibits complaints+# about features and limitations of the classic Bourne shell that were+# superseded or lifted in POSIX. However, this script identifies a wide+# variety of pre-POSIX systems that do not have POSIX shells at all, and+# even some reasonably current systems (Solaris 10 as case-in-point) still+# have a pre-POSIX /bin/sh.++me=`echo "$0" | sed -e 's,.*/,,'`++usage="\+Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS++Canonicalize a configuration name.++Options:+ -h, --help print this help, then exit+ -t, --time-stamp print date of last modification, then exit+ -v, --version print version number, then exit++Report bugs and patches to <config-patches@gnu.org>."++version="\+GNU config.sub ($timestamp)++Copyright 1992-2023 Free Software Foundation, Inc.++This is free software; see the source for copying conditions. There is NO+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."++help="+Try '$me --help' for more information."++# Parse command line+while test $# -gt 0 ; do+ case $1 in+ --time-stamp | --time* | -t )+ echo "$timestamp" ; exit ;;+ --version | -v )+ echo "$version" ; exit ;;+ --help | --h* | -h )+ echo "$usage"; exit ;;+ -- ) # Stop option processing+ shift; break ;;+ - ) # Use stdin as input.+ break ;;+ -* )+ echo "$me: invalid option $1$help" >&2+ exit 1 ;;++ *local*)+ # First pass through any local machine types.+ echo "$1"+ exit ;;++ * )+ break ;;+ esac+done++case $# in+ 0) echo "$me: missing argument$help" >&2+ exit 1;;+ 1) ;;+ *) echo "$me: too many arguments$help" >&2+ exit 1;;+esac++# Split fields of configuration type+# shellcheck disable=SC2162+saved_IFS=$IFS+IFS="-" read field1 field2 field3 field4 <<EOF+$1+EOF+IFS=$saved_IFS++# Separate into logical components for further validation+case $1 in+ *-*-*-*-*)+ echo "Invalid configuration '$1': more than four components" >&2+ exit 1+ ;;+ *-*-*-*)+ basic_machine=$field1-$field2+ basic_os=$field3-$field4+ ;;+ *-*-*)+ # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two+ # parts+ maybe_os=$field2-$field3+ case $maybe_os in+ nto-qnx* | linux-* | uclinux-uclibc* \+ | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \+ | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \+ | storm-chaos* | os2-emx* | rtmk-nova* | managarm-* \+ | windows-* )+ basic_machine=$field1+ basic_os=$maybe_os+ ;;+ android-linux)+ basic_machine=$field1-unknown+ basic_os=linux-android+ ;;+ *)+ basic_machine=$field1-$field2+ basic_os=$field3+ ;;+ esac+ ;;+ *-*)+ # A lone config we happen to match not fitting any pattern+ case $field1-$field2 in+ decstation-3100)+ basic_machine=mips-dec+ basic_os=+ ;;+ *-*)+ # Second component is usually, but not always the OS+ case $field2 in+ # Prevent following clause from handling this valid os+ sun*os*)+ basic_machine=$field1+ basic_os=$field2+ ;;+ zephyr*)+ basic_machine=$field1-unknown+ basic_os=$field2+ ;;+ # Manufacturers+ dec* | mips* | sequent* | encore* | pc533* | sgi* | sony* \+ | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \+ | unicom* | ibm* | next | hp | isi* | apollo | altos* \+ | convergent* | ncr* | news | 32* | 3600* | 3100* \+ | hitachi* | c[123]* | convex* | sun | crds | omron* | dg \+ | ultra | tti* | harris | dolphin | highlevel | gould \+ | cbm | ns | masscomp | apple | axis | knuth | cray \+ | microblaze* | sim | cisco \+ | oki | wec | wrs | winbond)+ basic_machine=$field1-$field2+ basic_os=+ ;;+ *)+ basic_machine=$field1+ basic_os=$field2+ ;;+ esac+ ;;+ esac+ ;;+ *)+ # Convert single-component short-hands not valid as part of+ # multi-component configurations.+ case $field1 in+ 386bsd)+ basic_machine=i386-pc+ basic_os=bsd+ ;;+ a29khif)+ basic_machine=a29k-amd+ basic_os=udi+ ;;+ adobe68k)+ basic_machine=m68010-adobe+ basic_os=scout+ ;;+ alliant)+ basic_machine=fx80-alliant+ basic_os=+ ;;+ altos | altos3068)+ basic_machine=m68k-altos+ basic_os=+ ;;+ am29k)+ basic_machine=a29k-none+ basic_os=bsd+ ;;+ amdahl)+ basic_machine=580-amdahl+ basic_os=sysv+ ;;+ amiga)+ basic_machine=m68k-unknown+ basic_os=+ ;;+ amigaos | amigados)+ basic_machine=m68k-unknown+ basic_os=amigaos+ ;;+ amigaunix | amix)+ basic_machine=m68k-unknown+ basic_os=sysv4+ ;;+ apollo68)+ basic_machine=m68k-apollo+ basic_os=sysv+ ;;+ apollo68bsd)+ basic_machine=m68k-apollo+ basic_os=bsd+ ;;+ aros)+ basic_machine=i386-pc+ basic_os=aros+ ;;+ aux)+ basic_machine=m68k-apple+ basic_os=aux+ ;;+ balance)+ basic_machine=ns32k-sequent+ basic_os=dynix+ ;;+ blackfin)+ basic_machine=bfin-unknown+ basic_os=linux+ ;;+ cegcc)+ basic_machine=arm-unknown+ basic_os=cegcc+ ;;+ convex-c1)+ basic_machine=c1-convex+ basic_os=bsd+ ;;+ convex-c2)+ basic_machine=c2-convex+ basic_os=bsd+ ;;+ convex-c32)+ basic_machine=c32-convex+ basic_os=bsd+ ;;+ convex-c34)+ basic_machine=c34-convex+ basic_os=bsd+ ;;+ convex-c38)+ basic_machine=c38-convex+ basic_os=bsd+ ;;+ cray)+ basic_machine=j90-cray+ basic_os=unicos+ ;;+ crds | unos)+ basic_machine=m68k-crds+ basic_os=+ ;;+ da30)+ basic_machine=m68k-da30+ basic_os=+ ;;+ decstation | pmax | pmin | dec3100 | decstatn)+ basic_machine=mips-dec+ basic_os=+ ;;+ delta88)+ basic_machine=m88k-motorola+ basic_os=sysv3+ ;;+ dicos)+ basic_machine=i686-pc+ basic_os=dicos+ ;;+ djgpp)+ basic_machine=i586-pc+ basic_os=msdosdjgpp+ ;;+ ebmon29k)+ basic_machine=a29k-amd+ basic_os=ebmon+ ;;+ es1800 | OSE68k | ose68k | ose | OSE)+ basic_machine=m68k-ericsson+ basic_os=ose+ ;;+ gmicro)+ basic_machine=tron-gmicro+ basic_os=sysv+ ;;+ go32)+ basic_machine=i386-pc+ basic_os=go32+ ;;+ h8300hms)+ basic_machine=h8300-hitachi+ basic_os=hms+ ;;+ h8300xray)+ basic_machine=h8300-hitachi+ basic_os=xray+ ;;+ h8500hms)+ basic_machine=h8500-hitachi+ basic_os=hms+ ;;+ harris)+ basic_machine=m88k-harris+ basic_os=sysv3+ ;;+ hp300 | hp300hpux)+ basic_machine=m68k-hp+ basic_os=hpux+ ;;+ hp300bsd)+ basic_machine=m68k-hp+ basic_os=bsd+ ;;+ hppaosf)+ basic_machine=hppa1.1-hp+ basic_os=osf+ ;;+ hppro)+ basic_machine=hppa1.1-hp+ basic_os=proelf+ ;;+ i386mach)+ basic_machine=i386-mach+ basic_os=mach+ ;;+ isi68 | isi)+ basic_machine=m68k-isi+ basic_os=sysv+ ;;+ m68knommu)+ basic_machine=m68k-unknown+ basic_os=linux+ ;;+ magnum | m3230)+ basic_machine=mips-mips+ basic_os=sysv+ ;;+ merlin)+ basic_machine=ns32k-utek+ basic_os=sysv+ ;;+ mingw64)+ basic_machine=x86_64-pc+ basic_os=mingw64+ ;;+ mingw32)+ basic_machine=i686-pc+ basic_os=mingw32+ ;;+ mingw32ce)+ basic_machine=arm-unknown+ basic_os=mingw32ce+ ;;+ monitor)+ basic_machine=m68k-rom68k+ basic_os=coff+ ;;+ morphos)+ basic_machine=powerpc-unknown+ basic_os=morphos+ ;;+ moxiebox)+ basic_machine=moxie-unknown+ basic_os=moxiebox+ ;;+ msdos)+ basic_machine=i386-pc+ basic_os=msdos+ ;;+ msys)+ basic_machine=i686-pc+ basic_os=msys+ ;;+ mvs)+ basic_machine=i370-ibm+ basic_os=mvs+ ;;+ nacl)+ basic_machine=le32-unknown+ basic_os=nacl+ ;;+ ncr3000)+ basic_machine=i486-ncr+ basic_os=sysv4+ ;;+ netbsd386)+ basic_machine=i386-pc+ basic_os=netbsd+ ;;+ netwinder)+ basic_machine=armv4l-rebel+ basic_os=linux+ ;;+ news | news700 | news800 | news900)+ basic_machine=m68k-sony+ basic_os=newsos+ ;;+ news1000)+ basic_machine=m68030-sony+ basic_os=newsos+ ;;+ necv70)+ basic_machine=v70-nec+ basic_os=sysv+ ;;+ nh3000)+ basic_machine=m68k-harris+ basic_os=cxux+ ;;+ nh[45]000)+ basic_machine=m88k-harris+ basic_os=cxux+ ;;+ nindy960)+ basic_machine=i960-intel+ basic_os=nindy+ ;;+ mon960)+ basic_machine=i960-intel+ basic_os=mon960+ ;;+ nonstopux)+ basic_machine=mips-compaq+ basic_os=nonstopux+ ;;+ os400)+ basic_machine=powerpc-ibm+ basic_os=os400+ ;;+ OSE68000 | ose68000)+ basic_machine=m68000-ericsson+ basic_os=ose+ ;;+ os68k)+ basic_machine=m68k-none+ basic_os=os68k+ ;;+ paragon)+ basic_machine=i860-intel+ basic_os=osf+ ;;+ parisc)+ basic_machine=hppa-unknown+ basic_os=linux+ ;;+ psp)+ basic_machine=mipsallegrexel-sony+ basic_os=psp+ ;;+ pw32)+ basic_machine=i586-unknown+ basic_os=pw32+ ;;+ rdos | rdos64)+ basic_machine=x86_64-pc+ basic_os=rdos+ ;;+ rdos32)+ basic_machine=i386-pc+ basic_os=rdos+ ;;+ rom68k)+ basic_machine=m68k-rom68k+ basic_os=coff+ ;;+ sa29200)+ basic_machine=a29k-amd+ basic_os=udi+ ;;+ sei)+ basic_machine=mips-sei+ basic_os=seiux+ ;;+ sequent)+ basic_machine=i386-sequent+ basic_os=+ ;;+ sps7)+ basic_machine=m68k-bull+ basic_os=sysv2+ ;;+ st2000)+ basic_machine=m68k-tandem+ basic_os=+ ;;+ stratus)+ basic_machine=i860-stratus+ basic_os=sysv4+ ;;+ sun2)+ basic_machine=m68000-sun+ basic_os=+ ;;+ sun2os3)+ basic_machine=m68000-sun+ basic_os=sunos3+ ;;+ sun2os4)+ basic_machine=m68000-sun+ basic_os=sunos4+ ;;+ sun3)+ basic_machine=m68k-sun+ basic_os=+ ;;+ sun3os3)+ basic_machine=m68k-sun+ basic_os=sunos3+ ;;+ sun3os4)+ basic_machine=m68k-sun+ basic_os=sunos4+ ;;+ sun4)+ basic_machine=sparc-sun+ basic_os=+ ;;+ sun4os3)+ basic_machine=sparc-sun+ basic_os=sunos3+ ;;+ sun4os4)+ basic_machine=sparc-sun+ basic_os=sunos4+ ;;+ sun4sol2)+ basic_machine=sparc-sun+ basic_os=solaris2+ ;;+ sun386 | sun386i | roadrunner)+ basic_machine=i386-sun+ basic_os=+ ;;+ sv1)+ basic_machine=sv1-cray+ basic_os=unicos+ ;;+ symmetry)+ basic_machine=i386-sequent+ basic_os=dynix+ ;;+ t3e)+ basic_machine=alphaev5-cray+ basic_os=unicos+ ;;+ t90)+ basic_machine=t90-cray+ basic_os=unicos+ ;;+ toad1)+ basic_machine=pdp10-xkl+ basic_os=tops20+ ;;+ tpf)+ basic_machine=s390x-ibm+ basic_os=tpf+ ;;+ udi29k)+ basic_machine=a29k-amd+ basic_os=udi+ ;;+ ultra3)+ basic_machine=a29k-nyu+ basic_os=sym1+ ;;+ v810 | necv810)+ basic_machine=v810-nec+ basic_os=none+ ;;+ vaxv)+ basic_machine=vax-dec+ basic_os=sysv+ ;;+ vms)+ basic_machine=vax-dec+ basic_os=vms+ ;;+ vsta)+ basic_machine=i386-pc+ basic_os=vsta+ ;;+ vxworks960)+ basic_machine=i960-wrs+ basic_os=vxworks+ ;;+ vxworks68)+ basic_machine=m68k-wrs+ basic_os=vxworks+ ;;+ vxworks29k)+ basic_machine=a29k-wrs+ basic_os=vxworks+ ;;+ xbox)+ basic_machine=i686-pc+ basic_os=mingw32+ ;;+ ymp)+ basic_machine=ymp-cray+ basic_os=unicos+ ;;+ *)+ basic_machine=$1+ basic_os=+ ;;+ esac+ ;;+esac++# Decode 1-component or ad-hoc basic machines+case $basic_machine in+ # Here we handle the default manufacturer of certain CPU types. It is in+ # some cases the only manufacturer, in others, it is the most popular.+ w89k)+ cpu=hppa1.1+ vendor=winbond+ ;;+ op50n)+ cpu=hppa1.1+ vendor=oki+ ;;+ op60c)+ cpu=hppa1.1+ vendor=oki+ ;;+ ibm*)+ cpu=i370+ vendor=ibm+ ;;+ orion105)+ cpu=clipper+ vendor=highlevel+ ;;+ mac | mpw | mac-mpw)+ cpu=m68k+ vendor=apple+ ;;+ pmac | pmac-mpw)+ cpu=powerpc+ vendor=apple+ ;;++ # Recognize the various machine names and aliases which stand+ # for a CPU type and a company and sometimes even an OS.+ 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)+ cpu=m68000+ vendor=att+ ;;+ 3b*)+ cpu=we32k+ vendor=att+ ;;+ bluegene*)+ cpu=powerpc+ vendor=ibm+ basic_os=cnk+ ;;+ decsystem10* | dec10*)+ cpu=pdp10+ vendor=dec+ basic_os=tops10+ ;;+ decsystem20* | dec20*)+ cpu=pdp10+ vendor=dec+ basic_os=tops20+ ;;+ delta | 3300 | motorola-3300 | motorola-delta \+ | 3300-motorola | delta-motorola)+ cpu=m68k+ vendor=motorola+ ;;+ dpx2*)+ cpu=m68k+ vendor=bull+ basic_os=sysv3+ ;;+ encore | umax | mmax)+ cpu=ns32k+ vendor=encore+ ;;+ elxsi)+ cpu=elxsi+ vendor=elxsi+ basic_os=${basic_os:-bsd}+ ;;+ fx2800)+ cpu=i860+ vendor=alliant+ ;;+ genix)+ cpu=ns32k+ vendor=ns+ ;;+ h3050r* | hiux*)+ cpu=hppa1.1+ vendor=hitachi+ basic_os=hiuxwe2+ ;;+ hp3k9[0-9][0-9] | hp9[0-9][0-9])+ cpu=hppa1.0+ vendor=hp+ ;;+ hp9k2[0-9][0-9] | hp9k31[0-9])+ cpu=m68000+ vendor=hp+ ;;+ hp9k3[2-9][0-9])+ cpu=m68k+ vendor=hp+ ;;+ hp9k6[0-9][0-9] | hp6[0-9][0-9])+ cpu=hppa1.0+ vendor=hp+ ;;+ hp9k7[0-79][0-9] | hp7[0-79][0-9])+ cpu=hppa1.1+ vendor=hp+ ;;+ hp9k78[0-9] | hp78[0-9])+ # FIXME: really hppa2.0-hp+ cpu=hppa1.1+ vendor=hp+ ;;+ hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)+ # FIXME: really hppa2.0-hp+ cpu=hppa1.1+ vendor=hp+ ;;+ hp9k8[0-9][13679] | hp8[0-9][13679])+ cpu=hppa1.1+ vendor=hp+ ;;+ hp9k8[0-9][0-9] | hp8[0-9][0-9])+ cpu=hppa1.0+ vendor=hp+ ;;+ i*86v32)+ cpu=`echo "$1" | sed -e 's/86.*/86/'`+ vendor=pc+ basic_os=sysv32+ ;;+ i*86v4*)+ cpu=`echo "$1" | sed -e 's/86.*/86/'`+ vendor=pc+ basic_os=sysv4+ ;;+ i*86v)+ cpu=`echo "$1" | sed -e 's/86.*/86/'`+ vendor=pc+ basic_os=sysv+ ;;+ i*86sol2)+ cpu=`echo "$1" | sed -e 's/86.*/86/'`+ vendor=pc+ basic_os=solaris2+ ;;+ j90 | j90-cray)+ cpu=j90+ vendor=cray+ basic_os=${basic_os:-unicos}+ ;;+ iris | iris4d)+ cpu=mips+ vendor=sgi+ case $basic_os in+ irix*)+ ;;+ *)+ basic_os=irix4+ ;;+ esac+ ;;+ miniframe)+ cpu=m68000+ vendor=convergent+ ;;+ *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)+ cpu=m68k+ vendor=atari+ basic_os=mint+ ;;+ news-3600 | risc-news)+ cpu=mips+ vendor=sony+ basic_os=newsos+ ;;+ next | m*-next)+ cpu=m68k+ vendor=next+ case $basic_os in+ openstep*)+ ;;+ nextstep*)+ ;;+ ns2*)+ basic_os=nextstep2+ ;;+ *)+ basic_os=nextstep3+ ;;+ esac+ ;;+ np1)+ cpu=np1+ vendor=gould+ ;;+ op50n-* | op60c-*)+ cpu=hppa1.1+ vendor=oki+ basic_os=proelf+ ;;+ pa-hitachi)+ cpu=hppa1.1+ vendor=hitachi+ basic_os=hiuxwe2+ ;;+ pbd)+ cpu=sparc+ vendor=tti+ ;;+ pbb)+ cpu=m68k+ vendor=tti+ ;;+ pc532)+ cpu=ns32k+ vendor=pc532+ ;;+ pn)+ cpu=pn+ vendor=gould+ ;;+ power)+ cpu=power+ vendor=ibm+ ;;+ ps2)+ cpu=i386+ vendor=ibm+ ;;+ rm[46]00)+ cpu=mips+ vendor=siemens+ ;;+ rtpc | rtpc-*)+ cpu=romp+ vendor=ibm+ ;;+ sde)+ cpu=mipsisa32+ vendor=sde+ basic_os=${basic_os:-elf}+ ;;+ simso-wrs)+ cpu=sparclite+ vendor=wrs+ basic_os=vxworks+ ;;+ tower | tower-32)+ cpu=m68k+ vendor=ncr+ ;;+ vpp*|vx|vx-*)+ cpu=f301+ vendor=fujitsu+ ;;+ w65)+ cpu=w65+ vendor=wdc+ ;;+ w89k-*)+ cpu=hppa1.1+ vendor=winbond+ basic_os=proelf+ ;;+ none)+ cpu=none+ vendor=none+ ;;+ leon|leon[3-9])+ cpu=sparc+ vendor=$basic_machine+ ;;+ leon-*|leon[3-9]-*)+ cpu=sparc+ vendor=`echo "$basic_machine" | sed 's/-.*//'`+ ;;++ *-*)+ # shellcheck disable=SC2162+ saved_IFS=$IFS+ IFS="-" read cpu vendor <<EOF+$basic_machine+EOF+ IFS=$saved_IFS+ ;;+ # We use 'pc' rather than 'unknown'+ # because (1) that's what they normally are, and+ # (2) the word "unknown" tends to confuse beginning users.+ i*86 | x86_64)+ cpu=$basic_machine+ vendor=pc+ ;;+ # These rules are duplicated from below for sake of the special case above;+ # i.e. things that normalized to x86 arches should also default to "pc"+ pc98)+ cpu=i386+ vendor=pc+ ;;+ x64 | amd64)+ cpu=x86_64+ vendor=pc+ ;;+ # Recognize the basic CPU types without company name.+ *)+ cpu=$basic_machine+ vendor=unknown+ ;;+esac++unset -v basic_machine++# Decode basic machines in the full and proper CPU-Company form.+case $cpu-$vendor in+ # Here we handle the default manufacturer of certain CPU types in canonical form. It is in+ # some cases the only manufacturer, in others, it is the most popular.+ craynv-unknown)+ vendor=cray+ basic_os=${basic_os:-unicosmp}+ ;;+ c90-unknown | c90-cray)+ vendor=cray+ basic_os=${Basic_os:-unicos}+ ;;+ fx80-unknown)+ vendor=alliant+ ;;+ romp-unknown)+ vendor=ibm+ ;;+ mmix-unknown)+ vendor=knuth+ ;;+ microblaze-unknown | microblazeel-unknown)+ vendor=xilinx+ ;;+ rs6000-unknown)+ vendor=ibm+ ;;+ vax-unknown)+ vendor=dec+ ;;+ pdp11-unknown)+ vendor=dec+ ;;+ we32k-unknown)+ vendor=att+ ;;+ cydra-unknown)+ vendor=cydrome+ ;;+ i370-ibm*)+ vendor=ibm+ ;;+ orion-unknown)+ vendor=highlevel+ ;;+ xps-unknown | xps100-unknown)+ cpu=xps100+ vendor=honeywell+ ;;++ # Here we normalize CPU types with a missing or matching vendor+ armh-unknown | armh-alt)+ cpu=armv7l+ vendor=alt+ basic_os=${basic_os:-linux-gnueabihf}+ ;;+ dpx20-unknown | dpx20-bull)+ cpu=rs6000+ vendor=bull+ basic_os=${basic_os:-bosx}+ ;;++ # Here we normalize CPU types irrespective of the vendor+ amd64-*)+ cpu=x86_64+ ;;+ blackfin-*)+ cpu=bfin+ basic_os=linux+ ;;+ c54x-*)+ cpu=tic54x+ ;;+ c55x-*)+ cpu=tic55x+ ;;+ c6x-*)+ cpu=tic6x+ ;;+ e500v[12]-*)+ cpu=powerpc+ basic_os=${basic_os}"spe"+ ;;+ mips3*-*)+ cpu=mips64+ ;;+ ms1-*)+ cpu=mt+ ;;+ m68knommu-*)+ cpu=m68k+ basic_os=linux+ ;;+ m9s12z-* | m68hcs12z-* | hcs12z-* | s12z-*)+ cpu=s12z+ ;;+ openrisc-*)+ cpu=or32+ ;;+ parisc-*)+ cpu=hppa+ basic_os=linux+ ;;+ pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)+ cpu=i586+ ;;+ pentiumpro-* | p6-* | 6x86-* | athlon-* | athlon_*-*)+ cpu=i686+ ;;+ pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)+ cpu=i686+ ;;+ pentium4-*)+ cpu=i786+ ;;+ pc98-*)+ cpu=i386+ ;;+ ppc-* | ppcbe-*)+ cpu=powerpc+ ;;+ ppcle-* | powerpclittle-*)+ cpu=powerpcle+ ;;+ ppc64-*)+ cpu=powerpc64+ ;;+ ppc64le-* | powerpc64little-*)+ cpu=powerpc64le+ ;;+ sb1-*)+ cpu=mipsisa64sb1+ ;;+ sb1el-*)+ cpu=mipsisa64sb1el+ ;;+ sh5e[lb]-*)+ cpu=`echo "$cpu" | sed 's/^\(sh.\)e\(.\)$/\1\2e/'`+ ;;+ spur-*)+ cpu=spur+ ;;+ strongarm-* | thumb-*)+ cpu=arm+ ;;+ tx39-*)+ cpu=mipstx39+ ;;+ tx39el-*)+ cpu=mipstx39el+ ;;+ x64-*)+ cpu=x86_64+ ;;+ xscale-* | xscalee[bl]-*)+ cpu=`echo "$cpu" | sed 's/^xscale/arm/'`+ ;;+ arm64-* | aarch64le-*)+ cpu=aarch64+ ;;++ # Recognize the canonical CPU Types that limit and/or modify the+ # company names they are paired with.+ cr16-*)+ basic_os=${basic_os:-elf}+ ;;+ crisv32-* | etraxfs*-*)+ cpu=crisv32+ vendor=axis+ ;;+ cris-* | etrax*-*)+ cpu=cris+ vendor=axis+ ;;+ crx-*)+ basic_os=${basic_os:-elf}+ ;;+ neo-tandem)+ cpu=neo+ vendor=tandem+ ;;+ nse-tandem)+ cpu=nse+ vendor=tandem+ ;;+ nsr-tandem)+ cpu=nsr+ vendor=tandem+ ;;+ nsv-tandem)+ cpu=nsv+ vendor=tandem+ ;;+ nsx-tandem)+ cpu=nsx+ vendor=tandem+ ;;+ mipsallegrexel-sony)+ cpu=mipsallegrexel+ vendor=sony+ ;;+ tile*-*)+ basic_os=${basic_os:-linux-gnu}+ ;;++ *)+ # Recognize the canonical CPU types that are allowed with any+ # company name.+ case $cpu in+ 1750a | 580 \+ | a29k \+ | aarch64 | aarch64_be | aarch64c | arm64ec \+ | abacus \+ | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \+ | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \+ | alphapca5[67] | alpha64pca5[67] \+ | am33_2.0 \+ | amdgcn \+ | arc | arceb | arc32 | arc64 \+ | arm | arm[lb]e | arme[lb] | armv* \+ | avr | avr32 \+ | asmjs \+ | ba \+ | be32 | be64 \+ | bfin | bpf | bs2000 \+ | c[123]* | c30 | [cjt]90 | c4x \+ | c8051 | clipper | craynv | csky | cydra \+ | d10v | d30v | dlx | dsp16xx \+ | e2k | elxsi | epiphany \+ | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \+ | javascript \+ | h8300 | h8500 \+ | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \+ | hexagon \+ | i370 | i*86 | i860 | i960 | ia16 | ia64 \+ | ip2k | iq2000 \+ | k1om \+ | kvx \+ | le32 | le64 \+ | lm32 \+ | loongarch32 | loongarch64 \+ | m32c | m32r | m32rle \+ | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \+ | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \+ | m88110 | m88k | maxq | mb | mcore | mep | metag \+ | microblaze | microblazeel \+ | mips* \+ | mmix \+ | mn10200 | mn10300 \+ | moxie \+ | mt \+ | msp430 \+ | nds32 | nds32le | nds32be \+ | nfp \+ | nios | nios2 | nios2eb | nios2el \+ | none | np1 | ns16k | ns32k | nvptx \+ | open8 \+ | or1k* \+ | or32 \+ | orion \+ | picochip \+ | pdp10 | pdp11 | pj | pjl | pn | power \+ | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \+ | pru \+ | pyramid \+ | riscv | riscv32 | riscv32be | riscv64 | riscv64be \+ | rl78 | romp | rs6000 | rx \+ | s390 | s390x \+ | score \+ | sh | shl \+ | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \+ | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \+ | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \+ | sparclite \+ | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \+ | spu \+ | tahoe \+ | thumbv7* \+ | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \+ | tron \+ | ubicom32 \+ | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \+ | vax \+ | visium \+ | w65 \+ | wasm32 | wasm64 \+ | we32k \+ | x86 | x86_64 | xc16x | xgate | xps100 \+ | xstormy16 | xtensa* \+ | ymp \+ | z8k | z80)+ ;;++ *)+ echo "Invalid configuration '$1': machine '$cpu-$vendor' not recognized" 1>&2+ exit 1+ ;;+ esac+ ;;+esac++# Here we canonicalize certain aliases for manufacturers.+case $vendor in+ digital*)+ vendor=dec+ ;;+ commodore*)+ vendor=cbm+ ;;+ *)+ ;;+esac++# Decode manufacturer-specific aliases for certain operating systems.++if test x"$basic_os" != x+then++# First recognize some ad-hoc cases, or perhaps split kernel-os, or else just+# set os.+obj=+case $basic_os in+ gnu/linux*)+ kernel=linux+ os=`echo "$basic_os" | sed -e 's|gnu/linux|gnu|'`+ ;;+ os2-emx)+ kernel=os2+ os=`echo "$basic_os" | sed -e 's|os2-emx|emx|'`+ ;;+ nto-qnx*)+ kernel=nto+ os=`echo "$basic_os" | sed -e 's|nto-qnx|qnx|'`+ ;;+ *-*)+ # shellcheck disable=SC2162+ saved_IFS=$IFS+ IFS="-" read kernel os <<EOF+$basic_os+EOF+ IFS=$saved_IFS+ ;;+ # Default OS when just kernel was specified+ nto*)+ kernel=nto+ os=`echo "$basic_os" | sed -e 's|nto|qnx|'`+ ;;+ linux*)+ kernel=linux+ os=`echo "$basic_os" | sed -e 's|linux|gnu|'`+ ;;+ managarm*)+ kernel=managarm+ os=`echo "$basic_os" | sed -e 's|managarm|mlibc|'`+ ;;+ *)+ kernel=+ os=$basic_os+ ;;+esac++# Now, normalize the OS (knowing we just have one component, it's not a kernel,+# etc.)+case $os in+ # First match some system type aliases that might get confused+ # with valid system types.+ # solaris* is a basic system type, with this one exception.+ auroraux)+ os=auroraux+ ;;+ bluegene*)+ os=cnk+ ;;+ solaris1 | solaris1.*)+ os=`echo "$os" | sed -e 's|solaris1|sunos4|'`+ ;;+ solaris)+ os=solaris2+ ;;+ unixware*)+ os=sysv4.2uw+ ;;+ # es1800 is here to avoid being matched by es* (a different OS)+ es1800*)+ os=ose+ ;;+ # Some version numbers need modification+ chorusos*)+ os=chorusos+ ;;+ isc)+ os=isc2.2+ ;;+ sco6)+ os=sco5v6+ ;;+ sco5)+ os=sco3.2v5+ ;;+ sco4)+ os=sco3.2v4+ ;;+ sco3.2.[4-9]*)+ os=`echo "$os" | sed -e 's/sco3.2./sco3.2v/'`+ ;;+ sco*v* | scout)+ # Don't match below+ ;;+ sco*)+ os=sco3.2v2+ ;;+ psos*)+ os=psos+ ;;+ qnx*)+ os=qnx+ ;;+ hiux*)+ os=hiuxwe2+ ;;+ lynx*178)+ os=lynxos178+ ;;+ lynx*5)+ os=lynxos5+ ;;+ lynxos*)+ # don't get caught up in next wildcard+ ;;+ lynx*)+ os=lynxos+ ;;+ mac[0-9]*)+ os=`echo "$os" | sed -e 's|mac|macos|'`+ ;;+ opened*)+ os=openedition+ ;;+ os400*)+ os=os400+ ;;+ sunos5*)+ os=`echo "$os" | sed -e 's|sunos5|solaris2|'`+ ;;+ sunos6*)+ os=`echo "$os" | sed -e 's|sunos6|solaris3|'`+ ;;+ wince*)+ os=wince+ ;;+ utek*)+ os=bsd+ ;;+ dynix*)+ os=bsd+ ;;+ acis*)+ os=aos+ ;;+ atheos*)+ os=atheos+ ;;+ syllable*)+ os=syllable+ ;;+ 386bsd)+ os=bsd+ ;;+ ctix* | uts*)+ os=sysv+ ;;+ nova*)+ os=rtmk-nova+ ;;+ ns2)+ os=nextstep2+ ;;+ # Preserve the version number of sinix5.+ sinix5.*)+ os=`echo "$os" | sed -e 's|sinix|sysv|'`+ ;;+ sinix*)+ os=sysv4+ ;;+ tpf*)+ os=tpf+ ;;+ triton*)+ os=sysv3+ ;;+ oss*)+ os=sysv3+ ;;+ svr4*)+ os=sysv4+ ;;+ svr3)+ os=sysv3+ ;;+ sysvr4)+ os=sysv4+ ;;+ ose*)+ os=ose+ ;;+ *mint | mint[0-9]* | *MiNT | MiNT[0-9]*)+ os=mint+ ;;+ dicos*)+ os=dicos+ ;;+ pikeos*)+ # Until real need of OS specific support for+ # particular features comes up, bare metal+ # configurations are quite functional.+ case $cpu in+ arm*)+ os=eabi+ ;;+ *)+ os=+ obj=elf+ ;;+ esac+ ;;+ aout* | coff* | elf* | pe*)+ # These are machine code file formats, not OSes+ obj=$os+ os=+ ;;+ *)+ # No normalization, but not necessarily accepted, that comes below.+ ;;+esac++else++# Here we handle the default operating systems that come with various machines.+# The value should be what the vendor currently ships out the door with their+# machine or put another way, the most popular os provided with the machine.++# Note that if you're going to try to match "-MANUFACTURER" here (say,+# "-sun"), then you have to tell the case statement up towards the top+# that MANUFACTURER isn't an operating system. Otherwise, code above+# will signal an error saying that MANUFACTURER isn't an operating+# system, and we'll never get to this point.++kernel=+obj=+case $cpu-$vendor in+ score-*)+ os=+ obj=elf+ ;;+ spu-*)+ os=+ obj=elf+ ;;+ *-acorn)+ os=riscix1.2+ ;;+ arm*-rebel)+ kernel=linux+ os=gnu+ ;;+ arm*-semi)+ os=+ obj=aout+ ;;+ c4x-* | tic4x-*)+ os=+ obj=coff+ ;;+ c8051-*)+ os=+ obj=elf+ ;;+ clipper-intergraph)+ os=clix+ ;;+ hexagon-*)+ os=+ obj=elf+ ;;+ tic54x-*)+ os=+ obj=coff+ ;;+ tic55x-*)+ os=+ obj=coff+ ;;+ tic6x-*)+ os=+ obj=coff+ ;;+ # This must come before the *-dec entry.+ pdp10-*)+ os=tops20+ ;;+ pdp11-*)+ os=none+ ;;+ *-dec | vax-*)+ os=ultrix4.2+ ;;+ m68*-apollo)+ os=domain+ ;;+ i386-sun)+ os=sunos4.0.2+ ;;+ m68000-sun)+ os=sunos3+ ;;+ m68*-cisco)+ os=+ obj=aout+ ;;+ mep-*)+ os=+ obj=elf+ ;;+ mips*-cisco)+ os=+ obj=elf+ ;;+ mips*-*)+ os=+ obj=elf+ ;;+ or32-*)+ os=+ obj=coff+ ;;+ *-tti) # must be before sparc entry or we get the wrong os.+ os=sysv3+ ;;+ sparc-* | *-sun)+ os=sunos4.1.1+ ;;+ pru-*)+ os=+ obj=elf+ ;;+ *-be)+ os=beos+ ;;+ *-ibm)+ os=aix+ ;;+ *-knuth)+ os=mmixware+ ;;+ *-wec)+ os=proelf+ ;;+ *-winbond)+ os=proelf+ ;;+ *-oki)+ os=proelf+ ;;+ *-hp)+ os=hpux+ ;;+ *-hitachi)+ os=hiux+ ;;+ i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)+ os=sysv+ ;;+ *-cbm)+ os=amigaos+ ;;+ *-dg)+ os=dgux+ ;;+ *-dolphin)+ os=sysv3+ ;;+ m68k-ccur)+ os=rtu+ ;;+ m88k-omron*)+ os=luna+ ;;+ *-next)+ os=nextstep+ ;;+ *-sequent)+ os=ptx+ ;;+ *-crds)+ os=unos+ ;;+ *-ns)+ os=genix+ ;;+ i370-*)+ os=mvs+ ;;+ *-gould)+ os=sysv+ ;;+ *-highlevel)+ os=bsd+ ;;+ *-encore)+ os=bsd+ ;;+ *-sgi)+ os=irix+ ;;+ *-siemens)+ os=sysv4+ ;;+ *-masscomp)+ os=rtu+ ;;+ f30[01]-fujitsu | f700-fujitsu)+ os=uxpv+ ;;+ *-rom68k)+ os=+ obj=coff+ ;;+ *-*bug)+ os=+ obj=coff+ ;;+ *-apple)+ os=macos+ ;;+ *-atari*)+ os=mint+ ;;+ *-wrs)+ os=vxworks+ ;;+ *)+ os=none+ ;;+esac++fi++# Now, validate our (potentially fixed-up) individual pieces (OS, OBJ).++case $os in+ # Sometimes we do "kernel-libc", so those need to count as OSes.+ musl* | newlib* | relibc* | uclibc*)+ ;;+ # Likewise for "kernel-abi"+ eabi* | gnueabi*)+ ;;+ # VxWorks passes extra cpu info in the 4th filed.+ simlinux | simwindows | spe)+ ;;+ # See `case $cpu-$os` validation below+ ghcjs)+ ;;+ # Now accept the basic system types.+ # The portable systems comes first.+ # Each alternative MUST end in a * to match a version number.+ gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \+ | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \+ | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \+ | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \+ | hiux* | abug | nacl* | netware* | windows* \+ | os9* | macos* | osx* | ios* | tvos* | watchos* \+ | mpw* | magic* | mmixware* | mon960* | lnews* \+ | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \+ | aos* | aros* | cloudabi* | sortix* | twizzler* \+ | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \+ | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \+ | mirbsd* | netbsd* | dicos* | openedition* | ose* \+ | bitrig* | openbsd* | secbsd* | solidbsd* | libertybsd* | os108* \+ | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \+ | bosx* | nextstep* | cxux* | oabi* \+ | ptx* | ecoff* | winnt* | domain* | vsta* \+ | udi* | lites* | ieee* | go32* | aux* | hcos* \+ | chorusrdb* | cegcc* | glidix* | serenity* \+ | cygwin* | msys* | moss* | proelf* | rtems* \+ | midipix* | mingw32* | mingw64* | mint* \+ | uxpv* | beos* | mpeix* | udk* | moxiebox* \+ | interix* | uwin* | mks* | rhapsody* | darwin* \+ | openstep* | oskit* | conix* | pw32* | nonstopux* \+ | storm-chaos* | tops10* | tenex* | tops20* | its* \+ | os2* | vos* | palmos* | uclinux* | nucleus* | morphos* \+ | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \+ | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \+ | skyos* | haiku* | rdos* | toppers* | drops* | es* \+ | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \+ | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \+ | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx* | zephyr* \+ | fiwix* | mlibc* | cos* | mbr* )+ ;;+ # This one is extra strict with allowed versions+ sco3.2v2 | sco3.2v[4-9]* | sco5v6*)+ # Don't forget version if it is 3.2v4 or newer.+ ;;+ none)+ ;;+ kernel* | msvc* )+ # Restricted further below+ ;;+ '')+ if test x"$obj" = x+ then+ echo "Invalid configuration '$1': Blank OS only allowed with explicit machine code file format" 1>&2+ fi+ ;;+ *)+ echo "Invalid configuration '$1': OS '$os' not recognized" 1>&2+ exit 1+ ;;+esac++case $obj in+ aout* | coff* | elf* | pe*)+ ;;+ '')+ # empty is fine+ ;;+ *)+ echo "Invalid configuration '$1': Machine code format '$obj' not recognized" 1>&2+ exit 1+ ;;+esac++# Here we handle the constraint that a (synthetic) cpu and os are+# valid only in combination with each other and nowhere else.+case $cpu-$os in+ # The "javascript-unknown-ghcjs" triple is used by GHC; we+ # accept it here in order to tolerate that, but reject any+ # variations.+ javascript-ghcjs)+ ;;+ javascript-* | *-ghcjs)+ echo "Invalid configuration '$1': cpu '$cpu' is not valid with os '$os$obj'" 1>&2+ exit 1+ ;;+esac++# As a final step for OS-related things, validate the OS-kernel combination+# (given a valid OS), if there is a kernel.+case $kernel-$os-$obj in+ linux-gnu*- | linux-dietlibc*- | linux-android*- | linux-newlib*- \+ | linux-musl*- | linux-relibc*- | linux-uclibc*- | linux-mlibc*- )+ ;;+ uclinux-uclibc*- )+ ;;+ managarm-mlibc*- | managarm-kernel*- )+ ;;+ windows*-msvc*-)+ ;;+ -dietlibc*- | -newlib*- | -musl*- | -relibc*- | -uclibc*- | -mlibc*- )+ # These are just libc implementations, not actual OSes, and thus+ # require a kernel.+ echo "Invalid configuration '$1': libc '$os' needs explicit kernel." 1>&2+ exit 1+ ;;+ -kernel*- )+ echo "Invalid configuration '$1': '$os' needs explicit kernel." 1>&2+ exit 1+ ;;+ *-kernel*- )+ echo "Invalid configuration '$1': '$kernel' does not support '$os'." 1>&2+ exit 1+ ;;+ *-msvc*- )+ echo "Invalid configuration '$1': '$os' needs 'windows'." 1>&2+ exit 1+ ;;+ kfreebsd*-gnu*- | kopensolaris*-gnu*-)+ ;;+ vxworks-simlinux- | vxworks-simwindows- | vxworks-spe-)+ ;;+ nto-qnx*-)+ ;;+ os2-emx-)+ ;;+ *-eabi*- | *-gnueabi*-)+ ;;+ none--*)+ # None (no kernel, i.e. freestanding / bare metal),+ # can be paired with an machine code file format+ ;;+ -*-)+ # Blank kernel with real OS is always fine.+ ;;+ --*)+ # Blank kernel and OS with real machine code file format is always fine.+ ;;+ *-*-*)+ echo "Invalid configuration '$1': Kernel '$kernel' not known to work with OS '$os'." 1>&2+ exit 1+ ;;+esac++# Here we handle the case where we know the os, and the CPU type, but not the+# manufacturer. We pick the logical manufacturer.+case $vendor in+ unknown)+ case $cpu-$os in+ *-riscix*)+ vendor=acorn+ ;;+ *-sunos*)+ vendor=sun+ ;;+ *-cnk* | *-aix*)+ vendor=ibm+ ;;+ *-beos*)+ vendor=be+ ;;+ *-hpux*)+ vendor=hp+ ;;+ *-mpeix*)+ vendor=hp+ ;;+ *-hiux*)+ vendor=hitachi+ ;;+ *-unos*)+ vendor=crds+ ;;+ *-dgux*)+ vendor=dg+ ;;+ *-luna*)+ vendor=omron+ ;;+ *-genix*)+ vendor=ns+ ;;+ *-clix*)+ vendor=intergraph+ ;;+ *-mvs* | *-opened*)+ vendor=ibm+ ;;+ *-os400*)+ vendor=ibm+ ;;+ s390-* | s390x-*)+ vendor=ibm+ ;;+ *-ptx*)+ vendor=sequent+ ;;+ *-tpf*)+ vendor=ibm+ ;;+ *-vxsim* | *-vxworks* | *-windiss*)+ vendor=wrs+ ;;+ *-aux*)+ vendor=apple+ ;;+ *-hms*)+ vendor=hitachi+ ;;+ *-mpw* | *-macos*)+ vendor=apple+ ;;+ *-*mint | *-mint[0-9]* | *-*MiNT | *-MiNT[0-9]*)+ vendor=atari+ ;;+ *-vos*)+ vendor=stratus+ ;;+ esac+ ;;+esac++echo "$cpu-$vendor${kernel:+-$kernel}${os:+-$os}${obj:+-$obj}"+exit++# Local variables:+# eval: (add-hook 'before-save-hook 'time-stamp)+# time-stamp-start: "timestamp='"+# time-stamp-format: "%:y-%02m-%02d"+# time-stamp-end: "'"+# End:
+ build/autoconf/install-sh view
@@ -0,0 +1,541 @@+#!/bin/sh+# install - install a program, script, or datafile++scriptversion=2023-11-23.18; # UTC++# This originates from X11R5 (mit/util/scripts/install.sh), which was+# later released in X11R6 (xc/config/util/install.sh) with the+# following copyright and license.+#+# Copyright (C) 1994 X Consortium+#+# Permission is hereby granted, free of charge, to any person obtaining a copy+# of this software and associated documentation files (the "Software"), to+# deal in the Software without restriction, including without limitation the+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or+# sell copies of the Software, and to permit persons to whom the Software is+# furnished to do so, subject to the following conditions:+#+# The above copyright notice and this permission notice shall be included in+# all copies or substantial portions of the Software.+#+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.+#+# Except as contained in this notice, the name of the X Consortium shall not+# be used in advertising or otherwise to promote the sale, use or other deal-+# ings in this Software without prior written authorization from the X Consor-+# tium.+#+#+# FSF changes to this file are in the public domain.+#+# Calling this script install-sh is preferred over install.sh, to prevent+# 'make' implicit rules from creating a file called install from it+# when there is no Makefile.+#+# This script is compatible with the BSD install script, but was written+# from scratch.++tab=' '+nl='+'+IFS=" $tab$nl"++# Set DOITPROG to "echo" to test this script.++doit=${DOITPROG-}+doit_exec=${doit:-exec}++# Put in absolute file names if you don't have them in your path;+# or use environment vars.++chgrpprog=${CHGRPPROG-chgrp}+chmodprog=${CHMODPROG-chmod}+chownprog=${CHOWNPROG-chown}+cmpprog=${CMPPROG-cmp}+cpprog=${CPPROG-cp}+mkdirprog=${MKDIRPROG-mkdir}+mvprog=${MVPROG-mv}+rmprog=${RMPROG-rm}+stripprog=${STRIPPROG-strip}++posix_mkdir=++# Desired mode of installed file.+mode=0755++# Create dirs (including intermediate dirs) using mode 755.+# This is like GNU 'install' as of coreutils 8.32 (2020).+mkdir_umask=22++backupsuffix=+chgrpcmd=+chmodcmd=$chmodprog+chowncmd=+mvcmd=$mvprog+rmcmd="$rmprog -f"+stripcmd=++src=+dst=+dir_arg=+dst_arg=++copy_on_change=false+is_target_a_directory=possibly++usage="\+Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE+ or: $0 [OPTION]... SRCFILES... DIRECTORY+ or: $0 [OPTION]... -t DIRECTORY SRCFILES...+ or: $0 [OPTION]... -d DIRECTORIES...++In the 1st form, copy SRCFILE to DSTFILE.+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.+In the 4th, create DIRECTORIES.++Options:+ --help display this help and exit.+ --version display version info and exit.++ -c (ignored)+ -C install only if different (preserve data modification time)+ -d create directories instead of installing files.+ -g GROUP $chgrpprog installed files to GROUP.+ -m MODE $chmodprog installed files to MODE.+ -o USER $chownprog installed files to USER.+ -p pass -p to $cpprog.+ -s $stripprog installed files.+ -S SUFFIX attempt to back up existing files, with suffix SUFFIX.+ -t DIRECTORY install into DIRECTORY.+ -T report an error if DSTFILE is a directory.++Environment variables override the default commands:+ CHGRPPROG CHMODPROG CHOWNPROG CMPPROG CPPROG MKDIRPROG MVPROG+ RMPROG STRIPPROG++By default, rm is invoked with -f; when overridden with RMPROG,+it's up to you to specify -f if you want it.++If -S is not specified, no backups are attempted.++Report bugs to <bug-automake@gnu.org>.+GNU Automake home page: <https://www.gnu.org/software/automake/>.+General help using GNU software: <https://www.gnu.org/gethelp/>."++while test $# -ne 0; do+ case $1 in+ -c) ;;++ -C) copy_on_change=true;;++ -d) dir_arg=true;;++ -g) chgrpcmd="$chgrpprog $2"+ shift;;++ --help) echo "$usage"; exit $?;;++ -m) mode=$2+ case $mode in+ *' '* | *"$tab"* | *"$nl"* | *'*'* | *'?'* | *'['*)+ echo "$0: invalid mode: $mode" >&2+ exit 1;;+ esac+ shift;;++ -o) chowncmd="$chownprog $2"+ shift;;++ -p) cpprog="$cpprog -p";;++ -s) stripcmd=$stripprog;;++ -S) backupsuffix="$2"+ shift;;++ -t)+ is_target_a_directory=always+ dst_arg=$2+ # Protect names problematic for 'test' and other utilities.+ case $dst_arg in+ -* | [=\(\)!]) dst_arg=./$dst_arg;;+ esac+ shift;;++ -T) is_target_a_directory=never;;++ --version) echo "$0 $scriptversion"; exit $?;;++ --) shift+ break;;++ -*) echo "$0: invalid option: $1" >&2+ exit 1;;++ *) break;;+ esac+ shift+done++# We allow the use of options -d and -T together, by making -d+# take the precedence; this is for compatibility with GNU install.++if test -n "$dir_arg"; then+ if test -n "$dst_arg"; then+ echo "$0: target directory not allowed when installing a directory." >&2+ exit 1+ fi+fi++if test $# -ne 0 && test -z "$dir_arg$dst_arg"; then+ # When -d is used, all remaining arguments are directories to create.+ # When -t is used, the destination is already specified.+ # Otherwise, the last argument is the destination. Remove it from $@.+ for arg+ do+ if test -n "$dst_arg"; then+ # $@ is not empty: it contains at least $arg.+ set fnord "$@" "$dst_arg"+ shift # fnord+ fi+ shift # arg+ dst_arg=$arg+ # Protect names problematic for 'test' and other utilities.+ case $dst_arg in+ -* | [=\(\)!]) dst_arg=./$dst_arg;;+ esac+ done+fi++if test $# -eq 0; then+ if test -z "$dir_arg"; then+ echo "$0: no input file specified." >&2+ exit 1+ fi+ # It's OK to call 'install-sh -d' without argument.+ # This can happen when creating conditional directories.+ exit 0+fi++if test -z "$dir_arg"; then+ if test $# -gt 1 || test "$is_target_a_directory" = always; then+ if test ! -d "$dst_arg"; then+ echo "$0: $dst_arg: Is not a directory." >&2+ exit 1+ fi+ fi+fi++if test -z "$dir_arg"; then+ do_exit='(exit $ret); exit $ret'+ trap "ret=129; $do_exit" 1+ trap "ret=130; $do_exit" 2+ trap "ret=141; $do_exit" 13+ trap "ret=143; $do_exit" 15++ # Set umask so as not to create temps with too-generous modes.+ # However, 'strip' requires both read and write access to temps.+ case $mode in+ # Optimize common cases.+ *644) cp_umask=133;;+ *755) cp_umask=22;;++ *[0-7])+ if test -z "$stripcmd"; then+ u_plus_rw=+ else+ u_plus_rw='% 200'+ fi+ cp_umask=`expr '(' 777 - $mode % 1000 ')' $u_plus_rw`;;+ *)+ if test -z "$stripcmd"; then+ u_plus_rw=+ else+ u_plus_rw=,u+rw+ fi+ cp_umask=$mode$u_plus_rw;;+ esac+fi++for src+do+ # Protect names problematic for 'test' and other utilities.+ case $src in+ -* | [=\(\)!]) src=./$src;;+ esac++ if test -n "$dir_arg"; then+ dst=$src+ dstdir=$dst+ test -d "$dstdir"+ dstdir_status=$?+ # Don't chown directories that already exist.+ if test $dstdir_status = 0; then+ chowncmd=""+ fi+ else++ # Waiting for this to be detected by the "$cpprog $src $dsttmp" command+ # might cause directories to be created, which would be especially bad+ # if $src (and thus $dsttmp) contains '*'.+ if test ! -f "$src" && test ! -d "$src"; then+ echo "$0: $src does not exist." >&2+ exit 1+ fi++ if test -z "$dst_arg"; then+ echo "$0: no destination specified." >&2+ exit 1+ fi+ dst=$dst_arg++ # If destination is a directory, append the input filename.+ if test -d "$dst"; then+ if test "$is_target_a_directory" = never; then+ echo "$0: $dst_arg: Is a directory" >&2+ exit 1+ fi+ dstdir=$dst+ dstbase=`basename "$src"`+ case $dst in+ */) dst=$dst$dstbase;;+ *) dst=$dst/$dstbase;;+ esac+ dstdir_status=0+ else+ dstdir=`dirname "$dst"`+ test -d "$dstdir"+ dstdir_status=$?+ fi+ fi++ case $dstdir in+ */) dstdirslash=$dstdir;;+ *) dstdirslash=$dstdir/;;+ esac++ obsolete_mkdir_used=false++ if test $dstdir_status != 0; then+ case $posix_mkdir in+ '')+ # With -d, create the new directory with the user-specified mode.+ # Otherwise, rely on $mkdir_umask.+ if test -n "$dir_arg"; then+ mkdir_mode=-m$mode+ else+ mkdir_mode=+ fi++ posix_mkdir=false+ # The $RANDOM variable is not portable (e.g., dash). Use it+ # here however when possible just to lower collision chance.+ tmpdir=${TMPDIR-/tmp}/ins$RANDOM-$$++ trap '+ ret=$?+ rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir" 2>/dev/null+ exit $ret+ ' 0++ # Because "mkdir -p" follows existing symlinks and we likely work+ # directly in world-writeable /tmp, make sure that the '$tmpdir'+ # directory is successfully created first before we actually test+ # 'mkdir -p'.+ if (umask $mkdir_umask &&+ $mkdirprog $mkdir_mode "$tmpdir" &&+ exec $mkdirprog $mkdir_mode -p -- "$tmpdir/a/b") >/dev/null 2>&1+ then+ if test -z "$dir_arg" || {+ # Check for POSIX incompatibilities with -m.+ # HP-UX 11.23 and IRIX 6.5 mkdir -m -p sets group- or+ # other-writable bit of parent directory when it shouldn't.+ # FreeBSD 6.1 mkdir -m -p sets mode of existing directory.+ test_tmpdir="$tmpdir/a"+ ls_ld_tmpdir=`ls -ld "$test_tmpdir"`+ case $ls_ld_tmpdir in+ d????-?r-*) different_mode=700;;+ d????-?--*) different_mode=755;;+ *) false;;+ esac &&+ $mkdirprog -m$different_mode -p -- "$test_tmpdir" && {+ ls_ld_tmpdir_1=`ls -ld "$test_tmpdir"`+ test "$ls_ld_tmpdir" = "$ls_ld_tmpdir_1"+ }+ }+ then posix_mkdir=:+ fi+ rmdir "$tmpdir/a/b" "$tmpdir/a" "$tmpdir"+ else+ # Remove any dirs left behind by ancient mkdir implementations.+ rmdir ./$mkdir_mode ./-p ./-- "$tmpdir" 2>/dev/null+ fi+ trap '' 0;;+ esac++ if+ $posix_mkdir && (+ umask $mkdir_umask &&+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir"+ )+ then :+ else++ # mkdir does not conform to POSIX,+ # or it failed possibly due to a race condition. Create the+ # directory the slow way, step by step, checking for races as we go.++ case $dstdir in+ /*) prefix='/';;+ [-=\(\)!]*) prefix='./';;+ *) prefix='';;+ esac++ oIFS=$IFS+ IFS=/+ set -f+ set fnord $dstdir+ shift+ set +f+ IFS=$oIFS++ prefixes=++ for d+ do+ test X"$d" = X && continue++ prefix=$prefix$d+ if test -d "$prefix"; then+ prefixes=+ else+ if $posix_mkdir; then+ (umask $mkdir_umask &&+ $doit_exec $mkdirprog $mkdir_mode -p -- "$dstdir") && break+ # Don't fail if two instances are running concurrently.+ test -d "$prefix" || exit 1+ else+ case $prefix in+ *\'*) qprefix=`echo "$prefix" | sed "s/'/'\\\\\\\\''/g"`;;+ *) qprefix=$prefix;;+ esac+ prefixes="$prefixes '$qprefix'"+ fi+ fi+ prefix=$prefix/+ done++ if test -n "$prefixes"; then+ # Don't fail if two instances are running concurrently.+ (umask $mkdir_umask &&+ eval "\$doit_exec \$mkdirprog $prefixes") ||+ test -d "$dstdir" || exit 1+ obsolete_mkdir_used=true+ fi+ fi+ fi++ if test -n "$dir_arg"; then+ { test -z "$chowncmd" || $doit $chowncmd "$dst"; } &&+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } &&+ { test "$obsolete_mkdir_used$chowncmd$chgrpcmd" = false ||+ test -z "$chmodcmd" || $doit $chmodcmd $mode "$dst"; } || exit 1+ else++ # Make a couple of temp file names in the proper directory.+ dsttmp=${dstdirslash}_inst.$$_+ rmtmp=${dstdirslash}_rm.$$_++ # Trap to clean up those temp files at exit.+ trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0++ # Copy the file name to the temp name.+ (umask $cp_umask &&+ { test -z "$stripcmd" || {+ # Create $dsttmp read-write so that cp doesn't create it read-only,+ # which would cause strip to fail.+ if test -z "$doit"; then+ : >"$dsttmp" # No need to fork-exec 'touch'.+ else+ $doit touch "$dsttmp"+ fi+ }+ } &&+ $doit_exec $cpprog "$src" "$dsttmp") &&++ # and set any options; do chmod last to preserve setuid bits.+ #+ # If any of these fail, we abort the whole thing. If we want to+ # ignore errors from any of these, just make sure not to ignore+ # errors from the above "$doit $cpprog $src $dsttmp" command.+ #+ { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } &&+ { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } &&+ { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } &&+ { test -z "$chmodcmd" || $doit $chmodcmd $mode "$dsttmp"; } &&++ # If -C, don't bother to copy if it wouldn't change the file.+ if $copy_on_change &&+ old=`LC_ALL=C ls -dlL "$dst" 2>/dev/null` &&+ new=`LC_ALL=C ls -dlL "$dsttmp" 2>/dev/null` &&+ set -f &&+ set X $old && old=:$2:$4:$5:$6 &&+ set X $new && new=:$2:$4:$5:$6 &&+ set +f &&+ test "$old" = "$new" &&+ $cmpprog "$dst" "$dsttmp" >/dev/null 2>&1+ then+ rm -f "$dsttmp"+ else+ # If $backupsuffix is set, and the file being installed+ # already exists, attempt a backup. Don't worry if it fails,+ # e.g., if mv doesn't support -f.+ if test -n "$backupsuffix" && test -f "$dst"; then+ $doit $mvcmd -f "$dst" "$dst$backupsuffix" 2>/dev/null+ fi++ # Rename the file to the real destination.+ $doit $mvcmd -f "$dsttmp" "$dst" 2>/dev/null ||++ # The rename failed, perhaps because mv can't rename something else+ # to itself, or perhaps because mv is so ancient that it does not+ # support -f.+ {+ # Now remove or move aside any old file at destination location.+ # We try this two ways since rm can't unlink itself on some+ # systems and the destination file might be busy for other+ # reasons. In this case, the final cleanup might fail but the new+ # file should still install successfully.+ {+ test ! -f "$dst" ||+ $doit $rmcmd "$dst" 2>/dev/null ||+ { $doit $mvcmd -f "$dst" "$rmtmp" 2>/dev/null &&+ { $doit $rmcmd "$rmtmp" 2>/dev/null; :; }+ } ||+ { echo "$0: cannot unlink or rename $dst" >&2+ (exit 1); exit 1+ }+ } &&++ # Now rename the file to the real destination.+ $doit $mvcmd "$dsttmp" "$dst"+ }+ fi || exit 1++ trap '' 0+ fi+done++# Local variables:+# eval: (add-hook 'before-save-hook 'time-stamp)+# time-stamp-start: "scriptversion="+# time-stamp-format: "%:y-%02m-%02d.%02H"+# time-stamp-time-zone: "UTC0"+# time-stamp-end: "; # UTC"+# End:
+ build/autoconf/ltmain.sh view
@@ -0,0 +1,11436 @@+#! /usr/bin/env sh+## DO NOT EDIT - This file generated from ./build-aux/ltmain.in+## by inline-source v2019-02-19.15++# libtool (GNU libtool) 2.4.7+# Provide generalized library-building support services.+# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996++# Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc.+# This is free software; see the source for copying conditions. There is NO+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.++# GNU Libtool 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.+#+# As a special exception to the GNU General Public License,+# if you distribute this file as part of a program or library that+# is built using GNU Libtool, you may include this file under the+# same distribution terms that you use for the rest of that program.+#+# GNU Libtool 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/>.+++PROGRAM=libtool+PACKAGE=libtool+VERSION=2.4.7+package_revision=2.4.7+++## ------ ##+## Usage. ##+## ------ ##++# Run './libtool --help' for help with using this script from the+# command line.+++## ------------------------------- ##+## User overridable command paths. ##+## ------------------------------- ##++# After configure completes, it has a better idea of some of the+# shell tools we need than the defaults used by the functions shared+# with bootstrap, so set those here where they can still be over-+# ridden by the user, but otherwise take precedence.++: ${AUTOCONF="autoconf"}+: ${AUTOMAKE="automake"}+++## -------------------------- ##+## Source external libraries. ##+## -------------------------- ##++# Much of our low-level functionality needs to be sourced from external+# libraries, which are installed to $pkgauxdir.++# Set a version string for this script.+scriptversion=2019-02-19.15; # UTC++# General shell script boiler plate, and helper functions.+# Written by Gary V. Vaughan, 2004++# This is free software. There is NO warranty; not even for+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.+#+# Copyright (C) 2004-2019, 2021 Bootstrap Authors+#+# This file is dual licensed under the terms of the MIT license+# <https://opensource.org/license/MIT>, and GPL version 2 or later+# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of+# these licenses when using or redistributing this software or any of+# the files within it. See the URLs above, or the file `LICENSE`+# included in the Bootstrap distribution for the full license texts.++# Please report bugs or propose patches to:+# <https://github.com/gnulib-modules/bootstrap/issues>+++## ------ ##+## Usage. ##+## ------ ##++# Evaluate this file near the top of your script to gain access to+# the functions and variables defined here:+#+# . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh+#+# If you need to override any of the default environment variable+# settings, do that before evaluating this file.+++## -------------------- ##+## Shell normalisation. ##+## -------------------- ##++# Some shells need a little help to be as Bourne compatible as possible.+# Before doing anything else, make sure all that help has been provided!++DUALCASE=1; export DUALCASE # for MKS sh+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :+ emulate sh+ NULLCMD=:+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which+ # is contrary to our usage. Disable this feature.+ alias -g '${1+"$@"}'='"$@"'+ setopt NO_GLOB_SUBST+else+ case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac+fi++# NLS nuisances: We save the old values in case they are required later.+_G_user_locale=+_G_safe_locale=+for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES+do+ eval "if test set = \"\${$_G_var+set}\"; then+ save_$_G_var=\$$_G_var+ $_G_var=C+ export $_G_var+ _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"+ _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"+ fi"+done+# These NLS vars are set unconditionally (bootstrap issue #24). Unset those+# in case the environment reset is needed later and the $save_* variant is not+# defined (see the code above).+LC_ALL=C+LANGUAGE=C+export LANGUAGE LC_ALL++# Make sure IFS has a sensible default+sp=' '+nl='+'+IFS="$sp $nl"++# There are apparently some retarded systems that use ';' as a PATH separator!+if test "${PATH_SEPARATOR+set}" != set; then+ PATH_SEPARATOR=:+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||+ PATH_SEPARATOR=';'+ }+fi+++# func_unset VAR+# --------------+# Portably unset VAR.+# In some shells, an 'unset VAR' statement leaves a non-zero return+# status if VAR is already unset, which might be problematic if the+# statement is used at the end of a function (thus poisoning its return+# value) or when 'set -e' is active (causing even a spurious abort of+# the script in this case).+func_unset ()+{+ { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; }+}+++# Make sure CDPATH doesn't cause `cd` commands to output the target dir.+func_unset CDPATH++# Make sure ${,E,F}GREP behave sanely.+func_unset GREP_OPTIONS+++## ------------------------- ##+## Locate command utilities. ##+## ------------------------- ##+++# func_executable_p FILE+# ----------------------+# Check that FILE is an executable regular file.+func_executable_p ()+{+ test -f "$1" && test -x "$1"+}+++# func_path_progs PROGS_LIST CHECK_FUNC [PATH]+# --------------------------------------------+# Search for either a program that responds to --version with output+# containing "GNU", or else returned by CHECK_FUNC otherwise, by+# trying all the directories in PATH with each of the elements of+# PROGS_LIST.+#+# CHECK_FUNC should accept the path to a candidate program, and+# set $func_check_prog_result if it truncates its output less than+# $_G_path_prog_max characters.+func_path_progs ()+{+ _G_progs_list=$1+ _G_check_func=$2+ _G_PATH=${3-"$PATH"}++ _G_path_prog_max=0+ _G_path_prog_found=false+ _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}+ for _G_dir in $_G_PATH; do+ IFS=$_G_save_IFS+ test -z "$_G_dir" && _G_dir=.+ for _G_prog_name in $_G_progs_list; do+ for _exeext in '' .EXE; do+ _G_path_prog=$_G_dir/$_G_prog_name$_exeext+ func_executable_p "$_G_path_prog" || continue+ case `"$_G_path_prog" --version 2>&1` in+ *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;+ *) $_G_check_func $_G_path_prog+ func_path_progs_result=$func_check_prog_result+ ;;+ esac+ $_G_path_prog_found && break 3+ done+ done+ done+ IFS=$_G_save_IFS+ test -z "$func_path_progs_result" && {+ echo "no acceptable sed could be found in \$PATH" >&2+ exit 1+ }+}+++# We want to be able to use the functions in this file before configure+# has figured out where the best binaries are kept, which means we have+# to search for them ourselves - except when the results are already set+# where we skip the searches.++# Unless the user overrides by setting SED, search the path for either GNU+# sed, or the sed that truncates its output the least.+test -z "$SED" && {+ _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/+ for _G_i in 1 2 3 4 5 6 7; do+ _G_sed_script=$_G_sed_script$nl$_G_sed_script+ done+ echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed+ _G_sed_script=++ func_check_prog_sed ()+ {+ _G_path_prog=$1++ _G_count=0+ printf 0123456789 >conftest.in+ while :+ do+ cat conftest.in conftest.in >conftest.tmp+ mv conftest.tmp conftest.in+ cp conftest.in conftest.nl+ echo '' >> conftest.nl+ "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break+ diff conftest.out conftest.nl >/dev/null 2>&1 || break+ _G_count=`expr $_G_count + 1`+ if test "$_G_count" -gt "$_G_path_prog_max"; then+ # Best one so far, save it but keep looking for a better one+ func_check_prog_result=$_G_path_prog+ _G_path_prog_max=$_G_count+ fi+ # 10*(2^10) chars as input seems more than enough+ test 10 -lt "$_G_count" && break+ done+ rm -f conftest.in conftest.tmp conftest.nl conftest.out+ }++ func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin"+ rm -f conftest.sed+ SED=$func_path_progs_result+}+++# Unless the user overrides by setting GREP, search the path for either GNU+# grep, or the grep that truncates its output the least.+test -z "$GREP" && {+ func_check_prog_grep ()+ {+ _G_path_prog=$1++ _G_count=0+ _G_path_prog_max=0+ printf 0123456789 >conftest.in+ while :+ do+ cat conftest.in conftest.in >conftest.tmp+ mv conftest.tmp conftest.in+ cp conftest.in conftest.nl+ echo 'GREP' >> conftest.nl+ "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break+ diff conftest.out conftest.nl >/dev/null 2>&1 || break+ _G_count=`expr $_G_count + 1`+ if test "$_G_count" -gt "$_G_path_prog_max"; then+ # Best one so far, save it but keep looking for a better one+ func_check_prog_result=$_G_path_prog+ _G_path_prog_max=$_G_count+ fi+ # 10*(2^10) chars as input seems more than enough+ test 10 -lt "$_G_count" && break+ done+ rm -f conftest.in conftest.tmp conftest.nl conftest.out+ }++ func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin"+ GREP=$func_path_progs_result+}+++## ------------------------------- ##+## User overridable command paths. ##+## ------------------------------- ##++# All uppercase variable names are used for environment variables. These+# variables can be overridden by the user before calling a script that+# uses them if a suitable command of that name is not already available+# in the command search PATH.++: ${CP="cp -f"}+: ${ECHO="printf %s\n"}+: ${EGREP="$GREP -E"}+: ${FGREP="$GREP -F"}+: ${LN_S="ln -s"}+: ${MAKE="make"}+: ${MKDIR="mkdir"}+: ${MV="mv -f"}+: ${RM="rm -f"}+: ${SHELL="${CONFIG_SHELL-/bin/sh}"}+++## -------------------- ##+## Useful sed snippets. ##+## -------------------- ##++sed_dirname='s|/[^/]*$||'+sed_basename='s|^.*/||'++# Sed substitution that helps us do robust quoting. It backslashifies+# metacharacters that are still active within double-quoted strings.+sed_quote_subst='s|\([`"$\\]\)|\\\1|g'++# Same as above, but do not quote variable references.+sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'++# Sed substitution that turns a string into a regex matching for the+# string literally.+sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'++# Sed substitution that converts a w32 file name or path+# that contains forward slashes, into one that contains+# (escaped) backslashes. A very naive implementation.+sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'++# Re-'\' parameter expansions in output of sed_double_quote_subst that+# were '\'-ed in input to the same. If an odd number of '\' preceded a+# '$' in input to sed_double_quote_subst, that '$' was protected from+# expansion. Since each input '\' is now two '\'s, look for any number+# of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.+_G_bs='\\'+_G_bs2='\\\\'+_G_bs4='\\\\\\\\'+_G_dollar='\$'+sed_double_backslash="\+ s/$_G_bs4/&\\+/g+ s/^$_G_bs2$_G_dollar/$_G_bs&/+ s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g+ s/\n//g"++# require_check_ifs_backslash+# ---------------------------+# Check if we can use backslash as IFS='\' separator, and set+# $check_ifs_backshlash_broken to ':' or 'false'.+require_check_ifs_backslash=func_require_check_ifs_backslash+func_require_check_ifs_backslash ()+{+ _G_save_IFS=$IFS+ IFS='\'+ _G_check_ifs_backshlash='a\\b'+ for _G_i in $_G_check_ifs_backshlash+ do+ case $_G_i in+ a)+ check_ifs_backshlash_broken=false+ ;;+ '')+ break+ ;;+ *)+ check_ifs_backshlash_broken=:+ break+ ;;+ esac+ done+ IFS=$_G_save_IFS+ require_check_ifs_backslash=:+}+++## ----------------- ##+## Global variables. ##+## ----------------- ##++# Except for the global variables explicitly listed below, the following+# functions in the '^func_' namespace, and the '^require_' namespace+# variables initialised in the 'Resource management' section, sourcing+# this file will not pollute your global namespace with anything+# else. There's no portable way to scope variables in Bourne shell+# though, so actually running these functions will sometimes place+# results into a variable named after the function, and often use+# temporary variables in the '^_G_' namespace. If you are careful to+# avoid using those namespaces casually in your sourcing script, things+# should continue to work as you expect. And, of course, you can freely+# overwrite any of the functions or variables defined here before+# calling anything to customize them.++EXIT_SUCCESS=0+EXIT_FAILURE=1+EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.+EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.++# Allow overriding, eg assuming that you follow the convention of+# putting '$debug_cmd' at the start of all your functions, you can get+# bash to show function call trace with:+#+# debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name+debug_cmd=${debug_cmd-":"}+exit_cmd=:++# By convention, finish your script with:+#+# exit $exit_status+#+# so that you can set exit_status to non-zero if you want to indicate+# something went wrong during execution without actually bailing out at+# the point of failure.+exit_status=$EXIT_SUCCESS++# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh+# is ksh but when the shell is invoked as "sh" and the current value of+# the _XPG environment variable is not equal to 1 (one), the special+# positional parameter $0, within a function call, is the name of the+# function.+progpath=$0++# The name of this program.+progname=`$ECHO "$progpath" |$SED "$sed_basename"`++# Make sure we have an absolute progpath for reexecution:+case $progpath in+ [\\/]*|[A-Za-z]:\\*) ;;+ *[\\/]*)+ progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`+ progdir=`cd "$progdir" && pwd`+ progpath=$progdir/$progname+ ;;+ *)+ _G_IFS=$IFS+ IFS=${PATH_SEPARATOR-:}+ for progdir in $PATH; do+ IFS=$_G_IFS+ test -x "$progdir/$progname" && break+ done+ IFS=$_G_IFS+ test -n "$progdir" || progdir=`pwd`+ progpath=$progdir/$progname+ ;;+esac+++## ----------------- ##+## Standard options. ##+## ----------------- ##++# The following options affect the operation of the functions defined+# below, and should be set appropriately depending on run-time para-+# meters passed on the command line.++opt_dry_run=false+opt_quiet=false+opt_verbose=false++# Categories 'all' and 'none' are always available. Append any others+# you will pass as the first argument to func_warning from your own+# code.+warning_categories=++# By default, display warnings according to 'opt_warning_types'. Set+# 'warning_func' to ':' to elide all warnings, or func_fatal_error to+# treat the next displayed warning as a fatal error.+warning_func=func_warn_and_continue++# Set to 'all' to display all warnings, 'none' to suppress all+# warnings, or a space delimited list of some subset of+# 'warning_categories' to display only the listed warnings.+opt_warning_types=all+++## -------------------- ##+## Resource management. ##+## -------------------- ##++# This section contains definitions for functions that each ensure a+# particular resource (a file, or a non-empty configuration variable for+# example) is available, and if appropriate to extract default values+# from pertinent package files. Call them using their associated+# 'require_*' variable to ensure that they are executed, at most, once.+#+# It's entirely deliberate that calling these functions can set+# variables that don't obey the namespace limitations obeyed by the rest+# of this file, in order that that they be as useful as possible to+# callers.+++# require_term_colors+# -------------------+# Allow display of bold text on terminals that support it.+require_term_colors=func_require_term_colors+func_require_term_colors ()+{+ $debug_cmd++ test -t 1 && {+ # COLORTERM and USE_ANSI_COLORS environment variables take+ # precedence, because most terminfo databases neglect to describe+ # whether color sequences are supported.+ test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}++ if test 1 = "$USE_ANSI_COLORS"; then+ # Standard ANSI escape sequences+ tc_reset='[0m'+ tc_bold='[1m'; tc_standout='[7m'+ tc_red='[31m'; tc_green='[32m'+ tc_blue='[34m'; tc_cyan='[36m'+ else+ # Otherwise trust the terminfo database after all.+ test -n "`tput sgr0 2>/dev/null`" && {+ tc_reset=`tput sgr0`+ test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`+ tc_standout=$tc_bold+ test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`+ test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`+ test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`+ test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`+ test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`+ }+ fi+ }++ require_term_colors=:+}+++## ----------------- ##+## Function library. ##+## ----------------- ##++# This section contains a variety of useful functions to call in your+# scripts. Take note of the portable wrappers for features provided by+# some modern shells, which will fall back to slower equivalents on+# less featureful shells.+++# func_append VAR VALUE+# ---------------------+# Append VALUE onto the existing contents of VAR.++ # We should try to minimise forks, especially on Windows where they are+ # unreasonably slow, so skip the feature probes when bash or zsh are+ # being used:+ if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then+ : ${_G_HAVE_ARITH_OP="yes"}+ : ${_G_HAVE_XSI_OPS="yes"}+ # The += operator was introduced in bash 3.1+ case $BASH_VERSION in+ [12].* | 3.0 | 3.0*) ;;+ *)+ : ${_G_HAVE_PLUSEQ_OP="yes"}+ ;;+ esac+ fi++ # _G_HAVE_PLUSEQ_OP+ # Can be empty, in which case the shell is probed, "yes" if += is+ # useable or anything else if it does not work.+ test -z "$_G_HAVE_PLUSEQ_OP" \+ && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \+ && _G_HAVE_PLUSEQ_OP=yes++if test yes = "$_G_HAVE_PLUSEQ_OP"+then+ # This is an XSI compatible shell, allowing a faster implementation...+ eval 'func_append ()+ {+ $debug_cmd++ eval "$1+=\$2"+ }'+else+ # ...otherwise fall back to using expr, which is often a shell builtin.+ func_append ()+ {+ $debug_cmd++ eval "$1=\$$1\$2"+ }+fi+++# func_append_quoted VAR VALUE+# ----------------------------+# Quote VALUE and append to the end of shell variable VAR, separated+# by a space.+if test yes = "$_G_HAVE_PLUSEQ_OP"; then+ eval 'func_append_quoted ()+ {+ $debug_cmd++ func_quote_arg pretty "$2"+ eval "$1+=\\ \$func_quote_arg_result"+ }'+else+ func_append_quoted ()+ {+ $debug_cmd++ func_quote_arg pretty "$2"+ eval "$1=\$$1\\ \$func_quote_arg_result"+ }+fi+++# func_append_uniq VAR VALUE+# --------------------------+# Append unique VALUE onto the existing contents of VAR, assuming+# entries are delimited by the first character of VALUE. For example:+#+# func_append_uniq options " --another-option option-argument"+#+# will only append to $options if " --another-option option-argument "+# is not already present somewhere in $options already (note spaces at+# each end implied by leading space in second argument).+func_append_uniq ()+{+ $debug_cmd++ eval _G_current_value='`$ECHO $'$1'`'+ _G_delim=`expr "$2" : '\(.\)'`++ case $_G_delim$_G_current_value$_G_delim in+ *"$2$_G_delim"*) ;;+ *) func_append "$@" ;;+ esac+}+++# func_arith TERM...+# ------------------+# Set func_arith_result to the result of evaluating TERMs.+ test -z "$_G_HAVE_ARITH_OP" \+ && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \+ && _G_HAVE_ARITH_OP=yes++if test yes = "$_G_HAVE_ARITH_OP"; then+ eval 'func_arith ()+ {+ $debug_cmd++ func_arith_result=$(( $* ))+ }'+else+ func_arith ()+ {+ $debug_cmd++ func_arith_result=`expr "$@"`+ }+fi+++# func_basename FILE+# ------------------+# Set func_basename_result to FILE with everything up to and including+# the last / stripped.+if test yes = "$_G_HAVE_XSI_OPS"; then+ # If this shell supports suffix pattern removal, then use it to avoid+ # forking. Hide the definitions single quotes in case the shell chokes+ # on unsupported syntax...+ _b='func_basename_result=${1##*/}'+ _d='case $1 in+ */*) func_dirname_result=${1%/*}$2 ;;+ * ) func_dirname_result=$3 ;;+ esac'++else+ # ...otherwise fall back to using sed.+ _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'+ _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`+ if test "X$func_dirname_result" = "X$1"; then+ func_dirname_result=$3+ else+ func_append func_dirname_result "$2"+ fi'+fi++eval 'func_basename ()+{+ $debug_cmd++ '"$_b"'+}'+++# func_dirname FILE APPEND NONDIR_REPLACEMENT+# -------------------------------------------+# Compute the dirname of FILE. If nonempty, add APPEND to the result,+# otherwise set result to NONDIR_REPLACEMENT.+eval 'func_dirname ()+{+ $debug_cmd++ '"$_d"'+}'+++# func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT+# --------------------------------------------------------+# Perform func_basename and func_dirname in a single function+# call:+# dirname: Compute the dirname of FILE. If nonempty,+# add APPEND to the result, otherwise set result+# to NONDIR_REPLACEMENT.+# value returned in "$func_dirname_result"+# basename: Compute filename of FILE.+# value retuned in "$func_basename_result"+# For efficiency, we do not delegate to the functions above but instead+# duplicate the functionality here.+eval 'func_dirname_and_basename ()+{+ $debug_cmd++ '"$_b"'+ '"$_d"'+}'+++# func_echo ARG...+# ----------------+# Echo program name prefixed message.+func_echo ()+{+ $debug_cmd++ _G_message=$*++ func_echo_IFS=$IFS+ IFS=$nl+ for _G_line in $_G_message; do+ IFS=$func_echo_IFS+ $ECHO "$progname: $_G_line"+ done+ IFS=$func_echo_IFS+}+++# func_echo_all ARG...+# --------------------+# Invoke $ECHO with all args, space-separated.+func_echo_all ()+{+ $ECHO "$*"+}+++# func_echo_infix_1 INFIX ARG...+# ------------------------------+# Echo program name, followed by INFIX on the first line, with any+# additional lines not showing INFIX.+func_echo_infix_1 ()+{+ $debug_cmd++ $require_term_colors++ _G_infix=$1; shift+ _G_indent=$_G_infix+ _G_prefix="$progname: $_G_infix: "+ _G_message=$*++ # Strip color escape sequences before counting printable length+ for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"+ do+ test -n "$_G_tc" && {+ _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`+ _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`+ }+ done+ _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes++ func_echo_infix_1_IFS=$IFS+ IFS=$nl+ for _G_line in $_G_message; do+ IFS=$func_echo_infix_1_IFS+ $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2+ _G_prefix=$_G_indent+ done+ IFS=$func_echo_infix_1_IFS+}+++# func_error ARG...+# -----------------+# Echo program name prefixed message to standard error.+func_error ()+{+ $debug_cmd++ $require_term_colors++ func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2+}+++# func_fatal_error ARG...+# -----------------------+# Echo program name prefixed message to standard error, and exit.+func_fatal_error ()+{+ $debug_cmd++ func_error "$*"+ exit $EXIT_FAILURE+}+++# func_grep EXPRESSION FILENAME+# -----------------------------+# Check whether EXPRESSION matches any line of FILENAME, without output.+func_grep ()+{+ $debug_cmd++ $GREP "$1" "$2" >/dev/null 2>&1+}+++# func_len STRING+# ---------------+# Set func_len_result to the length of STRING. STRING may not+# start with a hyphen.+ test -z "$_G_HAVE_XSI_OPS" \+ && (eval 'x=a/b/c;+ test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \+ && _G_HAVE_XSI_OPS=yes++if test yes = "$_G_HAVE_XSI_OPS"; then+ eval 'func_len ()+ {+ $debug_cmd++ func_len_result=${#1}+ }'+else+ func_len ()+ {+ $debug_cmd++ func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`+ }+fi+++# func_mkdir_p DIRECTORY-PATH+# ---------------------------+# Make sure the entire path to DIRECTORY-PATH is available.+func_mkdir_p ()+{+ $debug_cmd++ _G_directory_path=$1+ _G_dir_list=++ if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then++ # Protect directory names starting with '-'+ case $_G_directory_path in+ -*) _G_directory_path=./$_G_directory_path ;;+ esac++ # While some portion of DIR does not yet exist...+ while test ! -d "$_G_directory_path"; do+ # ...make a list in topmost first order. Use a colon delimited+ # list incase some portion of path contains whitespace.+ _G_dir_list=$_G_directory_path:$_G_dir_list++ # If the last portion added has no slash in it, the list is done+ case $_G_directory_path in */*) ;; *) break ;; esac++ # ...otherwise throw away the child directory and loop+ _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`+ done+ _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`++ func_mkdir_p_IFS=$IFS; IFS=:+ for _G_dir in $_G_dir_list; do+ IFS=$func_mkdir_p_IFS+ # mkdir can fail with a 'File exist' error if two processes+ # try to create one of the directories concurrently. Don't+ # stop in that case!+ $MKDIR "$_G_dir" 2>/dev/null || :+ done+ IFS=$func_mkdir_p_IFS++ # Bail out if we (or some other process) failed to create a directory.+ test -d "$_G_directory_path" || \+ func_fatal_error "Failed to create '$1'"+ fi+}+++# func_mktempdir [BASENAME]+# -------------------------+# Make a temporary directory that won't clash with other running+# libtool processes, and avoids race conditions if possible. If+# given, BASENAME is the basename for that directory.+func_mktempdir ()+{+ $debug_cmd++ _G_template=${TMPDIR-/tmp}/${1-$progname}++ if test : = "$opt_dry_run"; then+ # Return a directory name, but don't create it in dry-run mode+ _G_tmpdir=$_G_template-$$+ else++ # If mktemp works, use that first and foremost+ _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`++ if test ! -d "$_G_tmpdir"; then+ # Failing that, at least try and use $RANDOM to avoid a race+ _G_tmpdir=$_G_template-${RANDOM-0}$$++ func_mktempdir_umask=`umask`+ umask 0077+ $MKDIR "$_G_tmpdir"+ umask $func_mktempdir_umask+ fi++ # If we're not in dry-run mode, bomb out on failure+ test -d "$_G_tmpdir" || \+ func_fatal_error "cannot create temporary directory '$_G_tmpdir'"+ fi++ $ECHO "$_G_tmpdir"+}+++# func_normal_abspath PATH+# ------------------------+# Remove doubled-up and trailing slashes, "." path components,+# and cancel out any ".." path components in PATH after making+# it an absolute path.+func_normal_abspath ()+{+ $debug_cmd++ # These SED scripts presuppose an absolute path with a trailing slash.+ _G_pathcar='s|^/\([^/]*\).*$|\1|'+ _G_pathcdr='s|^/[^/]*||'+ _G_removedotparts=':dotsl+ s|/\./|/|g+ t dotsl+ s|/\.$|/|'+ _G_collapseslashes='s|/\{1,\}|/|g'+ _G_finalslash='s|/*$|/|'++ # Start from root dir and reassemble the path.+ func_normal_abspath_result=+ func_normal_abspath_tpath=$1+ func_normal_abspath_altnamespace=+ case $func_normal_abspath_tpath in+ "")+ # Empty path, that just means $cwd.+ func_stripname '' '/' "`pwd`"+ func_normal_abspath_result=$func_stripname_result+ return+ ;;+ # The next three entries are used to spot a run of precisely+ # two leading slashes without using negated character classes;+ # we take advantage of case's first-match behaviour.+ ///*)+ # Unusual form of absolute path, do nothing.+ ;;+ //*)+ # Not necessarily an ordinary path; POSIX reserves leading '//'+ # and for example Cygwin uses it to access remote file shares+ # over CIFS/SMB, so we conserve a leading double slash if found.+ func_normal_abspath_altnamespace=/+ ;;+ /*)+ # Absolute path, do nothing.+ ;;+ *)+ # Relative path, prepend $cwd.+ func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath+ ;;+ esac++ # Cancel out all the simple stuff to save iterations. We also want+ # the path to end with a slash for ease of parsing, so make sure+ # there is one (and only one) here.+ func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \+ -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`+ while :; do+ # Processed it all yet?+ if test / = "$func_normal_abspath_tpath"; then+ # If we ascended to the root using ".." the result may be empty now.+ if test -z "$func_normal_abspath_result"; then+ func_normal_abspath_result=/+ fi+ break+ fi+ func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \+ -e "$_G_pathcar"`+ func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \+ -e "$_G_pathcdr"`+ # Figure out what to do with it+ case $func_normal_abspath_tcomponent in+ "")+ # Trailing empty path component, ignore it.+ ;;+ ..)+ # Parent dir; strip last assembled component from result.+ func_dirname "$func_normal_abspath_result"+ func_normal_abspath_result=$func_dirname_result+ ;;+ *)+ # Actual path component, append it.+ func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"+ ;;+ esac+ done+ # Restore leading double-slash if one was found on entry.+ func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result+}+++# func_notquiet ARG...+# --------------------+# Echo program name prefixed message only when not in quiet mode.+func_notquiet ()+{+ $debug_cmd++ $opt_quiet || func_echo ${1+"$@"}++ # A bug in bash halts the script if the last line of a function+ # fails when set -e is in force, so we need another command to+ # work around that:+ :+}+++# func_relative_path SRCDIR DSTDIR+# --------------------------------+# Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.+func_relative_path ()+{+ $debug_cmd++ func_relative_path_result=+ func_normal_abspath "$1"+ func_relative_path_tlibdir=$func_normal_abspath_result+ func_normal_abspath "$2"+ func_relative_path_tbindir=$func_normal_abspath_result++ # Ascend the tree starting from libdir+ while :; do+ # check if we have found a prefix of bindir+ case $func_relative_path_tbindir in+ $func_relative_path_tlibdir)+ # found an exact match+ func_relative_path_tcancelled=+ break+ ;;+ $func_relative_path_tlibdir*)+ # found a matching prefix+ func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"+ func_relative_path_tcancelled=$func_stripname_result+ if test -z "$func_relative_path_result"; then+ func_relative_path_result=.+ fi+ break+ ;;+ *)+ func_dirname $func_relative_path_tlibdir+ func_relative_path_tlibdir=$func_dirname_result+ if test -z "$func_relative_path_tlibdir"; then+ # Have to descend all the way to the root!+ func_relative_path_result=../$func_relative_path_result+ func_relative_path_tcancelled=$func_relative_path_tbindir+ break+ fi+ func_relative_path_result=../$func_relative_path_result+ ;;+ esac+ done++ # Now calculate path; take care to avoid doubling-up slashes.+ func_stripname '' '/' "$func_relative_path_result"+ func_relative_path_result=$func_stripname_result+ func_stripname '/' '/' "$func_relative_path_tcancelled"+ if test -n "$func_stripname_result"; then+ func_append func_relative_path_result "/$func_stripname_result"+ fi++ # Normalisation. If bindir is libdir, return '.' else relative path.+ if test -n "$func_relative_path_result"; then+ func_stripname './' '' "$func_relative_path_result"+ func_relative_path_result=$func_stripname_result+ fi++ test -n "$func_relative_path_result" || func_relative_path_result=.++ :+}+++# func_quote_portable EVAL ARG+# ----------------------------+# Internal function to portably implement func_quote_arg. Note that we still+# keep attention to performance here so we as much as possible try to avoid+# calling sed binary (so far O(N) complexity as long as func_append is O(1)).+func_quote_portable ()+{+ $debug_cmd++ $require_check_ifs_backslash++ func_quote_portable_result=$2++ # one-time-loop (easy break)+ while true+ do+ if $1; then+ func_quote_portable_result=`$ECHO "$2" | $SED \+ -e "$sed_double_quote_subst" -e "$sed_double_backslash"`+ break+ fi++ # Quote for eval.+ case $func_quote_portable_result in+ *[\\\`\"\$]*)+ # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string+ # contains the shell wildcard characters.+ case $check_ifs_backshlash_broken$func_quote_portable_result in+ :*|*[\[\*\?]*)+ func_quote_portable_result=`$ECHO "$func_quote_portable_result" \+ | $SED "$sed_quote_subst"`+ break+ ;;+ esac++ func_quote_portable_old_IFS=$IFS+ for _G_char in '\' '`' '"' '$'+ do+ # STATE($1) PREV($2) SEPARATOR($3)+ set start "" ""+ func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy+ IFS=$_G_char+ for _G_part in $func_quote_portable_result+ do+ case $1 in+ quote)+ func_append func_quote_portable_result "$3$2"+ set quote "$_G_part" "\\$_G_char"+ ;;+ start)+ set first "" ""+ func_quote_portable_result=+ ;;+ first)+ set quote "$_G_part" ""+ ;;+ esac+ done+ done+ IFS=$func_quote_portable_old_IFS+ ;;+ *) ;;+ esac+ break+ done++ func_quote_portable_unquoted_result=$func_quote_portable_result+ case $func_quote_portable_result in+ # double-quote args containing shell metacharacters to delay+ # word splitting, command substitution and variable expansion+ # for a subsequent eval.+ # many bourne shells cannot handle close brackets correctly+ # in scan sets, so we specify it separately.+ *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")+ func_quote_portable_result=\"$func_quote_portable_result\"+ ;;+ esac+}+++# func_quotefast_eval ARG+# -----------------------+# Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG',+# but optimized for speed. Result is stored in $func_quotefast_eval.+if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then+ printf -v _GL_test_printf_tilde %q '~'+ if test '\~' = "$_GL_test_printf_tilde"; then+ func_quotefast_eval ()+ {+ printf -v func_quotefast_eval_result %q "$1"+ }+ else+ # Broken older Bash implementations. Make those faster too if possible.+ func_quotefast_eval ()+ {+ case $1 in+ '~'*)+ func_quote_portable false "$1"+ func_quotefast_eval_result=$func_quote_portable_result+ ;;+ *)+ printf -v func_quotefast_eval_result %q "$1"+ ;;+ esac+ }+ fi+else+ func_quotefast_eval ()+ {+ func_quote_portable false "$1"+ func_quotefast_eval_result=$func_quote_portable_result+ }+fi+++# func_quote_arg MODEs ARG+# ------------------------+# Quote one ARG to be evaled later. MODEs argument may contain zero or more+# specifiers listed below separated by ',' character. This function returns two+# values:+# i) func_quote_arg_result+# double-quoted (when needed), suitable for a subsequent eval+# ii) func_quote_arg_unquoted_result+# has all characters that are still active within double+# quotes backslashified. Available only if 'unquoted' is specified.+#+# Available modes:+# ----------------+# 'eval' (default)+# - escape shell special characters+# 'expand'+# - the same as 'eval'; but do not quote variable references+# 'pretty'+# - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might+# be used later in func_quote to get output like: 'echo "a b"' instead+# of 'echo a\ b'. This is slower than default on some shells.+# 'unquoted'+# - produce also $func_quote_arg_unquoted_result which does not contain+# wrapping double-quotes.+#+# Examples for 'func_quote_arg pretty,unquoted string':+#+# string | *_result | *_unquoted_result+# ------------+-----------------------+-------------------+# " | \" | \"+# a b | "a b" | a b+# "a b" | "\"a b\"" | \"a b\"+# * | "*" | *+# z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\"+#+# Examples for 'func_quote_arg pretty,unquoted,expand string':+#+# string | *_result | *_unquoted_result+# --------------+---------------------+--------------------+# z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\"+func_quote_arg ()+{+ _G_quote_expand=false+ case ,$1, in+ *,expand,*)+ _G_quote_expand=:+ ;;+ esac++ case ,$1, in+ *,pretty,*|*,expand,*|*,unquoted,*)+ func_quote_portable $_G_quote_expand "$2"+ func_quote_arg_result=$func_quote_portable_result+ func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result+ ;;+ *)+ # Faster quote-for-eval for some shells.+ func_quotefast_eval "$2"+ func_quote_arg_result=$func_quotefast_eval_result+ ;;+ esac+}+++# func_quote MODEs ARGs...+# ------------------------+# Quote all ARGs to be evaled later and join them into single command. See+# func_quote_arg's description for more info.+func_quote ()+{+ $debug_cmd+ _G_func_quote_mode=$1 ; shift+ func_quote_result=+ while test 0 -lt $#; do+ func_quote_arg "$_G_func_quote_mode" "$1"+ if test -n "$func_quote_result"; then+ func_append func_quote_result " $func_quote_arg_result"+ else+ func_append func_quote_result "$func_quote_arg_result"+ fi+ shift+ done+}+++# func_stripname PREFIX SUFFIX NAME+# ---------------------------------+# strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.+# PREFIX and SUFFIX must not contain globbing or regex special+# characters, hashes, percent signs, but SUFFIX may contain a leading+# dot (in which case that matches only a dot).+if test yes = "$_G_HAVE_XSI_OPS"; then+ eval 'func_stripname ()+ {+ $debug_cmd++ # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are+ # positional parameters, so assign one to ordinary variable first.+ func_stripname_result=$3+ func_stripname_result=${func_stripname_result#"$1"}+ func_stripname_result=${func_stripname_result%"$2"}+ }'+else+ func_stripname ()+ {+ $debug_cmd++ case $2 in+ .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;+ *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;+ esac+ }+fi+++# func_show_eval CMD [FAIL_EXP]+# -----------------------------+# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is+# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP+# is given, then evaluate it.+func_show_eval ()+{+ $debug_cmd++ _G_cmd=$1+ _G_fail_exp=${2-':'}++ func_quote_arg pretty,expand "$_G_cmd"+ eval "func_notquiet $func_quote_arg_result"++ $opt_dry_run || {+ eval "$_G_cmd"+ _G_status=$?+ if test 0 -ne "$_G_status"; then+ eval "(exit $_G_status); $_G_fail_exp"+ fi+ }+}+++# func_show_eval_locale CMD [FAIL_EXP]+# ------------------------------------+# Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is+# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP+# is given, then evaluate it. Use the saved locale for evaluation.+func_show_eval_locale ()+{+ $debug_cmd++ _G_cmd=$1+ _G_fail_exp=${2-':'}++ $opt_quiet || {+ func_quote_arg expand,pretty "$_G_cmd"+ eval "func_echo $func_quote_arg_result"+ }++ $opt_dry_run || {+ eval "$_G_user_locale+ $_G_cmd"+ _G_status=$?+ eval "$_G_safe_locale"+ if test 0 -ne "$_G_status"; then+ eval "(exit $_G_status); $_G_fail_exp"+ fi+ }+}+++# func_tr_sh+# ----------+# Turn $1 into a string suitable for a shell variable name.+# Result is stored in $func_tr_sh_result. All characters+# not in the set a-zA-Z0-9_ are replaced with '_'. Further,+# if $1 begins with a digit, a '_' is prepended as well.+func_tr_sh ()+{+ $debug_cmd++ case $1 in+ [0-9]* | *[!a-zA-Z0-9_]*)+ func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`+ ;;+ * )+ func_tr_sh_result=$1+ ;;+ esac+}+++# func_verbose ARG...+# -------------------+# Echo program name prefixed message in verbose mode only.+func_verbose ()+{+ $debug_cmd++ $opt_verbose && func_echo "$*"++ :+}+++# func_warn_and_continue ARG...+# -----------------------------+# Echo program name prefixed warning message to standard error.+func_warn_and_continue ()+{+ $debug_cmd++ $require_term_colors++ func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2+}+++# func_warning CATEGORY ARG...+# ----------------------------+# Echo program name prefixed warning message to standard error. Warning+# messages can be filtered according to CATEGORY, where this function+# elides messages where CATEGORY is not listed in the global variable+# 'opt_warning_types'.+func_warning ()+{+ $debug_cmd++ # CATEGORY must be in the warning_categories list!+ case " $warning_categories " in+ *" $1 "*) ;;+ *) func_internal_error "invalid warning category '$1'" ;;+ esac++ _G_category=$1+ shift++ case " $opt_warning_types " in+ *" $_G_category "*) $warning_func ${1+"$@"} ;;+ esac+}+++# func_sort_ver VER1 VER2+# -----------------------+# 'sort -V' is not generally available.+# Note this deviates from the version comparison in automake+# in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a+# but this should suffice as we won't be specifying old+# version formats or redundant trailing .0 in bootstrap.conf.+# If we did want full compatibility then we should probably+# use m4_version_compare from autoconf.+func_sort_ver ()+{+ $debug_cmd++ printf '%s\n%s\n' "$1" "$2" \+ | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n+}++# func_lt_ver PREV CURR+# ---------------------+# Return true if PREV and CURR are in the correct order according to+# func_sort_ver, otherwise false. Use it like this:+#+# func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."+func_lt_ver ()+{+ $debug_cmd++ test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`+}+++# Local variables:+# mode: shell-script+# sh-indentation: 2+# eval: (add-hook 'before-save-hook 'time-stamp)+# time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"+# time-stamp-time-zone: "UTC"+# End:+#! /bin/sh++# A portable, pluggable option parser for Bourne shell.+# Written by Gary V. Vaughan, 2010++# This is free software. There is NO warranty; not even for+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.+#+# Copyright (C) 2010-2019, 2021 Bootstrap Authors+#+# This file is dual licensed under the terms of the MIT license+# <https://opensource.org/license/MIT>, and GPL version 2 or later+# <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of+# these licenses when using or redistributing this software or any of+# the files within it. See the URLs above, or the file `LICENSE`+# included in the Bootstrap distribution for the full license texts.++# Please report bugs or propose patches to:+# <https://github.com/gnulib-modules/bootstrap/issues>++# Set a version string for this script.+scriptversion=2019-02-19.15; # UTC+++## ------ ##+## Usage. ##+## ------ ##++# This file is a library for parsing options in your shell scripts along+# with assorted other useful supporting features that you can make use+# of too.+#+# For the simplest scripts you might need only:+#+# #!/bin/sh+# . relative/path/to/funclib.sh+# . relative/path/to/options-parser+# scriptversion=1.0+# func_options ${1+"$@"}+# eval set dummy "$func_options_result"; shift+# ...rest of your script...+#+# In order for the '--version' option to work, you will need to have a+# suitably formatted comment like the one at the top of this file+# starting with '# Written by ' and ending with '# Copyright'.+#+# For '-h' and '--help' to work, you will also need a one line+# description of your script's purpose in a comment directly above the+# '# Written by ' line, like the one at the top of this file.+#+# The default options also support '--debug', which will turn on shell+# execution tracing (see the comment above debug_cmd below for another+# use), and '--verbose' and the func_verbose function to allow your script+# to display verbose messages only when your user has specified+# '--verbose'.+#+# After sourcing this file, you can plug in processing for additional+# options by amending the variables from the 'Configuration' section+# below, and following the instructions in the 'Option parsing'+# section further down.++## -------------- ##+## Configuration. ##+## -------------- ##++# You should override these variables in your script after sourcing this+# file so that they reflect the customisations you have added to the+# option parser.++# The usage line for option parsing errors and the start of '-h' and+# '--help' output messages. You can embed shell variables for delayed+# expansion at the time the message is displayed, but you will need to+# quote other shell meta-characters carefully to prevent them being+# expanded when the contents are evaled.+usage='$progpath [OPTION]...'++# Short help message in response to '-h' and '--help'. Add to this or+# override it after sourcing this library to reflect the full set of+# options your script accepts.+usage_message="\+ --debug enable verbose shell tracing+ -W, --warnings=CATEGORY+ report the warnings falling in CATEGORY [all]+ -v, --verbose verbosely report processing+ --version print version information and exit+ -h, --help print short or long help message and exit+"++# Additional text appended to 'usage_message' in response to '--help'.+long_help_message="+Warning categories include:+ 'all' show all warnings+ 'none' turn off all the warnings+ 'error' warnings are treated as fatal errors"++# Help message printed before fatal option parsing errors.+fatal_help="Try '\$progname --help' for more information."++++## ------------------------- ##+## Hook function management. ##+## ------------------------- ##++# This section contains functions for adding, removing, and running hooks+# in the main code. A hook is just a list of function names that can be+# run in order later on.++# func_hookable FUNC_NAME+# -----------------------+# Declare that FUNC_NAME will run hooks added with+# 'func_add_hook FUNC_NAME ...'.+func_hookable ()+{+ $debug_cmd++ func_append hookable_fns " $1"+}+++# func_add_hook FUNC_NAME HOOK_FUNC+# ---------------------------------+# Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must+# first have been declared "hookable" by a call to 'func_hookable'.+func_add_hook ()+{+ $debug_cmd++ case " $hookable_fns " in+ *" $1 "*) ;;+ *) func_fatal_error "'$1' does not accept hook functions." ;;+ esac++ eval func_append ${1}_hooks '" $2"'+}+++# func_remove_hook FUNC_NAME HOOK_FUNC+# ------------------------------------+# Remove HOOK_FUNC from the list of hook functions to be called by+# FUNC_NAME.+func_remove_hook ()+{+ $debug_cmd++ eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'+}+++# func_propagate_result FUNC_NAME_A FUNC_NAME_B+# ---------------------------------------------+# If the *_result variable of FUNC_NAME_A _is set_, assign its value to+# *_result variable of FUNC_NAME_B.+func_propagate_result ()+{+ $debug_cmd++ func_propagate_result_result=:+ if eval "test \"\${${1}_result+set}\" = set"+ then+ eval "${2}_result=\$${1}_result"+ else+ func_propagate_result_result=false+ fi+}+++# func_run_hooks FUNC_NAME [ARG]...+# ---------------------------------+# Run all hook functions registered to FUNC_NAME.+# It's assumed that the list of hook functions contains nothing more+# than a whitespace-delimited list of legal shell function names, and+# no effort is wasted trying to catch shell meta-characters or preserve+# whitespace.+func_run_hooks ()+{+ $debug_cmd++ case " $hookable_fns " in+ *" $1 "*) ;;+ *) func_fatal_error "'$1' does not support hook functions." ;;+ esac++ eval _G_hook_fns=\$$1_hooks; shift++ for _G_hook in $_G_hook_fns; do+ func_unset "${_G_hook}_result"+ eval $_G_hook '${1+"$@"}'+ func_propagate_result $_G_hook func_run_hooks+ if $func_propagate_result_result; then+ eval set dummy "$func_run_hooks_result"; shift+ fi+ done+}++++## --------------- ##+## Option parsing. ##+## --------------- ##++# In order to add your own option parsing hooks, you must accept the+# full positional parameter list from your hook function. You may remove+# or edit any options that you action, and then pass back the remaining+# unprocessed options in '<hooked_function_name>_result', escaped+# suitably for 'eval'.+#+# The '<hooked_function_name>_result' variable is automatically unset+# before your hook gets called; for best performance, only set the+# *_result variable when necessary (i.e. don't call the 'func_quote'+# function unnecessarily because it can be an expensive operation on some+# machines).+#+# Like this:+#+# my_options_prep ()+# {+# $debug_cmd+#+# # Extend the existing usage message.+# usage_message=$usage_message'+# -s, --silent don'\''t print informational messages+# '+# # No change in '$@' (ignored completely by this hook). Leave+# # my_options_prep_result variable intact.+# }+# func_add_hook func_options_prep my_options_prep+#+#+# my_silent_option ()+# {+# $debug_cmd+#+# args_changed=false+#+# # Note that, for efficiency, we parse as many options as we can+# # recognise in a loop before passing the remainder back to the+# # caller on the first unrecognised argument we encounter.+# while test $# -gt 0; do+# opt=$1; shift+# case $opt in+# --silent|-s) opt_silent=:+# args_changed=:+# ;;+# # Separate non-argument short options:+# -s*) func_split_short_opt "$_G_opt"+# set dummy "$func_split_short_opt_name" \+# "-$func_split_short_opt_arg" ${1+"$@"}+# shift+# args_changed=:+# ;;+# *) # Make sure the first unrecognised option "$_G_opt"+# # is added back to "$@" in case we need it later,+# # if $args_changed was set to 'true'.+# set dummy "$_G_opt" ${1+"$@"}; shift; break ;;+# esac+# done+#+# # Only call 'func_quote' here if we processed at least one argument.+# if $args_changed; then+# func_quote eval ${1+"$@"}+# my_silent_option_result=$func_quote_result+# fi+# }+# func_add_hook func_parse_options my_silent_option+#+#+# my_option_validation ()+# {+# $debug_cmd+#+# $opt_silent && $opt_verbose && func_fatal_help "\+# '--silent' and '--verbose' options are mutually exclusive."+# }+# func_add_hook func_validate_options my_option_validation+#+# You'll also need to manually amend $usage_message to reflect the extra+# options you parse. It's preferable to append if you can, so that+# multiple option parsing hooks can be added safely.+++# func_options_finish [ARG]...+# ----------------------------+# Finishing the option parse loop (call 'func_options' hooks ATM).+func_options_finish ()+{+ $debug_cmd++ func_run_hooks func_options ${1+"$@"}+ func_propagate_result func_run_hooks func_options_finish+}+++# func_options [ARG]...+# ---------------------+# All the functions called inside func_options are hookable. See the+# individual implementations for details.+func_hookable func_options+func_options ()+{+ $debug_cmd++ _G_options_quoted=false++ for my_func in options_prep parse_options validate_options options_finish+ do+ func_unset func_${my_func}_result+ func_unset func_run_hooks_result+ eval func_$my_func '${1+"$@"}'+ func_propagate_result func_$my_func func_options+ if $func_propagate_result_result; then+ eval set dummy "$func_options_result"; shift+ _G_options_quoted=:+ fi+ done++ $_G_options_quoted || {+ # As we (func_options) are top-level options-parser function and+ # nobody quoted "$@" for us yet, we need to do it explicitly for+ # caller.+ func_quote eval ${1+"$@"}+ func_options_result=$func_quote_result+ }+}+++# func_options_prep [ARG]...+# --------------------------+# All initialisations required before starting the option parse loop.+# Note that when calling hook functions, we pass through the list of+# positional parameters. If a hook function modifies that list, and+# needs to propagate that back to rest of this script, then the complete+# modified list must be put in 'func_run_hooks_result' before returning.+func_hookable func_options_prep+func_options_prep ()+{+ $debug_cmd++ # Option defaults:+ opt_verbose=false+ opt_warning_types=++ func_run_hooks func_options_prep ${1+"$@"}+ func_propagate_result func_run_hooks func_options_prep+}+++# func_parse_options [ARG]...+# ---------------------------+# The main option parsing loop.+func_hookable func_parse_options+func_parse_options ()+{+ $debug_cmd++ _G_parse_options_requote=false+ # this just eases exit handling+ while test $# -gt 0; do+ # Defer to hook functions for initial option parsing, so they+ # get priority in the event of reusing an option name.+ func_run_hooks func_parse_options ${1+"$@"}+ func_propagate_result func_run_hooks func_parse_options+ if $func_propagate_result_result; then+ eval set dummy "$func_parse_options_result"; shift+ # Even though we may have changed "$@", we passed the "$@" array+ # down into the hook and it quoted it for us (because we are in+ # this if-branch). No need to quote it again.+ _G_parse_options_requote=false+ fi++ # Break out of the loop if we already parsed every option.+ test $# -gt 0 || break++ # We expect that one of the options parsed in this function matches+ # and thus we remove _G_opt from "$@" and need to re-quote.+ _G_match_parse_options=:+ _G_opt=$1+ shift+ case $_G_opt in+ --debug|-x) debug_cmd='set -x'+ func_echo "enabling shell trace mode" >&2+ $debug_cmd+ ;;++ --no-warnings|--no-warning|--no-warn)+ set dummy --warnings none ${1+"$@"}+ shift+ ;;++ --warnings|--warning|-W)+ if test $# = 0 && func_missing_arg $_G_opt; then+ _G_parse_options_requote=:+ break+ fi+ case " $warning_categories $1" in+ *" $1 "*)+ # trailing space prevents matching last $1 above+ func_append_uniq opt_warning_types " $1"+ ;;+ *all)+ opt_warning_types=$warning_categories+ ;;+ *none)+ opt_warning_types=none+ warning_func=:+ ;;+ *error)+ opt_warning_types=$warning_categories+ warning_func=func_fatal_error+ ;;+ *)+ func_fatal_error \+ "unsupported warning category: '$1'"+ ;;+ esac+ shift+ ;;++ --verbose|-v) opt_verbose=: ;;+ --version) func_version ;;+ -\?|-h) func_usage ;;+ --help) func_help ;;++ # Separate optargs to long options (plugins may need this):+ --*=*) func_split_equals "$_G_opt"+ set dummy "$func_split_equals_lhs" \+ "$func_split_equals_rhs" ${1+"$@"}+ shift+ ;;++ # Separate optargs to short options:+ -W*)+ func_split_short_opt "$_G_opt"+ set dummy "$func_split_short_opt_name" \+ "$func_split_short_opt_arg" ${1+"$@"}+ shift+ ;;++ # Separate non-argument short options:+ -\?*|-h*|-v*|-x*)+ func_split_short_opt "$_G_opt"+ set dummy "$func_split_short_opt_name" \+ "-$func_split_short_opt_arg" ${1+"$@"}+ shift+ ;;++ --) _G_parse_options_requote=: ; break ;;+ -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;+ *) set dummy "$_G_opt" ${1+"$@"}; shift+ _G_match_parse_options=false+ break+ ;;+ esac++ if $_G_match_parse_options; then+ _G_parse_options_requote=:+ fi+ done++ if $_G_parse_options_requote; then+ # save modified positional parameters for caller+ func_quote eval ${1+"$@"}+ func_parse_options_result=$func_quote_result+ fi+}+++# func_validate_options [ARG]...+# ------------------------------+# Perform any sanity checks on option settings and/or unconsumed+# arguments.+func_hookable func_validate_options+func_validate_options ()+{+ $debug_cmd++ # Display all warnings if -W was not given.+ test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"++ func_run_hooks func_validate_options ${1+"$@"}+ func_propagate_result func_run_hooks func_validate_options++ # Bail if the options were screwed!+ $exit_cmd $EXIT_FAILURE+}++++## ----------------- ##+## Helper functions. ##+## ----------------- ##++# This section contains the helper functions used by the rest of the+# hookable option parser framework in ascii-betical order.+++# func_fatal_help ARG...+# ----------------------+# Echo program name prefixed message to standard error, followed by+# a help hint, and exit.+func_fatal_help ()+{+ $debug_cmd++ eval \$ECHO \""Usage: $usage"\"+ eval \$ECHO \""$fatal_help"\"+ func_error ${1+"$@"}+ exit $EXIT_FAILURE+}+++# func_help+# ---------+# Echo long help message to standard output and exit.+func_help ()+{+ $debug_cmd++ func_usage_message+ $ECHO "$long_help_message"+ exit 0+}+++# func_missing_arg ARGNAME+# ------------------------+# Echo program name prefixed message to standard error and set global+# exit_cmd.+func_missing_arg ()+{+ $debug_cmd++ func_error "Missing argument for '$1'."+ exit_cmd=exit+}+++# func_split_equals STRING+# ------------------------+# Set func_split_equals_lhs and func_split_equals_rhs shell variables+# after splitting STRING at the '=' sign.+test -z "$_G_HAVE_XSI_OPS" \+ && (eval 'x=a/b/c;+ test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \+ && _G_HAVE_XSI_OPS=yes++if test yes = "$_G_HAVE_XSI_OPS"+then+ # This is an XSI compatible shell, allowing a faster implementation...+ eval 'func_split_equals ()+ {+ $debug_cmd++ func_split_equals_lhs=${1%%=*}+ func_split_equals_rhs=${1#*=}+ if test "x$func_split_equals_lhs" = "x$1"; then+ func_split_equals_rhs=+ fi+ }'+else+ # ...otherwise fall back to using expr, which is often a shell builtin.+ func_split_equals ()+ {+ $debug_cmd++ func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`+ func_split_equals_rhs=+ test "x$func_split_equals_lhs=" = "x$1" \+ || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`+ }+fi #func_split_equals+++# func_split_short_opt SHORTOPT+# -----------------------------+# Set func_split_short_opt_name and func_split_short_opt_arg shell+# variables after splitting SHORTOPT after the 2nd character.+if test yes = "$_G_HAVE_XSI_OPS"+then+ # This is an XSI compatible shell, allowing a faster implementation...+ eval 'func_split_short_opt ()+ {+ $debug_cmd++ func_split_short_opt_arg=${1#??}+ func_split_short_opt_name=${1%"$func_split_short_opt_arg"}+ }'+else+ # ...otherwise fall back to using expr, which is often a shell builtin.+ func_split_short_opt ()+ {+ $debug_cmd++ func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'`+ func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`+ }+fi #func_split_short_opt+++# func_usage+# ----------+# Echo short help message to standard output and exit.+func_usage ()+{+ $debug_cmd++ func_usage_message+ $ECHO "Run '$progname --help |${PAGER-more}' for full usage"+ exit 0+}+++# func_usage_message+# ------------------+# Echo short help message to standard output.+func_usage_message ()+{+ $debug_cmd++ eval \$ECHO \""Usage: $usage"\"+ echo+ $SED -n 's|^# ||+ /^Written by/{+ x;p;x+ }+ h+ /^Written by/q' < "$progpath"+ echo+ eval \$ECHO \""$usage_message"\"+}+++# func_version+# ------------+# Echo version message to standard output and exit.+# The version message is extracted from the calling file's header+# comments, with leading '# ' stripped:+# 1. First display the progname and version+# 2. Followed by the header comment line matching /^# Written by /+# 3. Then a blank line followed by the first following line matching+# /^# Copyright /+# 4. Immediately followed by any lines between the previous matches,+# except lines preceding the intervening completely blank line.+# For example, see the header comments of this file.+func_version ()+{+ $debug_cmd++ printf '%s\n' "$progname $scriptversion"+ $SED -n '+ /^# Written by /!b+ s|^# ||; p; n++ :fwd2blnk+ /./ {+ n+ b fwd2blnk+ }+ p; n++ :holdwrnt+ s|^# ||+ s|^# *$||+ /^Copyright /!{+ /./H+ n+ b holdwrnt+ }++ s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|+ G+ s|\(\n\)\n*|\1|g+ p; q' < "$progpath"++ exit $?+}+++# Local variables:+# mode: shell-script+# sh-indentation: 2+# eval: (add-hook 'before-save-hook 'time-stamp)+# time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC"+# time-stamp-time-zone: "UTC"+# End:++# Set a version string.+scriptversion='(GNU libtool) 2.4.7'+++# func_echo ARG...+# ----------------+# Libtool also displays the current mode in messages, so override+# funclib.sh func_echo with this custom definition.+func_echo ()+{+ $debug_cmd++ _G_message=$*++ func_echo_IFS=$IFS+ IFS=$nl+ for _G_line in $_G_message; do+ IFS=$func_echo_IFS+ $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"+ done+ IFS=$func_echo_IFS+}+++# func_warning ARG...+# -------------------+# Libtool warnings are not categorized, so override funclib.sh+# func_warning with this simpler definition.+func_warning ()+{+ $debug_cmd++ $warning_func ${1+"$@"}+}+++## ---------------- ##+## Options parsing. ##+## ---------------- ##++# Hook in the functions to make sure our own options are parsed during+# the option parsing loop.++usage='$progpath [OPTION]... [MODE-ARG]...'++# Short help message in response to '-h'.+usage_message="Options:+ --config show all configuration variables+ --debug enable verbose shell tracing+ -n, --dry-run display commands without modifying any files+ --features display basic configuration information and exit+ --mode=MODE use operation mode MODE+ --no-warnings equivalent to '-Wnone'+ --preserve-dup-deps don't remove duplicate dependency libraries+ --quiet, --silent don't print informational messages+ --tag=TAG use configuration variables from tag TAG+ -v, --verbose print more informational messages than default+ --version print version information+ -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]+ -h, --help, --help-all print short, long, or detailed help message+"++# Additional text appended to 'usage_message' in response to '--help'.+func_help ()+{+ $debug_cmd++ func_usage_message+ $ECHO "$long_help_message++MODE must be one of the following:++ clean remove files from the build directory+ compile compile a source file into a libtool object+ execute automatically set library path, then run a program+ finish complete the installation of libtool libraries+ install install libraries or executables+ link create a library or an executable+ uninstall remove libraries from an installed directory++MODE-ARGS vary depending on the MODE. When passed as first option,+'--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.+Try '$progname --help --mode=MODE' for a more detailed description of MODE.++When reporting a bug, please describe a test case to reproduce it and+include the following information:++ host-triplet: $host+ shell: $SHELL+ compiler: $LTCC+ compiler flags: $LTCFLAGS+ linker: $LD (gnu? $with_gnu_ld)+ version: $progname (GNU libtool) 2.4.7+ automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`+ autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`++Report bugs to <bug-libtool@gnu.org>.+GNU libtool home page: <http://www.gnu.org/software/libtool/>.+General help using GNU software: <http://www.gnu.org/gethelp/>."+ exit 0+}+++# func_lo2o OBJECT-NAME+# ---------------------+# Transform OBJECT-NAME from a '.lo' suffix to the platform specific+# object suffix.++lo2o=s/\\.lo\$/.$objext/+o2lo=s/\\.$objext\$/.lo/++if test yes = "$_G_HAVE_XSI_OPS"; then+ eval 'func_lo2o ()+ {+ case $1 in+ *.lo) func_lo2o_result=${1%.lo}.$objext ;;+ * ) func_lo2o_result=$1 ;;+ esac+ }'++ # func_xform LIBOBJ-OR-SOURCE+ # ---------------------------+ # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)+ # suffix to a '.lo' libtool-object suffix.+ eval 'func_xform ()+ {+ func_xform_result=${1%.*}.lo+ }'+else+ # ...otherwise fall back to using sed.+ func_lo2o ()+ {+ func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`+ }++ func_xform ()+ {+ func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`+ }+fi+++# func_fatal_configuration ARG...+# -------------------------------+# Echo program name prefixed message to standard error, followed by+# a configuration failure hint, and exit.+func_fatal_configuration ()+{+ func_fatal_error ${1+"$@"} \+ "See the $PACKAGE documentation for more information." \+ "Fatal configuration error."+}+++# func_config+# -----------+# Display the configuration for all the tags in this script.+func_config ()+{+ re_begincf='^# ### BEGIN LIBTOOL'+ re_endcf='^# ### END LIBTOOL'++ # Default configuration.+ $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"++ # Now print the configurations for the tags.+ for tagname in $taglist; do+ $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"+ done++ exit $?+}+++# func_features+# -------------+# Display the features supported by this script.+func_features ()+{+ echo "host: $host"+ if test yes = "$build_libtool_libs"; then+ echo "enable shared libraries"+ else+ echo "disable shared libraries"+ fi+ if test yes = "$build_old_libs"; then+ echo "enable static libraries"+ else+ echo "disable static libraries"+ fi++ exit $?+}+++# func_enable_tag TAGNAME+# -----------------------+# Verify that TAGNAME is valid, and either flag an error and exit, or+# enable the TAGNAME tag. We also add TAGNAME to the global $taglist+# variable here.+func_enable_tag ()+{+ # Global variable:+ tagname=$1++ re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"+ re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"+ sed_extractcf=/$re_begincf/,/$re_endcf/p++ # Validate tagname.+ case $tagname in+ *[!-_A-Za-z0-9,/]*)+ func_fatal_error "invalid tag name: $tagname"+ ;;+ esac++ # Don't test for the "default" C tag, as we know it's+ # there but not specially marked.+ case $tagname in+ CC) ;;+ *)+ if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then+ taglist="$taglist $tagname"++ # Evaluate the configuration. Be careful to quote the path+ # and the sed script, to avoid splitting on whitespace, but+ # also don't use non-portable quotes within backquotes within+ # quotes we have to do it in 2 steps:+ extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`+ eval "$extractedcf"+ else+ func_error "ignoring unknown tag $tagname"+ fi+ ;;+ esac+}+++# func_check_version_match+# ------------------------+# Ensure that we are using m4 macros, and libtool script from the same+# release of libtool.+func_check_version_match ()+{+ if test "$package_revision" != "$macro_revision"; then+ if test "$VERSION" != "$macro_version"; then+ if test -z "$macro_version"; then+ cat >&2 <<_LT_EOF+$progname: Version mismatch error. This is $PACKAGE $VERSION, but the+$progname: definition of this LT_INIT comes from an older release.+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION+$progname: and run autoconf again.+_LT_EOF+ else+ cat >&2 <<_LT_EOF+$progname: Version mismatch error. This is $PACKAGE $VERSION, but the+$progname: definition of this LT_INIT comes from $PACKAGE $macro_version.+$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION+$progname: and run autoconf again.+_LT_EOF+ fi+ else+ cat >&2 <<_LT_EOF+$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,+$progname: but the definition of this LT_INIT comes from revision $macro_revision.+$progname: You should recreate aclocal.m4 with macros from revision $package_revision+$progname: of $PACKAGE $VERSION and run autoconf again.+_LT_EOF+ fi++ exit $EXIT_MISMATCH+ fi+}+++# libtool_options_prep [ARG]...+# -----------------------------+# Preparation for options parsed by libtool.+libtool_options_prep ()+{+ $debug_mode++ # Option defaults:+ opt_config=false+ opt_dlopen=+ opt_dry_run=false+ opt_help=false+ opt_mode=+ opt_preserve_dup_deps=false+ opt_quiet=false++ nonopt=+ preserve_args=++ _G_rc_lt_options_prep=:++ # Shorthand for --mode=foo, only valid as the first argument+ case $1 in+ clean|clea|cle|cl)+ shift; set dummy --mode clean ${1+"$@"}; shift+ ;;+ compile|compil|compi|comp|com|co|c)+ shift; set dummy --mode compile ${1+"$@"}; shift+ ;;+ execute|execut|execu|exec|exe|ex|e)+ shift; set dummy --mode execute ${1+"$@"}; shift+ ;;+ finish|finis|fini|fin|fi|f)+ shift; set dummy --mode finish ${1+"$@"}; shift+ ;;+ install|instal|insta|inst|ins|in|i)+ shift; set dummy --mode install ${1+"$@"}; shift+ ;;+ link|lin|li|l)+ shift; set dummy --mode link ${1+"$@"}; shift+ ;;+ uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)+ shift; set dummy --mode uninstall ${1+"$@"}; shift+ ;;+ *)+ _G_rc_lt_options_prep=false+ ;;+ esac++ if $_G_rc_lt_options_prep; then+ # Pass back the list of options.+ func_quote eval ${1+"$@"}+ libtool_options_prep_result=$func_quote_result+ fi+}+func_add_hook func_options_prep libtool_options_prep+++# libtool_parse_options [ARG]...+# ---------------------------------+# Provide handling for libtool specific options.+libtool_parse_options ()+{+ $debug_cmd++ _G_rc_lt_parse_options=false++ # Perform our own loop to consume as many options as possible in+ # each iteration.+ while test $# -gt 0; do+ _G_match_lt_parse_options=:+ _G_opt=$1+ shift+ case $_G_opt in+ --dry-run|--dryrun|-n)+ opt_dry_run=:+ ;;++ --config) func_config ;;++ --dlopen|-dlopen)+ opt_dlopen="${opt_dlopen+$opt_dlopen+}$1"+ shift+ ;;++ --preserve-dup-deps)+ opt_preserve_dup_deps=: ;;++ --features) func_features ;;++ --finish) set dummy --mode finish ${1+"$@"}; shift ;;++ --help) opt_help=: ;;++ --help-all) opt_help=': help-all' ;;++ --mode) test $# = 0 && func_missing_arg $_G_opt && break+ opt_mode=$1+ case $1 in+ # Valid mode arguments:+ clean|compile|execute|finish|install|link|relink|uninstall) ;;++ # Catch anything else as an error+ *) func_error "invalid argument for $_G_opt"+ exit_cmd=exit+ break+ ;;+ esac+ shift+ ;;++ --no-silent|--no-quiet)+ opt_quiet=false+ func_append preserve_args " $_G_opt"+ ;;++ --no-warnings|--no-warning|--no-warn)+ opt_warning=false+ func_append preserve_args " $_G_opt"+ ;;++ --no-verbose)+ opt_verbose=false+ func_append preserve_args " $_G_opt"+ ;;++ --silent|--quiet)+ opt_quiet=:+ opt_verbose=false+ func_append preserve_args " $_G_opt"+ ;;++ --tag) test $# = 0 && func_missing_arg $_G_opt && break+ opt_tag=$1+ func_append preserve_args " $_G_opt $1"+ func_enable_tag "$1"+ shift+ ;;++ --verbose|-v) opt_quiet=false+ opt_verbose=:+ func_append preserve_args " $_G_opt"+ ;;++ # An option not handled by this hook function:+ *) set dummy "$_G_opt" ${1+"$@"} ; shift+ _G_match_lt_parse_options=false+ break+ ;;+ esac+ $_G_match_lt_parse_options && _G_rc_lt_parse_options=:+ done++ if $_G_rc_lt_parse_options; then+ # save modified positional parameters for caller+ func_quote eval ${1+"$@"}+ libtool_parse_options_result=$func_quote_result+ fi+}+func_add_hook func_parse_options libtool_parse_options++++# libtool_validate_options [ARG]...+# ---------------------------------+# Perform any sanity checks on option settings and/or unconsumed+# arguments.+libtool_validate_options ()+{+ # save first non-option argument+ if test 0 -lt $#; then+ nonopt=$1+ shift+ fi++ # preserve --debug+ test : = "$debug_cmd" || func_append preserve_args " --debug"++ case $host in+ # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452+ # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788+ *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)+ # don't eliminate duplications in $postdeps and $predeps+ opt_duplicate_compiler_generated_deps=:+ ;;+ *)+ opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps+ ;;+ esac++ $opt_help || {+ # Sanity checks first:+ func_check_version_match++ test yes != "$build_libtool_libs" \+ && test yes != "$build_old_libs" \+ && func_fatal_configuration "not configured to build any kind of library"++ # Darwin sucks+ eval std_shrext=\"$shrext_cmds\"++ # Only execute mode is allowed to have -dlopen flags.+ if test -n "$opt_dlopen" && test execute != "$opt_mode"; then+ func_error "unrecognized option '-dlopen'"+ $ECHO "$help" 1>&2+ exit $EXIT_FAILURE+ fi++ # Change the help message to a mode-specific one.+ generic_help=$help+ help="Try '$progname --help --mode=$opt_mode' for more information."+ }++ # Pass back the unparsed argument list+ func_quote eval ${1+"$@"}+ libtool_validate_options_result=$func_quote_result+}+func_add_hook func_validate_options libtool_validate_options+++# Process options as early as possible so that --help and --version+# can return quickly.+func_options ${1+"$@"}+eval set dummy "$func_options_result"; shift++++## ----------- ##+## Main. ##+## ----------- ##++magic='%%%MAGIC variable%%%'+magic_exe='%%%MAGIC EXE variable%%%'++# Global variables.+extracted_archives=+extracted_serial=0++# If this variable is set in any of the actions, the command in it+# will be execed at the end. This prevents here-documents from being+# left over by shells.+exec_cmd=+++# A function that is used when there is no print builtin or printf.+func_fallback_echo ()+{+ eval 'cat <<_LTECHO_EOF+$1+_LTECHO_EOF'+}++# func_generated_by_libtool+# True iff stdin has been generated by Libtool. This function is only+# a basic sanity check; it will hardly flush out determined imposters.+func_generated_by_libtool_p ()+{+ $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1+}++# func_lalib_p file+# True iff FILE is a libtool '.la' library or '.lo' object file.+# This function is only a basic sanity check; it will hardly flush out+# determined imposters.+func_lalib_p ()+{+ test -f "$1" &&+ $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p+}++# func_lalib_unsafe_p file+# True iff FILE is a libtool '.la' library or '.lo' object file.+# This function implements the same check as func_lalib_p without+# resorting to external programs. To this end, it redirects stdin and+# closes it afterwards, without saving the original file descriptor.+# As a safety measure, use it only where a negative result would be+# fatal anyway. Works if 'file' does not exist.+func_lalib_unsafe_p ()+{+ lalib_p=no+ if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then+ for lalib_p_l in 1 2 3 4+ do+ read lalib_p_line+ case $lalib_p_line in+ \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;+ esac+ done+ exec 0<&5 5<&-+ fi+ test yes = "$lalib_p"+}++# func_ltwrapper_script_p file+# True iff FILE is a libtool wrapper script+# This function is only a basic sanity check; it will hardly flush out+# determined imposters.+func_ltwrapper_script_p ()+{+ test -f "$1" &&+ $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p+}++# func_ltwrapper_executable_p file+# True iff FILE is a libtool wrapper executable+# This function is only a basic sanity check; it will hardly flush out+# determined imposters.+func_ltwrapper_executable_p ()+{+ func_ltwrapper_exec_suffix=+ case $1 in+ *.exe) ;;+ *) func_ltwrapper_exec_suffix=.exe ;;+ esac+ $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1+}++# func_ltwrapper_scriptname file+# Assumes file is an ltwrapper_executable+# uses $file to determine the appropriate filename for a+# temporary ltwrapper_script.+func_ltwrapper_scriptname ()+{+ func_dirname_and_basename "$1" "" "."+ func_stripname '' '.exe' "$func_basename_result"+ func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper+}++# func_ltwrapper_p file+# True iff FILE is a libtool wrapper script or wrapper executable+# This function is only a basic sanity check; it will hardly flush out+# determined imposters.+func_ltwrapper_p ()+{+ func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"+}+++# func_execute_cmds commands fail_cmd+# Execute tilde-delimited COMMANDS.+# If FAIL_CMD is given, eval that upon failure.+# FAIL_CMD may read-access the current command in variable CMD!+func_execute_cmds ()+{+ $debug_cmd++ save_ifs=$IFS; IFS='~'+ for cmd in $1; do+ IFS=$sp$nl+ eval cmd=\"$cmd\"+ IFS=$save_ifs+ func_show_eval "$cmd" "${2-:}"+ done+ IFS=$save_ifs+}+++# func_source file+# Source FILE, adding directory component if necessary.+# Note that it is not necessary on cygwin/mingw to append a dot to+# FILE even if both FILE and FILE.exe exist: automatic-append-.exe+# behavior happens only for exec(3), not for open(2)! Also, sourcing+# 'FILE.' does not work on cygwin managed mounts.+func_source ()+{+ $debug_cmd++ case $1 in+ */* | *\\*) . "$1" ;;+ *) . "./$1" ;;+ esac+}+++# func_resolve_sysroot PATH+# Replace a leading = in PATH with a sysroot. Store the result into+# func_resolve_sysroot_result+func_resolve_sysroot ()+{+ func_resolve_sysroot_result=$1+ case $func_resolve_sysroot_result in+ =*)+ func_stripname '=' '' "$func_resolve_sysroot_result"+ func_resolve_sysroot_result=$lt_sysroot$func_stripname_result+ ;;+ esac+}++# func_replace_sysroot PATH+# If PATH begins with the sysroot, replace it with = and+# store the result into func_replace_sysroot_result.+func_replace_sysroot ()+{+ case $lt_sysroot:$1 in+ ?*:"$lt_sysroot"*)+ func_stripname "$lt_sysroot" '' "$1"+ func_replace_sysroot_result='='$func_stripname_result+ ;;+ *)+ # Including no sysroot.+ func_replace_sysroot_result=$1+ ;;+ esac+}++# func_infer_tag arg+# Infer tagged configuration to use if any are available and+# if one wasn't chosen via the "--tag" command line option.+# Only attempt this if the compiler in the base compile+# command doesn't match the default compiler.+# arg is usually of the form 'gcc ...'+func_infer_tag ()+{+ $debug_cmd++ if test -n "$available_tags" && test -z "$tagname"; then+ CC_quoted=+ for arg in $CC; do+ func_append_quoted CC_quoted "$arg"+ done+ CC_expanded=`func_echo_all $CC`+ CC_quoted_expanded=`func_echo_all $CC_quoted`+ case $@ in+ # Blanks in the command may have been stripped by the calling shell,+ # but not from the CC environment variable when configure was run.+ " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \+ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;+ # Blanks at the start of $base_compile will cause this to fail+ # if we don't check for them as well.+ *)+ for z in $available_tags; do+ if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then+ # Evaluate the configuration.+ eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"+ CC_quoted=+ for arg in $CC; do+ # Double-quote args containing other shell metacharacters.+ func_append_quoted CC_quoted "$arg"+ done+ CC_expanded=`func_echo_all $CC`+ CC_quoted_expanded=`func_echo_all $CC_quoted`+ case "$@ " in+ " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \+ " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)+ # The compiler in the base compile command matches+ # the one in the tagged configuration.+ # Assume this is the tagged configuration we want.+ tagname=$z+ break+ ;;+ esac+ fi+ done+ # If $tagname still isn't set, then no tagged configuration+ # was found and let the user know that the "--tag" command+ # line option must be used.+ if test -z "$tagname"; then+ func_echo "unable to infer tagged configuration"+ func_fatal_error "specify a tag with '--tag'"+# else+# func_verbose "using $tagname tagged configuration"+ fi+ ;;+ esac+ fi+}++++# func_write_libtool_object output_name pic_name nonpic_name+# Create a libtool object file (analogous to a ".la" file),+# but don't create it if we're doing a dry run.+func_write_libtool_object ()+{+ write_libobj=$1+ if test yes = "$build_libtool_libs"; then+ write_lobj=\'$2\'+ else+ write_lobj=none+ fi++ if test yes = "$build_old_libs"; then+ write_oldobj=\'$3\'+ else+ write_oldobj=none+ fi++ $opt_dry_run || {+ cat >${write_libobj}T <<EOF+# $write_libobj - a libtool object file+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION+#+# Please DO NOT delete this file!+# It is necessary for linking the library.++# Name of the PIC object.+pic_object=$write_lobj++# Name of the non-PIC object+non_pic_object=$write_oldobj++EOF+ $MV "${write_libobj}T" "$write_libobj"+ }+}+++##################################################+# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #+##################################################++# func_convert_core_file_wine_to_w32 ARG+# Helper function used by file name conversion functions when $build is *nix,+# and $host is mingw, cygwin, or some other w32 environment. Relies on a+# correctly configured wine environment available, with the winepath program+# in $build's $PATH.+#+# ARG is the $build file name to be converted to w32 format.+# Result is available in $func_convert_core_file_wine_to_w32_result, and will+# be empty on error (or when ARG is empty)+func_convert_core_file_wine_to_w32 ()+{+ $debug_cmd++ func_convert_core_file_wine_to_w32_result=$1+ if test -n "$1"; then+ # Unfortunately, winepath does not exit with a non-zero error code, so we+ # are forced to check the contents of stdout. On the other hand, if the+ # command is not found, the shell will set an exit code of 127 and print+ # *an error message* to stdout. So we must check for both error code of+ # zero AND non-empty stdout, which explains the odd construction:+ func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`+ if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then+ func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |+ $SED -e "$sed_naive_backslashify"`+ else+ func_convert_core_file_wine_to_w32_result=+ fi+ fi+}+# end: func_convert_core_file_wine_to_w32+++# func_convert_core_path_wine_to_w32 ARG+# Helper function used by path conversion functions when $build is *nix, and+# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly+# configured wine environment available, with the winepath program in $build's+# $PATH. Assumes ARG has no leading or trailing path separator characters.+#+# ARG is path to be converted from $build format to win32.+# Result is available in $func_convert_core_path_wine_to_w32_result.+# Unconvertible file (directory) names in ARG are skipped; if no directory names+# are convertible, then the result may be empty.+func_convert_core_path_wine_to_w32 ()+{+ $debug_cmd++ # unfortunately, winepath doesn't convert paths, only file names+ func_convert_core_path_wine_to_w32_result=+ if test -n "$1"; then+ oldIFS=$IFS+ IFS=:+ for func_convert_core_path_wine_to_w32_f in $1; do+ IFS=$oldIFS+ func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"+ if test -n "$func_convert_core_file_wine_to_w32_result"; then+ if test -z "$func_convert_core_path_wine_to_w32_result"; then+ func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result+ else+ func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"+ fi+ fi+ done+ IFS=$oldIFS+ fi+}+# end: func_convert_core_path_wine_to_w32+++# func_cygpath ARGS...+# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when+# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)+# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or+# (2), returns the Cygwin file name or path in func_cygpath_result (input+# file name or path is assumed to be in w32 format, as previously converted+# from $build's *nix or MSYS format). In case (3), returns the w32 file name+# or path in func_cygpath_result (input file name or path is assumed to be in+# Cygwin format). Returns an empty string on error.+#+# ARGS are passed to cygpath, with the last one being the file name or path to+# be converted.+#+# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH+# environment variable; do not put it in $PATH.+func_cygpath ()+{+ $debug_cmd++ if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then+ func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`+ if test "$?" -ne 0; then+ # on failure, ensure result is empty+ func_cygpath_result=+ fi+ else+ func_cygpath_result=+ func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"+ fi+}+#end: func_cygpath+++# func_convert_core_msys_to_w32 ARG+# Convert file name or path ARG from MSYS format to w32 format. Return+# result in func_convert_core_msys_to_w32_result.+func_convert_core_msys_to_w32 ()+{+ $debug_cmd++ # awkward: cmd appends spaces to result+ func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |+ $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`+}+#end: func_convert_core_msys_to_w32+++# func_convert_file_check ARG1 ARG2+# Verify that ARG1 (a file name in $build format) was converted to $host+# format in ARG2. Otherwise, emit an error message, but continue (resetting+# func_to_host_file_result to ARG1).+func_convert_file_check ()+{+ $debug_cmd++ if test -z "$2" && test -n "$1"; then+ func_error "Could not determine host file name corresponding to"+ func_error " '$1'"+ func_error "Continuing, but uninstalled executables may not work."+ # Fallback:+ func_to_host_file_result=$1+ fi+}+# end func_convert_file_check+++# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH+# Verify that FROM_PATH (a path in $build format) was converted to $host+# format in TO_PATH. Otherwise, emit an error message, but continue, resetting+# func_to_host_file_result to a simplistic fallback value (see below).+func_convert_path_check ()+{+ $debug_cmd++ if test -z "$4" && test -n "$3"; then+ func_error "Could not determine the host path corresponding to"+ func_error " '$3'"+ func_error "Continuing, but uninstalled executables may not work."+ # Fallback. This is a deliberately simplistic "conversion" and+ # should not be "improved". See libtool.info.+ if test "x$1" != "x$2"; then+ lt_replace_pathsep_chars="s|$1|$2|g"+ func_to_host_path_result=`echo "$3" |+ $SED -e "$lt_replace_pathsep_chars"`+ else+ func_to_host_path_result=$3+ fi+ fi+}+# end func_convert_path_check+++# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG+# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT+# and appending REPL if ORIG matches BACKPAT.+func_convert_path_front_back_pathsep ()+{+ $debug_cmd++ case $4 in+ $1 ) func_to_host_path_result=$3$func_to_host_path_result+ ;;+ esac+ case $4 in+ $2 ) func_append func_to_host_path_result "$3"+ ;;+ esac+}+# end func_convert_path_front_back_pathsep+++##################################################+# $build to $host FILE NAME CONVERSION FUNCTIONS #+##################################################+# invoked via '$to_host_file_cmd ARG'+#+# In each case, ARG is the path to be converted from $build to $host format.+# Result will be available in $func_to_host_file_result.+++# func_to_host_file ARG+# Converts the file name ARG from $build format to $host format. Return result+# in func_to_host_file_result.+func_to_host_file ()+{+ $debug_cmd++ $to_host_file_cmd "$1"+}+# end func_to_host_file+++# func_to_tool_file ARG LAZY+# converts the file name ARG from $build format to toolchain format. Return+# result in func_to_tool_file_result. If the conversion in use is listed+# in (the comma separated) LAZY, no conversion takes place.+func_to_tool_file ()+{+ $debug_cmd++ case ,$2, in+ *,"$to_tool_file_cmd",*)+ func_to_tool_file_result=$1+ ;;+ *)+ $to_tool_file_cmd "$1"+ func_to_tool_file_result=$func_to_host_file_result+ ;;+ esac+}+# end func_to_tool_file+++# func_convert_file_noop ARG+# Copy ARG to func_to_host_file_result.+func_convert_file_noop ()+{+ func_to_host_file_result=$1+}+# end func_convert_file_noop+++# func_convert_file_msys_to_w32 ARG+# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic+# conversion to w32 is not available inside the cwrapper. Returns result in+# func_to_host_file_result.+func_convert_file_msys_to_w32 ()+{+ $debug_cmd++ func_to_host_file_result=$1+ if test -n "$1"; then+ func_convert_core_msys_to_w32 "$1"+ func_to_host_file_result=$func_convert_core_msys_to_w32_result+ fi+ func_convert_file_check "$1" "$func_to_host_file_result"+}+# end func_convert_file_msys_to_w32+++# func_convert_file_cygwin_to_w32 ARG+# Convert file name ARG from Cygwin to w32 format. Returns result in+# func_to_host_file_result.+func_convert_file_cygwin_to_w32 ()+{+ $debug_cmd++ func_to_host_file_result=$1+ if test -n "$1"; then+ # because $build is cygwin, we call "the" cygpath in $PATH; no need to use+ # LT_CYGPATH in this case.+ func_to_host_file_result=`cygpath -m "$1"`+ fi+ func_convert_file_check "$1" "$func_to_host_file_result"+}+# end func_convert_file_cygwin_to_w32+++# func_convert_file_nix_to_w32 ARG+# Convert file name ARG from *nix to w32 format. Requires a wine environment+# and a working winepath. Returns result in func_to_host_file_result.+func_convert_file_nix_to_w32 ()+{+ $debug_cmd++ func_to_host_file_result=$1+ if test -n "$1"; then+ func_convert_core_file_wine_to_w32 "$1"+ func_to_host_file_result=$func_convert_core_file_wine_to_w32_result+ fi+ func_convert_file_check "$1" "$func_to_host_file_result"+}+# end func_convert_file_nix_to_w32+++# func_convert_file_msys_to_cygwin ARG+# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.+# Returns result in func_to_host_file_result.+func_convert_file_msys_to_cygwin ()+{+ $debug_cmd++ func_to_host_file_result=$1+ if test -n "$1"; then+ func_convert_core_msys_to_w32 "$1"+ func_cygpath -u "$func_convert_core_msys_to_w32_result"+ func_to_host_file_result=$func_cygpath_result+ fi+ func_convert_file_check "$1" "$func_to_host_file_result"+}+# end func_convert_file_msys_to_cygwin+++# func_convert_file_nix_to_cygwin ARG+# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed+# in a wine environment, working winepath, and LT_CYGPATH set. Returns result+# in func_to_host_file_result.+func_convert_file_nix_to_cygwin ()+{+ $debug_cmd++ func_to_host_file_result=$1+ if test -n "$1"; then+ # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.+ func_convert_core_file_wine_to_w32 "$1"+ func_cygpath -u "$func_convert_core_file_wine_to_w32_result"+ func_to_host_file_result=$func_cygpath_result+ fi+ func_convert_file_check "$1" "$func_to_host_file_result"+}+# end func_convert_file_nix_to_cygwin+++#############################################+# $build to $host PATH CONVERSION FUNCTIONS #+#############################################+# invoked via '$to_host_path_cmd ARG'+#+# In each case, ARG is the path to be converted from $build to $host format.+# The result will be available in $func_to_host_path_result.+#+# Path separators are also converted from $build format to $host format. If+# ARG begins or ends with a path separator character, it is preserved (but+# converted to $host format) on output.+#+# All path conversion functions are named using the following convention:+# file name conversion function : func_convert_file_X_to_Y ()+# path conversion function : func_convert_path_X_to_Y ()+# where, for any given $build/$host combination the 'X_to_Y' value is the+# same. If conversion functions are added for new $build/$host combinations,+# the two new functions must follow this pattern, or func_init_to_host_path_cmd+# will break.+++# func_init_to_host_path_cmd+# Ensures that function "pointer" variable $to_host_path_cmd is set to the+# appropriate value, based on the value of $to_host_file_cmd.+to_host_path_cmd=+func_init_to_host_path_cmd ()+{+ $debug_cmd++ if test -z "$to_host_path_cmd"; then+ func_stripname 'func_convert_file_' '' "$to_host_file_cmd"+ to_host_path_cmd=func_convert_path_$func_stripname_result+ fi+}+++# func_to_host_path ARG+# Converts the path ARG from $build format to $host format. Return result+# in func_to_host_path_result.+func_to_host_path ()+{+ $debug_cmd++ func_init_to_host_path_cmd+ $to_host_path_cmd "$1"+}+# end func_to_host_path+++# func_convert_path_noop ARG+# Copy ARG to func_to_host_path_result.+func_convert_path_noop ()+{+ func_to_host_path_result=$1+}+# end func_convert_path_noop+++# func_convert_path_msys_to_w32 ARG+# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic+# conversion to w32 is not available inside the cwrapper. Returns result in+# func_to_host_path_result.+func_convert_path_msys_to_w32 ()+{+ $debug_cmd++ func_to_host_path_result=$1+ if test -n "$1"; then+ # Remove leading and trailing path separator characters from ARG. MSYS+ # behavior is inconsistent here; cygpath turns them into '.;' and ';.';+ # and winepath ignores them completely.+ func_stripname : : "$1"+ func_to_host_path_tmp1=$func_stripname_result+ func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"+ func_to_host_path_result=$func_convert_core_msys_to_w32_result+ func_convert_path_check : ";" \+ "$func_to_host_path_tmp1" "$func_to_host_path_result"+ func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"+ fi+}+# end func_convert_path_msys_to_w32+++# func_convert_path_cygwin_to_w32 ARG+# Convert path ARG from Cygwin to w32 format. Returns result in+# func_to_host_file_result.+func_convert_path_cygwin_to_w32 ()+{+ $debug_cmd++ func_to_host_path_result=$1+ if test -n "$1"; then+ # See func_convert_path_msys_to_w32:+ func_stripname : : "$1"+ func_to_host_path_tmp1=$func_stripname_result+ func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`+ func_convert_path_check : ";" \+ "$func_to_host_path_tmp1" "$func_to_host_path_result"+ func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"+ fi+}+# end func_convert_path_cygwin_to_w32+++# func_convert_path_nix_to_w32 ARG+# Convert path ARG from *nix to w32 format. Requires a wine environment and+# a working winepath. Returns result in func_to_host_file_result.+func_convert_path_nix_to_w32 ()+{+ $debug_cmd++ func_to_host_path_result=$1+ if test -n "$1"; then+ # See func_convert_path_msys_to_w32:+ func_stripname : : "$1"+ func_to_host_path_tmp1=$func_stripname_result+ func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"+ func_to_host_path_result=$func_convert_core_path_wine_to_w32_result+ func_convert_path_check : ";" \+ "$func_to_host_path_tmp1" "$func_to_host_path_result"+ func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"+ fi+}+# end func_convert_path_nix_to_w32+++# func_convert_path_msys_to_cygwin ARG+# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.+# Returns result in func_to_host_file_result.+func_convert_path_msys_to_cygwin ()+{+ $debug_cmd++ func_to_host_path_result=$1+ if test -n "$1"; then+ # See func_convert_path_msys_to_w32:+ func_stripname : : "$1"+ func_to_host_path_tmp1=$func_stripname_result+ func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"+ func_cygpath -u -p "$func_convert_core_msys_to_w32_result"+ func_to_host_path_result=$func_cygpath_result+ func_convert_path_check : : \+ "$func_to_host_path_tmp1" "$func_to_host_path_result"+ func_convert_path_front_back_pathsep ":*" "*:" : "$1"+ fi+}+# end func_convert_path_msys_to_cygwin+++# func_convert_path_nix_to_cygwin ARG+# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a+# a wine environment, working winepath, and LT_CYGPATH set. Returns result in+# func_to_host_file_result.+func_convert_path_nix_to_cygwin ()+{+ $debug_cmd++ func_to_host_path_result=$1+ if test -n "$1"; then+ # Remove leading and trailing path separator characters from+ # ARG. msys behavior is inconsistent here, cygpath turns them+ # into '.;' and ';.', and winepath ignores them completely.+ func_stripname : : "$1"+ func_to_host_path_tmp1=$func_stripname_result+ func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"+ func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"+ func_to_host_path_result=$func_cygpath_result+ func_convert_path_check : : \+ "$func_to_host_path_tmp1" "$func_to_host_path_result"+ func_convert_path_front_back_pathsep ":*" "*:" : "$1"+ fi+}+# end func_convert_path_nix_to_cygwin+++# func_dll_def_p FILE+# True iff FILE is a Windows DLL '.def' file.+# Keep in sync with _LT_DLL_DEF_P in libtool.m4+func_dll_def_p ()+{+ $debug_cmd++ func_dll_def_p_tmp=`$SED -n \+ -e 's/^[ ]*//' \+ -e '/^\(;.*\)*$/d' \+ -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \+ -e q \+ "$1"`+ test DEF = "$func_dll_def_p_tmp"+}+++# func_mode_compile arg...+func_mode_compile ()+{+ $debug_cmd++ # Get the compilation command and the source file.+ base_compile=+ srcfile=$nonopt # always keep a non-empty value in "srcfile"+ suppress_opt=yes+ suppress_output=+ arg_mode=normal+ libobj=+ later=+ pie_flag=++ for arg+ do+ case $arg_mode in+ arg )+ # do not "continue". Instead, add this to base_compile+ lastarg=$arg+ arg_mode=normal+ ;;++ target )+ libobj=$arg+ arg_mode=normal+ continue+ ;;++ normal )+ # Accept any command-line options.+ case $arg in+ -o)+ test -n "$libobj" && \+ func_fatal_error "you cannot specify '-o' more than once"+ arg_mode=target+ continue+ ;;++ -pie | -fpie | -fPIE)+ func_append pie_flag " $arg"+ continue+ ;;++ -shared | -static | -prefer-pic | -prefer-non-pic)+ func_append later " $arg"+ continue+ ;;++ -no-suppress)+ suppress_opt=no+ continue+ ;;++ -Xcompiler)+ arg_mode=arg # the next one goes into the "base_compile" arg list+ continue # The current "srcfile" will either be retained or+ ;; # replaced later. I would guess that would be a bug.++ -Wc,*)+ func_stripname '-Wc,' '' "$arg"+ args=$func_stripname_result+ lastarg=+ save_ifs=$IFS; IFS=,+ for arg in $args; do+ IFS=$save_ifs+ func_append_quoted lastarg "$arg"+ done+ IFS=$save_ifs+ func_stripname ' ' '' "$lastarg"+ lastarg=$func_stripname_result++ # Add the arguments to base_compile.+ func_append base_compile " $lastarg"+ continue+ ;;++ *)+ # Accept the current argument as the source file.+ # The previous "srcfile" becomes the current argument.+ #+ lastarg=$srcfile+ srcfile=$arg+ ;;+ esac # case $arg+ ;;+ esac # case $arg_mode++ # Aesthetically quote the previous argument.+ func_append_quoted base_compile "$lastarg"+ done # for arg++ case $arg_mode in+ arg)+ func_fatal_error "you must specify an argument for -Xcompile"+ ;;+ target)+ func_fatal_error "you must specify a target with '-o'"+ ;;+ *)+ # Get the name of the library object.+ test -z "$libobj" && {+ func_basename "$srcfile"+ libobj=$func_basename_result+ }+ ;;+ esac++ # Recognize several different file suffixes.+ # If the user specifies -o file.o, it is replaced with file.lo+ case $libobj in+ *.[cCFSifmso] | \+ *.ada | *.adb | *.ads | *.asm | \+ *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \+ *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)+ func_xform "$libobj"+ libobj=$func_xform_result+ ;;+ esac++ case $libobj in+ *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;+ *)+ func_fatal_error "cannot determine name of library object from '$libobj'"+ ;;+ esac++ func_infer_tag $base_compile++ for arg in $later; do+ case $arg in+ -shared)+ test yes = "$build_libtool_libs" \+ || func_fatal_configuration "cannot build a shared library"+ build_old_libs=no+ continue+ ;;++ -static)+ build_libtool_libs=no+ build_old_libs=yes+ continue+ ;;++ -prefer-pic)+ pic_mode=yes+ continue+ ;;++ -prefer-non-pic)+ pic_mode=no+ continue+ ;;+ esac+ done++ func_quote_arg pretty "$libobj"+ test "X$libobj" != "X$func_quote_arg_result" \+ && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \+ && func_warning "libobj name '$libobj' may not contain shell special characters."+ func_dirname_and_basename "$obj" "/" ""+ objname=$func_basename_result+ xdir=$func_dirname_result+ lobj=$xdir$objdir/$objname++ test -z "$base_compile" && \+ func_fatal_help "you must specify a compilation command"++ # Delete any leftover library objects.+ if test yes = "$build_old_libs"; then+ removelist="$obj $lobj $libobj ${libobj}T"+ else+ removelist="$lobj $libobj ${libobj}T"+ fi++ # On Cygwin there's no "real" PIC flag so we must build both object types+ case $host_os in+ cygwin* | mingw* | pw32* | os2* | cegcc*)+ pic_mode=default+ ;;+ esac+ if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then+ # non-PIC code in shared libraries is not supported+ pic_mode=default+ fi++ # Calculate the filename of the output object if compiler does+ # not support -o with -c+ if test no = "$compiler_c_o"; then+ output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext+ lockfile=$output_obj.lock+ else+ output_obj=+ need_locks=no+ lockfile=+ fi++ # Lock this critical section if it is needed+ # We use this script file to make the link, it avoids creating a new file+ if test yes = "$need_locks"; then+ until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do+ func_echo "Waiting for $lockfile to be removed"+ sleep 2+ done+ elif test warn = "$need_locks"; then+ if test -f "$lockfile"; then+ $ECHO "\+*** ERROR, $lockfile exists and contains:+`cat $lockfile 2>/dev/null`++This indicates that another process is trying to use the same+temporary object file, and libtool could not work around it because+your compiler does not support '-c' and '-o' together. If you+repeat this compilation, it may succeed, by chance, but you had better+avoid parallel builds (make -j) in this platform, or get a better+compiler."++ $opt_dry_run || $RM $removelist+ exit $EXIT_FAILURE+ fi+ func_append removelist " $output_obj"+ $ECHO "$srcfile" > "$lockfile"+ fi++ $opt_dry_run || $RM $removelist+ func_append removelist " $lockfile"+ trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15++ func_to_tool_file "$srcfile" func_convert_file_msys_to_w32+ srcfile=$func_to_tool_file_result+ func_quote_arg pretty "$srcfile"+ qsrcfile=$func_quote_arg_result++ # Only build a PIC object if we are building libtool libraries.+ if test yes = "$build_libtool_libs"; then+ # Without this assignment, base_compile gets emptied.+ fbsd_hideous_sh_bug=$base_compile++ if test no != "$pic_mode"; then+ command="$base_compile $qsrcfile $pic_flag"+ else+ # Don't build PIC code+ command="$base_compile $qsrcfile"+ fi++ func_mkdir_p "$xdir$objdir"++ if test -z "$output_obj"; then+ # Place PIC objects in $objdir+ func_append command " -o $lobj"+ fi++ func_show_eval_locale "$command" \+ 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'++ if test warn = "$need_locks" &&+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then+ $ECHO "\+*** ERROR, $lockfile contains:+`cat $lockfile 2>/dev/null`++but it should contain:+$srcfile++This indicates that another process is trying to use the same+temporary object file, and libtool could not work around it because+your compiler does not support '-c' and '-o' together. If you+repeat this compilation, it may succeed, by chance, but you had better+avoid parallel builds (make -j) in this platform, or get a better+compiler."++ $opt_dry_run || $RM $removelist+ exit $EXIT_FAILURE+ fi++ # Just move the object if needed, then go on to compile the next one+ if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then+ func_show_eval '$MV "$output_obj" "$lobj"' \+ 'error=$?; $opt_dry_run || $RM $removelist; exit $error'+ fi++ # Allow error messages only from the first compilation.+ if test yes = "$suppress_opt"; then+ suppress_output=' >/dev/null 2>&1'+ fi+ fi++ # Only build a position-dependent object if we build old libraries.+ if test yes = "$build_old_libs"; then+ if test yes != "$pic_mode"; then+ # Don't build PIC code+ command="$base_compile $qsrcfile$pie_flag"+ else+ command="$base_compile $qsrcfile $pic_flag"+ fi+ if test yes = "$compiler_c_o"; then+ func_append command " -o $obj"+ fi++ # Suppress compiler output if we already did a PIC compilation.+ func_append command "$suppress_output"+ func_show_eval_locale "$command" \+ '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'++ if test warn = "$need_locks" &&+ test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then+ $ECHO "\+*** ERROR, $lockfile contains:+`cat $lockfile 2>/dev/null`++but it should contain:+$srcfile++This indicates that another process is trying to use the same+temporary object file, and libtool could not work around it because+your compiler does not support '-c' and '-o' together. If you+repeat this compilation, it may succeed, by chance, but you had better+avoid parallel builds (make -j) in this platform, or get a better+compiler."++ $opt_dry_run || $RM $removelist+ exit $EXIT_FAILURE+ fi++ # Just move the object if needed+ if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then+ func_show_eval '$MV "$output_obj" "$obj"' \+ 'error=$?; $opt_dry_run || $RM $removelist; exit $error'+ fi+ fi++ $opt_dry_run || {+ func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"++ # Unlock the critical section if it was locked+ if test no != "$need_locks"; then+ removelist=$lockfile+ $RM "$lockfile"+ fi+ }++ exit $EXIT_SUCCESS+}++$opt_help || {+ test compile = "$opt_mode" && func_mode_compile ${1+"$@"}+}++func_mode_help ()+{+ # We need to display help for each of the modes.+ case $opt_mode in+ "")+ # Generic help is extracted from the usage comments+ # at the start of this file.+ func_help+ ;;++ clean)+ $ECHO \+"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...++Remove files from the build directory.++RM is the name of the program to use to delete files associated with each FILE+(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed+to RM.++If FILE is a libtool library, object or program, all the files associated+with it are deleted. Otherwise, only FILE itself is deleted using RM."+ ;;++ compile)+ $ECHO \+"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE++Compile a source file into a libtool library object.++This mode accepts the following additional options:++ -o OUTPUT-FILE set the output file name to OUTPUT-FILE+ -no-suppress do not suppress compiler output for multiple passes+ -prefer-pic try to build PIC objects only+ -prefer-non-pic try to build non-PIC objects only+ -shared do not build a '.o' file suitable for static linking+ -static only build a '.o' file suitable for static linking+ -Wc,FLAG+ -Xcompiler FLAG pass FLAG directly to the compiler++COMPILE-COMMAND is a command to be used in creating a 'standard' object file+from the given SOURCEFILE.++The output file name is determined by removing the directory component from+SOURCEFILE, then substituting the C source code suffix '.c' with the+library object suffix, '.lo'."+ ;;++ execute)+ $ECHO \+"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...++Automatically set library path, then run a program.++This mode accepts the following additional options:++ -dlopen FILE add the directory containing FILE to the library path++This mode sets the library path environment variable according to '-dlopen'+flags.++If any of the ARGS are libtool executable wrappers, then they are translated+into their corresponding uninstalled binary, and any of their required library+directories are added to the library path.++Then, COMMAND is executed, with ARGS as arguments."+ ;;++ finish)+ $ECHO \+"Usage: $progname [OPTION]... --mode=finish [LIBDIR]...++Complete the installation of libtool libraries.++Each LIBDIR is a directory that contains libtool libraries.++The commands that this mode executes may require superuser privileges. Use+the '--dry-run' option if you just want to see what would be executed."+ ;;++ install)+ $ECHO \+"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...++Install executables or libraries.++INSTALL-COMMAND is the installation command. The first component should be+either the 'install' or 'cp' program.++The following components of INSTALL-COMMAND are treated specially:++ -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation++The rest of the components are interpreted as arguments to that command (only+BSD-compatible install options are recognized)."+ ;;++ link)+ $ECHO \+"Usage: $progname [OPTION]... --mode=link LINK-COMMAND...++Link object files or libraries together to form another library, or to+create an executable program.++LINK-COMMAND is a command using the C compiler that you would use to create+a program from several object files.++The following components of LINK-COMMAND are treated specially:++ -all-static do not do any dynamic linking at all+ -avoid-version do not add a version suffix if possible+ -bindir BINDIR specify path to binaries directory (for systems where+ libraries must be found in the PATH setting at runtime)+ -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime+ -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols+ -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)+ -export-symbols SYMFILE+ try to export only the symbols listed in SYMFILE+ -export-symbols-regex REGEX+ try to export only the symbols matching REGEX+ -LLIBDIR search LIBDIR for required installed libraries+ -lNAME OUTPUT-FILE requires the installed library libNAME+ -module build a library that can dlopened+ -no-fast-install disable the fast-install mode+ -no-install link a not-installable executable+ -no-undefined declare that a library does not refer to external symbols+ -o OUTPUT-FILE create OUTPUT-FILE from the specified objects+ -objectlist FILE use a list of object files found in FILE to specify objects+ -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)+ -precious-files-regex REGEX+ don't remove output files matching REGEX+ -release RELEASE specify package release information+ -rpath LIBDIR the created library will eventually be installed in LIBDIR+ -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries+ -shared only do dynamic linking of libtool libraries+ -shrext SUFFIX override the standard shared library file extension+ -static do not do any dynamic linking of uninstalled libtool libraries+ -static-libtool-libs+ do not do any dynamic linking of libtool libraries+ -version-info CURRENT[:REVISION[:AGE]]+ specify library version info [each variable defaults to 0]+ -weak LIBNAME declare that the target provides the LIBNAME interface+ -Wc,FLAG+ -Xcompiler FLAG pass linker-specific FLAG directly to the compiler+ -Wa,FLAG+ -Xassembler FLAG pass linker-specific FLAG directly to the assembler+ -Wl,FLAG+ -Xlinker FLAG pass linker-specific FLAG directly to the linker+ -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)++All other options (arguments beginning with '-') are ignored.++Every other argument is treated as a filename. Files ending in '.la' are+treated as uninstalled libtool libraries, other files are standard or library+object files.++If the OUTPUT-FILE ends in '.la', then a libtool library is created,+only library objects ('.lo' files) may be specified, and '-rpath' is+required, except when creating a convenience library.++If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created+using 'ar' and 'ranlib', or on Windows using 'lib'.++If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file+is created, otherwise an executable program is created."+ ;;++ uninstall)+ $ECHO \+"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...++Remove libraries from an installation directory.++RM is the name of the program to use to delete files associated with each FILE+(typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed+to RM.++If FILE is a libtool library, all the files associated with it are deleted.+Otherwise, only FILE itself is deleted using RM."+ ;;++ *)+ func_fatal_help "invalid operation mode '$opt_mode'"+ ;;+ esac++ echo+ $ECHO "Try '$progname --help' for more information about other modes."+}++# Now that we've collected a possible --mode arg, show help if necessary+if $opt_help; then+ if test : = "$opt_help"; then+ func_mode_help+ else+ {+ func_help noexit+ for opt_mode in compile link execute install finish uninstall clean; do+ func_mode_help+ done+ } | $SED -n '1p; 2,$s/^Usage:/ or: /p'+ {+ func_help noexit+ for opt_mode in compile link execute install finish uninstall clean; do+ echo+ func_mode_help+ done+ } |+ $SED '1d+ /^When reporting/,/^Report/{+ H+ d+ }+ $x+ /information about other modes/d+ /more detailed .*MODE/d+ s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'+ fi+ exit $?+fi+++# func_mode_execute arg...+func_mode_execute ()+{+ $debug_cmd++ # The first argument is the command name.+ cmd=$nonopt+ test -z "$cmd" && \+ func_fatal_help "you must specify a COMMAND"++ # Handle -dlopen flags immediately.+ for file in $opt_dlopen; do+ test -f "$file" \+ || func_fatal_help "'$file' is not a file"++ dir=+ case $file in+ *.la)+ func_resolve_sysroot "$file"+ file=$func_resolve_sysroot_result++ # Check to see that this really is a libtool archive.+ func_lalib_unsafe_p "$file" \+ || func_fatal_help "'$lib' is not a valid libtool archive"++ # Read the libtool library.+ dlname=+ library_names=+ func_source "$file"++ # Skip this library if it cannot be dlopened.+ if test -z "$dlname"; then+ # Warn if it was a shared library.+ test -n "$library_names" && \+ func_warning "'$file' was not linked with '-export-dynamic'"+ continue+ fi++ func_dirname "$file" "" "."+ dir=$func_dirname_result++ if test -f "$dir/$objdir/$dlname"; then+ func_append dir "/$objdir"+ else+ if test ! -f "$dir/$dlname"; then+ func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"+ fi+ fi+ ;;++ *.lo)+ # Just add the directory containing the .lo file.+ func_dirname "$file" "" "."+ dir=$func_dirname_result+ ;;++ *)+ func_warning "'-dlopen' is ignored for non-libtool libraries and objects"+ continue+ ;;+ esac++ # Get the absolute pathname.+ absdir=`cd "$dir" && pwd`+ test -n "$absdir" && dir=$absdir++ # Now add the directory to shlibpath_var.+ if eval "test -z \"\$$shlibpath_var\""; then+ eval "$shlibpath_var=\"\$dir\""+ else+ eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""+ fi+ done++ # This variable tells wrapper scripts just to set shlibpath_var+ # rather than running their programs.+ libtool_execute_magic=$magic++ # Check if any of the arguments is a wrapper script.+ args=+ for file+ do+ case $file in+ -* | *.la | *.lo ) ;;+ *)+ # Do a test to see if this is really a libtool program.+ if func_ltwrapper_script_p "$file"; then+ func_source "$file"+ # Transform arg to wrapped name.+ file=$progdir/$program+ elif func_ltwrapper_executable_p "$file"; then+ func_ltwrapper_scriptname "$file"+ func_source "$func_ltwrapper_scriptname_result"+ # Transform arg to wrapped name.+ file=$progdir/$program+ fi+ ;;+ esac+ # Quote arguments (to preserve shell metacharacters).+ func_append_quoted args "$file"+ done++ if $opt_dry_run; then+ # Display what would be done.+ if test -n "$shlibpath_var"; then+ eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""+ echo "export $shlibpath_var"+ fi+ $ECHO "$cmd$args"+ exit $EXIT_SUCCESS+ else+ if test -n "$shlibpath_var"; then+ # Export the shlibpath_var.+ eval "export $shlibpath_var"+ fi++ # Restore saved environment variables+ for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES+ do+ eval "if test \"\${save_$lt_var+set}\" = set; then+ $lt_var=\$save_$lt_var; export $lt_var+ else+ $lt_unset $lt_var+ fi"+ done++ # Now prepare to actually exec the command.+ exec_cmd=\$cmd$args+ fi+}++test execute = "$opt_mode" && func_mode_execute ${1+"$@"}+++# func_mode_finish arg...+func_mode_finish ()+{+ $debug_cmd++ libs=+ libdirs=+ admincmds=++ for opt in "$nonopt" ${1+"$@"}+ do+ if test -d "$opt"; then+ func_append libdirs " $opt"++ elif test -f "$opt"; then+ if func_lalib_unsafe_p "$opt"; then+ func_append libs " $opt"+ else+ func_warning "'$opt' is not a valid libtool archive"+ fi++ else+ func_fatal_error "invalid argument '$opt'"+ fi+ done++ if test -n "$libs"; then+ if test -n "$lt_sysroot"; then+ sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`+ sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"+ else+ sysroot_cmd=+ fi++ # Remove sysroot references+ if $opt_dry_run; then+ for lib in $libs; do+ echo "removing references to $lt_sysroot and '=' prefixes from $lib"+ done+ else+ tmpdir=`func_mktempdir`+ for lib in $libs; do+ $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \+ > $tmpdir/tmp-la+ mv -f $tmpdir/tmp-la $lib+ done+ ${RM}r "$tmpdir"+ fi+ fi++ if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then+ for libdir in $libdirs; do+ if test -n "$finish_cmds"; then+ # Do each command in the finish commands.+ func_execute_cmds "$finish_cmds" 'admincmds="$admincmds+'"$cmd"'"'+ fi+ if test -n "$finish_eval"; then+ # Do the single finish_eval.+ eval cmds=\"$finish_eval\"+ $opt_dry_run || eval "$cmds" || func_append admincmds "+ $cmds"+ fi+ done+ fi++ # Exit here if they wanted silent mode.+ $opt_quiet && exit $EXIT_SUCCESS++ if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then+ echo "----------------------------------------------------------------------"+ echo "Libraries have been installed in:"+ for libdir in $libdirs; do+ $ECHO " $libdir"+ done+ echo+ echo "If you ever happen to want to link against installed libraries"+ echo "in a given directory, LIBDIR, you must either use libtool, and"+ echo "specify the full pathname of the library, or use the '-LLIBDIR'"+ echo "flag during linking and do at least one of the following:"+ if test -n "$shlibpath_var"; then+ echo " - add LIBDIR to the '$shlibpath_var' environment variable"+ echo " during execution"+ fi+ if test -n "$runpath_var"; then+ echo " - add LIBDIR to the '$runpath_var' environment variable"+ echo " during linking"+ fi+ if test -n "$hardcode_libdir_flag_spec"; then+ libdir=LIBDIR+ eval flag=\"$hardcode_libdir_flag_spec\"++ $ECHO " - use the '$flag' linker flag"+ fi+ if test -n "$admincmds"; then+ $ECHO " - have your system administrator run these commands:$admincmds"+ fi+ if test -f /etc/ld.so.conf; then+ echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"+ fi+ echo++ echo "See any operating system documentation about shared libraries for"+ case $host in+ solaris2.[6789]|solaris2.1[0-9])+ echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"+ echo "pages."+ ;;+ *)+ echo "more information, such as the ld(1) and ld.so(8) manual pages."+ ;;+ esac+ echo "----------------------------------------------------------------------"+ fi+ exit $EXIT_SUCCESS+}++test finish = "$opt_mode" && func_mode_finish ${1+"$@"}+++# func_mode_install arg...+func_mode_install ()+{+ $debug_cmd++ # There may be an optional sh(1) argument at the beginning of+ # install_prog (especially on Windows NT).+ if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||+ # Allow the use of GNU shtool's install command.+ case $nonopt in *shtool*) :;; *) false;; esac+ then+ # Aesthetically quote it.+ func_quote_arg pretty "$nonopt"+ install_prog="$func_quote_arg_result "+ arg=$1+ shift+ else+ install_prog=+ arg=$nonopt+ fi++ # The real first argument should be the name of the installation program.+ # Aesthetically quote it.+ func_quote_arg pretty "$arg"+ func_append install_prog "$func_quote_arg_result"+ install_shared_prog=$install_prog+ case " $install_prog " in+ *[\\\ /]cp\ *) install_cp=: ;;+ *) install_cp=false ;;+ esac++ # We need to accept at least all the BSD install flags.+ dest=+ files=+ opts=+ prev=+ install_type=+ isdir=false+ stripme=+ no_mode=:+ for arg+ do+ arg2=+ if test -n "$dest"; then+ func_append files " $dest"+ dest=$arg+ continue+ fi++ case $arg in+ -d) isdir=: ;;+ -f)+ if $install_cp; then :; else+ prev=$arg+ fi+ ;;+ -g | -m | -o)+ prev=$arg+ ;;+ -s)+ stripme=" -s"+ continue+ ;;+ -*)+ ;;+ *)+ # If the previous option needed an argument, then skip it.+ if test -n "$prev"; then+ if test X-m = "X$prev" && test -n "$install_override_mode"; then+ arg2=$install_override_mode+ no_mode=false+ fi+ prev=+ else+ dest=$arg+ continue+ fi+ ;;+ esac++ # Aesthetically quote the argument.+ func_quote_arg pretty "$arg"+ func_append install_prog " $func_quote_arg_result"+ if test -n "$arg2"; then+ func_quote_arg pretty "$arg2"+ fi+ func_append install_shared_prog " $func_quote_arg_result"+ done++ test -z "$install_prog" && \+ func_fatal_help "you must specify an install program"++ test -n "$prev" && \+ func_fatal_help "the '$prev' option requires an argument"++ if test -n "$install_override_mode" && $no_mode; then+ if $install_cp; then :; else+ func_quote_arg pretty "$install_override_mode"+ func_append install_shared_prog " -m $func_quote_arg_result"+ fi+ fi++ if test -z "$files"; then+ if test -z "$dest"; then+ func_fatal_help "no file or destination specified"+ else+ func_fatal_help "you must specify a destination"+ fi+ fi++ # Strip any trailing slash from the destination.+ func_stripname '' '/' "$dest"+ dest=$func_stripname_result++ # Check to see that the destination is a directory.+ test -d "$dest" && isdir=:+ if $isdir; then+ destdir=$dest+ destname=+ else+ func_dirname_and_basename "$dest" "" "."+ destdir=$func_dirname_result+ destname=$func_basename_result++ # Not a directory, so check to see that there is only one file specified.+ set dummy $files; shift+ test "$#" -gt 1 && \+ func_fatal_help "'$dest' is not a directory"+ fi+ case $destdir in+ [\\/]* | [A-Za-z]:[\\/]*) ;;+ *)+ for file in $files; do+ case $file in+ *.lo) ;;+ *)+ func_fatal_help "'$destdir' must be an absolute directory name"+ ;;+ esac+ done+ ;;+ esac++ # This variable tells wrapper scripts just to set variables rather+ # than running their programs.+ libtool_install_magic=$magic++ staticlibs=+ future_libdirs=+ current_libdirs=+ for file in $files; do++ # Do each installation.+ case $file in+ *.$libext)+ # Do the static libraries later.+ func_append staticlibs " $file"+ ;;++ *.la)+ func_resolve_sysroot "$file"+ file=$func_resolve_sysroot_result++ # Check to see that this really is a libtool archive.+ func_lalib_unsafe_p "$file" \+ || func_fatal_help "'$file' is not a valid libtool archive"++ library_names=+ old_library=+ relink_command=+ func_source "$file"++ # Add the libdir to current_libdirs if it is the destination.+ if test "X$destdir" = "X$libdir"; then+ case "$current_libdirs " in+ *" $libdir "*) ;;+ *) func_append current_libdirs " $libdir" ;;+ esac+ else+ # Note the libdir as a future libdir.+ case "$future_libdirs " in+ *" $libdir "*) ;;+ *) func_append future_libdirs " $libdir" ;;+ esac+ fi++ func_dirname "$file" "/" ""+ dir=$func_dirname_result+ func_append dir "$objdir"++ if test -n "$relink_command"; then+ # Determine the prefix the user has applied to our future dir.+ inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`++ # Don't allow the user to place us outside of our expected+ # location b/c this prevents finding dependent libraries that+ # are installed to the same prefix.+ # At present, this check doesn't affect windows .dll's that+ # are installed into $libdir/../bin (currently, that works fine)+ # but it's something to keep an eye on.+ test "$inst_prefix_dir" = "$destdir" && \+ func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"++ if test -n "$inst_prefix_dir"; then+ # Stick the inst_prefix_dir data into the link command.+ relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`+ else+ relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`+ fi++ func_warning "relinking '$file'"+ func_show_eval "$relink_command" \+ 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'+ fi++ # See the names of the shared library.+ set dummy $library_names; shift+ if test -n "$1"; then+ realname=$1+ shift++ srcname=$realname+ test -n "$relink_command" && srcname=${realname}T++ # Install the shared library and build the symlinks.+ func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \+ 'exit $?'+ tstripme=$stripme+ case $host_os in+ cygwin* | mingw* | pw32* | cegcc*)+ case $realname in+ *.dll.a)+ tstripme=+ ;;+ esac+ ;;+ os2*)+ case $realname in+ *_dll.a)+ tstripme=+ ;;+ esac+ ;;+ esac+ if test -n "$tstripme" && test -n "$striplib"; then+ func_show_eval "$striplib $destdir/$realname" 'exit $?'+ fi++ if test "$#" -gt 0; then+ # Delete the old symlinks, and create new ones.+ # Try 'ln -sf' first, because the 'ln' binary might depend on+ # the symlink we replace! Solaris /bin/ln does not understand -f,+ # so we also need to try rm && ln -s.+ for linkname+ do+ test "$linkname" != "$realname" \+ && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"+ done+ fi++ # Do each command in the postinstall commands.+ lib=$destdir/$realname+ func_execute_cmds "$postinstall_cmds" 'exit $?'+ fi++ # Install the pseudo-library for information purposes.+ func_basename "$file"+ name=$func_basename_result+ instname=$dir/${name}i+ func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'++ # Maybe install the static library, too.+ test -n "$old_library" && func_append staticlibs " $dir/$old_library"+ ;;++ *.lo)+ # Install (i.e. copy) a libtool object.++ # Figure out destination file name, if it wasn't already specified.+ if test -n "$destname"; then+ destfile=$destdir/$destname+ else+ func_basename "$file"+ destfile=$func_basename_result+ destfile=$destdir/$destfile+ fi++ # Deduce the name of the destination old-style object file.+ case $destfile in+ *.lo)+ func_lo2o "$destfile"+ staticdest=$func_lo2o_result+ ;;+ *.$objext)+ staticdest=$destfile+ destfile=+ ;;+ *)+ func_fatal_help "cannot copy a libtool object to '$destfile'"+ ;;+ esac++ # Install the libtool object if requested.+ test -n "$destfile" && \+ func_show_eval "$install_prog $file $destfile" 'exit $?'++ # Install the old object if enabled.+ if test yes = "$build_old_libs"; then+ # Deduce the name of the old-style object file.+ func_lo2o "$file"+ staticobj=$func_lo2o_result+ func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'+ fi+ exit $EXIT_SUCCESS+ ;;++ *)+ # Figure out destination file name, if it wasn't already specified.+ if test -n "$destname"; then+ destfile=$destdir/$destname+ else+ func_basename "$file"+ destfile=$func_basename_result+ destfile=$destdir/$destfile+ fi++ # If the file is missing, and there is a .exe on the end, strip it+ # because it is most likely a libtool script we actually want to+ # install+ stripped_ext=+ case $file in+ *.exe)+ if test ! -f "$file"; then+ func_stripname '' '.exe' "$file"+ file=$func_stripname_result+ stripped_ext=.exe+ fi+ ;;+ esac++ # Do a test to see if this is really a libtool program.+ case $host in+ *cygwin* | *mingw*)+ if func_ltwrapper_executable_p "$file"; then+ func_ltwrapper_scriptname "$file"+ wrapper=$func_ltwrapper_scriptname_result+ else+ func_stripname '' '.exe' "$file"+ wrapper=$func_stripname_result+ fi+ ;;+ *)+ wrapper=$file+ ;;+ esac+ if func_ltwrapper_script_p "$wrapper"; then+ notinst_deplibs=+ relink_command=++ func_source "$wrapper"++ # Check the variables that should have been set.+ test -z "$generated_by_libtool_version" && \+ func_fatal_error "invalid libtool wrapper script '$wrapper'"++ finalize=:+ for lib in $notinst_deplibs; do+ # Check to see that each library is installed.+ libdir=+ if test -f "$lib"; then+ func_source "$lib"+ fi+ libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`+ if test -n "$libdir" && test ! -f "$libfile"; then+ func_warning "'$lib' has not been installed in '$libdir'"+ finalize=false+ fi+ done++ relink_command=+ func_source "$wrapper"++ outputname=+ if test no = "$fast_install" && test -n "$relink_command"; then+ $opt_dry_run || {+ if $finalize; then+ tmpdir=`func_mktempdir`+ func_basename "$file$stripped_ext"+ file=$func_basename_result+ outputname=$tmpdir/$file+ # Replace the output file specification.+ relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`++ $opt_quiet || {+ func_quote_arg expand,pretty "$relink_command"+ eval "func_echo $func_quote_arg_result"+ }+ if eval "$relink_command"; then :+ else+ func_error "error: relink '$file' with the above command before installing it"+ $opt_dry_run || ${RM}r "$tmpdir"+ continue+ fi+ file=$outputname+ else+ func_warning "cannot relink '$file'"+ fi+ }+ else+ # Install the binary that we compiled earlier.+ file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`+ fi+ fi++ # remove .exe since cygwin /usr/bin/install will append another+ # one anyway+ case $install_prog,$host in+ */usr/bin/install*,*cygwin*)+ case $file:$destfile in+ *.exe:*.exe)+ # this is ok+ ;;+ *.exe:*)+ destfile=$destfile.exe+ ;;+ *:*.exe)+ func_stripname '' '.exe' "$destfile"+ destfile=$func_stripname_result+ ;;+ esac+ ;;+ esac+ func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'+ $opt_dry_run || if test -n "$outputname"; then+ ${RM}r "$tmpdir"+ fi+ ;;+ esac+ done++ for file in $staticlibs; do+ func_basename "$file"+ name=$func_basename_result++ # Set up the ranlib parameters.+ oldlib=$destdir/$name+ func_to_tool_file "$oldlib" func_convert_file_msys_to_w32+ tool_oldlib=$func_to_tool_file_result++ func_show_eval "$install_prog \$file \$oldlib" 'exit $?'++ if test -n "$stripme" && test -n "$old_striplib"; then+ func_show_eval "$old_striplib $tool_oldlib" 'exit $?'+ fi++ # Do each command in the postinstall commands.+ func_execute_cmds "$old_postinstall_cmds" 'exit $?'+ done++ test -n "$future_libdirs" && \+ func_warning "remember to run '$progname --finish$future_libdirs'"++ if test -n "$current_libdirs"; then+ # Maybe just do a dry run.+ $opt_dry_run && current_libdirs=" -n$current_libdirs"+ exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'+ else+ exit $EXIT_SUCCESS+ fi+}++test install = "$opt_mode" && func_mode_install ${1+"$@"}+++# func_generate_dlsyms outputname originator pic_p+# Extract symbols from dlprefiles and create ${outputname}S.o with+# a dlpreopen symbol table.+func_generate_dlsyms ()+{+ $debug_cmd++ my_outputname=$1+ my_originator=$2+ my_pic_p=${3-false}+ my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`+ my_dlsyms=++ if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then+ if test -n "$NM" && test -n "$global_symbol_pipe"; then+ my_dlsyms=${my_outputname}S.c+ else+ func_error "not configured to extract global symbols from dlpreopened files"+ fi+ fi++ if test -n "$my_dlsyms"; then+ case $my_dlsyms in+ "") ;;+ *.c)+ # Discover the nlist of each of the dlfiles.+ nlist=$output_objdir/$my_outputname.nm++ func_show_eval "$RM $nlist ${nlist}S ${nlist}T"++ # Parse the name list into a source file.+ func_verbose "creating $output_objdir/$my_dlsyms"++ $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\+/* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */+/* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */++#ifdef __cplusplus+extern \"C\" {+#endif++#if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))+#pragma GCC diagnostic ignored \"-Wstrict-prototypes\"+#endif++/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE+/* DATA imports from DLLs on WIN32 can't be const, because runtime+ relocations are performed -- see ld's documentation on pseudo-relocs. */+# define LT_DLSYM_CONST+#elif defined __osf__+/* This system does not cope well with relocations in const data. */+# define LT_DLSYM_CONST+#else+# define LT_DLSYM_CONST const+#endif++#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)++/* External symbol declarations for the compiler. */\+"++ if test yes = "$dlself"; then+ func_verbose "generating symbol list for '$output'"++ $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"++ # Add our own program objects to the symbol list.+ progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`+ for progfile in $progfiles; do+ func_to_tool_file "$progfile" func_convert_file_msys_to_w32+ func_verbose "extracting global C symbols from '$func_to_tool_file_result'"+ $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"+ done++ if test -n "$exclude_expsyms"; then+ $opt_dry_run || {+ eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'+ eval '$MV "$nlist"T "$nlist"'+ }+ fi++ if test -n "$export_symbols_regex"; then+ $opt_dry_run || {+ eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'+ eval '$MV "$nlist"T "$nlist"'+ }+ fi++ # Prepare the list of exported symbols+ if test -z "$export_symbols"; then+ export_symbols=$output_objdir/$outputname.exp+ $opt_dry_run || {+ $RM $export_symbols+ eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'+ case $host in+ *cygwin* | *mingw* | *cegcc* )+ eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'+ eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'+ ;;+ esac+ }+ else+ $opt_dry_run || {+ eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'+ eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'+ eval '$MV "$nlist"T "$nlist"'+ case $host in+ *cygwin* | *mingw* | *cegcc* )+ eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'+ eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'+ ;;+ esac+ }+ fi+ fi++ for dlprefile in $dlprefiles; do+ func_verbose "extracting global C symbols from '$dlprefile'"+ func_basename "$dlprefile"+ name=$func_basename_result+ case $host in+ *cygwin* | *mingw* | *cegcc* )+ # if an import library, we need to obtain dlname+ if func_win32_import_lib_p "$dlprefile"; then+ func_tr_sh "$dlprefile"+ eval "curr_lafile=\$libfile_$func_tr_sh_result"+ dlprefile_dlbasename=+ if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then+ # Use subshell, to avoid clobbering current variable values+ dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`+ if test -n "$dlprefile_dlname"; then+ func_basename "$dlprefile_dlname"+ dlprefile_dlbasename=$func_basename_result+ else+ # no lafile. user explicitly requested -dlpreopen <import library>.+ $sharedlib_from_linklib_cmd "$dlprefile"+ dlprefile_dlbasename=$sharedlib_from_linklib_result+ fi+ fi+ $opt_dry_run || {+ if test -n "$dlprefile_dlbasename"; then+ eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'+ else+ func_warning "Could not compute DLL name from $name"+ eval '$ECHO ": $name " >> "$nlist"'+ fi+ func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32+ eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |+ $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"+ }+ else # not an import lib+ $opt_dry_run || {+ eval '$ECHO ": $name " >> "$nlist"'+ func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32+ eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"+ }+ fi+ ;;+ *)+ $opt_dry_run || {+ eval '$ECHO ": $name " >> "$nlist"'+ func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32+ eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"+ }+ ;;+ esac+ done++ $opt_dry_run || {+ # Make sure we have at least an empty file.+ test -f "$nlist" || : > "$nlist"++ if test -n "$exclude_expsyms"; then+ $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T+ $MV "$nlist"T "$nlist"+ fi++ # Try sorting and uniquifying the output.+ if $GREP -v "^: " < "$nlist" |+ if sort -k 3 </dev/null >/dev/null 2>&1; then+ sort -k 3+ else+ sort +2+ fi |+ uniq > "$nlist"S; then+ :+ else+ $GREP -v "^: " < "$nlist" > "$nlist"S+ fi++ if test -f "$nlist"S; then+ eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'+ else+ echo '/* NONE */' >> "$output_objdir/$my_dlsyms"+ fi++ func_show_eval '$RM "${nlist}I"'+ if test -n "$global_symbol_to_import"; then+ eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'+ fi++ echo >> "$output_objdir/$my_dlsyms" "\++/* The mapping between symbol names and symbols. */+typedef struct {+ const char *name;+ void *address;+} lt_dlsymlist;+extern LT_DLSYM_CONST lt_dlsymlist+lt_${my_prefix}_LTX_preloaded_symbols[];\+"++ if test -s "$nlist"I; then+ echo >> "$output_objdir/$my_dlsyms" "\+static void lt_syminit(void)+{+ LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;+ for (; symbol->name; ++symbol)+ {"+ $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"+ echo >> "$output_objdir/$my_dlsyms" "\+ }+}"+ fi+ echo >> "$output_objdir/$my_dlsyms" "\+LT_DLSYM_CONST lt_dlsymlist+lt_${my_prefix}_LTX_preloaded_symbols[] =+{ {\"$my_originator\", (void *) 0},"++ if test -s "$nlist"I; then+ echo >> "$output_objdir/$my_dlsyms" "\+ {\"@INIT@\", (void *) <_syminit},"+ fi++ case $need_lib_prefix in+ no)+ eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"+ ;;+ *)+ eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"+ ;;+ esac+ echo >> "$output_objdir/$my_dlsyms" "\+ {0, (void *) 0}+};++/* This works around a problem in FreeBSD linker */+#ifdef FREEBSD_WORKAROUND+static const void *lt_preloaded_setup() {+ return lt_${my_prefix}_LTX_preloaded_symbols;+}+#endif++#ifdef __cplusplus+}+#endif\+"+ } # !$opt_dry_run++ pic_flag_for_symtable=+ case "$compile_command " in+ *" -static "*) ;;+ *)+ case $host in+ # compiling the symbol table file with pic_flag works around+ # a FreeBSD bug that causes programs to crash when -lm is+ # linked before any other PIC object. But we must not use+ # pic_flag when linking with -static. The problem exists in+ # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.+ *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)+ pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;+ *-*-hpux*)+ pic_flag_for_symtable=" $pic_flag" ;;+ *)+ $my_pic_p && pic_flag_for_symtable=" $pic_flag"+ ;;+ esac+ ;;+ esac+ symtab_cflags=+ for arg in $LTCFLAGS; do+ case $arg in+ -pie | -fpie | -fPIE) ;;+ *) func_append symtab_cflags " $arg" ;;+ esac+ done++ # Now compile the dynamic symbol file.+ func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'++ # Clean up the generated files.+ func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'++ # Transform the symbol file into the correct name.+ symfileobj=$output_objdir/${my_outputname}S.$objext+ case $host in+ *cygwin* | *mingw* | *cegcc* )+ if test -f "$output_objdir/$my_outputname.def"; then+ compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`+ finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`+ else+ compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`+ finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`+ fi+ ;;+ *)+ compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`+ finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`+ ;;+ esac+ ;;+ *)+ func_fatal_error "unknown suffix for '$my_dlsyms'"+ ;;+ esac+ else+ # We keep going just in case the user didn't refer to+ # lt_preloaded_symbols. The linker will fail if global_symbol_pipe+ # really was required.++ # Nullify the symbol file.+ compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`+ finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`+ fi+}++# func_cygming_gnu_implib_p ARG+# This predicate returns with zero status (TRUE) if+# ARG is a GNU/binutils-style import library. Returns+# with nonzero status (FALSE) otherwise.+func_cygming_gnu_implib_p ()+{+ $debug_cmd++ func_to_tool_file "$1" func_convert_file_msys_to_w32+ func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`+ test -n "$func_cygming_gnu_implib_tmp"+}++# func_cygming_ms_implib_p ARG+# This predicate returns with zero status (TRUE) if+# ARG is an MS-style import library. Returns+# with nonzero status (FALSE) otherwise.+func_cygming_ms_implib_p ()+{+ $debug_cmd++ func_to_tool_file "$1" func_convert_file_msys_to_w32+ func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`+ test -n "$func_cygming_ms_implib_tmp"+}++# func_win32_libid arg+# return the library type of file 'arg'+#+# Need a lot of goo to handle *both* DLLs and import libs+# Has to be a shell function in order to 'eat' the argument+# that is supplied when $file_magic_command is called.+# Despite the name, also deal with 64 bit binaries.+func_win32_libid ()+{+ $debug_cmd++ win32_libid_type=unknown+ win32_fileres=`file -L $1 2>/dev/null`+ case $win32_fileres in+ *ar\ archive\ import\ library*) # definitely import+ win32_libid_type="x86 archive import"+ ;;+ *ar\ archive*) # could be an import, or static+ # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.+ if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |+ $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then+ case $nm_interface in+ "MS dumpbin")+ if func_cygming_ms_implib_p "$1" ||+ func_cygming_gnu_implib_p "$1"+ then+ win32_nmres=import+ else+ win32_nmres=+ fi+ ;;+ *)+ func_to_tool_file "$1" func_convert_file_msys_to_w32+ win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |+ $SED -n -e '+ 1,100{+ / I /{+ s|.*|import|+ p+ q+ }+ }'`+ ;;+ esac+ case $win32_nmres in+ import*) win32_libid_type="x86 archive import";;+ *) win32_libid_type="x86 archive static";;+ esac+ fi+ ;;+ *DLL*)+ win32_libid_type="x86 DLL"+ ;;+ *executable*) # but shell scripts are "executable" too...+ case $win32_fileres in+ *MS\ Windows\ PE\ Intel*)+ win32_libid_type="x86 DLL"+ ;;+ esac+ ;;+ esac+ $ECHO "$win32_libid_type"+}++# func_cygming_dll_for_implib ARG+#+# Platform-specific function to extract the+# name of the DLL associated with the specified+# import library ARG.+# Invoked by eval'ing the libtool variable+# $sharedlib_from_linklib_cmd+# Result is available in the variable+# $sharedlib_from_linklib_result+func_cygming_dll_for_implib ()+{+ $debug_cmd++ sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`+}++# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs+#+# The is the core of a fallback implementation of a+# platform-specific function to extract the name of the+# DLL associated with the specified import library LIBNAME.+#+# SECTION_NAME is either .idata$6 or .idata$7, depending+# on the platform and compiler that created the implib.+#+# Echos the name of the DLL associated with the+# specified import library.+func_cygming_dll_for_implib_fallback_core ()+{+ $debug_cmd++ match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`+ $OBJDUMP -s --section "$1" "$2" 2>/dev/null |+ $SED '/^Contents of section '"$match_literal"':/{+ # Place marker at beginning of archive member dllname section+ s/.*/====MARK====/+ p+ d+ }+ # These lines can sometimes be longer than 43 characters, but+ # are always uninteresting+ /:[ ]*file format pe[i]\{,1\}-/d+ /^In archive [^:]*:/d+ # Ensure marker is printed+ /^====MARK====/p+ # Remove all lines with less than 43 characters+ /^.\{43\}/!d+ # From remaining lines, remove first 43 characters+ s/^.\{43\}//' |+ $SED -n '+ # Join marker and all lines until next marker into a single line+ /^====MARK====/ b para+ H+ $ b para+ b+ :para+ x+ s/\n//g+ # Remove the marker+ s/^====MARK====//+ # Remove trailing dots and whitespace+ s/[\. \t]*$//+ # Print+ /./p' |+ # we now have a list, one entry per line, of the stringified+ # contents of the appropriate section of all members of the+ # archive that possess that section. Heuristic: eliminate+ # all those that have a first or second character that is+ # a '.' (that is, objdump's representation of an unprintable+ # character.) This should work for all archives with less than+ # 0x302f exports -- but will fail for DLLs whose name actually+ # begins with a literal '.' or a single character followed by+ # a '.'.+ #+ # Of those that remain, print the first one.+ $SED -e '/^\./d;/^.\./d;q'+}++# func_cygming_dll_for_implib_fallback ARG+# Platform-specific function to extract the+# name of the DLL associated with the specified+# import library ARG.+#+# This fallback implementation is for use when $DLLTOOL+# does not support the --identify-strict option.+# Invoked by eval'ing the libtool variable+# $sharedlib_from_linklib_cmd+# Result is available in the variable+# $sharedlib_from_linklib_result+func_cygming_dll_for_implib_fallback ()+{+ $debug_cmd++ if func_cygming_gnu_implib_p "$1"; then+ # binutils import library+ sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`+ elif func_cygming_ms_implib_p "$1"; then+ # ms-generated import library+ sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`+ else+ # unknown+ sharedlib_from_linklib_result=+ fi+}+++# func_extract_an_archive dir oldlib+func_extract_an_archive ()+{+ $debug_cmd++ f_ex_an_ar_dir=$1; shift+ f_ex_an_ar_oldlib=$1+ if test yes = "$lock_old_archive_extraction"; then+ lockfile=$f_ex_an_ar_oldlib.lock+ until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do+ func_echo "Waiting for $lockfile to be removed"+ sleep 2+ done+ fi+ func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \+ 'stat=$?; rm -f "$lockfile"; exit $stat'+ if test yes = "$lock_old_archive_extraction"; then+ $opt_dry_run || rm -f "$lockfile"+ fi+ if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then+ :+ else+ func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"+ fi+}+++# func_extract_archives gentop oldlib ...+func_extract_archives ()+{+ $debug_cmd++ my_gentop=$1; shift+ my_oldlibs=${1+"$@"}+ my_oldobjs=+ my_xlib=+ my_xabs=+ my_xdir=++ for my_xlib in $my_oldlibs; do+ # Extract the objects.+ case $my_xlib in+ [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;+ *) my_xabs=`pwd`"/$my_xlib" ;;+ esac+ func_basename "$my_xlib"+ my_xlib=$func_basename_result+ my_xlib_u=$my_xlib+ while :; do+ case " $extracted_archives " in+ *" $my_xlib_u "*)+ func_arith $extracted_serial + 1+ extracted_serial=$func_arith_result+ my_xlib_u=lt$extracted_serial-$my_xlib ;;+ *) break ;;+ esac+ done+ extracted_archives="$extracted_archives $my_xlib_u"+ my_xdir=$my_gentop/$my_xlib_u++ func_mkdir_p "$my_xdir"++ case $host in+ *-darwin*)+ func_verbose "Extracting $my_xabs"+ # Do not bother doing anything if just a dry run+ $opt_dry_run || {+ darwin_orig_dir=`pwd`+ cd $my_xdir || exit $?+ darwin_archive=$my_xabs+ darwin_curdir=`pwd`+ func_basename "$darwin_archive"+ darwin_base_archive=$func_basename_result+ darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`+ if test -n "$darwin_arches"; then+ darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`+ darwin_arch=+ func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"+ for darwin_arch in $darwin_arches; do+ func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"+ $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"+ cd "unfat-$$/$darwin_base_archive-$darwin_arch"+ func_extract_an_archive "`pwd`" "$darwin_base_archive"+ cd "$darwin_curdir"+ $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"+ done # $darwin_arches+ ## Okay now we've a bunch of thin objects, gotta fatten them up :)+ darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`+ darwin_file=+ darwin_files=+ for darwin_file in $darwin_filelist; do+ darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`+ $LIPO -create -output "$darwin_file" $darwin_files+ done # $darwin_filelist+ $RM -rf unfat-$$+ cd "$darwin_orig_dir"+ else+ cd $darwin_orig_dir+ func_extract_an_archive "$my_xdir" "$my_xabs"+ fi # $darwin_arches+ } # !$opt_dry_run+ ;;+ *)+ func_extract_an_archive "$my_xdir" "$my_xabs"+ ;;+ esac+ my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`+ done++ func_extract_archives_result=$my_oldobjs+}+++# func_emit_wrapper [arg=no]+#+# Emit a libtool wrapper script on stdout.+# Don't directly open a file because we may want to+# incorporate the script contents within a cygwin/mingw+# wrapper executable. Must ONLY be called from within+# func_mode_link because it depends on a number of variables+# set therein.+#+# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR+# variable will take. If 'yes', then the emitted script+# will assume that the directory where it is stored is+# the $objdir directory. This is a cygwin/mingw-specific+# behavior.+func_emit_wrapper ()+{+ func_emit_wrapper_arg1=${1-no}++ $ECHO "\+#! $SHELL++# $output - temporary wrapper script for $objdir/$outputname+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION+#+# The $output program cannot be directly executed until all the libtool+# libraries that it depends on are installed.+#+# This wrapper script should never be moved out of the build directory.+# If it is, it will not operate correctly.++# Sed substitution that helps us do robust quoting. It backslashifies+# metacharacters that are still active within double-quoted strings.+sed_quote_subst='$sed_quote_subst'++# Be Bourne compatible+if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then+ emulate sh+ NULLCMD=:+ # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which+ # is contrary to our usage. Disable this feature.+ alias -g '\${1+\"\$@\"}'='\"\$@\"'+ setopt NO_GLOB_SUBST+else+ case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac+fi+BIN_SH=xpg4; export BIN_SH # for Tru64+DUALCASE=1; export DUALCASE # for MKS sh++# The HP-UX ksh and POSIX shell print the target directory to stdout+# if CDPATH is set.+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH++relink_command=\"$relink_command\"++# This environment variable determines our operation mode.+if test \"\$libtool_install_magic\" = \"$magic\"; then+ # install mode needs the following variables:+ generated_by_libtool_version='$macro_version'+ notinst_deplibs='$notinst_deplibs'+else+ # When we are sourced in execute mode, \$file and \$ECHO are already set.+ if test \"\$libtool_execute_magic\" != \"$magic\"; then+ file=\"\$0\""++ func_quote_arg pretty "$ECHO"+ qECHO=$func_quote_arg_result+ $ECHO "\++# A function that is used when there is no print builtin or printf.+func_fallback_echo ()+{+ eval 'cat <<_LTECHO_EOF+\$1+_LTECHO_EOF'+}+ ECHO=$qECHO+ fi++# Very basic option parsing. These options are (a) specific to+# the libtool wrapper, (b) are identical between the wrapper+# /script/ and the wrapper /executable/ that is used only on+# windows platforms, and (c) all begin with the string "--lt-"+# (application programs are unlikely to have options that match+# this pattern).+#+# There are only two supported options: --lt-debug and+# --lt-dump-script. There is, deliberately, no --lt-help.+#+# The first argument to this parsing function should be the+# script's $0 value, followed by "$@".+lt_option_debug=+func_parse_lt_options ()+{+ lt_script_arg0=\$0+ shift+ for lt_opt+ do+ case \"\$lt_opt\" in+ --lt-debug) lt_option_debug=1 ;;+ --lt-dump-script)+ lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`+ test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.+ lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`+ cat \"\$lt_dump_D/\$lt_dump_F\"+ exit 0+ ;;+ --lt-*)+ \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2+ exit 1+ ;;+ esac+ done++ # Print the debug banner immediately:+ if test -n \"\$lt_option_debug\"; then+ echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2+ fi+}++# Used when --lt-debug. Prints its arguments to stdout+# (redirection is the responsibility of the caller)+func_lt_dump_args ()+{+ lt_dump_args_N=1;+ for lt_arg+ do+ \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"+ lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`+ done+}++# Core function for launching the target application+func_exec_program_core ()+{+"+ case $host in+ # Backslashes separate directories on plain windows+ *-*-mingw | *-*-os2* | *-cegcc*)+ $ECHO "\+ if test -n \"\$lt_option_debug\"; then+ \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2+ func_lt_dump_args \${1+\"\$@\"} 1>&2+ fi+ exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}+"+ ;;++ *)+ $ECHO "\+ if test -n \"\$lt_option_debug\"; then+ \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2+ func_lt_dump_args \${1+\"\$@\"} 1>&2+ fi+ exec \"\$progdir/\$program\" \${1+\"\$@\"}+"+ ;;+ esac+ $ECHO "\+ \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2+ exit 1+}++# A function to encapsulate launching the target application+# Strips options in the --lt-* namespace from \$@ and+# launches target application with the remaining arguments.+func_exec_program ()+{+ case \" \$* \" in+ *\\ --lt-*)+ for lt_wr_arg+ do+ case \$lt_wr_arg in+ --lt-*) ;;+ *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;+ esac+ shift+ done ;;+ esac+ func_exec_program_core \${1+\"\$@\"}+}++ # Parse options+ func_parse_lt_options \"\$0\" \${1+\"\$@\"}++ # Find the directory that this script lives in.+ thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`+ test \"x\$thisdir\" = \"x\$file\" && thisdir=.++ # Follow symbolic links until we get to the real thisdir.+ file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`+ while test -n \"\$file\"; do+ destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`++ # If there was a directory component, then change thisdir.+ if test \"x\$destdir\" != \"x\$file\"; then+ case \"\$destdir\" in+ [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;+ *) thisdir=\"\$thisdir/\$destdir\" ;;+ esac+ fi++ file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`+ file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`+ done++ # Usually 'no', except on cygwin/mingw when embedded into+ # the cwrapper.+ WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1+ if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then+ # special case for '.'+ if test \"\$thisdir\" = \".\"; then+ thisdir=\`pwd\`+ fi+ # remove .libs from thisdir+ case \"\$thisdir\" in+ *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;+ $objdir ) thisdir=. ;;+ esac+ fi++ # Try to get the absolute directory name.+ absdir=\`cd \"\$thisdir\" && pwd\`+ test -n \"\$absdir\" && thisdir=\"\$absdir\"+"++ if test yes = "$fast_install"; then+ $ECHO "\+ program=lt-'$outputname'$exeext+ progdir=\"\$thisdir/$objdir\"++ if test ! -f \"\$progdir/\$program\" ||+ { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\+ test \"X\$file\" != \"X\$progdir/\$program\"; }; then++ file=\"\$\$-\$program\"++ if test ! -d \"\$progdir\"; then+ $MKDIR \"\$progdir\"+ else+ $RM \"\$progdir/\$file\"+ fi"++ $ECHO "\++ # relink executable if necessary+ if test -n \"\$relink_command\"; then+ if relink_command_output=\`eval \$relink_command 2>&1\`; then :+ else+ \$ECHO \"\$relink_command_output\" >&2+ $RM \"\$progdir/\$file\"+ exit 1+ fi+ fi++ $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||+ { $RM \"\$progdir/\$program\";+ $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }+ $RM \"\$progdir/\$file\"+ fi"+ else+ $ECHO "\+ program='$outputname'+ progdir=\"\$thisdir/$objdir\"+"+ fi++ $ECHO "\++ if test -f \"\$progdir/\$program\"; then"++ # fixup the dll searchpath if we need to.+ #+ # Fix the DLL searchpath if we need to. Do this before prepending+ # to shlibpath, because on Windows, both are PATH and uninstalled+ # libraries must come first.+ if test -n "$dllsearchpath"; then+ $ECHO "\+ # Add the dll search path components to the executable PATH+ PATH=$dllsearchpath:\$PATH+"+ fi++ # Export our shlibpath_var if we have one.+ if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then+ $ECHO "\+ # Add our own library path to $shlibpath_var+ $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"++ # Some systems cannot cope with colon-terminated $shlibpath_var+ # The second colon is a workaround for a bug in BeOS R4 sed+ $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`++ export $shlibpath_var+"+ fi++ $ECHO "\+ if test \"\$libtool_execute_magic\" != \"$magic\"; then+ # Run the actual program with our arguments.+ func_exec_program \${1+\"\$@\"}+ fi+ else+ # The program doesn't exist.+ \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2+ \$ECHO \"This script is just a wrapper for \$program.\" 1>&2+ \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2+ exit 1+ fi+fi\+"+}+++# func_emit_cwrapperexe_src+# emit the source code for a wrapper executable on stdout+# Must ONLY be called from within func_mode_link because+# it depends on a number of variable set therein.+func_emit_cwrapperexe_src ()+{+ cat <<EOF++/* $cwrappersource - temporary wrapper executable for $objdir/$outputname+ Generated by $PROGRAM (GNU $PACKAGE) $VERSION++ The $output program cannot be directly executed until all the libtool+ libraries that it depends on are installed.++ This wrapper executable should never be moved out of the build directory.+ If it is, it will not operate correctly.+*/+EOF+ cat <<"EOF"+#ifdef _MSC_VER+# define _CRT_SECURE_NO_DEPRECATE 1+#endif+#include <stdio.h>+#include <stdlib.h>+#ifdef _MSC_VER+# include <direct.h>+# include <process.h>+# include <io.h>+#else+# include <unistd.h>+# include <stdint.h>+# ifdef __CYGWIN__+# include <io.h>+# endif+#endif+#include <malloc.h>+#include <stdarg.h>+#include <assert.h>+#include <string.h>+#include <ctype.h>+#include <errno.h>+#include <fcntl.h>+#include <sys/stat.h>++#define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)++/* declarations of non-ANSI functions */+#if defined __MINGW32__+# ifdef __STRICT_ANSI__+int _putenv (const char *);+# endif+#elif defined __CYGWIN__+# ifdef __STRICT_ANSI__+char *realpath (const char *, char *);+int putenv (char *);+int setenv (const char *, const char *, int);+# endif+/* #elif defined other_platform || defined ... */+#endif++/* portability defines, excluding path handling macros */+#if defined _MSC_VER+# define setmode _setmode+# define stat _stat+# define chmod _chmod+# define getcwd _getcwd+# define putenv _putenv+# define S_IXUSR _S_IEXEC+#elif defined __MINGW32__+# define setmode _setmode+# define stat _stat+# define chmod _chmod+# define getcwd _getcwd+# define putenv _putenv+#elif defined __CYGWIN__+# define HAVE_SETENV+# define FOPEN_WB "wb"+/* #elif defined other platforms ... */+#endif++#if defined PATH_MAX+# define LT_PATHMAX PATH_MAX+#elif defined MAXPATHLEN+# define LT_PATHMAX MAXPATHLEN+#else+# define LT_PATHMAX 1024+#endif++#ifndef S_IXOTH+# define S_IXOTH 0+#endif+#ifndef S_IXGRP+# define S_IXGRP 0+#endif++/* path handling portability macros */+#ifndef DIR_SEPARATOR+# define DIR_SEPARATOR '/'+# define PATH_SEPARATOR ':'+#endif++#if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \+ defined __OS2__+# define HAVE_DOS_BASED_FILE_SYSTEM+# define FOPEN_WB "wb"+# ifndef DIR_SEPARATOR_2+# define DIR_SEPARATOR_2 '\\'+# endif+# ifndef PATH_SEPARATOR_2+# define PATH_SEPARATOR_2 ';'+# endif+#endif++#ifndef DIR_SEPARATOR_2+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)+#else /* DIR_SEPARATOR_2 */+# define IS_DIR_SEPARATOR(ch) \+ (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))+#endif /* DIR_SEPARATOR_2 */++#ifndef PATH_SEPARATOR_2+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)+#else /* PATH_SEPARATOR_2 */+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)+#endif /* PATH_SEPARATOR_2 */++#ifndef FOPEN_WB+# define FOPEN_WB "w"+#endif+#ifndef _O_BINARY+# define _O_BINARY 0+#endif++#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))+#define XFREE(stale) do { \+ if (stale) { free (stale); stale = 0; } \+} while (0)++#if defined LT_DEBUGWRAPPER+static int lt_debug = 1;+#else+static int lt_debug = 0;+#endif++const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */++void *xmalloc (size_t num);+char *xstrdup (const char *string);+const char *base_name (const char *name);+char *find_executable (const char *wrapper);+char *chase_symlinks (const char *pathspec);+int make_executable (const char *path);+int check_executable (const char *path);+char *strendzap (char *str, const char *pat);+void lt_debugprintf (const char *file, int line, const char *fmt, ...);+void lt_fatal (const char *file, int line, const char *message, ...);+static const char *nonnull (const char *s);+static const char *nonempty (const char *s);+void lt_setenv (const char *name, const char *value);+char *lt_extend_str (const char *orig_value, const char *add, int to_end);+void lt_update_exe_path (const char *name, const char *value);+void lt_update_lib_path (const char *name, const char *value);+char **prepare_spawn (char **argv);+void lt_dump_script (FILE *f);+EOF++ cat <<EOF+#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)+# define externally_visible volatile+#else+# define externally_visible __attribute__((externally_visible)) volatile+#endif+externally_visible const char * MAGIC_EXE = "$magic_exe";+const char * LIB_PATH_VARNAME = "$shlibpath_var";+EOF++ if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then+ func_to_host_path "$temp_rpath"+ cat <<EOF+const char * LIB_PATH_VALUE = "$func_to_host_path_result";+EOF+ else+ cat <<"EOF"+const char * LIB_PATH_VALUE = "";+EOF+ fi++ if test -n "$dllsearchpath"; then+ func_to_host_path "$dllsearchpath:"+ cat <<EOF+const char * EXE_PATH_VARNAME = "PATH";+const char * EXE_PATH_VALUE = "$func_to_host_path_result";+EOF+ else+ cat <<"EOF"+const char * EXE_PATH_VARNAME = "";+const char * EXE_PATH_VALUE = "";+EOF+ fi++ if test yes = "$fast_install"; then+ cat <<EOF+const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */+EOF+ else+ cat <<EOF+const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */+EOF+ fi+++ cat <<"EOF"++#define LTWRAPPER_OPTION_PREFIX "--lt-"++static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;+static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";+static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";++int+main (int argc, char *argv[])+{+ char **newargz;+ int newargc;+ char *tmp_pathspec;+ char *actual_cwrapper_path;+ char *actual_cwrapper_name;+ char *target_name;+ char *lt_argv_zero;+ int rval = 127;++ int i;++ program_name = (char *) xstrdup (base_name (argv[0]));+ newargz = XMALLOC (char *, (size_t) argc + 1);++ /* very simple arg parsing; don't want to rely on getopt+ * also, copy all non cwrapper options to newargz, except+ * argz[0], which is handled differently+ */+ newargc=0;+ for (i = 1; i < argc; i++)+ {+ if (STREQ (argv[i], dumpscript_opt))+ {+EOF+ case $host in+ *mingw* | *cygwin* )+ # make stdout use "unix" line endings+ echo " setmode(1,_O_BINARY);"+ ;;+ esac++ cat <<"EOF"+ lt_dump_script (stdout);+ return 0;+ }+ if (STREQ (argv[i], debug_opt))+ {+ lt_debug = 1;+ continue;+ }+ if (STREQ (argv[i], ltwrapper_option_prefix))+ {+ /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX+ namespace, but it is not one of the ones we know about and+ have already dealt with, above (inluding dump-script), then+ report an error. Otherwise, targets might begin to believe+ they are allowed to use options in the LTWRAPPER_OPTION_PREFIX+ namespace. The first time any user complains about this, we'll+ need to make LTWRAPPER_OPTION_PREFIX a configure-time option+ or a configure.ac-settable value.+ */+ lt_fatal (__FILE__, __LINE__,+ "unrecognized %s option: '%s'",+ ltwrapper_option_prefix, argv[i]);+ }+ /* otherwise ... */+ newargz[++newargc] = xstrdup (argv[i]);+ }+ newargz[++newargc] = NULL;++EOF+ cat <<EOF+ /* The GNU banner must be the first non-error debug message */+ lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");+EOF+ cat <<"EOF"+ lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);+ lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);++ tmp_pathspec = find_executable (argv[0]);+ if (tmp_pathspec == NULL)+ lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);+ lt_debugprintf (__FILE__, __LINE__,+ "(main) found exe (before symlink chase) at: %s\n",+ tmp_pathspec);++ actual_cwrapper_path = chase_symlinks (tmp_pathspec);+ lt_debugprintf (__FILE__, __LINE__,+ "(main) found exe (after symlink chase) at: %s\n",+ actual_cwrapper_path);+ XFREE (tmp_pathspec);++ actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));+ strendzap (actual_cwrapper_path, actual_cwrapper_name);++ /* wrapper name transforms */+ strendzap (actual_cwrapper_name, ".exe");+ tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);+ XFREE (actual_cwrapper_name);+ actual_cwrapper_name = tmp_pathspec;+ tmp_pathspec = 0;++ /* target_name transforms -- use actual target program name; might have lt- prefix */+ target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));+ strendzap (target_name, ".exe");+ tmp_pathspec = lt_extend_str (target_name, ".exe", 1);+ XFREE (target_name);+ target_name = tmp_pathspec;+ tmp_pathspec = 0;++ lt_debugprintf (__FILE__, __LINE__,+ "(main) libtool target name: %s\n",+ target_name);+EOF++ cat <<EOF+ newargz[0] =+ XMALLOC (char, (strlen (actual_cwrapper_path) ++ strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));+ strcpy (newargz[0], actual_cwrapper_path);+ strcat (newargz[0], "$objdir");+ strcat (newargz[0], "/");+EOF++ cat <<"EOF"+ /* stop here, and copy so we don't have to do this twice */+ tmp_pathspec = xstrdup (newargz[0]);++ /* do NOT want the lt- prefix here, so use actual_cwrapper_name */+ strcat (newargz[0], actual_cwrapper_name);++ /* DO want the lt- prefix here if it exists, so use target_name */+ lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);+ XFREE (tmp_pathspec);+ tmp_pathspec = NULL;+EOF++ case $host_os in+ mingw*)+ cat <<"EOF"+ {+ char* p;+ while ((p = strchr (newargz[0], '\\')) != NULL)+ {+ *p = '/';+ }+ while ((p = strchr (lt_argv_zero, '\\')) != NULL)+ {+ *p = '/';+ }+ }+EOF+ ;;+ esac++ cat <<"EOF"+ XFREE (target_name);+ XFREE (actual_cwrapper_path);+ XFREE (actual_cwrapper_name);++ lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */+ lt_setenv ("DUALCASE", "1"); /* for MSK sh */+ /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must+ be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)+ because on Windows, both *_VARNAMEs are PATH but uninstalled+ libraries must come first. */+ lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);+ lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);++ lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",+ nonnull (lt_argv_zero));+ for (i = 0; i < newargc; i++)+ {+ lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",+ i, nonnull (newargz[i]));+ }++EOF++ case $host_os in+ mingw*)+ cat <<"EOF"+ /* execv doesn't actually work on mingw as expected on unix */+ newargz = prepare_spawn (newargz);+ rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);+ if (rval == -1)+ {+ /* failed to start process */+ lt_debugprintf (__FILE__, __LINE__,+ "(main) failed to launch target \"%s\": %s\n",+ lt_argv_zero, nonnull (strerror (errno)));+ return 127;+ }+ return rval;+EOF+ ;;+ *)+ cat <<"EOF"+ execv (lt_argv_zero, newargz);+ return rval; /* =127, but avoids unused variable warning */+EOF+ ;;+ esac++ cat <<"EOF"+}++void *+xmalloc (size_t num)+{+ void *p = (void *) malloc (num);+ if (!p)+ lt_fatal (__FILE__, __LINE__, "memory exhausted");++ return p;+}++char *+xstrdup (const char *string)+{+ return string ? strcpy ((char *) xmalloc (strlen (string) + 1),+ string) : NULL;+}++const char *+base_name (const char *name)+{+ const char *base;++#if defined HAVE_DOS_BASED_FILE_SYSTEM+ /* Skip over the disk name in MSDOS pathnames. */+ if (isalpha ((unsigned char) name[0]) && name[1] == ':')+ name += 2;+#endif++ for (base = name; *name; name++)+ if (IS_DIR_SEPARATOR (*name))+ base = name + 1;+ return base;+}++int+check_executable (const char *path)+{+ struct stat st;++ lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",+ nonempty (path));+ if ((!path) || (!*path))+ return 0;++ if ((stat (path, &st) >= 0)+ && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))+ return 1;+ else+ return 0;+}++int+make_executable (const char *path)+{+ int rval = 0;+ struct stat st;++ lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",+ nonempty (path));+ if ((!path) || (!*path))+ return 0;++ if (stat (path, &st) >= 0)+ {+ rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);+ }+ return rval;+}++/* Searches for the full path of the wrapper. Returns+ newly allocated full path name if found, NULL otherwise+ Does not chase symlinks, even on platforms that support them.+*/+char *+find_executable (const char *wrapper)+{+ int has_slash = 0;+ const char *p;+ const char *p_next;+ /* static buffer for getcwd */+ char tmp[LT_PATHMAX + 1];+ size_t tmp_len;+ char *concat_name;++ lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",+ nonempty (wrapper));++ if ((wrapper == NULL) || (*wrapper == '\0'))+ return NULL;++ /* Absolute path? */+#if defined HAVE_DOS_BASED_FILE_SYSTEM+ if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')+ {+ concat_name = xstrdup (wrapper);+ if (check_executable (concat_name))+ return concat_name;+ XFREE (concat_name);+ }+ else+ {+#endif+ if (IS_DIR_SEPARATOR (wrapper[0]))+ {+ concat_name = xstrdup (wrapper);+ if (check_executable (concat_name))+ return concat_name;+ XFREE (concat_name);+ }+#if defined HAVE_DOS_BASED_FILE_SYSTEM+ }+#endif++ for (p = wrapper; *p; p++)+ if (*p == '/')+ {+ has_slash = 1;+ break;+ }+ if (!has_slash)+ {+ /* no slashes; search PATH */+ const char *path = getenv ("PATH");+ if (path != NULL)+ {+ for (p = path; *p; p = p_next)+ {+ const char *q;+ size_t p_len;+ for (q = p; *q; q++)+ if (IS_PATH_SEPARATOR (*q))+ break;+ p_len = (size_t) (q - p);+ p_next = (*q == '\0' ? q : q + 1);+ if (p_len == 0)+ {+ /* empty path: current directory */+ if (getcwd (tmp, LT_PATHMAX) == NULL)+ lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",+ nonnull (strerror (errno)));+ tmp_len = strlen (tmp);+ concat_name =+ XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);+ memcpy (concat_name, tmp, tmp_len);+ concat_name[tmp_len] = '/';+ strcpy (concat_name + tmp_len + 1, wrapper);+ }+ else+ {+ concat_name =+ XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);+ memcpy (concat_name, p, p_len);+ concat_name[p_len] = '/';+ strcpy (concat_name + p_len + 1, wrapper);+ }+ if (check_executable (concat_name))+ return concat_name;+ XFREE (concat_name);+ }+ }+ /* not found in PATH; assume curdir */+ }+ /* Relative path | not found in path: prepend cwd */+ if (getcwd (tmp, LT_PATHMAX) == NULL)+ lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",+ nonnull (strerror (errno)));+ tmp_len = strlen (tmp);+ concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);+ memcpy (concat_name, tmp, tmp_len);+ concat_name[tmp_len] = '/';+ strcpy (concat_name + tmp_len + 1, wrapper);++ if (check_executable (concat_name))+ return concat_name;+ XFREE (concat_name);+ return NULL;+}++char *+chase_symlinks (const char *pathspec)+{+#ifndef S_ISLNK+ return xstrdup (pathspec);+#else+ char buf[LT_PATHMAX];+ struct stat s;+ char *tmp_pathspec = xstrdup (pathspec);+ char *p;+ int has_symlinks = 0;+ while (strlen (tmp_pathspec) && !has_symlinks)+ {+ lt_debugprintf (__FILE__, __LINE__,+ "checking path component for symlinks: %s\n",+ tmp_pathspec);+ if (lstat (tmp_pathspec, &s) == 0)+ {+ if (S_ISLNK (s.st_mode) != 0)+ {+ has_symlinks = 1;+ break;+ }++ /* search backwards for last DIR_SEPARATOR */+ p = tmp_pathspec + strlen (tmp_pathspec) - 1;+ while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))+ p--;+ if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))+ {+ /* no more DIR_SEPARATORS left */+ break;+ }+ *p = '\0';+ }+ else+ {+ lt_fatal (__FILE__, __LINE__,+ "error accessing file \"%s\": %s",+ tmp_pathspec, nonnull (strerror (errno)));+ }+ }+ XFREE (tmp_pathspec);++ if (!has_symlinks)+ {+ return xstrdup (pathspec);+ }++ tmp_pathspec = realpath (pathspec, buf);+ if (tmp_pathspec == 0)+ {+ lt_fatal (__FILE__, __LINE__,+ "could not follow symlinks for %s", pathspec);+ }+ return xstrdup (tmp_pathspec);+#endif+}++char *+strendzap (char *str, const char *pat)+{+ size_t len, patlen;++ assert (str != NULL);+ assert (pat != NULL);++ len = strlen (str);+ patlen = strlen (pat);++ if (patlen <= len)+ {+ str += len - patlen;+ if (STREQ (str, pat))+ *str = '\0';+ }+ return str;+}++void+lt_debugprintf (const char *file, int line, const char *fmt, ...)+{+ va_list args;+ if (lt_debug)+ {+ (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);+ va_start (args, fmt);+ (void) vfprintf (stderr, fmt, args);+ va_end (args);+ }+}++static void+lt_error_core (int exit_status, const char *file,+ int line, const char *mode,+ const char *message, va_list ap)+{+ fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);+ vfprintf (stderr, message, ap);+ fprintf (stderr, ".\n");++ if (exit_status >= 0)+ exit (exit_status);+}++void+lt_fatal (const char *file, int line, const char *message, ...)+{+ va_list ap;+ va_start (ap, message);+ lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);+ va_end (ap);+}++static const char *+nonnull (const char *s)+{+ return s ? s : "(null)";+}++static const char *+nonempty (const char *s)+{+ return (s && !*s) ? "(empty)" : nonnull (s);+}++void+lt_setenv (const char *name, const char *value)+{+ lt_debugprintf (__FILE__, __LINE__,+ "(lt_setenv) setting '%s' to '%s'\n",+ nonnull (name), nonnull (value));+ {+#ifdef HAVE_SETENV+ /* always make a copy, for consistency with !HAVE_SETENV */+ char *str = xstrdup (value);+ setenv (name, str, 1);+#else+ size_t len = strlen (name) + 1 + strlen (value) + 1;+ char *str = XMALLOC (char, len);+ sprintf (str, "%s=%s", name, value);+ if (putenv (str) != EXIT_SUCCESS)+ {+ XFREE (str);+ }+#endif+ }+}++char *+lt_extend_str (const char *orig_value, const char *add, int to_end)+{+ char *new_value;+ if (orig_value && *orig_value)+ {+ size_t orig_value_len = strlen (orig_value);+ size_t add_len = strlen (add);+ new_value = XMALLOC (char, add_len + orig_value_len + 1);+ if (to_end)+ {+ strcpy (new_value, orig_value);+ strcpy (new_value + orig_value_len, add);+ }+ else+ {+ strcpy (new_value, add);+ strcpy (new_value + add_len, orig_value);+ }+ }+ else+ {+ new_value = xstrdup (add);+ }+ return new_value;+}++void+lt_update_exe_path (const char *name, const char *value)+{+ lt_debugprintf (__FILE__, __LINE__,+ "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",+ nonnull (name), nonnull (value));++ if (name && *name && value && *value)+ {+ char *new_value = lt_extend_str (getenv (name), value, 0);+ /* some systems can't cope with a ':'-terminated path #' */+ size_t len = strlen (new_value);+ while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))+ {+ new_value[--len] = '\0';+ }+ lt_setenv (name, new_value);+ XFREE (new_value);+ }+}++void+lt_update_lib_path (const char *name, const char *value)+{+ lt_debugprintf (__FILE__, __LINE__,+ "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",+ nonnull (name), nonnull (value));++ if (name && *name && value && *value)+ {+ char *new_value = lt_extend_str (getenv (name), value, 0);+ lt_setenv (name, new_value);+ XFREE (new_value);+ }+}++EOF+ case $host_os in+ mingw*)+ cat <<"EOF"++/* Prepares an argument vector before calling spawn().+ Note that spawn() does not by itself call the command interpreter+ (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :+ ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);+ GetVersionEx(&v);+ v.dwPlatformId == VER_PLATFORM_WIN32_NT;+ }) ? "cmd.exe" : "command.com").+ Instead it simply concatenates the arguments, separated by ' ', and calls+ CreateProcess(). We must quote the arguments since Win32 CreateProcess()+ interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a+ special way:+ - Space and tab are interpreted as delimiters. They are not treated as+ delimiters if they are surrounded by double quotes: "...".+ - Unescaped double quotes are removed from the input. Their only effect is+ that within double quotes, space and tab are treated like normal+ characters.+ - Backslashes not followed by double quotes are not special.+ - But 2*n+1 backslashes followed by a double quote become+ n backslashes followed by a double quote (n >= 0):+ \" -> "+ \\\" -> \"+ \\\\\" -> \\"+ */+#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"+#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"+char **+prepare_spawn (char **argv)+{+ size_t argc;+ char **new_argv;+ size_t i;++ /* Count number of arguments. */+ for (argc = 0; argv[argc] != NULL; argc++)+ ;++ /* Allocate new argument vector. */+ new_argv = XMALLOC (char *, argc + 1);++ /* Put quoted arguments into the new argument vector. */+ for (i = 0; i < argc; i++)+ {+ const char *string = argv[i];++ if (string[0] == '\0')+ new_argv[i] = xstrdup ("\"\"");+ else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)+ {+ int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);+ size_t length;+ unsigned int backslashes;+ const char *s;+ char *quoted_string;+ char *p;++ length = 0;+ backslashes = 0;+ if (quote_around)+ length++;+ for (s = string; *s != '\0'; s++)+ {+ char c = *s;+ if (c == '"')+ length += backslashes + 1;+ length++;+ if (c == '\\')+ backslashes++;+ else+ backslashes = 0;+ }+ if (quote_around)+ length += backslashes + 1;++ quoted_string = XMALLOC (char, length + 1);++ p = quoted_string;+ backslashes = 0;+ if (quote_around)+ *p++ = '"';+ for (s = string; *s != '\0'; s++)+ {+ char c = *s;+ if (c == '"')+ {+ unsigned int j;+ for (j = backslashes + 1; j > 0; j--)+ *p++ = '\\';+ }+ *p++ = c;+ if (c == '\\')+ backslashes++;+ else+ backslashes = 0;+ }+ if (quote_around)+ {+ unsigned int j;+ for (j = backslashes; j > 0; j--)+ *p++ = '\\';+ *p++ = '"';+ }+ *p = '\0';++ new_argv[i] = quoted_string;+ }+ else+ new_argv[i] = (char *) string;+ }+ new_argv[argc] = NULL;++ return new_argv;+}+EOF+ ;;+ esac++ cat <<"EOF"+void lt_dump_script (FILE* f)+{+EOF+ func_emit_wrapper yes |+ $SED -n -e '+s/^\(.\{79\}\)\(..*\)/\1\+\2/+h+s/\([\\"]\)/\\\1/g+s/$/\\n/+s/\([^\n]*\).*/ fputs ("\1", f);/p+g+D'+ cat <<"EOF"+}+EOF+}+# end: func_emit_cwrapperexe_src++# func_win32_import_lib_p ARG+# True if ARG is an import lib, as indicated by $file_magic_cmd+func_win32_import_lib_p ()+{+ $debug_cmd++ case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in+ *import*) : ;;+ *) false ;;+ esac+}++# func_suncc_cstd_abi+# !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!+# Several compiler flags select an ABI that is incompatible with the+# Cstd library. Avoid specifying it if any are in CXXFLAGS.+func_suncc_cstd_abi ()+{+ $debug_cmd++ case " $compile_command " in+ *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)+ suncc_use_cstd_abi=no+ ;;+ *)+ suncc_use_cstd_abi=yes+ ;;+ esac+}++# func_mode_link arg...+func_mode_link ()+{+ $debug_cmd++ case $host in+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)+ # It is impossible to link a dll without this setting, and+ # we shouldn't force the makefile maintainer to figure out+ # what system we are compiling for in order to pass an extra+ # flag for every libtool invocation.+ # allow_undefined=no++ # FIXME: Unfortunately, there are problems with the above when trying+ # to make a dll that has undefined symbols, in which case not+ # even a static library is built. For now, we need to specify+ # -no-undefined on the libtool link line when we can be certain+ # that all symbols are satisfied, otherwise we get a static library.+ allow_undefined=yes+ ;;+ *)+ allow_undefined=yes+ ;;+ esac+ libtool_args=$nonopt+ base_compile="$nonopt $@"+ compile_command=$nonopt+ finalize_command=$nonopt++ compile_rpath=+ finalize_rpath=+ compile_shlibpath=+ finalize_shlibpath=+ convenience=+ old_convenience=+ deplibs=+ old_deplibs=+ compiler_flags=+ linker_flags=+ dllsearchpath=+ lib_search_path=`pwd`+ inst_prefix_dir=+ new_inherited_linker_flags=++ avoid_version=no+ bindir=+ dlfiles=+ dlprefiles=+ dlself=no+ export_dynamic=no+ export_symbols=+ export_symbols_regex=+ generated=+ libobjs=+ ltlibs=+ module=no+ no_install=no+ objs=+ os2dllname=+ non_pic_objects=+ precious_files_regex=+ prefer_static_libs=no+ preload=false+ prev=+ prevarg=+ release=+ rpath=+ xrpath=+ perm_rpath=+ temp_rpath=+ thread_safe=no+ vinfo=+ vinfo_number=no+ weak_libs=+ single_module=$wl-single_module+ func_infer_tag $base_compile++ # We need to know -static, to get the right output filenames.+ for arg+ do+ case $arg in+ -shared)+ test yes != "$build_libtool_libs" \+ && func_fatal_configuration "cannot build a shared library"+ build_old_libs=no+ break+ ;;+ -all-static | -static | -static-libtool-libs)+ case $arg in+ -all-static)+ if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then+ func_warning "complete static linking is impossible in this configuration"+ fi+ if test -n "$link_static_flag"; then+ dlopen_self=$dlopen_self_static+ fi+ prefer_static_libs=yes+ ;;+ -static)+ if test -z "$pic_flag" && test -n "$link_static_flag"; then+ dlopen_self=$dlopen_self_static+ fi+ prefer_static_libs=built+ ;;+ -static-libtool-libs)+ if test -z "$pic_flag" && test -n "$link_static_flag"; then+ dlopen_self=$dlopen_self_static+ fi+ prefer_static_libs=yes+ ;;+ esac+ build_libtool_libs=no+ build_old_libs=yes+ break+ ;;+ esac+ done++ # See if our shared archives depend on static archives.+ test -n "$old_archive_from_new_cmds" && build_old_libs=yes++ # Go through the arguments, transforming them on the way.+ while test "$#" -gt 0; do+ arg=$1+ shift+ func_quote_arg pretty,unquoted "$arg"+ qarg=$func_quote_arg_unquoted_result+ func_append libtool_args " $func_quote_arg_result"++ # If the previous option needs an argument, assign it.+ if test -n "$prev"; then+ case $prev in+ output)+ func_append compile_command " @OUTPUT@"+ func_append finalize_command " @OUTPUT@"+ ;;+ esac++ case $prev in+ bindir)+ bindir=$arg+ prev=+ continue+ ;;+ dlfiles|dlprefiles)+ $preload || {+ # Add the symbol object into the linking commands.+ func_append compile_command " @SYMFILE@"+ func_append finalize_command " @SYMFILE@"+ preload=:+ }+ case $arg in+ *.la | *.lo) ;; # We handle these cases below.+ force)+ if test no = "$dlself"; then+ dlself=needless+ export_dynamic=yes+ fi+ prev=+ continue+ ;;+ self)+ if test dlprefiles = "$prev"; then+ dlself=yes+ elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then+ dlself=yes+ else+ dlself=needless+ export_dynamic=yes+ fi+ prev=+ continue+ ;;+ *)+ if test dlfiles = "$prev"; then+ func_append dlfiles " $arg"+ else+ func_append dlprefiles " $arg"+ fi+ prev=+ continue+ ;;+ esac+ ;;+ expsyms)+ export_symbols=$arg+ test -f "$arg" \+ || func_fatal_error "symbol file '$arg' does not exist"+ prev=+ continue+ ;;+ expsyms_regex)+ export_symbols_regex=$arg+ prev=+ continue+ ;;+ framework)+ case $host in+ *-*-darwin*)+ case "$deplibs " in+ *" $qarg.ltframework "*) ;;+ *) func_append deplibs " $qarg.ltframework" # this is fixed later+ ;;+ esac+ ;;+ esac+ prev=+ continue+ ;;+ inst_prefix)+ inst_prefix_dir=$arg+ prev=+ continue+ ;;+ mllvm)+ # Clang does not use LLVM to link, so we can simply discard any+ # '-mllvm $arg' options when doing the link step.+ prev=+ continue+ ;;+ objectlist)+ if test -f "$arg"; then+ save_arg=$arg+ moreargs=+ for fil in `cat "$save_arg"`+ do+# func_append moreargs " $fil"+ arg=$fil+ # A libtool-controlled object.++ # Check to see that this really is a libtool object.+ if func_lalib_unsafe_p "$arg"; then+ pic_object=+ non_pic_object=++ # Read the .lo file+ func_source "$arg"++ if test -z "$pic_object" ||+ test -z "$non_pic_object" ||+ test none = "$pic_object" &&+ test none = "$non_pic_object"; then+ func_fatal_error "cannot find name of object for '$arg'"+ fi++ # Extract subdirectory from the argument.+ func_dirname "$arg" "/" ""+ xdir=$func_dirname_result++ if test none != "$pic_object"; then+ # Prepend the subdirectory the object is found in.+ pic_object=$xdir$pic_object++ if test dlfiles = "$prev"; then+ if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then+ func_append dlfiles " $pic_object"+ prev=+ continue+ else+ # If libtool objects are unsupported, then we need to preload.+ prev=dlprefiles+ fi+ fi++ # CHECK ME: I think I busted this. -Ossama+ if test dlprefiles = "$prev"; then+ # Preload the old-style object.+ func_append dlprefiles " $pic_object"+ prev=+ fi++ # A PIC object.+ func_append libobjs " $pic_object"+ arg=$pic_object+ fi++ # Non-PIC object.+ if test none != "$non_pic_object"; then+ # Prepend the subdirectory the object is found in.+ non_pic_object=$xdir$non_pic_object++ # A standard non-PIC object+ func_append non_pic_objects " $non_pic_object"+ if test -z "$pic_object" || test none = "$pic_object"; then+ arg=$non_pic_object+ fi+ else+ # If the PIC object exists, use it instead.+ # $xdir was prepended to $pic_object above.+ non_pic_object=$pic_object+ func_append non_pic_objects " $non_pic_object"+ fi+ else+ # Only an error if not doing a dry-run.+ if $opt_dry_run; then+ # Extract subdirectory from the argument.+ func_dirname "$arg" "/" ""+ xdir=$func_dirname_result++ func_lo2o "$arg"+ pic_object=$xdir$objdir/$func_lo2o_result+ non_pic_object=$xdir$func_lo2o_result+ func_append libobjs " $pic_object"+ func_append non_pic_objects " $non_pic_object"+ else+ func_fatal_error "'$arg' is not a valid libtool object"+ fi+ fi+ done+ else+ func_fatal_error "link input file '$arg' does not exist"+ fi+ arg=$save_arg+ prev=+ continue+ ;;+ os2dllname)+ os2dllname=$arg+ prev=+ continue+ ;;+ precious_regex)+ precious_files_regex=$arg+ prev=+ continue+ ;;+ release)+ release=-$arg+ prev=+ continue+ ;;+ rpath | xrpath)+ # We need an absolute path.+ case $arg in+ [\\/]* | [A-Za-z]:[\\/]*) ;;+ *)+ func_fatal_error "only absolute run-paths are allowed"+ ;;+ esac+ if test rpath = "$prev"; then+ case "$rpath " in+ *" $arg "*) ;;+ *) func_append rpath " $arg" ;;+ esac+ else+ case "$xrpath " in+ *" $arg "*) ;;+ *) func_append xrpath " $arg" ;;+ esac+ fi+ prev=+ continue+ ;;+ shrext)+ shrext_cmds=$arg+ prev=+ continue+ ;;+ weak)+ func_append weak_libs " $arg"+ prev=+ continue+ ;;+ xassembler)+ func_append compiler_flags " -Xassembler $qarg"+ prev=+ func_append compile_command " -Xassembler $qarg"+ func_append finalize_command " -Xassembler $qarg"+ continue+ ;;+ xcclinker)+ func_append linker_flags " $qarg"+ func_append compiler_flags " $qarg"+ prev=+ func_append compile_command " $qarg"+ func_append finalize_command " $qarg"+ continue+ ;;+ xcompiler)+ func_append compiler_flags " $qarg"+ prev=+ func_append compile_command " $qarg"+ func_append finalize_command " $qarg"+ continue+ ;;+ xlinker)+ func_append linker_flags " $qarg"+ func_append compiler_flags " $wl$qarg"+ prev=+ func_append compile_command " $wl$qarg"+ func_append finalize_command " $wl$qarg"+ continue+ ;;+ *)+ eval "$prev=\"\$arg\""+ prev=+ continue+ ;;+ esac+ fi # test -n "$prev"++ prevarg=$arg++ case $arg in+ -all-static)+ if test -n "$link_static_flag"; then+ # See comment for -static flag below, for more details.+ func_append compile_command " $link_static_flag"+ func_append finalize_command " $link_static_flag"+ fi+ continue+ ;;++ -allow-undefined)+ # FIXME: remove this flag sometime in the future.+ func_fatal_error "'-allow-undefined' must not be used because it is the default"+ ;;++ -avoid-version)+ avoid_version=yes+ continue+ ;;++ -bindir)+ prev=bindir+ continue+ ;;++ -dlopen)+ prev=dlfiles+ continue+ ;;++ -dlpreopen)+ prev=dlprefiles+ continue+ ;;++ -export-dynamic)+ export_dynamic=yes+ continue+ ;;++ -export-symbols | -export-symbols-regex)+ if test -n "$export_symbols" || test -n "$export_symbols_regex"; then+ func_fatal_error "more than one -exported-symbols argument is not allowed"+ fi+ if test X-export-symbols = "X$arg"; then+ prev=expsyms+ else+ prev=expsyms_regex+ fi+ continue+ ;;++ -framework)+ prev=framework+ continue+ ;;++ -inst-prefix-dir)+ prev=inst_prefix+ continue+ ;;++ # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*+ # so, if we see these flags be careful not to treat them like -L+ -L[A-Z][A-Z]*:*)+ case $with_gcc/$host in+ no/*-*-irix* | /*-*-irix*)+ func_append compile_command " $arg"+ func_append finalize_command " $arg"+ ;;+ esac+ continue+ ;;++ -L*)+ func_stripname "-L" '' "$arg"+ if test -z "$func_stripname_result"; then+ if test "$#" -gt 0; then+ func_fatal_error "require no space between '-L' and '$1'"+ else+ func_fatal_error "need path for '-L' option"+ fi+ fi+ func_resolve_sysroot "$func_stripname_result"+ dir=$func_resolve_sysroot_result+ # We need an absolute path.+ case $dir in+ [\\/]* | [A-Za-z]:[\\/]*) ;;+ *)+ absdir=`cd "$dir" && pwd`+ test -z "$absdir" && \+ func_fatal_error "cannot determine absolute directory name of '$dir'"+ dir=$absdir+ ;;+ esac+ case "$deplibs " in+ *" -L$dir "* | *" $arg "*)+ # Will only happen for absolute or sysroot arguments+ ;;+ *)+ # Preserve sysroot, but never include relative directories+ case $dir in+ [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;+ *) func_append deplibs " -L$dir" ;;+ esac+ func_append lib_search_path " $dir"+ ;;+ esac+ case $host in+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)+ testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`+ case :$dllsearchpath: in+ *":$dir:"*) ;;+ ::) dllsearchpath=$dir;;+ *) func_append dllsearchpath ":$dir";;+ esac+ case :$dllsearchpath: in+ *":$testbindir:"*) ;;+ ::) dllsearchpath=$testbindir;;+ *) func_append dllsearchpath ":$testbindir";;+ esac+ ;;+ esac+ continue+ ;;++ -l*)+ if test X-lc = "X$arg" || test X-lm = "X$arg"; then+ case $host in+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)+ # These systems don't actually have a C or math library (as such)+ continue+ ;;+ *-*-os2*)+ # These systems don't actually have a C library (as such)+ test X-lc = "X$arg" && continue+ ;;+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*)+ # Do not include libc due to us having libc/libc_r.+ test X-lc = "X$arg" && continue+ ;;+ *-*-rhapsody* | *-*-darwin1.[012])+ # Rhapsody C and math libraries are in the System framework+ func_append deplibs " System.ltframework"+ continue+ ;;+ *-*-sco3.2v5* | *-*-sco5v6*)+ # Causes problems with __ctype+ test X-lc = "X$arg" && continue+ ;;+ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)+ # Compiler inserts libc in the correct place for threads to work+ test X-lc = "X$arg" && continue+ ;;+ esac+ elif test X-lc_r = "X$arg"; then+ case $host in+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*)+ # Do not include libc_r directly, use -pthread flag.+ continue+ ;;+ esac+ fi+ func_append deplibs " $arg"+ continue+ ;;++ -mllvm)+ prev=mllvm+ continue+ ;;++ -module)+ module=yes+ continue+ ;;++ # Tru64 UNIX uses -model [arg] to determine the layout of C+++ # classes, name mangling, and exception handling.+ # Darwin uses the -arch flag to determine output architecture.+ -model|-arch|-isysroot|--sysroot)+ func_append compiler_flags " $arg"+ func_append compile_command " $arg"+ func_append finalize_command " $arg"+ prev=xcompiler+ continue+ ;;+ # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199.+ -pthread)+ case $host in+ *solaris2*) ;;+ *)+ case "$new_inherited_linker_flags " in+ *" $arg "*) ;;+ * ) func_append new_inherited_linker_flags " $arg" ;;+ esac+ ;;+ esac+ continue+ ;;+ -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \+ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)+ func_append compiler_flags " $arg"+ func_append compile_command " $arg"+ func_append finalize_command " $arg"+ case "$new_inherited_linker_flags " in+ *" $arg "*) ;;+ * ) func_append new_inherited_linker_flags " $arg" ;;+ esac+ continue+ ;;++ -multi_module)+ single_module=$wl-multi_module+ continue+ ;;++ -no-fast-install)+ fast_install=no+ continue+ ;;++ -no-install)+ case $host in+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)+ # The PATH hackery in wrapper scripts is required on Windows+ # and Darwin in order for the loader to find any dlls it needs.+ func_warning "'-no-install' is ignored for $host"+ func_warning "assuming '-no-fast-install' instead"+ fast_install=no+ ;;+ *) no_install=yes ;;+ esac+ continue+ ;;++ -no-undefined)+ allow_undefined=no+ continue+ ;;++ -objectlist)+ prev=objectlist+ continue+ ;;++ -os2dllname)+ prev=os2dllname+ continue+ ;;++ -o) prev=output ;;++ -precious-files-regex)+ prev=precious_regex+ continue+ ;;++ -release)+ prev=release+ continue+ ;;++ -rpath)+ prev=rpath+ continue+ ;;++ -R)+ prev=xrpath+ continue+ ;;++ -R*)+ func_stripname '-R' '' "$arg"+ dir=$func_stripname_result+ # We need an absolute path.+ case $dir in+ [\\/]* | [A-Za-z]:[\\/]*) ;;+ =*)+ func_stripname '=' '' "$dir"+ dir=$lt_sysroot$func_stripname_result+ ;;+ *)+ func_fatal_error "only absolute run-paths are allowed"+ ;;+ esac+ case "$xrpath " in+ *" $dir "*) ;;+ *) func_append xrpath " $dir" ;;+ esac+ continue+ ;;++ -shared)+ # The effects of -shared are defined in a previous loop.+ continue+ ;;++ -shrext)+ prev=shrext+ continue+ ;;++ -static | -static-libtool-libs)+ # The effects of -static are defined in a previous loop.+ # We used to do the same as -all-static on platforms that+ # didn't have a PIC flag, but the assumption that the effects+ # would be equivalent was wrong. It would break on at least+ # Digital Unix and AIX.+ continue+ ;;++ -thread-safe)+ thread_safe=yes+ continue+ ;;++ -version-info)+ prev=vinfo+ continue+ ;;++ -version-number)+ prev=vinfo+ vinfo_number=yes+ continue+ ;;++ -weak)+ prev=weak+ continue+ ;;++ -Wc,*)+ func_stripname '-Wc,' '' "$arg"+ args=$func_stripname_result+ arg=+ save_ifs=$IFS; IFS=,+ for flag in $args; do+ IFS=$save_ifs+ func_quote_arg pretty "$flag"+ func_append arg " $func_quote_arg_result"+ func_append compiler_flags " $func_quote_arg_result"+ done+ IFS=$save_ifs+ func_stripname ' ' '' "$arg"+ arg=$func_stripname_result+ ;;++ -Wl,*)+ func_stripname '-Wl,' '' "$arg"+ args=$func_stripname_result+ arg=+ save_ifs=$IFS; IFS=,+ for flag in $args; do+ IFS=$save_ifs+ func_quote_arg pretty "$flag"+ func_append arg " $wl$func_quote_arg_result"+ func_append compiler_flags " $wl$func_quote_arg_result"+ func_append linker_flags " $func_quote_arg_result"+ done+ IFS=$save_ifs+ func_stripname ' ' '' "$arg"+ arg=$func_stripname_result+ ;;++ -Xassembler)+ prev=xassembler+ continue+ ;;++ -Xcompiler)+ prev=xcompiler+ continue+ ;;++ -Xlinker)+ prev=xlinker+ continue+ ;;++ -XCClinker)+ prev=xcclinker+ continue+ ;;++ # -msg_* for osf cc+ -msg_*)+ func_quote_arg pretty "$arg"+ arg=$func_quote_arg_result+ ;;++ # Flags to be passed through unchanged, with rationale:+ # -64, -mips[0-9] enable 64-bit mode for the SGI compiler+ # -r[0-9][0-9]* specify processor for the SGI compiler+ # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler+ # +DA*, +DD* enable 64-bit mode for the HP compiler+ # -q* compiler args for the IBM compiler+ # -m*, -t[45]*, -txscale* architecture-specific flags for GCC+ # -F/path path to uninstalled frameworks, gcc on darwin+ # -p, -pg, --coverage, -fprofile-* profiling flags for GCC+ # -fstack-protector* stack protector flags for GCC+ # @file GCC response files+ # -tp=* Portland pgcc target processor selection+ # --sysroot=* for sysroot support+ # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization+ # -specs=* GCC specs files+ # -stdlib=* select c++ std lib with clang+ # -fsanitize=* Clang/GCC memory and address sanitizer+ # -fuse-ld=* Linker select flags for GCC+ # -Wa,* Pass flags directly to the assembler+ -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \+ -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \+ -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \+ -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*)+ func_quote_arg pretty "$arg"+ arg=$func_quote_arg_result+ func_append compile_command " $arg"+ func_append finalize_command " $arg"+ func_append compiler_flags " $arg"+ continue+ ;;++ -Z*)+ if test os2 = "`expr $host : '.*\(os2\)'`"; then+ # OS/2 uses -Zxxx to specify OS/2-specific options+ compiler_flags="$compiler_flags $arg"+ func_append compile_command " $arg"+ func_append finalize_command " $arg"+ case $arg in+ -Zlinker | -Zstack)+ prev=xcompiler+ ;;+ esac+ continue+ else+ # Otherwise treat like 'Some other compiler flag' below+ func_quote_arg pretty "$arg"+ arg=$func_quote_arg_result+ fi+ ;;++ # Some other compiler flag.+ -* | +*)+ func_quote_arg pretty "$arg"+ arg=$func_quote_arg_result+ ;;++ *.$objext)+ # A standard object.+ func_append objs " $arg"+ ;;++ *.lo)+ # A libtool-controlled object.++ # Check to see that this really is a libtool object.+ if func_lalib_unsafe_p "$arg"; then+ pic_object=+ non_pic_object=++ # Read the .lo file+ func_source "$arg"++ if test -z "$pic_object" ||+ test -z "$non_pic_object" ||+ test none = "$pic_object" &&+ test none = "$non_pic_object"; then+ func_fatal_error "cannot find name of object for '$arg'"+ fi++ # Extract subdirectory from the argument.+ func_dirname "$arg" "/" ""+ xdir=$func_dirname_result++ test none = "$pic_object" || {+ # Prepend the subdirectory the object is found in.+ pic_object=$xdir$pic_object++ if test dlfiles = "$prev"; then+ if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then+ func_append dlfiles " $pic_object"+ prev=+ continue+ else+ # If libtool objects are unsupported, then we need to preload.+ prev=dlprefiles+ fi+ fi++ # CHECK ME: I think I busted this. -Ossama+ if test dlprefiles = "$prev"; then+ # Preload the old-style object.+ func_append dlprefiles " $pic_object"+ prev=+ fi++ # A PIC object.+ func_append libobjs " $pic_object"+ arg=$pic_object+ }++ # Non-PIC object.+ if test none != "$non_pic_object"; then+ # Prepend the subdirectory the object is found in.+ non_pic_object=$xdir$non_pic_object++ # A standard non-PIC object+ func_append non_pic_objects " $non_pic_object"+ if test -z "$pic_object" || test none = "$pic_object"; then+ arg=$non_pic_object+ fi+ else+ # If the PIC object exists, use it instead.+ # $xdir was prepended to $pic_object above.+ non_pic_object=$pic_object+ func_append non_pic_objects " $non_pic_object"+ fi+ else+ # Only an error if not doing a dry-run.+ if $opt_dry_run; then+ # Extract subdirectory from the argument.+ func_dirname "$arg" "/" ""+ xdir=$func_dirname_result++ func_lo2o "$arg"+ pic_object=$xdir$objdir/$func_lo2o_result+ non_pic_object=$xdir$func_lo2o_result+ func_append libobjs " $pic_object"+ func_append non_pic_objects " $non_pic_object"+ else+ func_fatal_error "'$arg' is not a valid libtool object"+ fi+ fi+ ;;++ *.$libext)+ # An archive.+ func_append deplibs " $arg"+ func_append old_deplibs " $arg"+ continue+ ;;++ *.la)+ # A libtool-controlled library.++ func_resolve_sysroot "$arg"+ if test dlfiles = "$prev"; then+ # This library was specified with -dlopen.+ func_append dlfiles " $func_resolve_sysroot_result"+ prev=+ elif test dlprefiles = "$prev"; then+ # The library was specified with -dlpreopen.+ func_append dlprefiles " $func_resolve_sysroot_result"+ prev=+ else+ func_append deplibs " $func_resolve_sysroot_result"+ fi+ continue+ ;;++ # Some other compiler argument.+ *)+ # Unknown arguments in both finalize_command and compile_command need+ # to be aesthetically quoted because they are evaled later.+ func_quote_arg pretty "$arg"+ arg=$func_quote_arg_result+ ;;+ esac # arg++ # Now actually substitute the argument into the commands.+ if test -n "$arg"; then+ func_append compile_command " $arg"+ func_append finalize_command " $arg"+ fi+ done # argument parsing loop++ test -n "$prev" && \+ func_fatal_help "the '$prevarg' option requires an argument"++ if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then+ eval arg=\"$export_dynamic_flag_spec\"+ func_append compile_command " $arg"+ func_append finalize_command " $arg"+ fi++ oldlibs=+ # calculate the name of the file, without its directory+ func_basename "$output"+ outputname=$func_basename_result+ libobjs_save=$libobjs++ if test -n "$shlibpath_var"; then+ # get the directories listed in $shlibpath_var+ eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`+ else+ shlib_search_path=+ fi+ eval sys_lib_search_path=\"$sys_lib_search_path_spec\"+ eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"++ # Definition is injected by LT_CONFIG during libtool generation.+ func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"++ func_dirname "$output" "/" ""+ output_objdir=$func_dirname_result$objdir+ func_to_tool_file "$output_objdir/"+ tool_output_objdir=$func_to_tool_file_result+ # Create the object directory.+ func_mkdir_p "$output_objdir"++ # Determine the type of output+ case $output in+ "")+ func_fatal_help "you must specify an output file"+ ;;+ *.$libext) linkmode=oldlib ;;+ *.lo | *.$objext) linkmode=obj ;;+ *.la) linkmode=lib ;;+ *) linkmode=prog ;; # Anything else should be a program.+ esac++ specialdeplibs=++ libs=+ # Find all interdependent deplibs by searching for libraries+ # that are linked more than once (e.g. -la -lb -la)+ for deplib in $deplibs; do+ if $opt_preserve_dup_deps; then+ case "$libs " in+ *" $deplib "*) func_append specialdeplibs " $deplib" ;;+ esac+ fi+ func_append libs " $deplib"+ done++ if test lib = "$linkmode"; then+ libs="$predeps $libs $compiler_lib_search_path $postdeps"++ # Compute libraries that are listed more than once in $predeps+ # $postdeps and mark them as special (i.e., whose duplicates are+ # not to be eliminated).+ pre_post_deps=+ if $opt_duplicate_compiler_generated_deps; then+ for pre_post_dep in $predeps $postdeps; do+ case "$pre_post_deps " in+ *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;+ esac+ func_append pre_post_deps " $pre_post_dep"+ done+ fi+ pre_post_deps=+ fi++ deplibs=+ newdependency_libs=+ newlib_search_path=+ need_relink=no # whether we're linking any uninstalled libtool libraries+ notinst_deplibs= # not-installed libtool libraries+ notinst_path= # paths that contain not-installed libtool libraries++ case $linkmode in+ lib)+ passes="conv dlpreopen link"+ for file in $dlfiles $dlprefiles; do+ case $file in+ *.la) ;;+ *)+ func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"+ ;;+ esac+ done+ ;;+ prog)+ compile_deplibs=+ finalize_deplibs=+ alldeplibs=false+ newdlfiles=+ newdlprefiles=+ passes="conv scan dlopen dlpreopen link"+ ;;+ *) passes="conv"+ ;;+ esac++ for pass in $passes; do+ # The preopen pass in lib mode reverses $deplibs; put it back here+ # so that -L comes before libs that need it for instance...+ if test lib,link = "$linkmode,$pass"; then+ ## FIXME: Find the place where the list is rebuilt in the wrong+ ## order, and fix it there properly+ tmp_deplibs=+ for deplib in $deplibs; do+ tmp_deplibs="$deplib $tmp_deplibs"+ done+ deplibs=$tmp_deplibs+ fi++ if test lib,link = "$linkmode,$pass" ||+ test prog,scan = "$linkmode,$pass"; then+ libs=$deplibs+ deplibs=+ fi+ if test prog = "$linkmode"; then+ case $pass in+ dlopen) libs=$dlfiles ;;+ dlpreopen) libs=$dlprefiles ;;+ link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;+ esac+ fi+ if test lib,dlpreopen = "$linkmode,$pass"; then+ # Collect and forward deplibs of preopened libtool libs+ for lib in $dlprefiles; do+ # Ignore non-libtool-libs+ dependency_libs=+ func_resolve_sysroot "$lib"+ case $lib in+ *.la) func_source "$func_resolve_sysroot_result" ;;+ esac++ # Collect preopened libtool deplibs, except any this library+ # has declared as weak libs+ for deplib in $dependency_libs; do+ func_basename "$deplib"+ deplib_base=$func_basename_result+ case " $weak_libs " in+ *" $deplib_base "*) ;;+ *) func_append deplibs " $deplib" ;;+ esac+ done+ done+ libs=$dlprefiles+ fi+ if test dlopen = "$pass"; then+ # Collect dlpreopened libraries+ save_deplibs=$deplibs+ deplibs=+ fi++ for deplib in $libs; do+ lib=+ found=false+ case $deplib in+ -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \+ |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)+ if test prog,link = "$linkmode,$pass"; then+ compile_deplibs="$deplib $compile_deplibs"+ finalize_deplibs="$deplib $finalize_deplibs"+ else+ func_append compiler_flags " $deplib"+ if test lib = "$linkmode"; then+ case "$new_inherited_linker_flags " in+ *" $deplib "*) ;;+ * ) func_append new_inherited_linker_flags " $deplib" ;;+ esac+ fi+ fi+ continue+ ;;+ -l*)+ if test lib != "$linkmode" && test prog != "$linkmode"; then+ func_warning "'-l' is ignored for archives/objects"+ continue+ fi+ func_stripname '-l' '' "$deplib"+ name=$func_stripname_result+ if test lib = "$linkmode"; then+ searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"+ else+ searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"+ fi+ for searchdir in $searchdirs; do+ for search_ext in .la $std_shrext .so .a; do+ # Search the libtool library+ lib=$searchdir/lib$name$search_ext+ if test -f "$lib"; then+ if test .la = "$search_ext"; then+ found=:+ else+ found=false+ fi+ break 2+ fi+ done+ done+ if $found; then+ # deplib is a libtool library+ # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,+ # We need to do some special things here, and not later.+ if test yes = "$allow_libtool_libs_with_static_runtimes"; then+ case " $predeps $postdeps " in+ *" $deplib "*)+ if func_lalib_p "$lib"; then+ library_names=+ old_library=+ func_source "$lib"+ for l in $old_library $library_names; do+ ll=$l+ done+ if test "X$ll" = "X$old_library"; then # only static version available+ found=false+ func_dirname "$lib" "" "."+ ladir=$func_dirname_result+ lib=$ladir/$old_library+ if test prog,link = "$linkmode,$pass"; then+ compile_deplibs="$deplib $compile_deplibs"+ finalize_deplibs="$deplib $finalize_deplibs"+ else+ deplibs="$deplib $deplibs"+ test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"+ fi+ continue+ fi+ fi+ ;;+ *) ;;+ esac+ fi+ else+ # deplib doesn't seem to be a libtool library+ if test prog,link = "$linkmode,$pass"; then+ compile_deplibs="$deplib $compile_deplibs"+ finalize_deplibs="$deplib $finalize_deplibs"+ else+ deplibs="$deplib $deplibs"+ test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"+ fi+ continue+ fi+ ;; # -l+ *.ltframework)+ if test prog,link = "$linkmode,$pass"; then+ compile_deplibs="$deplib $compile_deplibs"+ finalize_deplibs="$deplib $finalize_deplibs"+ else+ deplibs="$deplib $deplibs"+ if test lib = "$linkmode"; then+ case "$new_inherited_linker_flags " in+ *" $deplib "*) ;;+ * ) func_append new_inherited_linker_flags " $deplib" ;;+ esac+ fi+ fi+ continue+ ;;+ -L*)+ case $linkmode in+ lib)+ deplibs="$deplib $deplibs"+ test conv = "$pass" && continue+ newdependency_libs="$deplib $newdependency_libs"+ func_stripname '-L' '' "$deplib"+ func_resolve_sysroot "$func_stripname_result"+ func_append newlib_search_path " $func_resolve_sysroot_result"+ ;;+ prog)+ if test conv = "$pass"; then+ deplibs="$deplib $deplibs"+ continue+ fi+ if test scan = "$pass"; then+ deplibs="$deplib $deplibs"+ else+ compile_deplibs="$deplib $compile_deplibs"+ finalize_deplibs="$deplib $finalize_deplibs"+ fi+ func_stripname '-L' '' "$deplib"+ func_resolve_sysroot "$func_stripname_result"+ func_append newlib_search_path " $func_resolve_sysroot_result"+ ;;+ *)+ func_warning "'-L' is ignored for archives/objects"+ ;;+ esac # linkmode+ continue+ ;; # -L+ -R*)+ if test link = "$pass"; then+ func_stripname '-R' '' "$deplib"+ func_resolve_sysroot "$func_stripname_result"+ dir=$func_resolve_sysroot_result+ # Make sure the xrpath contains only unique directories.+ case "$xrpath " in+ *" $dir "*) ;;+ *) func_append xrpath " $dir" ;;+ esac+ fi+ deplibs="$deplib $deplibs"+ continue+ ;;+ *.la)+ func_resolve_sysroot "$deplib"+ lib=$func_resolve_sysroot_result+ ;;+ *.$libext)+ if test conv = "$pass"; then+ deplibs="$deplib $deplibs"+ continue+ fi+ case $linkmode in+ lib)+ # Linking convenience modules into shared libraries is allowed,+ # but linking other static libraries is non-portable.+ case " $dlpreconveniencelibs " in+ *" $deplib "*) ;;+ *)+ valid_a_lib=false+ case $deplibs_check_method in+ match_pattern*)+ set dummy $deplibs_check_method; shift+ match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`+ if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \+ | $EGREP "$match_pattern_regex" > /dev/null; then+ valid_a_lib=:+ fi+ ;;+ pass_all)+ valid_a_lib=:+ ;;+ esac+ if $valid_a_lib; then+ echo+ $ECHO "*** Warning: Linking the shared library $output against the"+ $ECHO "*** static library $deplib is not portable!"+ deplibs="$deplib $deplibs"+ else+ echo+ $ECHO "*** Warning: Trying to link with static lib archive $deplib."+ echo "*** I have the capability to make that library automatically link in when"+ echo "*** you link to this library. But I can only do this if you have a"+ echo "*** shared version of the library, which you do not appear to have"+ echo "*** because the file extensions .$libext of this argument makes me believe"+ echo "*** that it is just a static archive that I should not use here."+ fi+ ;;+ esac+ continue+ ;;+ prog)+ if test link != "$pass"; then+ deplibs="$deplib $deplibs"+ else+ compile_deplibs="$deplib $compile_deplibs"+ finalize_deplibs="$deplib $finalize_deplibs"+ fi+ continue+ ;;+ esac # linkmode+ ;; # *.$libext+ *.lo | *.$objext)+ if test conv = "$pass"; then+ deplibs="$deplib $deplibs"+ elif test prog = "$linkmode"; then+ if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then+ # If there is no dlopen support or we're linking statically,+ # we need to preload.+ func_append newdlprefiles " $deplib"+ compile_deplibs="$deplib $compile_deplibs"+ finalize_deplibs="$deplib $finalize_deplibs"+ else+ func_append newdlfiles " $deplib"+ fi+ fi+ continue+ ;;+ %DEPLIBS%)+ alldeplibs=:+ continue+ ;;+ esac # case $deplib++ $found || test -f "$lib" \+ || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"++ # Check to see that this really is a libtool archive.+ func_lalib_unsafe_p "$lib" \+ || func_fatal_error "'$lib' is not a valid libtool archive"++ func_dirname "$lib" "" "."+ ladir=$func_dirname_result++ dlname=+ dlopen=+ dlpreopen=+ libdir=+ library_names=+ old_library=+ inherited_linker_flags=+ # If the library was installed with an old release of libtool,+ # it will not redefine variables installed, or shouldnotlink+ installed=yes+ shouldnotlink=no+ avoidtemprpath=+++ # Read the .la file+ func_source "$lib"++ # Convert "-framework foo" to "foo.ltframework"+ if test -n "$inherited_linker_flags"; then+ tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`+ for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do+ case " $new_inherited_linker_flags " in+ *" $tmp_inherited_linker_flag "*) ;;+ *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;+ esac+ done+ fi+ dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`+ if test lib,link = "$linkmode,$pass" ||+ test prog,scan = "$linkmode,$pass" ||+ { test prog != "$linkmode" && test lib != "$linkmode"; }; then+ test -n "$dlopen" && func_append dlfiles " $dlopen"+ test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"+ fi++ if test conv = "$pass"; then+ # Only check for convenience libraries+ deplibs="$lib $deplibs"+ if test -z "$libdir"; then+ if test -z "$old_library"; then+ func_fatal_error "cannot find name of link library for '$lib'"+ fi+ # It is a libtool convenience library, so add in its objects.+ func_append convenience " $ladir/$objdir/$old_library"+ func_append old_convenience " $ladir/$objdir/$old_library"+ elif test prog != "$linkmode" && test lib != "$linkmode"; then+ func_fatal_error "'$lib' is not a convenience library"+ fi+ tmp_libs=+ for deplib in $dependency_libs; do+ deplibs="$deplib $deplibs"+ if $opt_preserve_dup_deps; then+ case "$tmp_libs " in+ *" $deplib "*) func_append specialdeplibs " $deplib" ;;+ esac+ fi+ func_append tmp_libs " $deplib"+ done+ continue+ fi # $pass = conv+++ # Get the name of the library we link against.+ linklib=+ if test -n "$old_library" &&+ { test yes = "$prefer_static_libs" ||+ test built,no = "$prefer_static_libs,$installed"; }; then+ linklib=$old_library+ else+ for l in $old_library $library_names; do+ linklib=$l+ done+ fi+ if test -z "$linklib"; then+ func_fatal_error "cannot find name of link library for '$lib'"+ fi++ # This library was specified with -dlopen.+ if test dlopen = "$pass"; then+ test -z "$libdir" \+ && func_fatal_error "cannot -dlopen a convenience library: '$lib'"+ if test -z "$dlname" ||+ test yes != "$dlopen_support" ||+ test no = "$build_libtool_libs"+ then+ # If there is no dlname, no dlopen support or we're linking+ # statically, we need to preload. We also need to preload any+ # dependent libraries so libltdl's deplib preloader doesn't+ # bomb out in the load deplibs phase.+ func_append dlprefiles " $lib $dependency_libs"+ else+ func_append newdlfiles " $lib"+ fi+ continue+ fi # $pass = dlopen++ # We need an absolute path.+ case $ladir in+ [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;+ *)+ abs_ladir=`cd "$ladir" && pwd`+ if test -z "$abs_ladir"; then+ func_warning "cannot determine absolute directory name of '$ladir'"+ func_warning "passing it literally to the linker, although it might fail"+ abs_ladir=$ladir+ fi+ ;;+ esac+ func_basename "$lib"+ laname=$func_basename_result++ # Find the relevant object directory and library name.+ if test yes = "$installed"; then+ if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then+ func_warning "library '$lib' was moved."+ dir=$ladir+ absdir=$abs_ladir+ libdir=$abs_ladir+ else+ dir=$lt_sysroot$libdir+ absdir=$lt_sysroot$libdir+ fi+ test yes = "$hardcode_automatic" && avoidtemprpath=yes+ else+ if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then+ dir=$ladir+ absdir=$abs_ladir+ # Remove this search path later+ func_append notinst_path " $abs_ladir"+ else+ dir=$ladir/$objdir+ absdir=$abs_ladir/$objdir+ # Remove this search path later+ func_append notinst_path " $abs_ladir"+ fi+ fi # $installed = yes+ func_stripname 'lib' '.la' "$laname"+ name=$func_stripname_result++ # This library was specified with -dlpreopen.+ if test dlpreopen = "$pass"; then+ if test -z "$libdir" && test prog = "$linkmode"; then+ func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"+ fi+ case $host in+ # special handling for platforms with PE-DLLs.+ *cygwin* | *mingw* | *cegcc* )+ # Linker will automatically link against shared library if both+ # static and shared are present. Therefore, ensure we extract+ # symbols from the import library if a shared library is present+ # (otherwise, the dlopen module name will be incorrect). We do+ # this by putting the import library name into $newdlprefiles.+ # We recover the dlopen module name by 'saving' the la file+ # name in a special purpose variable, and (later) extracting the+ # dlname from the la file.+ if test -n "$dlname"; then+ func_tr_sh "$dir/$linklib"+ eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"+ func_append newdlprefiles " $dir/$linklib"+ else+ func_append newdlprefiles " $dir/$old_library"+ # Keep a list of preopened convenience libraries to check+ # that they are being used correctly in the link pass.+ test -z "$libdir" && \+ func_append dlpreconveniencelibs " $dir/$old_library"+ fi+ ;;+ * )+ # Prefer using a static library (so that no silly _DYNAMIC symbols+ # are required to link).+ if test -n "$old_library"; then+ func_append newdlprefiles " $dir/$old_library"+ # Keep a list of preopened convenience libraries to check+ # that they are being used correctly in the link pass.+ test -z "$libdir" && \+ func_append dlpreconveniencelibs " $dir/$old_library"+ # Otherwise, use the dlname, so that lt_dlopen finds it.+ elif test -n "$dlname"; then+ func_append newdlprefiles " $dir/$dlname"+ else+ func_append newdlprefiles " $dir/$linklib"+ fi+ ;;+ esac+ fi # $pass = dlpreopen++ if test -z "$libdir"; then+ # Link the convenience library+ if test lib = "$linkmode"; then+ deplibs="$dir/$old_library $deplibs"+ elif test prog,link = "$linkmode,$pass"; then+ compile_deplibs="$dir/$old_library $compile_deplibs"+ finalize_deplibs="$dir/$old_library $finalize_deplibs"+ else+ deplibs="$lib $deplibs" # used for prog,scan pass+ fi+ continue+ fi+++ if test prog = "$linkmode" && test link != "$pass"; then+ func_append newlib_search_path " $ladir"+ deplibs="$lib $deplibs"++ linkalldeplibs=false+ if test no != "$link_all_deplibs" || test -z "$library_names" ||+ test no = "$build_libtool_libs"; then+ linkalldeplibs=:+ fi++ tmp_libs=+ for deplib in $dependency_libs; do+ case $deplib in+ -L*) func_stripname '-L' '' "$deplib"+ func_resolve_sysroot "$func_stripname_result"+ func_append newlib_search_path " $func_resolve_sysroot_result"+ ;;+ esac+ # Need to link against all dependency_libs?+ if $linkalldeplibs; then+ deplibs="$deplib $deplibs"+ else+ # Need to hardcode shared library paths+ # or/and link against static libraries+ newdependency_libs="$deplib $newdependency_libs"+ fi+ if $opt_preserve_dup_deps; then+ case "$tmp_libs " in+ *" $deplib "*) func_append specialdeplibs " $deplib" ;;+ esac+ fi+ func_append tmp_libs " $deplib"+ done # for deplib+ continue+ fi # $linkmode = prog...++ if test prog,link = "$linkmode,$pass"; then+ if test -n "$library_names" &&+ { { test no = "$prefer_static_libs" ||+ test built,yes = "$prefer_static_libs,$installed"; } ||+ test -z "$old_library"; }; then+ # We need to hardcode the library path+ if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then+ # Make sure the rpath contains only unique directories.+ case $temp_rpath: in+ *"$absdir:"*) ;;+ *) func_append temp_rpath "$absdir:" ;;+ esac+ fi++ # Hardcode the library path.+ # Skip directories that are in the system default run-time+ # search path.+ case " $sys_lib_dlsearch_path " in+ *" $absdir "*) ;;+ *)+ case "$compile_rpath " in+ *" $absdir "*) ;;+ *) func_append compile_rpath " $absdir" ;;+ esac+ ;;+ esac+ case " $sys_lib_dlsearch_path " in+ *" $libdir "*) ;;+ *)+ case "$finalize_rpath " in+ *" $libdir "*) ;;+ *) func_append finalize_rpath " $libdir" ;;+ esac+ ;;+ esac+ fi # $linkmode,$pass = prog,link...++ if $alldeplibs &&+ { test pass_all = "$deplibs_check_method" ||+ { test yes = "$build_libtool_libs" &&+ test -n "$library_names"; }; }; then+ # We only need to search for static libraries+ continue+ fi+ fi++ link_static=no # Whether the deplib will be linked statically+ use_static_libs=$prefer_static_libs+ if test built = "$use_static_libs" && test yes = "$installed"; then+ use_static_libs=no+ fi+ if test -n "$library_names" &&+ { test no = "$use_static_libs" || test -z "$old_library"; }; then+ case $host in+ *cygwin* | *mingw* | *cegcc* | *os2*)+ # No point in relinking DLLs because paths are not encoded+ func_append notinst_deplibs " $lib"+ need_relink=no+ ;;+ *)+ if test no = "$installed"; then+ func_append notinst_deplibs " $lib"+ need_relink=yes+ fi+ ;;+ esac+ # This is a shared library++ # Warn about portability, can't link against -module's on some+ # systems (darwin). Don't bleat about dlopened modules though!+ dlopenmodule=+ for dlpremoduletest in $dlprefiles; do+ if test "X$dlpremoduletest" = "X$lib"; then+ dlopenmodule=$dlpremoduletest+ break+ fi+ done+ if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then+ echo+ if test prog = "$linkmode"; then+ $ECHO "*** Warning: Linking the executable $output against the loadable module"+ else+ $ECHO "*** Warning: Linking the shared library $output against the loadable module"+ fi+ $ECHO "*** $linklib is not portable!"+ fi+ if test lib = "$linkmode" &&+ test yes = "$hardcode_into_libs"; then+ # Hardcode the library path.+ # Skip directories that are in the system default run-time+ # search path.+ case " $sys_lib_dlsearch_path " in+ *" $absdir "*) ;;+ *)+ case "$compile_rpath " in+ *" $absdir "*) ;;+ *) func_append compile_rpath " $absdir" ;;+ esac+ ;;+ esac+ case " $sys_lib_dlsearch_path " in+ *" $libdir "*) ;;+ *)+ case "$finalize_rpath " in+ *" $libdir "*) ;;+ *) func_append finalize_rpath " $libdir" ;;+ esac+ ;;+ esac+ fi++ if test -n "$old_archive_from_expsyms_cmds"; then+ # figure out the soname+ set dummy $library_names+ shift+ realname=$1+ shift+ libname=`eval "\\$ECHO \"$libname_spec\""`+ # use dlname if we got it. it's perfectly good, no?+ if test -n "$dlname"; then+ soname=$dlname+ elif test -n "$soname_spec"; then+ # bleh windows+ case $host in+ *cygwin* | mingw* | *cegcc* | *os2*)+ func_arith $current - $age+ major=$func_arith_result+ versuffix=-$major+ ;;+ esac+ eval soname=\"$soname_spec\"+ else+ soname=$realname+ fi++ # Make a new name for the extract_expsyms_cmds to use+ soroot=$soname+ func_basename "$soroot"+ soname=$func_basename_result+ func_stripname 'lib' '.dll' "$soname"+ newlib=libimp-$func_stripname_result.a++ # If the library has no export list, then create one now+ if test -f "$output_objdir/$soname-def"; then :+ else+ func_verbose "extracting exported symbol list from '$soname'"+ func_execute_cmds "$extract_expsyms_cmds" 'exit $?'+ fi++ # Create $newlib+ if test -f "$output_objdir/$newlib"; then :; else+ func_verbose "generating import library for '$soname'"+ func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'+ fi+ # make sure the library variables are pointing to the new library+ dir=$output_objdir+ linklib=$newlib+ fi # test -n "$old_archive_from_expsyms_cmds"++ if test prog = "$linkmode" || test relink != "$opt_mode"; then+ add_shlibpath=+ add_dir=+ add=+ lib_linked=yes+ case $hardcode_action in+ immediate | unsupported)+ if test no = "$hardcode_direct"; then+ add=$dir/$linklib+ case $host in+ *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;+ *-*-sysv4*uw2*) add_dir=-L$dir ;;+ *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \+ *-*-unixware7*) add_dir=-L$dir ;;+ *-*-darwin* )+ # if the lib is a (non-dlopened) module then we cannot+ # link against it, someone is ignoring the earlier warnings+ if /usr/bin/file -L $add 2> /dev/null |+ $GREP ": [^:]* bundle" >/dev/null; then+ if test "X$dlopenmodule" != "X$lib"; then+ $ECHO "*** Warning: lib $linklib is a module, not a shared library"+ if test -z "$old_library"; then+ echo+ echo "*** And there doesn't seem to be a static archive available"+ echo "*** The link will probably fail, sorry"+ else+ add=$dir/$old_library+ fi+ elif test -n "$old_library"; then+ add=$dir/$old_library+ fi+ fi+ esac+ elif test no = "$hardcode_minus_L"; then+ case $host in+ *-*-sunos*) add_shlibpath=$dir ;;+ esac+ add_dir=-L$dir+ add=-l$name+ elif test no = "$hardcode_shlibpath_var"; then+ add_shlibpath=$dir+ add=-l$name+ else+ lib_linked=no+ fi+ ;;+ relink)+ if test yes = "$hardcode_direct" &&+ test no = "$hardcode_direct_absolute"; then+ add=$dir/$linklib+ elif test yes = "$hardcode_minus_L"; then+ add_dir=-L$absdir+ # Try looking first in the location we're being installed to.+ if test -n "$inst_prefix_dir"; then+ case $libdir in+ [\\/]*)+ func_append add_dir " -L$inst_prefix_dir$libdir"+ ;;+ esac+ fi+ add=-l$name+ elif test yes = "$hardcode_shlibpath_var"; then+ add_shlibpath=$dir+ add=-l$name+ else+ lib_linked=no+ fi+ ;;+ *) lib_linked=no ;;+ esac++ if test yes != "$lib_linked"; then+ func_fatal_configuration "unsupported hardcode properties"+ fi++ if test -n "$add_shlibpath"; then+ case :$compile_shlibpath: in+ *":$add_shlibpath:"*) ;;+ *) func_append compile_shlibpath "$add_shlibpath:" ;;+ esac+ fi+ if test prog = "$linkmode"; then+ test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"+ test -n "$add" && compile_deplibs="$add $compile_deplibs"+ else+ test -n "$add_dir" && deplibs="$add_dir $deplibs"+ test -n "$add" && deplibs="$add $deplibs"+ if test yes != "$hardcode_direct" &&+ test yes != "$hardcode_minus_L" &&+ test yes = "$hardcode_shlibpath_var"; then+ case :$finalize_shlibpath: in+ *":$libdir:"*) ;;+ *) func_append finalize_shlibpath "$libdir:" ;;+ esac+ fi+ fi+ fi++ if test prog = "$linkmode" || test relink = "$opt_mode"; then+ add_shlibpath=+ add_dir=+ add=+ # Finalize command for both is simple: just hardcode it.+ if test yes = "$hardcode_direct" &&+ test no = "$hardcode_direct_absolute"; then+ add=$libdir/$linklib+ elif test yes = "$hardcode_minus_L"; then+ add_dir=-L$libdir+ add=-l$name+ elif test yes = "$hardcode_shlibpath_var"; then+ case :$finalize_shlibpath: in+ *":$libdir:"*) ;;+ *) func_append finalize_shlibpath "$libdir:" ;;+ esac+ add=-l$name+ elif test yes = "$hardcode_automatic"; then+ if test -n "$inst_prefix_dir" &&+ test -f "$inst_prefix_dir$libdir/$linklib"; then+ add=$inst_prefix_dir$libdir/$linklib+ else+ add=$libdir/$linklib+ fi+ else+ # We cannot seem to hardcode it, guess we'll fake it.+ add_dir=-L$libdir+ # Try looking first in the location we're being installed to.+ if test -n "$inst_prefix_dir"; then+ case $libdir in+ [\\/]*)+ func_append add_dir " -L$inst_prefix_dir$libdir"+ ;;+ esac+ fi+ add=-l$name+ fi++ if test prog = "$linkmode"; then+ test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"+ test -n "$add" && finalize_deplibs="$add $finalize_deplibs"+ else+ test -n "$add_dir" && deplibs="$add_dir $deplibs"+ test -n "$add" && deplibs="$add $deplibs"+ fi+ fi+ elif test prog = "$linkmode"; then+ # Here we assume that one of hardcode_direct or hardcode_minus_L+ # is not unsupported. This is valid on all known static and+ # shared platforms.+ if test unsupported != "$hardcode_direct"; then+ test -n "$old_library" && linklib=$old_library+ compile_deplibs="$dir/$linklib $compile_deplibs"+ finalize_deplibs="$dir/$linklib $finalize_deplibs"+ else+ compile_deplibs="-l$name -L$dir $compile_deplibs"+ finalize_deplibs="-l$name -L$dir $finalize_deplibs"+ fi+ elif test yes = "$build_libtool_libs"; then+ # Not a shared library+ if test pass_all != "$deplibs_check_method"; then+ # We're trying link a shared library against a static one+ # but the system doesn't support it.++ # Just print a warning and add the library to dependency_libs so+ # that the program can be linked against the static library.+ echo+ $ECHO "*** Warning: This system cannot link to static lib archive $lib."+ echo "*** I have the capability to make that library automatically link in when"+ echo "*** you link to this library. But I can only do this if you have a"+ echo "*** shared version of the library, which you do not appear to have."+ if test yes = "$module"; then+ echo "*** But as you try to build a module library, libtool will still create "+ echo "*** a static module, that should work as long as the dlopening application"+ echo "*** is linked with the -dlopen flag to resolve symbols at runtime."+ if test -z "$global_symbol_pipe"; then+ echo+ echo "*** However, this would only work if libtool was able to extract symbol"+ echo "*** lists from a program, using 'nm' or equivalent, but libtool could"+ echo "*** not find such a program. So, this module is probably useless."+ echo "*** 'nm' from GNU binutils and a full rebuild may help."+ fi+ if test no = "$build_old_libs"; then+ build_libtool_libs=module+ build_old_libs=yes+ else+ build_libtool_libs=no+ fi+ fi+ else+ deplibs="$dir/$old_library $deplibs"+ link_static=yes+ fi+ fi # link shared/static library?++ if test lib = "$linkmode"; then+ if test -n "$dependency_libs" &&+ { test yes != "$hardcode_into_libs" ||+ test yes = "$build_old_libs" ||+ test yes = "$link_static"; }; then+ # Extract -R from dependency_libs+ temp_deplibs=+ for libdir in $dependency_libs; do+ case $libdir in+ -R*) func_stripname '-R' '' "$libdir"+ temp_xrpath=$func_stripname_result+ case " $xrpath " in+ *" $temp_xrpath "*) ;;+ *) func_append xrpath " $temp_xrpath";;+ esac;;+ *) func_append temp_deplibs " $libdir";;+ esac+ done+ dependency_libs=$temp_deplibs+ fi++ func_append newlib_search_path " $absdir"+ # Link against this library+ test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"+ # ... and its dependency_libs+ tmp_libs=+ for deplib in $dependency_libs; do+ newdependency_libs="$deplib $newdependency_libs"+ case $deplib in+ -L*) func_stripname '-L' '' "$deplib"+ func_resolve_sysroot "$func_stripname_result";;+ *) func_resolve_sysroot "$deplib" ;;+ esac+ if $opt_preserve_dup_deps; then+ case "$tmp_libs " in+ *" $func_resolve_sysroot_result "*)+ func_append specialdeplibs " $func_resolve_sysroot_result" ;;+ esac+ fi+ func_append tmp_libs " $func_resolve_sysroot_result"+ done++ if test no != "$link_all_deplibs"; then+ # Add the search paths of all dependency libraries+ for deplib in $dependency_libs; do+ path=+ case $deplib in+ -L*) path=$deplib ;;+ *.la)+ func_resolve_sysroot "$deplib"+ deplib=$func_resolve_sysroot_result+ func_dirname "$deplib" "" "."+ dir=$func_dirname_result+ # We need an absolute path.+ case $dir in+ [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;+ *)+ absdir=`cd "$dir" && pwd`+ if test -z "$absdir"; then+ func_warning "cannot determine absolute directory name of '$dir'"+ absdir=$dir+ fi+ ;;+ esac+ if $GREP "^installed=no" $deplib > /dev/null; then+ case $host in+ *-*-darwin*)+ depdepl=+ eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`+ if test -n "$deplibrary_names"; then+ for tmp in $deplibrary_names; do+ depdepl=$tmp+ done+ if test -f "$absdir/$objdir/$depdepl"; then+ depdepl=$absdir/$objdir/$depdepl+ darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`+ if test -z "$darwin_install_name"; then+ darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`+ fi+ func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"+ func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"+ path=+ fi+ fi+ ;;+ *)+ path=-L$absdir/$objdir+ ;;+ esac+ else+ eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`+ test -z "$libdir" && \+ func_fatal_error "'$deplib' is not a valid libtool archive"+ test "$absdir" != "$libdir" && \+ func_warning "'$deplib' seems to be moved"++ path=-L$absdir+ fi+ ;;+ esac+ case " $deplibs " in+ *" $path "*) ;;+ *) deplibs="$path $deplibs" ;;+ esac+ done+ fi # link_all_deplibs != no+ fi # linkmode = lib+ done # for deplib in $libs+ if test link = "$pass"; then+ if test prog = "$linkmode"; then+ compile_deplibs="$new_inherited_linker_flags $compile_deplibs"+ finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"+ else+ compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`+ fi+ fi+ dependency_libs=$newdependency_libs+ if test dlpreopen = "$pass"; then+ # Link the dlpreopened libraries before other libraries+ for deplib in $save_deplibs; do+ deplibs="$deplib $deplibs"+ done+ fi+ if test dlopen != "$pass"; then+ test conv = "$pass" || {+ # Make sure lib_search_path contains only unique directories.+ lib_search_path=+ for dir in $newlib_search_path; do+ case "$lib_search_path " in+ *" $dir "*) ;;+ *) func_append lib_search_path " $dir" ;;+ esac+ done+ newlib_search_path=+ }++ if test prog,link = "$linkmode,$pass"; then+ vars="compile_deplibs finalize_deplibs"+ else+ vars=deplibs+ fi+ for var in $vars dependency_libs; do+ # Add libraries to $var in reverse order+ eval tmp_libs=\"\$$var\"+ new_libs=+ for deplib in $tmp_libs; do+ # FIXME: Pedantically, this is the right thing to do, so+ # that some nasty dependency loop isn't accidentally+ # broken:+ #new_libs="$deplib $new_libs"+ # Pragmatically, this seems to cause very few problems in+ # practice:+ case $deplib in+ -L*) new_libs="$deplib $new_libs" ;;+ -R*) ;;+ *)+ # And here is the reason: when a library appears more+ # than once as an explicit dependence of a library, or+ # is implicitly linked in more than once by the+ # compiler, it is considered special, and multiple+ # occurrences thereof are not removed. Compare this+ # with having the same library being listed as a+ # dependency of multiple other libraries: in this case,+ # we know (pedantically, we assume) the library does not+ # need to be listed more than once, so we keep only the+ # last copy. This is not always right, but it is rare+ # enough that we require users that really mean to play+ # such unportable linking tricks to link the library+ # using -Wl,-lname, so that libtool does not consider it+ # for duplicate removal.+ case " $specialdeplibs " in+ *" $deplib "*) new_libs="$deplib $new_libs" ;;+ *)+ case " $new_libs " in+ *" $deplib "*) ;;+ *) new_libs="$deplib $new_libs" ;;+ esac+ ;;+ esac+ ;;+ esac+ done+ tmp_libs=+ for deplib in $new_libs; do+ case $deplib in+ -L*)+ case " $tmp_libs " in+ *" $deplib "*) ;;+ *) func_append tmp_libs " $deplib" ;;+ esac+ ;;+ *) func_append tmp_libs " $deplib" ;;+ esac+ done+ eval $var=\"$tmp_libs\"+ done # for var+ fi++ # Add Sun CC postdeps if required:+ test CXX = "$tagname" && {+ case $host_os in+ linux*)+ case `$CC -V 2>&1 | $SED 5q` in+ *Sun\ C*) # Sun C++ 5.9+ func_suncc_cstd_abi++ if test no != "$suncc_use_cstd_abi"; then+ func_append postdeps ' -library=Cstd -library=Crun'+ fi+ ;;+ esac+ ;;++ solaris*)+ func_cc_basename "$CC"+ case $func_cc_basename_result in+ CC* | sunCC*)+ func_suncc_cstd_abi++ if test no != "$suncc_use_cstd_abi"; then+ func_append postdeps ' -library=Cstd -library=Crun'+ fi+ ;;+ esac+ ;;+ esac+ }++ # Last step: remove runtime libs from dependency_libs+ # (they stay in deplibs)+ tmp_libs=+ for i in $dependency_libs; do+ case " $predeps $postdeps $compiler_lib_search_path " in+ *" $i "*)+ i=+ ;;+ esac+ if test -n "$i"; then+ func_append tmp_libs " $i"+ fi+ done+ dependency_libs=$tmp_libs+ done # for pass+ if test prog = "$linkmode"; then+ dlfiles=$newdlfiles+ fi+ if test prog = "$linkmode" || test lib = "$linkmode"; then+ dlprefiles=$newdlprefiles+ fi++ case $linkmode in+ oldlib)+ if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then+ func_warning "'-dlopen' is ignored for archives"+ fi++ case " $deplibs" in+ *\ -l* | *\ -L*)+ func_warning "'-l' and '-L' are ignored for archives" ;;+ esac++ test -n "$rpath" && \+ func_warning "'-rpath' is ignored for archives"++ test -n "$xrpath" && \+ func_warning "'-R' is ignored for archives"++ test -n "$vinfo" && \+ func_warning "'-version-info/-version-number' is ignored for archives"++ test -n "$release" && \+ func_warning "'-release' is ignored for archives"++ test -n "$export_symbols$export_symbols_regex" && \+ func_warning "'-export-symbols' is ignored for archives"++ # Now set the variables for building old libraries.+ build_libtool_libs=no+ oldlibs=$output+ func_append objs "$old_deplibs"+ ;;++ lib)+ # Make sure we only generate libraries of the form 'libNAME.la'.+ case $outputname in+ lib*)+ func_stripname 'lib' '.la' "$outputname"+ name=$func_stripname_result+ eval shared_ext=\"$shrext_cmds\"+ eval libname=\"$libname_spec\"+ ;;+ *)+ test no = "$module" \+ && func_fatal_help "libtool library '$output' must begin with 'lib'"++ if test no != "$need_lib_prefix"; then+ # Add the "lib" prefix for modules if required+ func_stripname '' '.la' "$outputname"+ name=$func_stripname_result+ eval shared_ext=\"$shrext_cmds\"+ eval libname=\"$libname_spec\"+ else+ func_stripname '' '.la' "$outputname"+ libname=$func_stripname_result+ fi+ ;;+ esac++ if test -n "$objs"; then+ if test pass_all != "$deplibs_check_method"; then+ func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"+ else+ echo+ $ECHO "*** Warning: Linking the shared library $output against the non-libtool"+ $ECHO "*** objects $objs is not portable!"+ func_append libobjs " $objs"+ fi+ fi++ test no = "$dlself" \+ || func_warning "'-dlopen self' is ignored for libtool libraries"++ set dummy $rpath+ shift+ test 1 -lt "$#" \+ && func_warning "ignoring multiple '-rpath's for a libtool library"++ install_libdir=$1++ oldlibs=+ if test -z "$rpath"; then+ if test yes = "$build_libtool_libs"; then+ # Building a libtool convenience library.+ # Some compilers have problems with a '.al' extension so+ # convenience libraries should have the same extension an+ # archive normally would.+ oldlibs="$output_objdir/$libname.$libext $oldlibs"+ build_libtool_libs=convenience+ build_old_libs=yes+ fi++ test -n "$vinfo" && \+ func_warning "'-version-info/-version-number' is ignored for convenience libraries"++ test -n "$release" && \+ func_warning "'-release' is ignored for convenience libraries"+ else++ # Parse the version information argument.+ save_ifs=$IFS; IFS=:+ set dummy $vinfo 0 0 0+ shift+ IFS=$save_ifs++ test -n "$7" && \+ func_fatal_help "too many parameters to '-version-info'"++ # convert absolute version numbers to libtool ages+ # this retains compatibility with .la files and attempts+ # to make the code below a bit more comprehensible++ case $vinfo_number in+ yes)+ number_major=$1+ number_minor=$2+ number_revision=$3+ #+ # There are really only two kinds -- those that+ # use the current revision as the major version+ # and those that subtract age and use age as+ # a minor version. But, then there is irix+ # that has an extra 1 added just for fun+ #+ case $version_type in+ # correct linux to gnu/linux during the next big refactor+ darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none)+ func_arith $number_major + $number_minor+ current=$func_arith_result+ age=$number_minor+ revision=$number_revision+ ;;+ freebsd-aout|qnx|sunos)+ current=$number_major+ revision=$number_minor+ age=0+ ;;+ irix|nonstopux)+ func_arith $number_major + $number_minor+ current=$func_arith_result+ age=$number_minor+ revision=$number_minor+ lt_irix_increment=no+ ;;+ esac+ ;;+ no)+ current=$1+ revision=$2+ age=$3+ ;;+ esac++ # Check that each of the things are valid numbers.+ case $current in+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;+ *)+ func_error "CURRENT '$current' must be a nonnegative integer"+ func_fatal_error "'$vinfo' is not valid version information"+ ;;+ esac++ case $revision in+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;+ *)+ func_error "REVISION '$revision' must be a nonnegative integer"+ func_fatal_error "'$vinfo' is not valid version information"+ ;;+ esac++ case $age in+ 0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;+ *)+ func_error "AGE '$age' must be a nonnegative integer"+ func_fatal_error "'$vinfo' is not valid version information"+ ;;+ esac++ if test "$age" -gt "$current"; then+ func_error "AGE '$age' is greater than the current interface number '$current'"+ func_fatal_error "'$vinfo' is not valid version information"+ fi++ # Calculate the version variables.+ major=+ versuffix=+ verstring=+ case $version_type in+ none) ;;++ darwin)+ # Like Linux, but with the current version available in+ # verstring for coding it into the library header+ func_arith $current - $age+ major=.$func_arith_result+ versuffix=$major.$age.$revision+ # Darwin ld doesn't like 0 for these options...+ func_arith $current + 1+ minor_current=$func_arith_result+ xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"+ verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"+ # On Darwin other compilers+ case $CC in+ nagfor*)+ verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"+ ;;+ *)+ verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"+ ;;+ esac+ ;;++ freebsd-aout)+ major=.$current+ versuffix=.$current.$revision+ ;;++ freebsd-elf | midnightbsd-elf)+ func_arith $current - $age+ major=.$func_arith_result+ versuffix=$major.$age.$revision+ ;;++ irix | nonstopux)+ if test no = "$lt_irix_increment"; then+ func_arith $current - $age+ else+ func_arith $current - $age + 1+ fi+ major=$func_arith_result++ case $version_type in+ nonstopux) verstring_prefix=nonstopux ;;+ *) verstring_prefix=sgi ;;+ esac+ verstring=$verstring_prefix$major.$revision++ # Add in all the interfaces that we are compatible with.+ loop=$revision+ while test 0 -ne "$loop"; do+ func_arith $revision - $loop+ iface=$func_arith_result+ func_arith $loop - 1+ loop=$func_arith_result+ verstring=$verstring_prefix$major.$iface:$verstring+ done++ # Before this point, $major must not contain '.'.+ major=.$major+ versuffix=$major.$revision+ ;;++ linux) # correct to gnu/linux during the next big refactor+ func_arith $current - $age+ major=.$func_arith_result+ versuffix=$major.$age.$revision+ ;;++ osf)+ func_arith $current - $age+ major=.$func_arith_result+ versuffix=.$current.$age.$revision+ verstring=$current.$age.$revision++ # Add in all the interfaces that we are compatible with.+ loop=$age+ while test 0 -ne "$loop"; do+ func_arith $current - $loop+ iface=$func_arith_result+ func_arith $loop - 1+ loop=$func_arith_result+ verstring=$verstring:$iface.0+ done++ # Make executables depend on our current version.+ func_append verstring ":$current.0"+ ;;++ qnx)+ major=.$current+ versuffix=.$current+ ;;++ sco)+ major=.$current+ versuffix=.$current+ ;;++ sunos)+ major=.$current+ versuffix=.$current.$revision+ ;;++ windows)+ # Use '-' rather than '.', since we only want one+ # extension on DOS 8.3 file systems.+ func_arith $current - $age+ major=$func_arith_result+ versuffix=-$major+ ;;++ *)+ func_fatal_configuration "unknown library version type '$version_type'"+ ;;+ esac++ # Clear the version info if we defaulted, and they specified a release.+ if test -z "$vinfo" && test -n "$release"; then+ major=+ case $version_type in+ darwin)+ # we can't check for "0.0" in archive_cmds due to quoting+ # problems, so we reset it completely+ verstring=+ ;;+ *)+ verstring=0.0+ ;;+ esac+ if test no = "$need_version"; then+ versuffix=+ else+ versuffix=.0.0+ fi+ fi++ # Remove version info from name if versioning should be avoided+ if test yes,no = "$avoid_version,$need_version"; then+ major=+ versuffix=+ verstring=+ fi++ # Check to see if the archive will have undefined symbols.+ if test yes = "$allow_undefined"; then+ if test unsupported = "$allow_undefined_flag"; then+ if test yes = "$build_old_libs"; then+ func_warning "undefined symbols not allowed in $host shared libraries; building static only"+ build_libtool_libs=no+ else+ func_fatal_error "can't build $host shared library unless -no-undefined is specified"+ fi+ fi+ else+ # Don't allow undefined symbols.+ allow_undefined_flag=$no_undefined_flag+ fi++ fi++ func_generate_dlsyms "$libname" "$libname" :+ func_append libobjs " $symfileobj"+ test " " = "$libobjs" && libobjs=++ if test relink != "$opt_mode"; then+ # Remove our outputs, but don't remove object files since they+ # may have been created when compiling PIC objects.+ removelist=+ tempremovelist=`$ECHO "$output_objdir/*"`+ for p in $tempremovelist; do+ case $p in+ *.$objext | *.gcno)+ ;;+ $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)+ if test -n "$precious_files_regex"; then+ if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1+ then+ continue+ fi+ fi+ func_append removelist " $p"+ ;;+ *) ;;+ esac+ done+ test -n "$removelist" && \+ func_show_eval "${RM}r \$removelist"+ fi++ # Now set the variables for building old libraries.+ if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then+ func_append oldlibs " $output_objdir/$libname.$libext"++ # Transform .lo files to .o files.+ oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`+ fi++ # Eliminate all temporary directories.+ #for path in $notinst_path; do+ # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`+ # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`+ # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`+ #done++ if test -n "$xrpath"; then+ # If the user specified any rpath flags, then add them.+ temp_xrpath=+ for libdir in $xrpath; do+ func_replace_sysroot "$libdir"+ func_append temp_xrpath " -R$func_replace_sysroot_result"+ case "$finalize_rpath " in+ *" $libdir "*) ;;+ *) func_append finalize_rpath " $libdir" ;;+ esac+ done+ if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then+ dependency_libs="$temp_xrpath $dependency_libs"+ fi+ fi++ # Make sure dlfiles contains only unique files that won't be dlpreopened+ old_dlfiles=$dlfiles+ dlfiles=+ for lib in $old_dlfiles; do+ case " $dlprefiles $dlfiles " in+ *" $lib "*) ;;+ *) func_append dlfiles " $lib" ;;+ esac+ done++ # Make sure dlprefiles contains only unique files+ old_dlprefiles=$dlprefiles+ dlprefiles=+ for lib in $old_dlprefiles; do+ case "$dlprefiles " in+ *" $lib "*) ;;+ *) func_append dlprefiles " $lib" ;;+ esac+ done++ if test yes = "$build_libtool_libs"; then+ if test -n "$rpath"; then+ case $host in+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)+ # these systems don't actually have a c library (as such)!+ ;;+ *-*-rhapsody* | *-*-darwin1.[012])+ # Rhapsody C library is in the System framework+ func_append deplibs " System.ltframework"+ ;;+ *-*-netbsd*)+ # Don't link with libc until the a.out ld.so is fixed.+ ;;+ *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)+ # Do not include libc due to us having libc/libc_r.+ ;;+ *-*-sco3.2v5* | *-*-sco5v6*)+ # Causes problems with __ctype+ ;;+ *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)+ # Compiler inserts libc in the correct place for threads to work+ ;;+ *)+ # Add libc to deplibs on all other systems if necessary.+ if test yes = "$build_libtool_need_lc"; then+ func_append deplibs " -lc"+ fi+ ;;+ esac+ fi++ # Transform deplibs into only deplibs that can be linked in shared.+ name_save=$name+ libname_save=$libname+ release_save=$release+ versuffix_save=$versuffix+ major_save=$major+ # I'm not sure if I'm treating the release correctly. I think+ # release should show up in the -l (ie -lgmp5) so we don't want to+ # add it in twice. Is that correct?+ release=+ versuffix=+ major=+ newdeplibs=+ droppeddeps=no+ case $deplibs_check_method in+ pass_all)+ # Don't check for shared/static. Everything works.+ # This might be a little naive. We might want to check+ # whether the library exists or not. But this is on+ # osf3 & osf4 and I'm not really sure... Just+ # implementing what was already the behavior.+ newdeplibs=$deplibs+ ;;+ test_compile)+ # This code stresses the "libraries are programs" paradigm to its+ # limits. Maybe even breaks it. We compile a program, linking it+ # against the deplibs as a proxy for the library. Then we can check+ # whether they linked in statically or dynamically with ldd.+ $opt_dry_run || $RM conftest.c+ cat > conftest.c <<EOF+ int main() { return 0; }+EOF+ $opt_dry_run || $RM conftest+ if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then+ ldd_output=`ldd conftest`+ for i in $deplibs; do+ case $i in+ -l*)+ func_stripname -l '' "$i"+ name=$func_stripname_result+ if test yes = "$allow_libtool_libs_with_static_runtimes"; then+ case " $predeps $postdeps " in+ *" $i "*)+ func_append newdeplibs " $i"+ i=+ ;;+ esac+ fi+ if test -n "$i"; then+ libname=`eval "\\$ECHO \"$libname_spec\""`+ deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`+ set dummy $deplib_matches; shift+ deplib_match=$1+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then+ func_append newdeplibs " $i"+ else+ droppeddeps=yes+ echo+ $ECHO "*** Warning: dynamic linker does not accept needed library $i."+ echo "*** I have the capability to make that library automatically link in when"+ echo "*** you link to this library. But I can only do this if you have a"+ echo "*** shared version of the library, which I believe you do not have"+ echo "*** because a test_compile did reveal that the linker did not use it for"+ echo "*** its dynamic dependency list that programs get resolved with at runtime."+ fi+ fi+ ;;+ *)+ func_append newdeplibs " $i"+ ;;+ esac+ done+ else+ # Error occurred in the first compile. Let's try to salvage+ # the situation: Compile a separate program for each library.+ for i in $deplibs; do+ case $i in+ -l*)+ func_stripname -l '' "$i"+ name=$func_stripname_result+ $opt_dry_run || $RM conftest+ if $LTCC $LTCFLAGS -o conftest conftest.c $i; then+ ldd_output=`ldd conftest`+ if test yes = "$allow_libtool_libs_with_static_runtimes"; then+ case " $predeps $postdeps " in+ *" $i "*)+ func_append newdeplibs " $i"+ i=+ ;;+ esac+ fi+ if test -n "$i"; then+ libname=`eval "\\$ECHO \"$libname_spec\""`+ deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`+ set dummy $deplib_matches; shift+ deplib_match=$1+ if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then+ func_append newdeplibs " $i"+ else+ droppeddeps=yes+ echo+ $ECHO "*** Warning: dynamic linker does not accept needed library $i."+ echo "*** I have the capability to make that library automatically link in when"+ echo "*** you link to this library. But I can only do this if you have a"+ echo "*** shared version of the library, which you do not appear to have"+ echo "*** because a test_compile did reveal that the linker did not use this one"+ echo "*** as a dynamic dependency that programs can get resolved with at runtime."+ fi+ fi+ else+ droppeddeps=yes+ echo+ $ECHO "*** Warning! Library $i is needed by this library but I was not able to"+ echo "*** make it link in! You will probably need to install it or some"+ echo "*** library that it depends on before this library will be fully"+ echo "*** functional. Installing it before continuing would be even better."+ fi+ ;;+ *)+ func_append newdeplibs " $i"+ ;;+ esac+ done+ fi+ ;;+ file_magic*)+ set dummy $deplibs_check_method; shift+ file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`+ for a_deplib in $deplibs; do+ case $a_deplib in+ -l*)+ func_stripname -l '' "$a_deplib"+ name=$func_stripname_result+ if test yes = "$allow_libtool_libs_with_static_runtimes"; then+ case " $predeps $postdeps " in+ *" $a_deplib "*)+ func_append newdeplibs " $a_deplib"+ a_deplib=+ ;;+ esac+ fi+ if test -n "$a_deplib"; then+ libname=`eval "\\$ECHO \"$libname_spec\""`+ if test -n "$file_magic_glob"; then+ libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`+ else+ libnameglob=$libname+ fi+ test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do+ if test yes = "$want_nocaseglob"; then+ shopt -s nocaseglob+ potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`+ $nocaseglob+ else+ potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`+ fi+ for potent_lib in $potential_libs; do+ # Follow soft links.+ if ls -lLd "$potent_lib" 2>/dev/null |+ $GREP " -> " >/dev/null; then+ continue+ fi+ # The statement above tries to avoid entering an+ # endless loop below, in case of cyclic links.+ # We might still enter an endless loop, since a link+ # loop can be closed while we follow links,+ # but so what?+ potlib=$potent_lib+ while test -h "$potlib" 2>/dev/null; do+ potliblink=`ls -ld $potlib | $SED 's/.* -> //'`+ case $potliblink in+ [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;+ *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;+ esac+ done+ if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |+ $SED -e 10q |+ $EGREP "$file_magic_regex" > /dev/null; then+ func_append newdeplibs " $a_deplib"+ a_deplib=+ break 2+ fi+ done+ done+ fi+ if test -n "$a_deplib"; then+ droppeddeps=yes+ echo+ $ECHO "*** Warning: linker path does not have real file for library $a_deplib."+ echo "*** I have the capability to make that library automatically link in when"+ echo "*** you link to this library. But I can only do this if you have a"+ echo "*** shared version of the library, which you do not appear to have"+ echo "*** because I did check the linker path looking for a file starting"+ if test -z "$potlib"; then+ $ECHO "*** with $libname but no candidates were found. (...for file magic test)"+ else+ $ECHO "*** with $libname and none of the candidates passed a file format test"+ $ECHO "*** using a file magic. Last file checked: $potlib"+ fi+ fi+ ;;+ *)+ # Add a -L argument.+ func_append newdeplibs " $a_deplib"+ ;;+ esac+ done # Gone through all deplibs.+ ;;+ match_pattern*)+ set dummy $deplibs_check_method; shift+ match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`+ for a_deplib in $deplibs; do+ case $a_deplib in+ -l*)+ func_stripname -l '' "$a_deplib"+ name=$func_stripname_result+ if test yes = "$allow_libtool_libs_with_static_runtimes"; then+ case " $predeps $postdeps " in+ *" $a_deplib "*)+ func_append newdeplibs " $a_deplib"+ a_deplib=+ ;;+ esac+ fi+ if test -n "$a_deplib"; then+ libname=`eval "\\$ECHO \"$libname_spec\""`+ for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do+ potential_libs=`ls $i/$libname[.-]* 2>/dev/null`+ for potent_lib in $potential_libs; do+ potlib=$potent_lib # see symlink-check above in file_magic test+ if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \+ $EGREP "$match_pattern_regex" > /dev/null; then+ func_append newdeplibs " $a_deplib"+ a_deplib=+ break 2+ fi+ done+ done+ fi+ if test -n "$a_deplib"; then+ droppeddeps=yes+ echo+ $ECHO "*** Warning: linker path does not have real file for library $a_deplib."+ echo "*** I have the capability to make that library automatically link in when"+ echo "*** you link to this library. But I can only do this if you have a"+ echo "*** shared version of the library, which you do not appear to have"+ echo "*** because I did check the linker path looking for a file starting"+ if test -z "$potlib"; then+ $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"+ else+ $ECHO "*** with $libname and none of the candidates passed a file format test"+ $ECHO "*** using a regex pattern. Last file checked: $potlib"+ fi+ fi+ ;;+ *)+ # Add a -L argument.+ func_append newdeplibs " $a_deplib"+ ;;+ esac+ done # Gone through all deplibs.+ ;;+ none | unknown | *)+ newdeplibs=+ tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`+ if test yes = "$allow_libtool_libs_with_static_runtimes"; then+ for i in $predeps $postdeps; do+ # can't use Xsed below, because $i might contain '/'+ tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`+ done+ fi+ case $tmp_deplibs in+ *[!\ \ ]*)+ echo+ if test none = "$deplibs_check_method"; then+ echo "*** Warning: inter-library dependencies are not supported in this platform."+ else+ echo "*** Warning: inter-library dependencies are not known to be supported."+ fi+ echo "*** All declared inter-library dependencies are being dropped."+ droppeddeps=yes+ ;;+ esac+ ;;+ esac+ versuffix=$versuffix_save+ major=$major_save+ release=$release_save+ libname=$libname_save+ name=$name_save++ case $host in+ *-*-rhapsody* | *-*-darwin1.[012])+ # On Rhapsody replace the C library with the System framework+ newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`+ ;;+ esac++ if test yes = "$droppeddeps"; then+ if test yes = "$module"; then+ echo+ echo "*** Warning: libtool could not satisfy all declared inter-library"+ $ECHO "*** dependencies of module $libname. Therefore, libtool will create"+ echo "*** a static module, that should work as long as the dlopening"+ echo "*** application is linked with the -dlopen flag."+ if test -z "$global_symbol_pipe"; then+ echo+ echo "*** However, this would only work if libtool was able to extract symbol"+ echo "*** lists from a program, using 'nm' or equivalent, but libtool could"+ echo "*** not find such a program. So, this module is probably useless."+ echo "*** 'nm' from GNU binutils and a full rebuild may help."+ fi+ if test no = "$build_old_libs"; then+ oldlibs=$output_objdir/$libname.$libext+ build_libtool_libs=module+ build_old_libs=yes+ else+ build_libtool_libs=no+ fi+ else+ echo "*** The inter-library dependencies that have been dropped here will be"+ echo "*** automatically added whenever a program is linked with this library"+ echo "*** or is declared to -dlopen it."++ if test no = "$allow_undefined"; then+ echo+ echo "*** Since this library must not contain undefined symbols,"+ echo "*** because either the platform does not support them or"+ echo "*** it was explicitly requested with -no-undefined,"+ echo "*** libtool will only create a static version of it."+ if test no = "$build_old_libs"; then+ oldlibs=$output_objdir/$libname.$libext+ build_libtool_libs=module+ build_old_libs=yes+ else+ build_libtool_libs=no+ fi+ fi+ fi+ fi+ # Done checking deplibs!+ deplibs=$newdeplibs+ fi+ # Time to change all our "foo.ltframework" stuff back to "-framework foo"+ case $host in+ *-*-darwin*)+ newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`+ new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`+ deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`+ ;;+ esac++ # move library search paths that coincide with paths to not yet+ # installed libraries to the beginning of the library search list+ new_libs=+ for path in $notinst_path; do+ case " $new_libs " in+ *" -L$path/$objdir "*) ;;+ *)+ case " $deplibs " in+ *" -L$path/$objdir "*)+ func_append new_libs " -L$path/$objdir" ;;+ esac+ ;;+ esac+ done+ for deplib in $deplibs; do+ case $deplib in+ -L*)+ case " $new_libs " in+ *" $deplib "*) ;;+ *) func_append new_libs " $deplib" ;;+ esac+ ;;+ *) func_append new_libs " $deplib" ;;+ esac+ done+ deplibs=$new_libs++ # All the library-specific variables (install_libdir is set above).+ library_names=+ old_library=+ dlname=++ # Test again, we may have decided not to build it any more+ if test yes = "$build_libtool_libs"; then+ # Remove $wl instances when linking with ld.+ # FIXME: should test the right _cmds variable.+ case $archive_cmds in+ *\$LD\ *) wl= ;;+ esac+ if test yes = "$hardcode_into_libs"; then+ # Hardcode the library paths+ hardcode_libdirs=+ dep_rpath=+ rpath=$finalize_rpath+ test relink = "$opt_mode" || rpath=$compile_rpath$rpath+ for libdir in $rpath; do+ if test -n "$hardcode_libdir_flag_spec"; then+ if test -n "$hardcode_libdir_separator"; then+ func_replace_sysroot "$libdir"+ libdir=$func_replace_sysroot_result+ if test -z "$hardcode_libdirs"; then+ hardcode_libdirs=$libdir+ else+ # Just accumulate the unique libdirs.+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)+ ;;+ *)+ func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"+ ;;+ esac+ fi+ else+ eval flag=\"$hardcode_libdir_flag_spec\"+ func_append dep_rpath " $flag"+ fi+ elif test -n "$runpath_var"; then+ case "$perm_rpath " in+ *" $libdir "*) ;;+ *) func_append perm_rpath " $libdir" ;;+ esac+ fi+ done+ # Substitute the hardcoded libdirs into the rpath.+ if test -n "$hardcode_libdir_separator" &&+ test -n "$hardcode_libdirs"; then+ libdir=$hardcode_libdirs+ eval "dep_rpath=\"$hardcode_libdir_flag_spec\""+ fi+ if test -n "$runpath_var" && test -n "$perm_rpath"; then+ # We should set the runpath_var.+ rpath=+ for dir in $perm_rpath; do+ func_append rpath "$dir:"+ done+ eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"+ fi+ test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"+ fi++ shlibpath=$finalize_shlibpath+ test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath+ if test -n "$shlibpath"; then+ eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"+ fi++ # Get the real and link names of the library.+ eval shared_ext=\"$shrext_cmds\"+ eval library_names=\"$library_names_spec\"+ set dummy $library_names+ shift+ realname=$1+ shift++ if test -n "$soname_spec"; then+ eval soname=\"$soname_spec\"+ else+ soname=$realname+ fi+ if test -z "$dlname"; then+ dlname=$soname+ fi++ lib=$output_objdir/$realname+ linknames=+ for link+ do+ func_append linknames " $link"+ done++ # Use standard objects if they are pic+ test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`+ test "X$libobjs" = "X " && libobjs=++ delfiles=+ if test -n "$export_symbols" && test -n "$include_expsyms"; then+ $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"+ export_symbols=$output_objdir/$libname.uexp+ func_append delfiles " $export_symbols"+ fi++ orig_export_symbols=+ case $host_os in+ cygwin* | mingw* | cegcc*)+ if test -n "$export_symbols" && test -z "$export_symbols_regex"; then+ # exporting using user supplied symfile+ func_dll_def_p "$export_symbols" || {+ # and it's NOT already a .def file. Must figure out+ # which of the given symbols are data symbols and tag+ # them as such. So, trigger use of export_symbols_cmds.+ # export_symbols gets reassigned inside the "prepare+ # the list of exported symbols" if statement, so the+ # include_expsyms logic still works.+ orig_export_symbols=$export_symbols+ export_symbols=+ always_export_symbols=yes+ }+ fi+ ;;+ esac++ # Prepare the list of exported symbols+ if test -z "$export_symbols"; then+ if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then+ func_verbose "generating symbol list for '$libname.la'"+ export_symbols=$output_objdir/$libname.exp+ $opt_dry_run || $RM $export_symbols+ cmds=$export_symbols_cmds+ save_ifs=$IFS; IFS='~'+ for cmd1 in $cmds; do+ IFS=$save_ifs+ # Take the normal branch if the nm_file_list_spec branch+ # doesn't work or if tool conversion is not needed.+ case $nm_file_list_spec~$to_tool_file_cmd in+ *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)+ try_normal_branch=yes+ eval cmd=\"$cmd1\"+ func_len " $cmd"+ len=$func_len_result+ ;;+ *)+ try_normal_branch=no+ ;;+ esac+ if test yes = "$try_normal_branch" \+ && { test "$len" -lt "$max_cmd_len" \+ || test "$max_cmd_len" -le -1; }+ then+ func_show_eval "$cmd" 'exit $?'+ skipped_export=false+ elif test -n "$nm_file_list_spec"; then+ func_basename "$output"+ output_la=$func_basename_result+ save_libobjs=$libobjs+ save_output=$output+ output=$output_objdir/$output_la.nm+ func_to_tool_file "$output"+ libobjs=$nm_file_list_spec$func_to_tool_file_result+ func_append delfiles " $output"+ func_verbose "creating $NM input file list: $output"+ for obj in $save_libobjs; do+ func_to_tool_file "$obj"+ $ECHO "$func_to_tool_file_result"+ done > "$output"+ eval cmd=\"$cmd1\"+ func_show_eval "$cmd" 'exit $?'+ output=$save_output+ libobjs=$save_libobjs+ skipped_export=false+ else+ # The command line is too long to execute in one step.+ func_verbose "using reloadable object file for export list..."+ skipped_export=:+ # Break out early, otherwise skipped_export may be+ # set to false by a later but shorter cmd.+ break+ fi+ done+ IFS=$save_ifs+ if test -n "$export_symbols_regex" && test : != "$skipped_export"; then+ func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'+ func_show_eval '$MV "${export_symbols}T" "$export_symbols"'+ fi+ fi+ fi++ if test -n "$export_symbols" && test -n "$include_expsyms"; then+ tmp_export_symbols=$export_symbols+ test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols+ $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'+ fi++ if test : != "$skipped_export" && test -n "$orig_export_symbols"; then+ # The given exports_symbols file has to be filtered, so filter it.+ func_verbose "filter symbol list for '$libname.la' to tag DATA exports"+ # FIXME: $output_objdir/$libname.filter potentially contains lots of+ # 's' commands, which not all seds can handle. GNU sed should be fine+ # though. Also, the filter scales superlinearly with the number of+ # global variables. join(1) would be nice here, but unfortunately+ # isn't a blessed tool.+ $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter+ func_append delfiles " $export_symbols $output_objdir/$libname.filter"+ export_symbols=$output_objdir/$libname.def+ $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols+ fi++ tmp_deplibs=+ for test_deplib in $deplibs; do+ case " $convenience " in+ *" $test_deplib "*) ;;+ *)+ func_append tmp_deplibs " $test_deplib"+ ;;+ esac+ done+ deplibs=$tmp_deplibs++ if test -n "$convenience"; then+ if test -n "$whole_archive_flag_spec" &&+ test yes = "$compiler_needs_object" &&+ test -z "$libobjs"; then+ # extract the archives, so we have objects to list.+ # TODO: could optimize this to just extract one archive.+ whole_archive_flag_spec=+ fi+ if test -n "$whole_archive_flag_spec"; then+ save_libobjs=$libobjs+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"+ test "X$libobjs" = "X " && libobjs=+ else+ gentop=$output_objdir/${outputname}x+ func_append generated " $gentop"++ func_extract_archives $gentop $convenience+ func_append libobjs " $func_extract_archives_result"+ test "X$libobjs" = "X " && libobjs=+ fi+ fi++ if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then+ eval flag=\"$thread_safe_flag_spec\"+ func_append linker_flags " $flag"+ fi++ # Make a backup of the uninstalled library when relinking+ if test relink = "$opt_mode"; then+ $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?+ fi++ # Do each of the archive commands.+ if test yes = "$module" && test -n "$module_cmds"; then+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then+ eval test_cmds=\"$module_expsym_cmds\"+ cmds=$module_expsym_cmds+ else+ eval test_cmds=\"$module_cmds\"+ cmds=$module_cmds+ fi+ else+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then+ eval test_cmds=\"$archive_expsym_cmds\"+ cmds=$archive_expsym_cmds+ else+ eval test_cmds=\"$archive_cmds\"+ cmds=$archive_cmds+ fi+ fi++ if test : != "$skipped_export" &&+ func_len " $test_cmds" &&+ len=$func_len_result &&+ test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then+ :+ else+ # The command line is too long to link in one step, link piecewise+ # or, if using GNU ld and skipped_export is not :, use a linker+ # script.++ # Save the value of $output and $libobjs because we want to+ # use them later. If we have whole_archive_flag_spec, we+ # want to use save_libobjs as it was before+ # whole_archive_flag_spec was expanded, because we can't+ # assume the linker understands whole_archive_flag_spec.+ # This may have to be revisited, in case too many+ # convenience libraries get linked in and end up exceeding+ # the spec.+ if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then+ save_libobjs=$libobjs+ fi+ save_output=$output+ func_basename "$output"+ output_la=$func_basename_result++ # Clear the reloadable object creation command queue and+ # initialize k to one.+ test_cmds=+ concat_cmds=+ objlist=+ last_robj=+ k=1++ if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then+ output=$output_objdir/$output_la.lnkscript+ func_verbose "creating GNU ld script: $output"+ echo 'INPUT (' > $output+ for obj in $save_libobjs+ do+ func_to_tool_file "$obj"+ $ECHO "$func_to_tool_file_result" >> $output+ done+ echo ')' >> $output+ func_append delfiles " $output"+ func_to_tool_file "$output"+ output=$func_to_tool_file_result+ elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then+ output=$output_objdir/$output_la.lnk+ func_verbose "creating linker input file list: $output"+ : > $output+ set x $save_libobjs+ shift+ firstobj=+ if test yes = "$compiler_needs_object"; then+ firstobj="$1 "+ shift+ fi+ for obj+ do+ func_to_tool_file "$obj"+ $ECHO "$func_to_tool_file_result" >> $output+ done+ func_append delfiles " $output"+ func_to_tool_file "$output"+ output=$firstobj\"$file_list_spec$func_to_tool_file_result\"+ else+ if test -n "$save_libobjs"; then+ func_verbose "creating reloadable object files..."+ output=$output_objdir/$output_la-$k.$objext+ eval test_cmds=\"$reload_cmds\"+ func_len " $test_cmds"+ len0=$func_len_result+ len=$len0++ # Loop over the list of objects to be linked.+ for obj in $save_libobjs+ do+ func_len " $obj"+ func_arith $len + $func_len_result+ len=$func_arith_result+ if test -z "$objlist" ||+ test "$len" -lt "$max_cmd_len"; then+ func_append objlist " $obj"+ else+ # The command $test_cmds is almost too long, add a+ # command to the queue.+ if test 1 -eq "$k"; then+ # The first file doesn't have a previous command to add.+ reload_objs=$objlist+ eval concat_cmds=\"$reload_cmds\"+ else+ # All subsequent reloadable object files will link in+ # the last one created.+ reload_objs="$objlist $last_robj"+ eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"+ fi+ last_robj=$output_objdir/$output_la-$k.$objext+ func_arith $k + 1+ k=$func_arith_result+ output=$output_objdir/$output_la-$k.$objext+ objlist=" $obj"+ func_len " $last_robj"+ func_arith $len0 + $func_len_result+ len=$func_arith_result+ fi+ done+ # Handle the remaining objects by creating one last+ # reloadable object file. All subsequent reloadable object+ # files will link in the last one created.+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~+ reload_objs="$objlist $last_robj"+ eval concat_cmds=\"\$concat_cmds$reload_cmds\"+ if test -n "$last_robj"; then+ eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"+ fi+ func_append delfiles " $output"++ else+ output=+ fi++ ${skipped_export-false} && {+ func_verbose "generating symbol list for '$libname.la'"+ export_symbols=$output_objdir/$libname.exp+ $opt_dry_run || $RM $export_symbols+ libobjs=$output+ # Append the command to create the export file.+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~+ eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"+ if test -n "$last_robj"; then+ eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"+ fi+ }++ test -n "$save_libobjs" &&+ func_verbose "creating a temporary reloadable object file: $output"++ # Loop through the commands generated above and execute them.+ save_ifs=$IFS; IFS='~'+ for cmd in $concat_cmds; do+ IFS=$save_ifs+ $opt_quiet || {+ func_quote_arg expand,pretty "$cmd"+ eval "func_echo $func_quote_arg_result"+ }+ $opt_dry_run || eval "$cmd" || {+ lt_exit=$?++ # Restore the uninstalled library and exit+ if test relink = "$opt_mode"; then+ ( cd "$output_objdir" && \+ $RM "${realname}T" && \+ $MV "${realname}U" "$realname" )+ fi++ exit $lt_exit+ }+ done+ IFS=$save_ifs++ if test -n "$export_symbols_regex" && ${skipped_export-false}; then+ func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'+ func_show_eval '$MV "${export_symbols}T" "$export_symbols"'+ fi+ fi++ ${skipped_export-false} && {+ if test -n "$export_symbols" && test -n "$include_expsyms"; then+ tmp_export_symbols=$export_symbols+ test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols+ $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'+ fi++ if test -n "$orig_export_symbols"; then+ # The given exports_symbols file has to be filtered, so filter it.+ func_verbose "filter symbol list for '$libname.la' to tag DATA exports"+ # FIXME: $output_objdir/$libname.filter potentially contains lots of+ # 's' commands, which not all seds can handle. GNU sed should be fine+ # though. Also, the filter scales superlinearly with the number of+ # global variables. join(1) would be nice here, but unfortunately+ # isn't a blessed tool.+ $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter+ func_append delfiles " $export_symbols $output_objdir/$libname.filter"+ export_symbols=$output_objdir/$libname.def+ $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols+ fi+ }++ libobjs=$output+ # Restore the value of output.+ output=$save_output++ if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then+ eval libobjs=\"\$libobjs $whole_archive_flag_spec\"+ test "X$libobjs" = "X " && libobjs=+ fi+ # Expand the library linking commands again to reset the+ # value of $libobjs for piecewise linking.++ # Do each of the archive commands.+ if test yes = "$module" && test -n "$module_cmds"; then+ if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then+ cmds=$module_expsym_cmds+ else+ cmds=$module_cmds+ fi+ else+ if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then+ cmds=$archive_expsym_cmds+ else+ cmds=$archive_cmds+ fi+ fi+ fi++ if test -n "$delfiles"; then+ # Append the command to remove temporary files to $cmds.+ eval cmds=\"\$cmds~\$RM $delfiles\"+ fi++ # Add any objects from preloaded convenience libraries+ if test -n "$dlprefiles"; then+ gentop=$output_objdir/${outputname}x+ func_append generated " $gentop"++ func_extract_archives $gentop $dlprefiles+ func_append libobjs " $func_extract_archives_result"+ test "X$libobjs" = "X " && libobjs=+ fi++ save_ifs=$IFS; IFS='~'+ for cmd in $cmds; do+ IFS=$sp$nl+ eval cmd=\"$cmd\"+ IFS=$save_ifs+ $opt_quiet || {+ func_quote_arg expand,pretty "$cmd"+ eval "func_echo $func_quote_arg_result"+ }+ $opt_dry_run || eval "$cmd" || {+ lt_exit=$?++ # Restore the uninstalled library and exit+ if test relink = "$opt_mode"; then+ ( cd "$output_objdir" && \+ $RM "${realname}T" && \+ $MV "${realname}U" "$realname" )+ fi++ exit $lt_exit+ }+ done+ IFS=$save_ifs++ # Restore the uninstalled library and exit+ if test relink = "$opt_mode"; then+ $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?++ if test -n "$convenience"; then+ if test -z "$whole_archive_flag_spec"; then+ func_show_eval '${RM}r "$gentop"'+ fi+ fi++ exit $EXIT_SUCCESS+ fi++ # Create links to the real library.+ for linkname in $linknames; do+ if test "$realname" != "$linkname"; then+ func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'+ fi+ done++ # If -module or -export-dynamic was specified, set the dlname.+ if test yes = "$module" || test yes = "$export_dynamic"; then+ # On all known operating systems, these are identical.+ dlname=$soname+ fi+ fi+ ;;++ obj)+ if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then+ func_warning "'-dlopen' is ignored for objects"+ fi++ case " $deplibs" in+ *\ -l* | *\ -L*)+ func_warning "'-l' and '-L' are ignored for objects" ;;+ esac++ test -n "$rpath" && \+ func_warning "'-rpath' is ignored for objects"++ test -n "$xrpath" && \+ func_warning "'-R' is ignored for objects"++ test -n "$vinfo" && \+ func_warning "'-version-info' is ignored for objects"++ test -n "$release" && \+ func_warning "'-release' is ignored for objects"++ case $output in+ *.lo)+ test -n "$objs$old_deplibs" && \+ func_fatal_error "cannot build library object '$output' from non-libtool objects"++ libobj=$output+ func_lo2o "$libobj"+ obj=$func_lo2o_result+ ;;+ *)+ libobj=+ obj=$output+ ;;+ esac++ # Delete the old objects.+ $opt_dry_run || $RM $obj $libobj++ # Objects from convenience libraries. This assumes+ # single-version convenience libraries. Whenever we create+ # different ones for PIC/non-PIC, this we'll have to duplicate+ # the extraction.+ reload_conv_objs=+ gentop=+ # if reload_cmds runs $LD directly, get rid of -Wl from+ # whole_archive_flag_spec and hope we can get by with turning comma+ # into space.+ case $reload_cmds in+ *\$LD[\ \$]*) wl= ;;+ esac+ if test -n "$convenience"; then+ if test -n "$whole_archive_flag_spec"; then+ eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"+ test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`+ reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags+ else+ gentop=$output_objdir/${obj}x+ func_append generated " $gentop"++ func_extract_archives $gentop $convenience+ reload_conv_objs="$reload_objs $func_extract_archives_result"+ fi+ fi++ # If we're not building shared, we need to use non_pic_objs+ test yes = "$build_libtool_libs" || libobjs=$non_pic_objects++ # Create the old-style object.+ reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs++ output=$obj+ func_execute_cmds "$reload_cmds" 'exit $?'++ # Exit if we aren't doing a library object file.+ if test -z "$libobj"; then+ if test -n "$gentop"; then+ func_show_eval '${RM}r "$gentop"'+ fi++ exit $EXIT_SUCCESS+ fi++ test yes = "$build_libtool_libs" || {+ if test -n "$gentop"; then+ func_show_eval '${RM}r "$gentop"'+ fi++ # Create an invalid libtool object if no PIC, so that we don't+ # accidentally link it into a program.+ # $show "echo timestamp > $libobj"+ # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?+ exit $EXIT_SUCCESS+ }++ if test -n "$pic_flag" || test default != "$pic_mode"; then+ # Only do commands if we really have different PIC objects.+ reload_objs="$libobjs $reload_conv_objs"+ output=$libobj+ func_execute_cmds "$reload_cmds" 'exit $?'+ fi++ if test -n "$gentop"; then+ func_show_eval '${RM}r "$gentop"'+ fi++ exit $EXIT_SUCCESS+ ;;++ prog)+ case $host in+ *cygwin*) func_stripname '' '.exe' "$output"+ output=$func_stripname_result.exe;;+ esac+ test -n "$vinfo" && \+ func_warning "'-version-info' is ignored for programs"++ test -n "$release" && \+ func_warning "'-release' is ignored for programs"++ $preload \+ && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \+ && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."++ case $host in+ *-*-rhapsody* | *-*-darwin1.[012])+ # On Rhapsody replace the C library is the System framework+ compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`+ finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`+ ;;+ esac++ case $host in+ *-*-darwin*)+ # Don't allow lazy linking, it breaks C++ global constructors+ # But is supposedly fixed on 10.4 or later (yay!).+ if test CXX = "$tagname"; then+ case ${MACOSX_DEPLOYMENT_TARGET-10.0} in+ 10.[0123])+ func_append compile_command " $wl-bind_at_load"+ func_append finalize_command " $wl-bind_at_load"+ ;;+ esac+ fi+ # Time to change all our "foo.ltframework" stuff back to "-framework foo"+ compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`+ finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`+ ;;+ esac+++ # move library search paths that coincide with paths to not yet+ # installed libraries to the beginning of the library search list+ new_libs=+ for path in $notinst_path; do+ case " $new_libs " in+ *" -L$path/$objdir "*) ;;+ *)+ case " $compile_deplibs " in+ *" -L$path/$objdir "*)+ func_append new_libs " -L$path/$objdir" ;;+ esac+ ;;+ esac+ done+ for deplib in $compile_deplibs; do+ case $deplib in+ -L*)+ case " $new_libs " in+ *" $deplib "*) ;;+ *) func_append new_libs " $deplib" ;;+ esac+ ;;+ *) func_append new_libs " $deplib" ;;+ esac+ done+ compile_deplibs=$new_libs+++ func_append compile_command " $compile_deplibs"+ func_append finalize_command " $finalize_deplibs"++ if test -n "$rpath$xrpath"; then+ # If the user specified any rpath flags, then add them.+ for libdir in $rpath $xrpath; do+ # This is the magic to use -rpath.+ case "$finalize_rpath " in+ *" $libdir "*) ;;+ *) func_append finalize_rpath " $libdir" ;;+ esac+ done+ fi++ # Now hardcode the library paths+ rpath=+ hardcode_libdirs=+ for libdir in $compile_rpath $finalize_rpath; do+ if test -n "$hardcode_libdir_flag_spec"; then+ if test -n "$hardcode_libdir_separator"; then+ if test -z "$hardcode_libdirs"; then+ hardcode_libdirs=$libdir+ else+ # Just accumulate the unique libdirs.+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)+ ;;+ *)+ func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"+ ;;+ esac+ fi+ else+ eval flag=\"$hardcode_libdir_flag_spec\"+ func_append rpath " $flag"+ fi+ elif test -n "$runpath_var"; then+ case "$perm_rpath " in+ *" $libdir "*) ;;+ *) func_append perm_rpath " $libdir" ;;+ esac+ fi+ case $host in+ *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)+ testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`+ case :$dllsearchpath: in+ *":$libdir:"*) ;;+ ::) dllsearchpath=$libdir;;+ *) func_append dllsearchpath ":$libdir";;+ esac+ case :$dllsearchpath: in+ *":$testbindir:"*) ;;+ ::) dllsearchpath=$testbindir;;+ *) func_append dllsearchpath ":$testbindir";;+ esac+ ;;+ esac+ done+ # Substitute the hardcoded libdirs into the rpath.+ if test -n "$hardcode_libdir_separator" &&+ test -n "$hardcode_libdirs"; then+ libdir=$hardcode_libdirs+ eval rpath=\" $hardcode_libdir_flag_spec\"+ fi+ compile_rpath=$rpath++ rpath=+ hardcode_libdirs=+ for libdir in $finalize_rpath; do+ if test -n "$hardcode_libdir_flag_spec"; then+ if test -n "$hardcode_libdir_separator"; then+ if test -z "$hardcode_libdirs"; then+ hardcode_libdirs=$libdir+ else+ # Just accumulate the unique libdirs.+ case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in+ *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)+ ;;+ *)+ func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"+ ;;+ esac+ fi+ else+ eval flag=\"$hardcode_libdir_flag_spec\"+ func_append rpath " $flag"+ fi+ elif test -n "$runpath_var"; then+ case "$finalize_perm_rpath " in+ *" $libdir "*) ;;+ *) func_append finalize_perm_rpath " $libdir" ;;+ esac+ fi+ done+ # Substitute the hardcoded libdirs into the rpath.+ if test -n "$hardcode_libdir_separator" &&+ test -n "$hardcode_libdirs"; then+ libdir=$hardcode_libdirs+ eval rpath=\" $hardcode_libdir_flag_spec\"+ fi+ finalize_rpath=$rpath++ if test -n "$libobjs" && test yes = "$build_old_libs"; then+ # Transform all the library objects into standard objects.+ compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`+ finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`+ fi++ func_generate_dlsyms "$outputname" "@PROGRAM@" false++ # template prelinking step+ if test -n "$prelink_cmds"; then+ func_execute_cmds "$prelink_cmds" 'exit $?'+ fi++ wrappers_required=:+ case $host in+ *cegcc* | *mingw32ce*)+ # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.+ wrappers_required=false+ ;;+ *cygwin* | *mingw* )+ test yes = "$build_libtool_libs" || wrappers_required=false+ ;;+ *)+ if test no = "$need_relink" || test yes != "$build_libtool_libs"; then+ wrappers_required=false+ fi+ ;;+ esac+ $wrappers_required || {+ # Replace the output file specification.+ compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`+ link_command=$compile_command$compile_rpath++ # We have no uninstalled library dependencies, so finalize right now.+ exit_status=0+ func_show_eval "$link_command" 'exit_status=$?'++ if test -n "$postlink_cmds"; then+ func_to_tool_file "$output"+ postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`+ func_execute_cmds "$postlink_cmds" 'exit $?'+ fi++ # Delete the generated files.+ if test -f "$output_objdir/${outputname}S.$objext"; then+ func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'+ fi++ exit $exit_status+ }++ if test -n "$compile_shlibpath$finalize_shlibpath"; then+ compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"+ fi+ if test -n "$finalize_shlibpath"; then+ finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"+ fi++ compile_var=+ finalize_var=+ if test -n "$runpath_var"; then+ if test -n "$perm_rpath"; then+ # We should set the runpath_var.+ rpath=+ for dir in $perm_rpath; do+ func_append rpath "$dir:"+ done+ compile_var="$runpath_var=\"$rpath\$$runpath_var\" "+ fi+ if test -n "$finalize_perm_rpath"; then+ # We should set the runpath_var.+ rpath=+ for dir in $finalize_perm_rpath; do+ func_append rpath "$dir:"+ done+ finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "+ fi+ fi++ if test yes = "$no_install"; then+ # We don't need to create a wrapper script.+ link_command=$compile_var$compile_command$compile_rpath+ # Replace the output file specification.+ link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`+ # Delete the old output file.+ $opt_dry_run || $RM $output+ # Link the executable and exit+ func_show_eval "$link_command" 'exit $?'++ if test -n "$postlink_cmds"; then+ func_to_tool_file "$output"+ postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`+ func_execute_cmds "$postlink_cmds" 'exit $?'+ fi++ exit $EXIT_SUCCESS+ fi++ case $hardcode_action,$fast_install in+ relink,*)+ # Fast installation is not supported+ link_command=$compile_var$compile_command$compile_rpath+ relink_command=$finalize_var$finalize_command$finalize_rpath++ func_warning "this platform does not like uninstalled shared libraries"+ func_warning "'$output' will be relinked during installation"+ ;;+ *,yes)+ link_command=$finalize_var$compile_command$finalize_rpath+ relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`+ ;;+ *,no)+ link_command=$compile_var$compile_command$compile_rpath+ relink_command=$finalize_var$finalize_command$finalize_rpath+ ;;+ *,needless)+ link_command=$finalize_var$compile_command$finalize_rpath+ relink_command=+ ;;+ esac++ # Replace the output file specification.+ link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`++ # Delete the old output files.+ $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname++ func_show_eval "$link_command" 'exit $?'++ if test -n "$postlink_cmds"; then+ func_to_tool_file "$output_objdir/$outputname"+ postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`+ func_execute_cmds "$postlink_cmds" 'exit $?'+ fi++ # Now create the wrapper script.+ func_verbose "creating $output"++ # Quote the relink command for shipping.+ if test -n "$relink_command"; then+ # Preserve any variables that may affect compiler behavior+ for var in $variables_saved_for_relink; do+ if eval test -z \"\${$var+set}\"; then+ relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"+ elif eval var_value=\$$var; test -z "$var_value"; then+ relink_command="$var=; export $var; $relink_command"+ else+ func_quote_arg pretty "$var_value"+ relink_command="$var=$func_quote_arg_result; export $var; $relink_command"+ fi+ done+ func_quote eval cd "`pwd`"+ func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)"+ relink_command=$func_quote_arg_unquoted_result+ fi++ # Only actually do things if not in dry run mode.+ $opt_dry_run || {+ # win32 will think the script is a binary if it has+ # a .exe suffix, so we strip it off here.+ case $output in+ *.exe) func_stripname '' '.exe' "$output"+ output=$func_stripname_result ;;+ esac+ # test for cygwin because mv fails w/o .exe extensions+ case $host in+ *cygwin*)+ exeext=.exe+ func_stripname '' '.exe' "$outputname"+ outputname=$func_stripname_result ;;+ *) exeext= ;;+ esac+ case $host in+ *cygwin* | *mingw* )+ func_dirname_and_basename "$output" "" "."+ output_name=$func_basename_result+ output_path=$func_dirname_result+ cwrappersource=$output_path/$objdir/lt-$output_name.c+ cwrapper=$output_path/$output_name.exe+ $RM $cwrappersource $cwrapper+ trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15++ func_emit_cwrapperexe_src > $cwrappersource++ # The wrapper executable is built using the $host compiler,+ # because it contains $host paths and files. If cross-+ # compiling, it, like the target executable, must be+ # executed on the $host or under an emulation environment.+ $opt_dry_run || {+ $LTCC $LTCFLAGS -o $cwrapper $cwrappersource+ $STRIP $cwrapper+ }++ # Now, create the wrapper script for func_source use:+ func_ltwrapper_scriptname $cwrapper+ $RM $func_ltwrapper_scriptname_result+ trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15+ $opt_dry_run || {+ # note: this script will not be executed, so do not chmod.+ if test "x$build" = "x$host"; then+ $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result+ else+ func_emit_wrapper no > $func_ltwrapper_scriptname_result+ fi+ }+ ;;+ * )+ $RM $output+ trap "$RM $output; exit $EXIT_FAILURE" 1 2 15++ func_emit_wrapper no > $output+ chmod +x $output+ ;;+ esac+ }+ exit $EXIT_SUCCESS+ ;;+ esac++ # See if we need to build an old-fashioned archive.+ for oldlib in $oldlibs; do++ case $build_libtool_libs in+ convenience)+ oldobjs="$libobjs_save $symfileobj"+ addlibs=$convenience+ build_libtool_libs=no+ ;;+ module)+ oldobjs=$libobjs_save+ addlibs=$old_convenience+ build_libtool_libs=no+ ;;+ *)+ oldobjs="$old_deplibs $non_pic_objects"+ $preload && test -f "$symfileobj" \+ && func_append oldobjs " $symfileobj"+ addlibs=$old_convenience+ ;;+ esac++ if test -n "$addlibs"; then+ gentop=$output_objdir/${outputname}x+ func_append generated " $gentop"++ func_extract_archives $gentop $addlibs+ func_append oldobjs " $func_extract_archives_result"+ fi++ # Do each command in the archive commands.+ if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then+ cmds=$old_archive_from_new_cmds+ else++ # Add any objects from preloaded convenience libraries+ if test -n "$dlprefiles"; then+ gentop=$output_objdir/${outputname}x+ func_append generated " $gentop"++ func_extract_archives $gentop $dlprefiles+ func_append oldobjs " $func_extract_archives_result"+ fi++ # POSIX demands no paths to be encoded in archives. We have+ # to avoid creating archives with duplicate basenames if we+ # might have to extract them afterwards, e.g., when creating a+ # static archive out of a convenience library, or when linking+ # the entirety of a libtool archive into another (currently+ # not supported by libtool).+ if (for obj in $oldobjs+ do+ func_basename "$obj"+ $ECHO "$func_basename_result"+ done | sort | sort -uc >/dev/null 2>&1); then+ :+ else+ echo "copying selected object files to avoid basename conflicts..."+ gentop=$output_objdir/${outputname}x+ func_append generated " $gentop"+ func_mkdir_p "$gentop"+ save_oldobjs=$oldobjs+ oldobjs=+ counter=1+ for obj in $save_oldobjs+ do+ func_basename "$obj"+ objbase=$func_basename_result+ case " $oldobjs " in+ " ") oldobjs=$obj ;;+ *[\ /]"$objbase "*)+ while :; do+ # Make sure we don't pick an alternate name that also+ # overlaps.+ newobj=lt$counter-$objbase+ func_arith $counter + 1+ counter=$func_arith_result+ case " $oldobjs " in+ *[\ /]"$newobj "*) ;;+ *) if test ! -f "$gentop/$newobj"; then break; fi ;;+ esac+ done+ func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"+ func_append oldobjs " $gentop/$newobj"+ ;;+ *) func_append oldobjs " $obj" ;;+ esac+ done+ fi+ func_to_tool_file "$oldlib" func_convert_file_msys_to_w32+ tool_oldlib=$func_to_tool_file_result+ eval cmds=\"$old_archive_cmds\"++ func_len " $cmds"+ len=$func_len_result+ if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then+ cmds=$old_archive_cmds+ elif test -n "$archiver_list_spec"; then+ func_verbose "using command file archive linking..."+ for obj in $oldobjs+ do+ func_to_tool_file "$obj"+ $ECHO "$func_to_tool_file_result"+ done > $output_objdir/$libname.libcmd+ func_to_tool_file "$output_objdir/$libname.libcmd"+ oldobjs=" $archiver_list_spec$func_to_tool_file_result"+ cmds=$old_archive_cmds+ else+ # the command line is too long to link in one step, link in parts+ func_verbose "using piecewise archive linking..."+ save_RANLIB=$RANLIB+ RANLIB=:+ objlist=+ concat_cmds=+ save_oldobjs=$oldobjs+ oldobjs=+ # Is there a better way of finding the last object in the list?+ for obj in $save_oldobjs+ do+ last_oldobj=$obj+ done+ eval test_cmds=\"$old_archive_cmds\"+ func_len " $test_cmds"+ len0=$func_len_result+ len=$len0+ for obj in $save_oldobjs+ do+ func_len " $obj"+ func_arith $len + $func_len_result+ len=$func_arith_result+ func_append objlist " $obj"+ if test "$len" -lt "$max_cmd_len"; then+ :+ else+ # the above command should be used before it gets too long+ oldobjs=$objlist+ if test "$obj" = "$last_oldobj"; then+ RANLIB=$save_RANLIB+ fi+ test -z "$concat_cmds" || concat_cmds=$concat_cmds~+ eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"+ objlist=+ len=$len0+ fi+ done+ RANLIB=$save_RANLIB+ oldobjs=$objlist+ if test -z "$oldobjs"; then+ eval cmds=\"\$concat_cmds\"+ else+ eval cmds=\"\$concat_cmds~\$old_archive_cmds\"+ fi+ fi+ fi+ func_execute_cmds "$cmds" 'exit $?'+ done++ test -n "$generated" && \+ func_show_eval "${RM}r$generated"++ # Now create the libtool archive.+ case $output in+ *.la)+ old_library=+ test yes = "$build_old_libs" && old_library=$libname.$libext+ func_verbose "creating $output"++ # Preserve any variables that may affect compiler behavior+ for var in $variables_saved_for_relink; do+ if eval test -z \"\${$var+set}\"; then+ relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"+ elif eval var_value=\$$var; test -z "$var_value"; then+ relink_command="$var=; export $var; $relink_command"+ else+ func_quote_arg pretty,unquoted "$var_value"+ relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command"+ fi+ done+ # Quote the link command for shipping.+ func_quote eval cd "`pwd`"+ relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"+ func_quote_arg pretty,unquoted "$relink_command"+ relink_command=$func_quote_arg_unquoted_result+ if test yes = "$hardcode_automatic"; then+ relink_command=+ fi++ # Only create the output if not a dry run.+ $opt_dry_run || {+ for installed in no yes; do+ if test yes = "$installed"; then+ if test -z "$install_libdir"; then+ break+ fi+ output=$output_objdir/${outputname}i+ # Replace all uninstalled libtool libraries with the installed ones+ newdependency_libs=+ for deplib in $dependency_libs; do+ case $deplib in+ *.la)+ func_basename "$deplib"+ name=$func_basename_result+ func_resolve_sysroot "$deplib"+ eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`+ test -z "$libdir" && \+ func_fatal_error "'$deplib' is not a valid libtool archive"+ func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"+ ;;+ -L*)+ func_stripname -L '' "$deplib"+ func_replace_sysroot "$func_stripname_result"+ func_append newdependency_libs " -L$func_replace_sysroot_result"+ ;;+ -R*)+ func_stripname -R '' "$deplib"+ func_replace_sysroot "$func_stripname_result"+ func_append newdependency_libs " -R$func_replace_sysroot_result"+ ;;+ *) func_append newdependency_libs " $deplib" ;;+ esac+ done+ dependency_libs=$newdependency_libs+ newdlfiles=++ for lib in $dlfiles; do+ case $lib in+ *.la)+ func_basename "$lib"+ name=$func_basename_result+ eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`+ test -z "$libdir" && \+ func_fatal_error "'$lib' is not a valid libtool archive"+ func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"+ ;;+ *) func_append newdlfiles " $lib" ;;+ esac+ done+ dlfiles=$newdlfiles+ newdlprefiles=+ for lib in $dlprefiles; do+ case $lib in+ *.la)+ # Only pass preopened files to the pseudo-archive (for+ # eventual linking with the app. that links it) if we+ # didn't already link the preopened objects directly into+ # the library:+ func_basename "$lib"+ name=$func_basename_result+ eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`+ test -z "$libdir" && \+ func_fatal_error "'$lib' is not a valid libtool archive"+ func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"+ ;;+ esac+ done+ dlprefiles=$newdlprefiles+ else+ newdlfiles=+ for lib in $dlfiles; do+ case $lib in+ [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;+ *) abs=`pwd`"/$lib" ;;+ esac+ func_append newdlfiles " $abs"+ done+ dlfiles=$newdlfiles+ newdlprefiles=+ for lib in $dlprefiles; do+ case $lib in+ [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;+ *) abs=`pwd`"/$lib" ;;+ esac+ func_append newdlprefiles " $abs"+ done+ dlprefiles=$newdlprefiles+ fi+ $RM $output+ # place dlname in correct position for cygwin+ # In fact, it would be nice if we could use this code for all target+ # systems that can't hard-code library paths into their executables+ # and that have no shared library path variable independent of PATH,+ # but it turns out we can't easily determine that from inspecting+ # libtool variables, so we have to hard-code the OSs to which it+ # applies here; at the moment, that means platforms that use the PE+ # object format with DLL files. See the long comment at the top of+ # tests/bindir.at for full details.+ tdlname=$dlname+ case $host,$output,$installed,$module,$dlname in+ *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)+ # If a -bindir argument was supplied, place the dll there.+ if test -n "$bindir"; then+ func_relative_path "$install_libdir" "$bindir"+ tdlname=$func_relative_path_result/$dlname+ else+ # Otherwise fall back on heuristic.+ tdlname=../bin/$dlname+ fi+ ;;+ esac+ $ECHO > $output "\+# $outputname - a libtool library file+# Generated by $PROGRAM (GNU $PACKAGE) $VERSION+#+# Please DO NOT delete this file!+# It is necessary for linking the library.++# The name that we can dlopen(3).+dlname='$tdlname'++# Names of this library.+library_names='$library_names'++# The name of the static archive.+old_library='$old_library'++# Linker flags that cannot go in dependency_libs.+inherited_linker_flags='$new_inherited_linker_flags'++# Libraries that this one depends upon.+dependency_libs='$dependency_libs'++# Names of additional weak libraries provided by this library+weak_library_names='$weak_libs'++# Version information for $libname.+current=$current+age=$age+revision=$revision++# Is this an already installed library?+installed=$installed++# Should we warn about portability when linking against -modules?+shouldnotlink=$module++# Files to dlopen/dlpreopen+dlopen='$dlfiles'+dlpreopen='$dlprefiles'++# Directory that this library needs to be installed in:+libdir='$install_libdir'"+ if test no,yes = "$installed,$need_relink"; then+ $ECHO >> $output "\+relink_command=\"$relink_command\""+ fi+ done+ }++ # Do a symbolic link so that the libtool archive can be found in+ # LD_LIBRARY_PATH before the program is installed.+ func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'+ ;;+ esac+ exit $EXIT_SUCCESS+}++if test link = "$opt_mode" || test relink = "$opt_mode"; then+ func_mode_link ${1+"$@"}+fi+++# func_mode_uninstall arg...+func_mode_uninstall ()+{+ $debug_cmd++ RM=$nonopt+ files=+ rmforce=false+ exit_status=0++ # This variable tells wrapper scripts just to set variables rather+ # than running their programs.+ libtool_install_magic=$magic++ for arg+ do+ case $arg in+ -f) func_append RM " $arg"; rmforce=: ;;+ -*) func_append RM " $arg" ;;+ *) func_append files " $arg" ;;+ esac+ done++ test -z "$RM" && \+ func_fatal_help "you must specify an RM program"++ rmdirs=++ for file in $files; do+ func_dirname "$file" "" "."+ dir=$func_dirname_result+ if test . = "$dir"; then+ odir=$objdir+ else+ odir=$dir/$objdir+ fi+ func_basename "$file"+ name=$func_basename_result+ test uninstall = "$opt_mode" && odir=$dir++ # Remember odir for removal later, being careful to avoid duplicates+ if test clean = "$opt_mode"; then+ case " $rmdirs " in+ *" $odir "*) ;;+ *) func_append rmdirs " $odir" ;;+ esac+ fi++ # Don't error if the file doesn't exist and rm -f was used.+ if { test -L "$file"; } >/dev/null 2>&1 ||+ { test -h "$file"; } >/dev/null 2>&1 ||+ test -f "$file"; then+ :+ elif test -d "$file"; then+ exit_status=1+ continue+ elif $rmforce; then+ continue+ fi++ rmfiles=$file++ case $name in+ *.la)+ # Possibly a libtool archive, so verify it.+ if func_lalib_p "$file"; then+ func_source $dir/$name++ # Delete the libtool libraries and symlinks.+ for n in $library_names; do+ func_append rmfiles " $odir/$n"+ done+ test -n "$old_library" && func_append rmfiles " $odir/$old_library"++ case $opt_mode in+ clean)+ case " $library_names " in+ *" $dlname "*) ;;+ *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;+ esac+ test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"+ ;;+ uninstall)+ if test -n "$library_names"; then+ # Do each command in the postuninstall commands.+ func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'+ fi++ if test -n "$old_library"; then+ # Do each command in the old_postuninstall commands.+ func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'+ fi+ # FIXME: should reinstall the best remaining shared library.+ ;;+ esac+ fi+ ;;++ *.lo)+ # Possibly a libtool object, so verify it.+ if func_lalib_p "$file"; then++ # Read the .lo file+ func_source $dir/$name++ # Add PIC object to the list of files to remove.+ if test -n "$pic_object" && test none != "$pic_object"; then+ func_append rmfiles " $dir/$pic_object"+ fi++ # Add non-PIC object to the list of files to remove.+ if test -n "$non_pic_object" && test none != "$non_pic_object"; then+ func_append rmfiles " $dir/$non_pic_object"+ fi+ fi+ ;;++ *)+ if test clean = "$opt_mode"; then+ noexename=$name+ case $file in+ *.exe)+ func_stripname '' '.exe' "$file"+ file=$func_stripname_result+ func_stripname '' '.exe' "$name"+ noexename=$func_stripname_result+ # $file with .exe has already been added to rmfiles,+ # add $file without .exe+ func_append rmfiles " $file"+ ;;+ esac+ # Do a test to see if this is a libtool program.+ if func_ltwrapper_p "$file"; then+ if func_ltwrapper_executable_p "$file"; then+ func_ltwrapper_scriptname "$file"+ relink_command=+ func_source $func_ltwrapper_scriptname_result+ func_append rmfiles " $func_ltwrapper_scriptname_result"+ else+ relink_command=+ func_source $dir/$noexename+ fi++ # note $name still contains .exe if it was in $file originally+ # as does the version of $file that was added into $rmfiles+ func_append rmfiles " $odir/$name $odir/${name}S.$objext"+ if test yes = "$fast_install" && test -n "$relink_command"; then+ func_append rmfiles " $odir/lt-$name"+ fi+ if test "X$noexename" != "X$name"; then+ func_append rmfiles " $odir/lt-$noexename.c"+ fi+ fi+ fi+ ;;+ esac+ func_show_eval "$RM $rmfiles" 'exit_status=1'+ done++ # Try to remove the $objdir's in the directories where we deleted files+ for dir in $rmdirs; do+ if test -d "$dir"; then+ func_show_eval "rmdir $dir >/dev/null 2>&1"+ fi+ done++ exit $exit_status+}++if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then+ func_mode_uninstall ${1+"$@"}+fi++test -z "$opt_mode" && {+ help=$generic_help+ func_fatal_help "you must specify a MODE"+}++test -z "$exec_cmd" && \+ func_fatal_help "invalid operation mode '$opt_mode'"++if test -n "$exec_cmd"; then+ eval exec "$exec_cmd"+ exit $EXIT_FAILURE+fi++exit $exit_status+++# The TAGs below are defined such that we never get into a situation+# where we disable both kinds of libraries. Given conflicting+# choices, we go for a static library, that is the most portable,+# since we can't tell whether shared libraries were disabled because+# the user asked for that or because the platform doesn't support+# them. This is particularly important on AIX, because we don't+# support having both static and shared libraries enabled at the same+# time on that platform, so we default to a shared-only configuration.+# If a disable-shared tag is given, we'll fallback to a static-only+# configuration. But we'll never go from static-only to shared-only.++# ### BEGIN LIBTOOL TAG CONFIG: disable-shared+build_libtool_libs=no+build_old_libs=yes+# ### END LIBTOOL TAG CONFIG: disable-shared++# ### BEGIN LIBTOOL TAG CONFIG: disable-static+build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`+# ### END LIBTOOL TAG CONFIG: disable-static++# Local Variables:+# mode:shell-script+# sh-indentation:2+# End:
+ cbits/LICENSE view
@@ -0,0 +1,11 @@+Permission to use, copy, modify, and/or distribute this+software for any purpose with or without fee is hereby granted.++THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL+WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED+WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL+THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR+CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM+LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,+NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN+CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
+ cbits/common/mythread.h view
@@ -0,0 +1,548 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file mythread.h+/// \brief Some threading related helper macros and functions+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef MYTHREAD_H+#define MYTHREAD_H++#include "sysdefs.h"++// If any type of threading is enabled, #define MYTHREAD_ENABLED.+#if defined(MYTHREAD_POSIX) || defined(MYTHREAD_WIN95) \+ || defined(MYTHREAD_VISTA)+# define MYTHREAD_ENABLED 1+#endif+++#ifdef MYTHREAD_ENABLED++////////////////////////////////////////+// Shared between all threading types //+////////////////////////////////////////++// Locks a mutex for a duration of a block.+//+// Perform mythread_mutex_lock(&mutex) in the beginning of a block+// and mythread_mutex_unlock(&mutex) at the end of the block. "break"+// may be used to unlock the mutex and jump out of the block.+// mythread_sync blocks may be nested.+//+// Example:+//+// mythread_sync(mutex) {+// foo();+// if (some_error)+// break; // Skips bar()+// bar();+// }+//+// At least GCC optimizes the loops completely away so it doesn't slow+// things down at all compared to plain mythread_mutex_lock(&mutex)+// and mythread_mutex_unlock(&mutex) calls.+//+#define mythread_sync(mutex) mythread_sync_helper1(mutex, __LINE__)+#define mythread_sync_helper1(mutex, line) mythread_sync_helper2(mutex, line)+#define mythread_sync_helper2(mutex, line) \+ for (unsigned int mythread_i_ ## line = 0; \+ mythread_i_ ## line \+ ? (mythread_mutex_unlock(&(mutex)), 0) \+ : (mythread_mutex_lock(&(mutex)), 1); \+ mythread_i_ ## line = 1) \+ for (unsigned int mythread_j_ ## line = 0; \+ !mythread_j_ ## line; \+ mythread_j_ ## line = 1)+#endif+++#if !defined(MYTHREAD_ENABLED)++//////////////////+// No threading //+//////////////////++// Calls the given function once. This isn't thread safe.+#define mythread_once(func) \+do { \+ static bool once_ = false; \+ if (!once_) { \+ func(); \+ once_ = true; \+ } \+} while (0)+++#if !(defined(_WIN32) && !defined(__CYGWIN__)) && !defined(__wasm__)+// Use sigprocmask() to set the signal mask in single-threaded programs.+#include <signal.h>++static inline void+mythread_sigmask(int how, const sigset_t *restrict set,+ sigset_t *restrict oset)+{+ int ret = sigprocmask(how, set, oset);+ assert(ret == 0);+ (void)ret;+}+#endif+++#elif defined(MYTHREAD_POSIX)++////////////////////+// Using pthreads //+////////////////////++#include <pthread.h>+#include <signal.h>+#include <time.h>+#include <errno.h>++// If clock_gettime() isn't available, use gettimeofday() from <sys/time.h>+// as a fallback. gettimeofday() is in SUSv2 and thus is supported on all+// relevant POSIX systems.+#ifndef HAVE_CLOCK_GETTIME+# include <sys/time.h>+#endif++// MinGW-w64 with winpthreads:+//+// NOTE: Typical builds with MinGW-w64 don't use this code (MYTHREAD_POSIX).+// Instead, native Windows threading APIs are used (MYTHREAD_VISTA or+// MYTHREAD_WIN95).+//+// MinGW-w64 has _sigset_t (an integer type) in <sys/types.h>.+// If _POSIX was #defined, the header would add the alias sigset_t too.+// Let's keep this working even without _POSIX.+//+// There are no functions that actually do something with sigset_t+// because signals barely exist on Windows. The sigfillset macro below+// is just to silence warnings. There is no sigfillset() in MinGW-w64.+#ifdef __MINGW32__+# include <sys/types.h>+# define sigset_t _sigset_t+# define sigfillset(set_ptr) do { *(set_ptr) = 0; } while (0)+#endif++#define MYTHREAD_RET_TYPE void *+#define MYTHREAD_RET_VALUE NULL++typedef pthread_t mythread;+typedef pthread_mutex_t mythread_mutex;++typedef struct {+ pthread_cond_t cond;+#ifdef HAVE_CLOCK_GETTIME+ // Clock ID (CLOCK_REALTIME or CLOCK_MONOTONIC) associated with+ // the condition variable.+ clockid_t clk_id;+#endif+} mythread_cond;++typedef struct timespec mythread_condtime;+++// Calls the given function once in a thread-safe way.+#define mythread_once(func) \+ do { \+ static pthread_once_t once_ = PTHREAD_ONCE_INIT; \+ pthread_once(&once_, &func); \+ } while (0)+++// Use pthread_sigmask() to set the signal mask in multi-threaded programs.+// Do nothing on OpenVMS since it lacks pthread_sigmask().+// Do nothing on MinGW-w64 too to silence warnings (its pthread_sigmask()+// is #defined to 0 so it's a no-op).+static inline void+mythread_sigmask(int how, const sigset_t *restrict set,+ sigset_t *restrict oset)+{+#if defined(__VMS) || defined(__MINGW32__)+ (void)how;+ (void)set;+ (void)oset;+#else+ int ret = pthread_sigmask(how, set, oset);+ assert(ret == 0);+ (void)ret;+#endif+}+++// Creates a new thread with all signals blocked. Returns zero on success+// and non-zero on error.+static inline int+mythread_create(mythread *thread, void *(*func)(void *arg), void *arg)+{+ sigset_t old;+ sigset_t all;+ sigfillset(&all);++ mythread_sigmask(SIG_SETMASK, &all, &old);+ const int ret = pthread_create(thread, NULL, func, arg);+ mythread_sigmask(SIG_SETMASK, &old, NULL);++ return ret;+}++// Joins a thread. Returns zero on success and non-zero on error.+static inline int+mythread_join(mythread thread)+{+ return pthread_join(thread, NULL);+}+++// Initializes a mutex. Returns zero on success and non-zero on error.+static inline int+mythread_mutex_init(mythread_mutex *mutex)+{+ return pthread_mutex_init(mutex, NULL);+}++static inline void+mythread_mutex_destroy(mythread_mutex *mutex)+{+ int ret = pthread_mutex_destroy(mutex);+ assert(ret == 0);+ (void)ret;+}++static inline void+mythread_mutex_lock(mythread_mutex *mutex)+{+ int ret = pthread_mutex_lock(mutex);+ assert(ret == 0);+ (void)ret;+}++static inline void+mythread_mutex_unlock(mythread_mutex *mutex)+{+ int ret = pthread_mutex_unlock(mutex);+ assert(ret == 0);+ (void)ret;+}+++// Initializes a condition variable.+//+// Using CLOCK_MONOTONIC instead of the default CLOCK_REALTIME makes the+// timeout in pthread_cond_timedwait() work correctly also if system time+// is suddenly changed. Unfortunately CLOCK_MONOTONIC isn't available+// everywhere while the default CLOCK_REALTIME is, so the default is+// used if CLOCK_MONOTONIC isn't available.+//+// If clock_gettime() isn't available at all, gettimeofday() will be used.+static inline int+mythread_cond_init(mythread_cond *mycond)+{+#ifdef HAVE_CLOCK_GETTIME+# if defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && \+ defined(HAVE_CLOCK_MONOTONIC)+ struct timespec ts;+ pthread_condattr_t condattr;++ // POSIX doesn't seem to *require* that pthread_condattr_setclock()+ // will fail if given an unsupported clock ID. Test that+ // CLOCK_MONOTONIC really is supported using clock_gettime().+ if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0+ && pthread_condattr_init(&condattr) == 0) {+ int ret = pthread_condattr_setclock(+ &condattr, CLOCK_MONOTONIC);+ if (ret == 0)+ ret = pthread_cond_init(&mycond->cond, &condattr);++ pthread_condattr_destroy(&condattr);++ if (ret == 0) {+ mycond->clk_id = CLOCK_MONOTONIC;+ return 0;+ }+ }++ // If anything above fails, fall back to the default CLOCK_REALTIME.+ // POSIX requires that all implementations of clock_gettime() must+ // support at least CLOCK_REALTIME.+# endif++ mycond->clk_id = CLOCK_REALTIME;+#endif++ return pthread_cond_init(&mycond->cond, NULL);+}++static inline void+mythread_cond_destroy(mythread_cond *cond)+{+ int ret = pthread_cond_destroy(&cond->cond);+ assert(ret == 0);+ (void)ret;+}++static inline void+mythread_cond_signal(mythread_cond *cond)+{+ int ret = pthread_cond_signal(&cond->cond);+ assert(ret == 0);+ (void)ret;+}++static inline void+mythread_cond_wait(mythread_cond *cond, mythread_mutex *mutex)+{+ int ret = pthread_cond_wait(&cond->cond, mutex);+ assert(ret == 0);+ (void)ret;+}++// Waits on a condition or until a timeout expires. If the timeout expires,+// non-zero is returned, otherwise zero is returned.+static inline int+mythread_cond_timedwait(mythread_cond *cond, mythread_mutex *mutex,+ const mythread_condtime *condtime)+{+ int ret = pthread_cond_timedwait(&cond->cond, mutex, condtime);+ assert(ret == 0 || ret == ETIMEDOUT);+ return ret;+}++// Sets condtime to the absolute time that is timeout_ms milliseconds+// in the future. The type of the clock to use is taken from cond.+static inline void+mythread_condtime_set(mythread_condtime *condtime, const mythread_cond *cond,+ uint32_t timeout_ms)+{+ condtime->tv_sec = (time_t)(timeout_ms / 1000);+ condtime->tv_nsec = (long)((timeout_ms % 1000) * 1000000);++#ifdef HAVE_CLOCK_GETTIME+ struct timespec now;+ int ret = clock_gettime(cond->clk_id, &now);+ assert(ret == 0);+ (void)ret;++ condtime->tv_sec += now.tv_sec;+ condtime->tv_nsec += now.tv_nsec;+#else+ (void)cond;++ struct timeval now;+ gettimeofday(&now, NULL);++ condtime->tv_sec += now.tv_sec;+ condtime->tv_nsec += now.tv_usec * 1000L;+#endif++ // tv_nsec must stay in the range [0, 999_999_999].+ if (condtime->tv_nsec >= 1000000000L) {+ condtime->tv_nsec -= 1000000000L;+ ++condtime->tv_sec;+ }+}+++#elif defined(MYTHREAD_WIN95) || defined(MYTHREAD_VISTA)++/////////////////////+// Windows threads //+/////////////////////++#define WIN32_LEAN_AND_MEAN+#ifdef MYTHREAD_VISTA+# undef _WIN32_WINNT+# define _WIN32_WINNT 0x0600+#endif+#include <windows.h>+#include <process.h>++#define MYTHREAD_RET_TYPE unsigned int __stdcall+#define MYTHREAD_RET_VALUE 0++typedef HANDLE mythread;+typedef CRITICAL_SECTION mythread_mutex;++#ifdef MYTHREAD_WIN95+typedef HANDLE mythread_cond;+#else+typedef CONDITION_VARIABLE mythread_cond;+#endif++typedef struct {+ // Tick count (milliseconds) in the beginning of the timeout.+ // NOTE: This is 32 bits so it wraps around after 49.7 days.+ // Multi-day timeouts may not work as expected.+ DWORD start;++ // Length of the timeout in milliseconds. The timeout expires+ // when the current tick count minus "start" is equal or greater+ // than "timeout".+ DWORD timeout;+} mythread_condtime;+++// mythread_once() is only available with Vista threads.+#ifdef MYTHREAD_VISTA+#define mythread_once(func) \+ do { \+ static INIT_ONCE once_ = INIT_ONCE_STATIC_INIT; \+ BOOL pending_; \+ if (!InitOnceBeginInitialize(&once_, 0, &pending_, NULL)) \+ abort(); \+ if (pending_) { \+ func(); \+ if (!InitOnceComplete(&once_, 0, NULL)) \+ abort(); \+ } \+ } while (0)+#endif+++// mythread_sigmask() isn't available on Windows. Even a dummy version would+// make no sense because the other POSIX signal functions are missing anyway.+++static inline int+mythread_create(mythread *thread,+ unsigned int (__stdcall *func)(void *arg), void *arg)+{+ uintptr_t ret = _beginthreadex(NULL, 0, func, arg, 0, NULL);+ if (ret == 0)+ return -1;++ *thread = (HANDLE)ret;+ return 0;+}++static inline int+mythread_join(mythread thread)+{+ int ret = 0;++ if (WaitForSingleObject(thread, INFINITE) != WAIT_OBJECT_0)+ ret = -1;++ if (!CloseHandle(thread))+ ret = -1;++ return ret;+}+++static inline int+mythread_mutex_init(mythread_mutex *mutex)+{+ InitializeCriticalSection(mutex);+ return 0;+}++static inline void+mythread_mutex_destroy(mythread_mutex *mutex)+{+ DeleteCriticalSection(mutex);+}++static inline void+mythread_mutex_lock(mythread_mutex *mutex)+{+ EnterCriticalSection(mutex);+}++static inline void+mythread_mutex_unlock(mythread_mutex *mutex)+{+ LeaveCriticalSection(mutex);+}+++static inline int+mythread_cond_init(mythread_cond *cond)+{+#ifdef MYTHREAD_WIN95+ *cond = CreateEvent(NULL, FALSE, FALSE, NULL);+ return *cond == NULL ? -1 : 0;+#else+ InitializeConditionVariable(cond);+ return 0;+#endif+}++static inline void+mythread_cond_destroy(mythread_cond *cond)+{+#ifdef MYTHREAD_WIN95+ CloseHandle(*cond);+#else+ (void)cond;+#endif+}++static inline void+mythread_cond_signal(mythread_cond *cond)+{+#ifdef MYTHREAD_WIN95+ SetEvent(*cond);+#else+ WakeConditionVariable(cond);+#endif+}++static inline void+mythread_cond_wait(mythread_cond *cond, mythread_mutex *mutex)+{+#ifdef MYTHREAD_WIN95+ LeaveCriticalSection(mutex);+ WaitForSingleObject(*cond, INFINITE);+ EnterCriticalSection(mutex);+#else+ BOOL ret = SleepConditionVariableCS(cond, mutex, INFINITE);+ assert(ret);+ (void)ret;+#endif+}++static inline int+mythread_cond_timedwait(mythread_cond *cond, mythread_mutex *mutex,+ const mythread_condtime *condtime)+{+#ifdef MYTHREAD_WIN95+ LeaveCriticalSection(mutex);+#endif++ DWORD elapsed = GetTickCount() - condtime->start;+ DWORD timeout = elapsed >= condtime->timeout+ ? 0 : condtime->timeout - elapsed;++#ifdef MYTHREAD_WIN95+ DWORD ret = WaitForSingleObject(*cond, timeout);+ assert(ret == WAIT_OBJECT_0 || ret == WAIT_TIMEOUT);++ EnterCriticalSection(mutex);++ return ret == WAIT_TIMEOUT;+#else+ BOOL ret = SleepConditionVariableCS(cond, mutex, timeout);+ assert(ret || GetLastError() == ERROR_TIMEOUT);+ return !ret;+#endif+}++static inline void+mythread_condtime_set(mythread_condtime *condtime, const mythread_cond *cond,+ uint32_t timeout)+{+ (void)cond;+ condtime->start = GetTickCount();+ condtime->timeout = timeout;+}++#endif++#endif
+ cbits/common/sysdefs.h view
@@ -0,0 +1,199 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file sysdefs.h+/// \brief Common includes, definitions, system-specific things etc.+///+/// This file is used also by the lzma command line tool, that's why this+/// file is separate from common.h.+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_SYSDEFS_H+#define LZMA_SYSDEFS_H++//////////////+// Includes //+//////////////++#ifdef HAVE_CONFIG_H+# include <config.h>+#endif++// This #define ensures that C99 and POSIX compliant stdio functions are+// available with MinGW-w64 (both 32-bit and 64-bit). Modern MinGW-w64 adds+// this automatically, for example, when the compiler is in C99 (or later)+// mode when building against msvcrt.dll. It still doesn't hurt to be explicit+// that we always want this and #define this unconditionally.+//+// With Universal CRT (UCRT) this is less important because UCRT contains+// C99-compatible stdio functions. It's still nice to #define this as UCRT+// doesn't support the POSIX thousand separator flag in printf (like "%'u").+#ifdef __MINGW32__+# define __USE_MINGW_ANSI_STDIO 1+#endif++// 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.+#include <limits.h>++// 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 unsigned int is not 32-bit.+# endif+# define UINT32_C(n) n ## U+#endif+#ifndef UINT32_MAX+# define UINT32_MAX UINT32_C(4294967295)+#endif+#ifndef PRIu32+# define PRIu32 "u"+#endif+#ifndef PRIx32+# define PRIx32 "x"+#endif+#ifndef PRIX32+# define PRIX32 "X"+#endif++#if ULONG_MAX == 4294967295UL+# ifndef UINT64_C+# define UINT64_C(n) n ## ULL+# endif+# ifndef PRIu64+# define PRIu64 "llu"+# endif+# ifndef PRIx64+# define PRIx64 "llx"+# endif+# ifndef PRIX64+# define PRIX64 "llX"+# endif+#else+# ifndef UINT64_C+# define UINT64_C(n) n ## UL+# endif+# ifndef PRIu64+# define PRIu64 "lu"+# endif+# ifndef PRIx64+# define PRIx64 "lx"+# endif+# ifndef PRIX64+# define PRIX64 "lX"+# endif+#endif+#ifndef UINT64_MAX+# define UINT64_MAX UINT64_C(18446744073709551615)+#endif++// Incorrect(?) SIZE_MAX:+// - Interix headers typedef size_t to unsigned long,+// but a few lines later define SIZE_MAX to INT32_MAX.+// - SCO OpenServer (x86) headers typedef size_t to unsigned int+// but define SIZE_MAX to INT32_MAX.+#if defined(__INTERIX) || defined(_SCO_DS)+# undef SIZE_MAX+#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+# elif SIZEOF_SIZE_T == 8+# define SIZE_MAX UINT64_MAX+# else+# error size_t is not 32-bit or 64-bit+# endif+#endif+#if SIZE_MAX != UINT32_MAX && SIZE_MAX != UINT64_MAX+# error size_t is not 32-bit or 64-bit+#endif++#include <stdlib.h>+#include <assert.h>++// Pre-C99 systems lack stdbool.h. All the code in XZ 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+# if ! HAVE__BOOL+typedef unsigned char _Bool;+# endif+# define bool _Bool+# define false 0+# define true 1+# define __bool_true_false_are_defined 1+#endif++#include <string.h>++// Visual Studio 2013 update 2 supports only __inline, not inline.+// MSVC v19.0 / VS 2015 and newer support both.+//+// MSVC v19.27 (VS 2019 version 16.7) added support for restrict.+// Older ones support only __restrict.+#ifdef _MSC_VER+# if _MSC_VER < 1900 && !defined(inline)+# define inline __inline+# endif+# if _MSC_VER < 1927 && !defined(restrict)+# define restrict __restrict+# endif+#endif++////////////+// Macros //+////////////++#undef memzero+#define memzero(s, n) memset(s, 0, n)++// NOTE: Avoid using MIN() and MAX(), because even conditionally defining+// those macros can cause some portability trouble, since on some systems+// the system headers insist defining their own versions.+#define my_min(x, y) ((x) < (y) ? (x) : (y))+#define my_max(x, y) ((x) > (y) ? (x) : (y))++#ifndef ARRAY_SIZE+# define ARRAY_SIZE(array) (sizeof(array) / sizeof((array)[0]))+#endif++#if defined(__GNUC__) \+ && ((__GNUC__ == 4 && __GNUC_MINOR__ >= 3) || __GNUC__ > 4)+# define lzma_attr_alloc_size(x) __attribute__((__alloc_size__(x)))+#else+# define lzma_attr_alloc_size(x)+#endif++#endif
+ cbits/common/tuklib_common.h view
@@ -0,0 +1,90 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_common.h+/// \brief Common definitions for tuklib modules+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef TUKLIB_COMMON_H+#define TUKLIB_COMMON_H++// The config file may be replaced by a package-specific file.+// It should include at least stddef.h, stdbool.h, inttypes.h, and limits.h.+#include "tuklib_config.h"++// TUKLIB_SYMBOL_PREFIX is prefixed to all symbols exported by+// the tuklib modules. If you use a tuklib module in a library,+// you should use TUKLIB_SYMBOL_PREFIX to make sure that there+// are no symbol conflicts in case someone links your library+// into application that also uses the same tuklib module.+#ifndef TUKLIB_SYMBOL_PREFIX+# define TUKLIB_SYMBOL_PREFIX+#endif++#define TUKLIB_CAT_X(a, b) a ## b+#define TUKLIB_CAT(a, b) TUKLIB_CAT_X(a, b)++#ifndef TUKLIB_SYMBOL+# define TUKLIB_SYMBOL(sym) TUKLIB_CAT(TUKLIB_SYMBOL_PREFIX, sym)+#endif++#ifndef TUKLIB_DECLS_BEGIN+# ifdef __cplusplus+# define TUKLIB_DECLS_BEGIN extern "C" {+# else+# define TUKLIB_DECLS_BEGIN+# endif+#endif++#ifndef TUKLIB_DECLS_END+# ifdef __cplusplus+# define TUKLIB_DECLS_END }+# else+# define TUKLIB_DECLS_END+# endif+#endif++#if defined(__GNUC__) && defined(__GNUC_MINOR__)+# define TUKLIB_GNUC_REQ(major, minor) \+ ((__GNUC__ == (major) && __GNUC_MINOR__ >= (minor)) \+ || __GNUC__ > (major))+#else+# define TUKLIB_GNUC_REQ(major, minor) 0+#endif++// tuklib_attr_noreturn attribute is used to mark functions as non-returning.+// We cannot use "noreturn" as the macro name because then C23 code that+// uses [[noreturn]] would break as it would expand to [[ [[noreturn]] ]].+//+// tuklib_attr_noreturn must be used at the beginning of function declaration+// to work in all cases. The [[noreturn]] syntax is the most limiting, it+// must be even before any GNU C's __attribute__ keywords:+//+// tuklib_attr_noreturn+// __attribute__((nonnull(1)))+// extern void foo(const char *s);+//+// FIXME: Update __STDC_VERSION__ for the final C23 version. 202000 is used+// by GCC 13 and Clang 15 with -std=c2x.+#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 202000+# define tuklib_attr_noreturn [[noreturn]]+#elif defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201112+# define tuklib_attr_noreturn _Noreturn+#elif TUKLIB_GNUC_REQ(2, 5)+# define tuklib_attr_noreturn __attribute__((__noreturn__))+#elif defined(_MSC_VER)+# define tuklib_attr_noreturn __declspec(noreturn)+#else+# define tuklib_attr_noreturn+#endif++#if (defined(_WIN32) && !defined(__CYGWIN__)) \+ || defined(__OS2__) || defined(__MSDOS__)+# define TUKLIB_DOSLIKE 1+#endif++#endif
+ cbits/common/tuklib_config.h view
@@ -0,0 +1,12 @@+// SPDX-License-Identifier: 0BSD++// If config.h isn't available, assume that the headers required by+// tuklib_common.h are available. This is required by crc32_tablegen.c.+#ifdef HAVE_CONFIG_H+# include "sysdefs.h"+#else+# include <stddef.h>+# include <stdbool.h>+# include <inttypes.h>+# include <limits.h>+#endif
+ cbits/common/tuklib_cpucores.c view
@@ -0,0 +1,108 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_cpucores.c+/// \brief Get the number of CPU cores online+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "tuklib_cpucores.h"++#if defined(_WIN32) || defined(__CYGWIN__)+# ifndef _WIN32_WINNT+# define _WIN32_WINNT 0x0500+# endif+# include <windows.h>++// glibc >= 2.9+#elif defined(TUKLIB_CPUCORES_SCHED_GETAFFINITY)+# include <sched.h>++// FreeBSD+#elif defined(TUKLIB_CPUCORES_CPUSET)+# include <sys/param.h>+# include <sys/cpuset.h>++#elif defined(TUKLIB_CPUCORES_SYSCTL)+# ifdef HAVE_SYS_PARAM_H+# include <sys/param.h>+# endif+# include <sys/sysctl.h>++#elif defined(TUKLIB_CPUCORES_SYSCONF)+# include <unistd.h>++// HP-UX+#elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC)+# include <sys/param.h>+# include <sys/pstat.h>+#endif+++extern uint32_t+tuklib_cpucores(void)+{+ uint32_t ret = 0;++#if defined(_WIN32) || defined(__CYGWIN__)+ SYSTEM_INFO sysinfo;+ GetSystemInfo(&sysinfo);+ ret = sysinfo.dwNumberOfProcessors;++#elif defined(TUKLIB_CPUCORES_SCHED_GETAFFINITY)+ cpu_set_t cpu_mask;+ if (sched_getaffinity(0, sizeof(cpu_mask), &cpu_mask) == 0)+ ret = (uint32_t)CPU_COUNT(&cpu_mask);++#elif defined(TUKLIB_CPUCORES_CPUSET)+ cpuset_t set;+ if (cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,+ sizeof(set), &set) == 0) {+# ifdef CPU_COUNT+ ret = (uint32_t)CPU_COUNT(&set);+# else+ for (unsigned i = 0; i < CPU_SETSIZE; ++i)+ if (CPU_ISSET(i, &set))+ ++ret;+# endif+ }++#elif defined(TUKLIB_CPUCORES_SYSCTL)+ // On OpenBSD HW_NCPUONLINE tells the number of processor cores that+ // are online so it is preferred over HW_NCPU which also counts cores+ // that aren't currently available. The number of cores online is+ // often less than HW_NCPU because OpenBSD disables simultaneous+ // multi-threading (SMT) by default.+# ifdef HW_NCPUONLINE+ int name[2] = { CTL_HW, HW_NCPUONLINE };+# else+ int name[2] = { CTL_HW, HW_NCPU };+# endif+ int cpus;+ size_t cpus_size = sizeof(cpus);+ if (sysctl(name, 2, &cpus, &cpus_size, NULL, 0) != -1+ && cpus_size == sizeof(cpus) && cpus > 0)+ ret = (uint32_t)cpus;++#elif defined(TUKLIB_CPUCORES_SYSCONF)+# ifdef _SC_NPROCESSORS_ONLN+ // Most systems+ const long cpus = sysconf(_SC_NPROCESSORS_ONLN);+# else+ // IRIX+ const long cpus = sysconf(_SC_NPROC_ONLN);+# endif+ if (cpus > 0)+ ret = (uint32_t)cpus;++#elif defined(TUKLIB_CPUCORES_PSTAT_GETDYNAMIC)+ struct pst_dynamic pst;+ if (pstat_getdynamic(&pst, sizeof(pst), 1, 0) != -1)+ ret = (uint32_t)pst.psd_proc_cnt;+#endif++ return ret;+}
+ cbits/common/tuklib_cpucores.h view
@@ -0,0 +1,22 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_cpucores.h+/// \brief Get the number of CPU cores online+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef TUKLIB_CPUCORES_H+#define TUKLIB_CPUCORES_H++#include "tuklib_common.h"+TUKLIB_DECLS_BEGIN++#define tuklib_cpucores TUKLIB_SYMBOL(tuklib_cpucores)+extern uint32_t tuklib_cpucores(void);++TUKLIB_DECLS_END+#endif
+ cbits/common/tuklib_exit.c view
@@ -0,0 +1,57 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_exit.c+/// \brief Close stdout and stderr, and exit+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "tuklib_common.h"++#include <stdlib.h>+#include <stdio.h>+#include <string.h>++#include "tuklib_gettext.h"+#include "tuklib_progname.h"+#include "tuklib_exit.h"+++extern void+tuklib_exit(int status, int err_status, int show_error)+{+ if (status != err_status) {+ // Close stdout. If something goes wrong,+ // print an error message to stderr.+ const int ferror_err = ferror(stdout);+ const int fclose_err = fclose(stdout);+ if (ferror_err || fclose_err) {+ status = err_status;++ // If it was fclose() that failed, we have the reason+ // in errno. If only ferror() indicated an error,+ // we have no idea what the reason was.+ if (show_error)+ fprintf(stderr, "%s: %s: %s\n", progname,+ _("Writing to standard "+ "output failed"),+ fclose_err ? strerror(errno)+ : _("Unknown error"));+ }+ }++ if (status != err_status) {+ // Close stderr. If something goes wrong, there's+ // nothing where we could print an error message.+ // Just set the exit status.+ const int ferror_err = ferror(stderr);+ const int fclose_err = fclose(stderr);+ if (fclose_err || ferror_err)+ status = err_status;+ }++ exit(status);+}
+ cbits/common/tuklib_exit.h view
@@ -0,0 +1,24 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_exit.h+/// \brief Close stdout and stderr, and exit+/// \note Requires tuklib_progname and tuklib_gettext modules+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef TUKLIB_EXIT_H+#define TUKLIB_EXIT_H++#include "tuklib_common.h"+TUKLIB_DECLS_BEGIN++#define tuklib_exit TUKLIB_SYMBOL(tuklib_exit)+tuklib_attr_noreturn+extern void tuklib_exit(int status, int err_status, int show_error);++TUKLIB_DECLS_END+#endif
+ cbits/common/tuklib_gettext.h view
@@ -0,0 +1,43 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_gettext.h+/// \brief Wrapper for gettext and friends+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef TUKLIB_GETTEXT_H+#define TUKLIB_GETTEXT_H++#include "tuklib_common.h"+#include <locale.h>++#ifndef TUKLIB_GETTEXT+# ifdef ENABLE_NLS+# define TUKLIB_GETTEXT 1+# else+# define TUKLIB_GETTEXT 0+# endif+#endif++#if TUKLIB_GETTEXT+# include <libintl.h>+# define tuklib_gettext_init(package, localedir) \+ do { \+ setlocale(LC_ALL, ""); \+ bindtextdomain(package, localedir); \+ textdomain(package); \+ } while (0)+# define _(msgid) gettext(msgid)+#else+# define tuklib_gettext_init(package, localedir) \+ setlocale(LC_ALL, "")+# define _(msgid) (msgid)+# define ngettext(msgid1, msgid2, n) ((n) == 1 ? (msgid1) : (msgid2))+#endif+#define N_(msgid) msgid++#endif
+ cbits/common/tuklib_integer.h view
@@ -0,0 +1,954 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_integer.h+/// \brief Various integer and bit operations+///+/// This file provides macros or functions to do some basic integer and bit+/// operations.+///+/// Native endian inline functions (XX = 16, 32, or 64):+/// - Unaligned native endian reads: readXXne(ptr)+/// - Unaligned native endian writes: writeXXne(ptr, num)+/// - Aligned native endian reads: aligned_readXXne(ptr)+/// - Aligned native endian writes: aligned_writeXXne(ptr, num)+///+/// Endianness-converting integer operations (these can be macros!)+/// (XX = 16, 32, or 64; Y = b or l):+/// - Byte swapping: byteswapXX(num)+/// - Byte order conversions to/from native (byteswaps if Y isn't+/// the native endianness): convXXYe(num)+/// - Unaligned reads: readXXYe(ptr)+/// - Unaligned writes: writeXXYe(ptr, num)+/// - Aligned reads: aligned_readXXYe(ptr)+/// - Aligned writes: aligned_writeXXYe(ptr, num)+///+/// Since the above can macros, the arguments should have no side effects+/// because they may be evaluated more than once.+///+/// Bit scan operations for non-zero 32-bit integers (inline functions):+/// - Bit scan reverse (find highest non-zero bit): bsr32(num)+/// - Count leading zeros: clz32(num)+/// - Count trailing zeros: ctz32(num)+/// - Bit scan forward (simply an alias for ctz32()): bsf32(num)+///+/// The above bit scan operations return 0-31. If num is zero,+/// the result is undefined.+//+// Authors: Lasse Collin+// Joachim Henke+//+///////////////////////////////////////////////////////////////////////////////++#ifndef TUKLIB_INTEGER_H+#define TUKLIB_INTEGER_H++#include "tuklib_common.h"+#include <string.h>++// Newer Intel C compilers require immintrin.h for _bit_scan_reverse()+// and such functions.+#if defined(__INTEL_COMPILER) && (__INTEL_COMPILER >= 1500)+# include <immintrin.h>+// Only include <intrin.h> when it is needed. GCC and Clang can both+// use __builtin's, so we only need Windows instrincs when using MSVC.+// GCC and Clang can set _MSC_VER on Windows, so we need to exclude these+// cases explicitly.+#elif defined(_MSC_VER) && !TUKLIB_GNUC_REQ(3, 4) && !defined(__clang__)+# include <intrin.h>+#endif+++///////////////////+// Byte swapping //+///////////////////++#if defined(HAVE___BUILTIN_BSWAPXX)+ // GCC >= 4.8 and Clang+# define byteswap16(num) __builtin_bswap16(num)+# define byteswap32(num) __builtin_bswap32(num)+# define byteswap64(num) __builtin_bswap64(num)++#elif defined(HAVE_BYTESWAP_H)+ // glibc, uClibc, dietlibc+# include <byteswap.h>+# ifdef HAVE_BSWAP_16+# define byteswap16(num) bswap_16(num)+# endif+# ifdef HAVE_BSWAP_32+# define byteswap32(num) bswap_32(num)+# endif+# ifdef HAVE_BSWAP_64+# define byteswap64(num) bswap_64(num)+# endif++#elif defined(HAVE_SYS_ENDIAN_H)+ // *BSDs and Darwin+# include <sys/endian.h>+# ifdef __OpenBSD__+# define byteswap16(num) swap16(num)+# define byteswap32(num) swap32(num)+# define byteswap64(num) swap64(num)+# else+# define byteswap16(num) bswap16(num)+# define byteswap32(num) bswap32(num)+# define byteswap64(num) bswap64(num)+# endif++#elif defined(HAVE_SYS_BYTEORDER_H)+ // Solaris+# include <sys/byteorder.h>+# ifdef BSWAP_16+# define byteswap16(num) BSWAP_16(num)+# endif+# ifdef BSWAP_32+# define byteswap32(num) BSWAP_32(num)+# endif+# ifdef BSWAP_64+# define byteswap64(num) BSWAP_64(num)+# endif+# ifdef BE_16+# define conv16be(num) BE_16(num)+# endif+# ifdef BE_32+# define conv32be(num) BE_32(num)+# endif+# ifdef BE_64+# define conv64be(num) BE_64(num)+# endif+# ifdef LE_16+# define conv16le(num) LE_16(num)+# endif+# ifdef LE_32+# define conv32le(num) LE_32(num)+# endif+# ifdef LE_64+# define conv64le(num) LE_64(num)+# endif+#endif++#ifndef byteswap16+# define byteswap16(n) (uint16_t)( \+ (((n) & 0x00FFU) << 8) \+ | (((n) & 0xFF00U) >> 8) \+ )+#endif++#ifndef byteswap32+# define byteswap32(n) (uint32_t)( \+ (((n) & UINT32_C(0x000000FF)) << 24) \+ | (((n) & UINT32_C(0x0000FF00)) << 8) \+ | (((n) & UINT32_C(0x00FF0000)) >> 8) \+ | (((n) & UINT32_C(0xFF000000)) >> 24) \+ )+#endif++#ifndef byteswap64+# define byteswap64(n) (uint64_t)( \+ (((n) & UINT64_C(0x00000000000000FF)) << 56) \+ | (((n) & UINT64_C(0x000000000000FF00)) << 40) \+ | (((n) & UINT64_C(0x0000000000FF0000)) << 24) \+ | (((n) & UINT64_C(0x00000000FF000000)) << 8) \+ | (((n) & UINT64_C(0x000000FF00000000)) >> 8) \+ | (((n) & UINT64_C(0x0000FF0000000000)) >> 24) \+ | (((n) & UINT64_C(0x00FF000000000000)) >> 40) \+ | (((n) & UINT64_C(0xFF00000000000000)) >> 56) \+ )+#endif++// Define conversion macros using the basic byte swapping macros.+#ifdef WORDS_BIGENDIAN+# ifndef conv16be+# define conv16be(num) ((uint16_t)(num))+# endif+# ifndef conv32be+# define conv32be(num) ((uint32_t)(num))+# endif+# ifndef conv64be+# define conv64be(num) ((uint64_t)(num))+# endif+# ifndef conv16le+# define conv16le(num) byteswap16(num)+# endif+# ifndef conv32le+# define conv32le(num) byteswap32(num)+# endif+# ifndef conv64le+# define conv64le(num) byteswap64(num)+# endif+#else+# ifndef conv16be+# define conv16be(num) byteswap16(num)+# endif+# ifndef conv32be+# define conv32be(num) byteswap32(num)+# endif+# ifndef conv64be+# define conv64be(num) byteswap64(num)+# endif+# ifndef conv16le+# define conv16le(num) ((uint16_t)(num))+# endif+# ifndef conv32le+# define conv32le(num) ((uint32_t)(num))+# endif+# ifndef conv64le+# define conv64le(num) ((uint64_t)(num))+# endif+#endif+++////////////////////////////////+// Unaligned reads and writes //+////////////////////////////////++// No-strict-align archs like x86-64+// ---------------------------------+//+// The traditional way of casting e.g. *(const uint16_t *)uint8_pointer+// is bad even if the uint8_pointer is properly aligned because this kind+// of casts break strict aliasing rules and result in undefined behavior.+// With unaligned pointers it's even worse: compilers may emit vector+// instructions that require aligned pointers even if non-vector+// instructions work with unaligned pointers.+//+// Using memcpy() is the standard compliant way to do unaligned access.+// Many modern compilers inline it so there is no function call overhead.+// For those compilers that don't handle the memcpy() method well, the+// old casting method (that violates strict aliasing) can be requested at+// build time. A third method, casting to a packed struct, would also be+// an option but isn't provided to keep things simpler (it's already a mess).+// Hopefully this is flexible enough in practice.+//+// Some compilers on x86-64 like Clang >= 10 and GCC >= 5.1 detect that+//+// buf[0] | (buf[1] << 8)+//+// reads a 16-bit value and can emit a single 16-bit load and produce+// identical code than with the memcpy() method. In other cases Clang and GCC+// produce either the same or better code with memcpy(). For example, Clang 9+// on x86-64 can detect 32-bit load but not 16-bit load.+//+// MSVC uses unaligned access with the memcpy() method but emits byte-by-byte+// code for "buf[0] | (buf[1] << 8)".+//+// Conclusion: The memcpy() method is the best choice when unaligned access+// is supported.+//+// Strict-align archs like SPARC+// -----------------------------+//+// GCC versions from around 4.x to to at least 13.2.0 produce worse code+// from the memcpy() method than from simple byte-by-byte shift-or code+// when reading a 32-bit integer:+//+// (1) It may be constructed on stack using four 8-bit loads,+// four 8-bit stores to stack, and finally one 32-bit load from stack.+//+// (2) Especially with -Os, an actual memcpy() call may be emitted.+//+// This is true on at least on ARM, ARM64, SPARC, SPARC64, MIPS64EL, and+// RISC-V. Of these, ARM, ARM64, and RISC-V support unaligned access in+// some processors but not all so this is relevant only in the case when+// GCC assumes that unaligned is not supported or -mstrict-align or+// -mno-unaligned-access is used.+//+// For Clang it makes little difference. ARM64 with -O2 -mstrict-align+// was one the very few with a minor difference: the memcpy() version+// was one instruction longer.+//+// Conclusion: At least in case of GCC and Clang, byte-by-byte code is+// the best choice for strict-align archs to do unaligned access.+//+// See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111502+//+// Thanks to <https://godbolt.org/> it was easy to test different compilers.+// The following is for little endian targets:+/*+#include <stdint.h>+#include <string.h>++uint32_t bytes16(const uint8_t *b)+{+ return (uint32_t)b[0]+ | ((uint32_t)b[1] << 8);+}++uint32_t copy16(const uint8_t *b)+{+ uint16_t v;+ memcpy(&v, b, sizeof(v));+ return v;+}++uint32_t bytes32(const uint8_t *b)+{+ return (uint32_t)b[0]+ | ((uint32_t)b[1] << 8)+ | ((uint32_t)b[2] << 16)+ | ((uint32_t)b[3] << 24);+}++uint32_t copy32(const uint8_t *b)+{+ uint32_t v;+ memcpy(&v, b, sizeof(v));+ return v;+}++void wbytes16(uint8_t *b, uint16_t v)+{+ b[0] = (uint8_t)v;+ b[1] = (uint8_t)(v >> 8);+}++void wcopy16(uint8_t *b, uint16_t v)+{+ memcpy(b, &v, sizeof(v));+}++void wbytes32(uint8_t *b, uint32_t v)+{+ b[0] = (uint8_t)v;+ b[1] = (uint8_t)(v >> 8);+ b[2] = (uint8_t)(v >> 16);+ b[3] = (uint8_t)(v >> 24);+}++void wcopy32(uint8_t *b, uint32_t v)+{+ memcpy(b, &v, sizeof(v));+}+*/+++#ifdef TUKLIB_FAST_UNALIGNED_ACCESS++static inline uint16_t+read16ne(const uint8_t *buf)+{+#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING+ return *(const uint16_t *)buf;+#else+ uint16_t num;+ memcpy(&num, buf, sizeof(num));+ return num;+#endif+}+++static inline uint32_t+read32ne(const uint8_t *buf)+{+#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING+ return *(const uint32_t *)buf;+#else+ uint32_t num;+ memcpy(&num, buf, sizeof(num));+ return num;+#endif+}+++static inline uint64_t+read64ne(const uint8_t *buf)+{+#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING+ return *(const uint64_t *)buf;+#else+ uint64_t num;+ memcpy(&num, buf, sizeof(num));+ return num;+#endif+}+++static inline void+write16ne(uint8_t *buf, uint16_t num)+{+#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING+ *(uint16_t *)buf = num;+#else+ memcpy(buf, &num, sizeof(num));+#endif+ return;+}+++static inline void+write32ne(uint8_t *buf, uint32_t num)+{+#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING+ *(uint32_t *)buf = num;+#else+ memcpy(buf, &num, sizeof(num));+#endif+ return;+}+++static inline void+write64ne(uint8_t *buf, uint64_t num)+{+#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING+ *(uint64_t *)buf = num;+#else+ memcpy(buf, &num, sizeof(num));+#endif+ return;+}+++static inline uint16_t+read16be(const uint8_t *buf)+{+ uint16_t num = read16ne(buf);+ return conv16be(num);+}+++static inline uint16_t+read16le(const uint8_t *buf)+{+ uint16_t num = read16ne(buf);+ return conv16le(num);+}+++static inline uint32_t+read32be(const uint8_t *buf)+{+ uint32_t num = read32ne(buf);+ return conv32be(num);+}+++static inline uint32_t+read32le(const uint8_t *buf)+{+ uint32_t num = read32ne(buf);+ return conv32le(num);+}+++static inline uint64_t+read64be(const uint8_t *buf)+{+ uint64_t num = read64ne(buf);+ return conv64be(num);+}+++static inline uint64_t+read64le(const uint8_t *buf)+{+ uint64_t num = read64ne(buf);+ return conv64le(num);+}+++// NOTE: Possible byte swapping must be done in a macro to allow the compiler+// to optimize byte swapping of constants when using glibc's or *BSD's+// byte swapping macros. The actual write is done in an inline function+// to make type checking of the buf pointer possible.+#define write16be(buf, num) write16ne(buf, conv16be(num))+#define write32be(buf, num) write32ne(buf, conv32be(num))+#define write64be(buf, num) write64ne(buf, conv64be(num))+#define write16le(buf, num) write16ne(buf, conv16le(num))+#define write32le(buf, num) write32ne(buf, conv32le(num))+#define write64le(buf, num) write64ne(buf, conv64le(num))++#else++#ifdef WORDS_BIGENDIAN+# define read16ne read16be+# define read32ne read32be+# define read64ne read64be+# define write16ne write16be+# define write32ne write32be+# define write64ne write64be+#else+# define read16ne read16le+# define read32ne read32le+# define read64ne read64le+# define write16ne write16le+# define write32ne write32le+# define write64ne write64le+#endif+++static inline uint16_t+read16be(const uint8_t *buf)+{+ uint16_t num = ((uint16_t)buf[0] << 8) | (uint16_t)buf[1];+ return num;+}+++static inline uint16_t+read16le(const uint8_t *buf)+{+ uint16_t num = ((uint16_t)buf[0]) | ((uint16_t)buf[1] << 8);+ return num;+}+++static inline uint32_t+read32be(const uint8_t *buf)+{+ uint32_t num = (uint32_t)buf[0] << 24;+ num |= (uint32_t)buf[1] << 16;+ num |= (uint32_t)buf[2] << 8;+ num |= (uint32_t)buf[3];+ return num;+}+++static inline uint32_t+read32le(const uint8_t *buf)+{+ uint32_t num = (uint32_t)buf[0];+ num |= (uint32_t)buf[1] << 8;+ num |= (uint32_t)buf[2] << 16;+ num |= (uint32_t)buf[3] << 24;+ return num;+}+++static inline uint64_t+read64be(const uint8_t *buf)+{+ uint64_t num = (uint64_t)buf[0] << 56;+ num |= (uint64_t)buf[1] << 48;+ num |= (uint64_t)buf[2] << 40;+ num |= (uint64_t)buf[3] << 32;+ num |= (uint64_t)buf[4] << 24;+ num |= (uint64_t)buf[5] << 16;+ num |= (uint64_t)buf[6] << 8;+ num |= (uint64_t)buf[7];+ return num;+}+++static inline uint64_t+read64le(const uint8_t *buf)+{+ uint64_t num = (uint64_t)buf[0];+ num |= (uint64_t)buf[1] << 8;+ num |= (uint64_t)buf[2] << 16;+ num |= (uint64_t)buf[3] << 24;+ num |= (uint64_t)buf[4] << 32;+ num |= (uint64_t)buf[5] << 40;+ num |= (uint64_t)buf[6] << 48;+ num |= (uint64_t)buf[7] << 56;+ return num;+}+++static inline void+write16be(uint8_t *buf, uint16_t num)+{+ buf[0] = (uint8_t)(num >> 8);+ buf[1] = (uint8_t)num;+ return;+}+++static inline void+write16le(uint8_t *buf, uint16_t num)+{+ buf[0] = (uint8_t)num;+ buf[1] = (uint8_t)(num >> 8);+ return;+}+++static inline void+write32be(uint8_t *buf, uint32_t num)+{+ buf[0] = (uint8_t)(num >> 24);+ buf[1] = (uint8_t)(num >> 16);+ buf[2] = (uint8_t)(num >> 8);+ buf[3] = (uint8_t)num;+ return;+}+++static inline void+write32le(uint8_t *buf, uint32_t num)+{+ buf[0] = (uint8_t)num;+ buf[1] = (uint8_t)(num >> 8);+ buf[2] = (uint8_t)(num >> 16);+ buf[3] = (uint8_t)(num >> 24);+ return;+}+++static inline void+write64be(uint8_t *buf, uint64_t num)+{+ buf[0] = (uint8_t)(num >> 56);+ buf[1] = (uint8_t)(num >> 48);+ buf[2] = (uint8_t)(num >> 40);+ buf[3] = (uint8_t)(num >> 32);+ buf[4] = (uint8_t)(num >> 24);+ buf[5] = (uint8_t)(num >> 16);+ buf[6] = (uint8_t)(num >> 8);+ buf[7] = (uint8_t)num;+ return;+}+++static inline void+write64le(uint8_t *buf, uint64_t num)+{+ buf[0] = (uint8_t)num;+ buf[1] = (uint8_t)(num >> 8);+ buf[2] = (uint8_t)(num >> 16);+ buf[3] = (uint8_t)(num >> 24);+ buf[4] = (uint8_t)(num >> 32);+ buf[5] = (uint8_t)(num >> 40);+ buf[6] = (uint8_t)(num >> 48);+ buf[7] = (uint8_t)(num >> 56);+ return;+}++#endif+++//////////////////////////////+// Aligned reads and writes //+//////////////////////////////++// Separate functions for aligned reads and writes are provided since on+// strict-align archs aligned access is much faster than unaligned access.+//+// Just like in the unaligned case, memcpy() is needed to avoid+// strict aliasing violations. However, on archs that don't support+// unaligned access the compiler cannot know that the pointers given+// to memcpy() are aligned which results in slow code. As of C11 there is+// no standard way to tell the compiler that we know that the address is+// aligned but some compilers have language extensions to do that. With+// such language extensions the memcpy() method gives excellent results.+//+// What to do on a strict-align system when no known language extensions+// are available? Falling back to byte-by-byte access would be safe but ruin+// optimizations that have been made specifically with aligned access in mind.+// As a compromise, aligned reads will fall back to non-compliant type punning+// but aligned writes will be byte-by-byte, that is, fast reads are preferred+// over fast writes. This obviously isn't great but hopefully it's a working+// compromise for now.+//+// __builtin_assume_aligned is support by GCC >= 4.7 and clang >= 3.6.+#ifdef HAVE___BUILTIN_ASSUME_ALIGNED+# define tuklib_memcpy_aligned(dest, src, size) \+ memcpy(dest, __builtin_assume_aligned(src, size), size)+#else+# define tuklib_memcpy_aligned(dest, src, size) \+ memcpy(dest, src, size)+# ifndef TUKLIB_FAST_UNALIGNED_ACCESS+# define TUKLIB_USE_UNSAFE_ALIGNED_READS 1+# endif+#endif+++static inline uint16_t+aligned_read16ne(const uint8_t *buf)+{+#if defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) \+ || defined(TUKLIB_USE_UNSAFE_ALIGNED_READS)+ return *(const uint16_t *)buf;+#else+ uint16_t num;+ tuklib_memcpy_aligned(&num, buf, sizeof(num));+ return num;+#endif+}+++static inline uint32_t+aligned_read32ne(const uint8_t *buf)+{+#if defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) \+ || defined(TUKLIB_USE_UNSAFE_ALIGNED_READS)+ return *(const uint32_t *)buf;+#else+ uint32_t num;+ tuklib_memcpy_aligned(&num, buf, sizeof(num));+ return num;+#endif+}+++static inline uint64_t+aligned_read64ne(const uint8_t *buf)+{+#if defined(TUKLIB_USE_UNSAFE_TYPE_PUNNING) \+ || defined(TUKLIB_USE_UNSAFE_ALIGNED_READS)+ return *(const uint64_t *)buf;+#else+ uint64_t num;+ tuklib_memcpy_aligned(&num, buf, sizeof(num));+ return num;+#endif+}+++static inline void+aligned_write16ne(uint8_t *buf, uint16_t num)+{+#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING+ *(uint16_t *)buf = num;+#else+ tuklib_memcpy_aligned(buf, &num, sizeof(num));+#endif+ return;+}+++static inline void+aligned_write32ne(uint8_t *buf, uint32_t num)+{+#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING+ *(uint32_t *)buf = num;+#else+ tuklib_memcpy_aligned(buf, &num, sizeof(num));+#endif+ return;+}+++static inline void+aligned_write64ne(uint8_t *buf, uint64_t num)+{+#ifdef TUKLIB_USE_UNSAFE_TYPE_PUNNING+ *(uint64_t *)buf = num;+#else+ tuklib_memcpy_aligned(buf, &num, sizeof(num));+#endif+ return;+}+++static inline uint16_t+aligned_read16be(const uint8_t *buf)+{+ uint16_t num = aligned_read16ne(buf);+ return conv16be(num);+}+++static inline uint16_t+aligned_read16le(const uint8_t *buf)+{+ uint16_t num = aligned_read16ne(buf);+ return conv16le(num);+}+++static inline uint32_t+aligned_read32be(const uint8_t *buf)+{+ uint32_t num = aligned_read32ne(buf);+ return conv32be(num);+}+++static inline uint32_t+aligned_read32le(const uint8_t *buf)+{+ uint32_t num = aligned_read32ne(buf);+ return conv32le(num);+}+++static inline uint64_t+aligned_read64be(const uint8_t *buf)+{+ uint64_t num = aligned_read64ne(buf);+ return conv64be(num);+}+++static inline uint64_t+aligned_read64le(const uint8_t *buf)+{+ uint64_t num = aligned_read64ne(buf);+ return conv64le(num);+}+++// These need to be macros like in the unaligned case.+#define aligned_write16be(buf, num) aligned_write16ne((buf), conv16be(num))+#define aligned_write16le(buf, num) aligned_write16ne((buf), conv16le(num))+#define aligned_write32be(buf, num) aligned_write32ne((buf), conv32be(num))+#define aligned_write32le(buf, num) aligned_write32ne((buf), conv32le(num))+#define aligned_write64be(buf, num) aligned_write64ne((buf), conv64be(num))+#define aligned_write64le(buf, num) aligned_write64ne((buf), conv64le(num))+++////////////////////+// Bit operations //+////////////////////++static inline uint32_t+bsr32(uint32_t n)+{+ // Check for ICC first, since it tends to define __GNUC__ too.+#if defined(__INTEL_COMPILER)+ return _bit_scan_reverse(n);++#elif (TUKLIB_GNUC_REQ(3, 4) || defined(__clang__)) && UINT_MAX == UINT32_MAX+ // GCC >= 3.4 has __builtin_clz(), which gives good results on+ // multiple architectures. On x86, __builtin_clz() ^ 31U becomes+ // either plain BSR (so the XOR gets optimized away) or LZCNT and+ // XOR (if -march indicates that SSE4a instructions are supported).+ return (uint32_t)__builtin_clz(n) ^ 31U;++#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))+ uint32_t i;+ __asm__("bsrl %1, %0" : "=r" (i) : "rm" (n));+ return i;++#elif defined(_MSC_VER)+ unsigned long i;+ _BitScanReverse(&i, n);+ return i;++#else+ uint32_t i = 31;++ if ((n & 0xFFFF0000) == 0) {+ n <<= 16;+ i = 15;+ }++ if ((n & 0xFF000000) == 0) {+ n <<= 8;+ i -= 8;+ }++ if ((n & 0xF0000000) == 0) {+ n <<= 4;+ i -= 4;+ }++ if ((n & 0xC0000000) == 0) {+ n <<= 2;+ i -= 2;+ }++ if ((n & 0x80000000) == 0)+ --i;++ return i;+#endif+}+++static inline uint32_t+clz32(uint32_t n)+{+#if defined(__INTEL_COMPILER)+ return _bit_scan_reverse(n) ^ 31U;++#elif (TUKLIB_GNUC_REQ(3, 4) || defined(__clang__)) && UINT_MAX == UINT32_MAX+ return (uint32_t)__builtin_clz(n);++#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))+ uint32_t i;+ __asm__("bsrl %1, %0\n\t"+ "xorl $31, %0"+ : "=r" (i) : "rm" (n));+ return i;++#elif defined(_MSC_VER)+ unsigned long i;+ _BitScanReverse(&i, n);+ return i ^ 31U;++#else+ uint32_t i = 0;++ if ((n & 0xFFFF0000) == 0) {+ n <<= 16;+ i = 16;+ }++ if ((n & 0xFF000000) == 0) {+ n <<= 8;+ i += 8;+ }++ if ((n & 0xF0000000) == 0) {+ n <<= 4;+ i += 4;+ }++ if ((n & 0xC0000000) == 0) {+ n <<= 2;+ i += 2;+ }++ if ((n & 0x80000000) == 0)+ ++i;++ return i;+#endif+}+++static inline uint32_t+ctz32(uint32_t n)+{+#if defined(__INTEL_COMPILER)+ return _bit_scan_forward(n);++#elif (TUKLIB_GNUC_REQ(3, 4) || defined(__clang__)) && UINT_MAX >= UINT32_MAX+ return (uint32_t)__builtin_ctz(n);++#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__))+ uint32_t i;+ __asm__("bsfl %1, %0" : "=r" (i) : "rm" (n));+ return i;++#elif defined(_MSC_VER)+ unsigned long i;+ _BitScanForward(&i, n);+ return i;++#else+ uint32_t i = 0;++ if ((n & 0x0000FFFF) == 0) {+ n >>= 16;+ i = 16;+ }++ if ((n & 0x000000FF) == 0) {+ n >>= 8;+ i += 8;+ }++ if ((n & 0x0000000F) == 0) {+ n >>= 4;+ i += 4;+ }++ if ((n & 0x00000003) == 0) {+ n >>= 2;+ i += 2;+ }++ if ((n & 0x00000001) == 0)+ ++i;++ return i;+#endif+}++#define bsf32 ctz32++#endif
+ cbits/common/tuklib_mbstr.h view
@@ -0,0 +1,65 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_mbstr.h+/// \brief Utility functions for handling multibyte strings+///+/// If not enough multibyte string support is available in the C library,+/// these functions keep working with the assumption that all strings+/// are in a single-byte character set without combining characters, e.g.+/// US-ASCII or ISO-8859-*.+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef TUKLIB_MBSTR_H+#define TUKLIB_MBSTR_H++#include "tuklib_common.h"+TUKLIB_DECLS_BEGIN++#define tuklib_mbstr_width TUKLIB_SYMBOL(tuklib_mbstr_width)+extern size_t tuklib_mbstr_width(const char *str, size_t *bytes);+///<+/// \brief Get the number of columns needed for the multibyte string+///+/// This is somewhat similar to wcswidth() but works on multibyte strings.+///+/// \param str String whose width is to be calculated. If the+/// current locale uses a multibyte character set+/// that has shift states, the string must begin+/// and end in the initial shift state.+/// \param bytes If this is not NULL, *bytes is set to the+/// value returned by strlen(str) (even if an+/// error occurs when calculating the width).+///+/// \return On success, the number of columns needed to display the+/// string e.g. in a terminal emulator is returned. On error,+/// (size_t)-1 is returned. Possible errors include invalid,+/// partial, or non-printable multibyte character in str, or+/// that str doesn't end in the initial shift state.++#define tuklib_mbstr_fw TUKLIB_SYMBOL(tuklib_mbstr_fw)+extern int tuklib_mbstr_fw(const char *str, int columns_min);+///<+/// \brief Get the field width for printf() e.g. to align table columns+///+/// Printing simple tables to a terminal can be done using the field field+/// feature in the printf() format string, but it works only with single-byte+/// character sets. To do the same with multibyte strings, tuklib_mbstr_fw()+/// can be used to calculate appropriate field width.+///+/// The behavior of this function is undefined, if+/// - str is NULL or not terminated with '\0';+/// - columns_min <= 0; or+/// - the calculated field width exceeds INT_MAX.+///+/// \return If tuklib_mbstr_width(str, NULL) fails, -1 is returned.+/// If str needs more columns than columns_min, zero is returned.+/// Otherwise a positive integer is returned, which can be+/// used as the field width, e.g. printf("%*s", fw, str).++TUKLIB_DECLS_END+#endif
+ cbits/common/tuklib_mbstr_fw.c view
@@ -0,0 +1,30 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_mbstr_fw.c+/// \brief Get the field width for printf() e.g. to align table columns+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "tuklib_mbstr.h"+++extern int+tuklib_mbstr_fw(const char *str, int columns_min)+{+ size_t len;+ const size_t width = tuklib_mbstr_width(str, &len);+ if (width == (size_t)-1)+ return -1;++ if (width > (size_t)columns_min)+ return 0;++ if (width < (size_t)columns_min)+ len += (size_t)columns_min - width;++ return (int)len;+}
+ cbits/common/tuklib_mbstr_width.c view
@@ -0,0 +1,64 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_mbstr_width.c+/// \brief Calculate width of a multibyte string+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "tuklib_mbstr.h"+#include <string.h>++#if defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH)+# include <wchar.h>+#endif+++extern size_t+tuklib_mbstr_width(const char *str, size_t *bytes)+{+ const size_t len = strlen(str);+ if (bytes != NULL)+ *bytes = len;++#if !(defined(HAVE_MBRTOWC) && defined(HAVE_WCWIDTH))+ // In single-byte mode, the width of the string is the same+ // as its length.+ return len;++#else+ mbstate_t state;+ memset(&state, 0, sizeof(state));++ size_t width = 0;+ size_t i = 0;++ // Convert one multibyte character at a time to wchar_t+ // and get its width using wcwidth().+ while (i < len) {+ wchar_t wc;+ const size_t ret = mbrtowc(&wc, str + i, len - i, &state);+ if (ret < 1 || ret > len)+ return (size_t)-1;++ i += ret;++ const int wc_width = wcwidth(wc);+ if (wc_width < 0)+ return (size_t)-1;++ width += (size_t)wc_width;+ }++ // Require that the string ends in the initial shift state.+ // This way the caller can be combine the string with other+ // strings without needing to worry about the shift states.+ if (!mbsinit(&state))+ return (size_t)-1;++ return width;+#endif+}
+ cbits/common/tuklib_open_stdxxx.c view
@@ -0,0 +1,56 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_open_stdxxx.c+/// \brief Make sure that file descriptors 0, 1, and 2 are open+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "tuklib_open_stdxxx.h"++#ifndef TUKLIB_DOSLIKE+# include <stdlib.h>+# include <errno.h>+# include <fcntl.h>+# include <unistd.h>+#endif+++extern void+tuklib_open_stdxxx(int err_status)+{+#ifdef TUKLIB_DOSLIKE+ // Do nothing, just silence warnings.+ (void)err_status;++#else+ for (int i = 0; i <= 2; ++i) {+ // We use fcntl() to check if the file descriptor is open.+ if (fcntl(i, F_GETFD) == -1 && errno == EBADF) {+ // With stdin, we could use /dev/full so that+ // writing to stdin would fail. However, /dev/full+ // is Linux specific, and if the program tries to+ // write to stdin, there's already a problem anyway.+ const int fd = open("/dev/null", O_NOCTTY+ | (i == 0 ? O_WRONLY : O_RDONLY));++ if (fd != i) {+ if (fd != -1)+ (void)close(fd);++ // Something went wrong. Exit with the+ // exit status we were given. Don't try+ // to print an error message, since stderr+ // may very well be non-existent. This+ // error should be extremely rare.+ exit(err_status);+ }+ }+ }+#endif++ return;+}
+ cbits/common/tuklib_open_stdxxx.h view
@@ -0,0 +1,22 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_open_stdxxx.h+/// \brief Make sure that file descriptors 0, 1, and 2 are open+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef TUKLIB_OPEN_STDXXX_H+#define TUKLIB_OPEN_STDXXX_H++#include "tuklib_common.h"+TUKLIB_DECLS_BEGIN++#define tuklib_open_stdxx TUKLIB_SYMBOL(tuklib_open_stdxxx)+extern void tuklib_open_stdxxx(int err_status);++TUKLIB_DECLS_END+#endif
+ cbits/common/tuklib_physmem.c view
@@ -0,0 +1,231 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_physmem.c+/// \brief Get the amount of physical memory+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "tuklib_physmem.h"++// We want to use Windows-specific code on Cygwin, which also has memory+// information available via sysconf(), but on Cygwin 1.5 and older it+// gives wrong results (from our point of view).+#if defined(_WIN32) || defined(__CYGWIN__)+# ifndef _WIN32_WINNT+# define _WIN32_WINNT 0x0500+# endif+# include <windows.h>++#elif defined(__OS2__)+# define INCL_DOSMISC+# include <os2.h>++#elif defined(__DJGPP__)+# include <dpmi.h>++#elif defined(__VMS)+# include <lib$routines.h>+# include <syidef.h>+# include <ssdef.h>++#elif defined(AMIGA) || defined(__AROS__)+# define __USE_INLINE__+# include <proto/exec.h>++#elif defined(__QNX__)+# include <sys/syspage.h>+# include <string.h>++#elif defined(TUKLIB_PHYSMEM_AIX)+# include <sys/systemcfg.h>++#elif defined(TUKLIB_PHYSMEM_SYSCONF)+# include <unistd.h>++#elif defined(TUKLIB_PHYSMEM_SYSCTL)+# ifdef HAVE_SYS_PARAM_H+# include <sys/param.h>+# endif+# include <sys/sysctl.h>++// Tru64+#elif defined(TUKLIB_PHYSMEM_GETSYSINFO)+# include <sys/sysinfo.h>+# include <machine/hal_sysinfo.h>++// HP-UX+#elif defined(TUKLIB_PHYSMEM_PSTAT_GETSTATIC)+# include <sys/param.h>+# include <sys/pstat.h>++// IRIX+#elif defined(TUKLIB_PHYSMEM_GETINVENT_R)+# include <invent.h>++// This sysinfo() is Linux-specific.+#elif defined(TUKLIB_PHYSMEM_SYSINFO)+# include <sys/sysinfo.h>+#endif+++extern uint64_t+tuklib_physmem(void)+{+ uint64_t ret = 0;++#if defined(_WIN32) || defined(__CYGWIN__)+ // This requires Windows 2000 or later.+ MEMORYSTATUSEX meminfo;+ meminfo.dwLength = sizeof(meminfo);+ if (GlobalMemoryStatusEx(&meminfo))+ ret = meminfo.ullTotalPhys;++/*+ // Old version that is compatible with even Win95:+ if ((GetVersion() & 0xFF) >= 5) {+ // Windows 2000 and later have GlobalMemoryStatusEx() which+ // supports reporting values greater than 4 GiB. To keep the+ // code working also on older Windows versions, use+ // GlobalMemoryStatusEx() conditionally.+ HMODULE kernel32 = GetModuleHandle(TEXT("kernel32.dll"));+ if (kernel32 != NULL) {+ typedef BOOL (WINAPI *gmse_type)(LPMEMORYSTATUSEX);+#ifdef CAN_DISABLE_WCAST_FUNCTION_TYPE+# pragma GCC diagnostic push+# pragma GCC diagnostic ignored "-Wcast-function-type"+#endif+ gmse_type gmse = (gmse_type)GetProcAddress(+ kernel32, "GlobalMemoryStatusEx");+#ifdef CAN_DISABLE_WCAST_FUNCTION_TYPE+# pragma GCC diagnostic pop+#endif+ if (gmse != NULL) {+ MEMORYSTATUSEX meminfo;+ meminfo.dwLength = sizeof(meminfo);+ if (gmse(&meminfo))+ ret = meminfo.ullTotalPhys;+ }+ }+ }++ if (ret == 0) {+ // GlobalMemoryStatus() is supported by Windows 95 and later,+ // so it is fine to link against it unconditionally. Note that+ // GlobalMemoryStatus() has no return value.+ MEMORYSTATUS meminfo;+ meminfo.dwLength = sizeof(meminfo);+ GlobalMemoryStatus(&meminfo);+ ret = meminfo.dwTotalPhys;+ }+*/++#elif defined(__OS2__)+ unsigned long mem;+ if (DosQuerySysInfo(QSV_TOTPHYSMEM, QSV_TOTPHYSMEM,+ &mem, sizeof(mem)) == 0)+ ret = mem;++#elif defined(__DJGPP__)+ __dpmi_free_mem_info meminfo;+ if (__dpmi_get_free_memory_information(&meminfo) == 0+ && meminfo.total_number_of_physical_pages+ != (unsigned long)-1)+ ret = (uint64_t)meminfo.total_number_of_physical_pages * 4096;++#elif defined(__VMS)+ int vms_mem;+ int val = SYI$_MEMSIZE;+ if (LIB$GETSYI(&val, &vms_mem, 0, 0, 0, 0) == SS$_NORMAL)+ ret = (uint64_t)vms_mem * 8192;++#elif defined(AMIGA) || defined(__AROS__)+ ret = AvailMem(MEMF_TOTAL);++#elif defined(__QNX__)+ const struct asinfo_entry *entries = SYSPAGE_ENTRY(asinfo);+ size_t count = SYSPAGE_ENTRY_SIZE(asinfo) / sizeof(struct asinfo_entry);+ const char *strings = SYSPAGE_ENTRY(strings)->data;++ for (size_t i = 0; i < count; ++i)+ if (strcmp(strings + entries[i].name, "ram") == 0)+ ret += entries[i].end - entries[i].start + 1;++#elif defined(TUKLIB_PHYSMEM_AIX)+ ret = _system_configuration.physmem;++#elif defined(TUKLIB_PHYSMEM_SYSCONF)+ const long pagesize = sysconf(_SC_PAGESIZE);+ const long pages = sysconf(_SC_PHYS_PAGES);+ if (pagesize != -1 && pages != -1)+ // According to docs, pagesize * pages can overflow.+ // Simple case is 32-bit box with 4 GiB or more RAM,+ // which may report exactly 4 GiB of RAM, and "long"+ // being 32-bit will overflow. Casting to uint64_t+ // hopefully avoids overflows in the near future.+ ret = (uint64_t)pagesize * (uint64_t)pages;++#elif defined(TUKLIB_PHYSMEM_SYSCTL)+ int name[2] = {+ CTL_HW,+#ifdef HW_PHYSMEM64+ HW_PHYSMEM64+#else+ HW_PHYSMEM+#endif+ };+ union {+ uint32_t u32;+ uint64_t u64;+ } mem;+ size_t mem_ptr_size = sizeof(mem.u64);+ if (sysctl(name, 2, &mem.u64, &mem_ptr_size, NULL, 0) != -1) {+ // IIRC, 64-bit "return value" is possible on some 64-bit+ // BSD systems even with HW_PHYSMEM (instead of HW_PHYSMEM64),+ // so support both.+ if (mem_ptr_size == sizeof(mem.u64))+ ret = mem.u64;+ else if (mem_ptr_size == sizeof(mem.u32))+ ret = mem.u32;+ }++#elif defined(TUKLIB_PHYSMEM_GETSYSINFO)+ // Docs are unclear if "start" is needed, but it doesn't hurt+ // much to have it.+ int memkb;+ int start = 0;+ if (getsysinfo(GSI_PHYSMEM, (caddr_t)&memkb, sizeof(memkb), &start)+ != -1)+ ret = (uint64_t)memkb * 1024;++#elif defined(TUKLIB_PHYSMEM_PSTAT_GETSTATIC)+ struct pst_static pst;+ if (pstat_getstatic(&pst, sizeof(pst), 1, 0) != -1)+ ret = (uint64_t)pst.physical_memory * (uint64_t)pst.page_size;++#elif defined(TUKLIB_PHYSMEM_GETINVENT_R)+ inv_state_t *st = NULL;+ if (setinvent_r(&st) != -1) {+ inventory_t *i;+ while ((i = getinvent_r(st)) != NULL) {+ if (i->inv_class == INV_MEMORY+ && i->inv_type == INV_MAIN_MB) {+ ret = (uint64_t)i->inv_state << 20;+ break;+ }+ }++ endinvent_r(st);+ }++#elif defined(TUKLIB_PHYSMEM_SYSINFO)+ struct sysinfo si;+ if (sysinfo(&si) == 0)+ ret = (uint64_t)si.totalram * si.mem_unit;+#endif++ return ret;+}
+ cbits/common/tuklib_physmem.h view
@@ -0,0 +1,27 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_physmem.h+/// \brief Get the amount of physical memory+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef TUKLIB_PHYSMEM_H+#define TUKLIB_PHYSMEM_H++#include "tuklib_common.h"+TUKLIB_DECLS_BEGIN++#define tuklib_physmem TUKLIB_SYMBOL(tuklib_physmem)+extern uint64_t tuklib_physmem(void);+///<+/// \brief Get the amount of physical memory in bytes+///+/// \return Amount of physical memory in bytes. On error, zero is+/// returned.++TUKLIB_DECLS_END+#endif
+ cbits/common/tuklib_progname.c view
@@ -0,0 +1,49 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_progname.c+/// \brief Program name to be displayed in messages+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "tuklib_progname.h"+#include <string.h>+++#ifndef HAVE_PROGRAM_INVOCATION_NAME+char *progname = NULL;+#endif+++extern void+tuklib_progname_init(char **argv)+{+#ifdef TUKLIB_DOSLIKE+ // On these systems, argv[0] always has the full path and .exe+ // suffix even if the user just types the plain program name.+ // We modify argv[0] to make it nicer to read.++ // Strip the leading path.+ char *p = argv[0] + strlen(argv[0]);+ while (argv[0] < p && p[-1] != '/' && p[-1] != '\\')+ --p;++ argv[0] = p;++ // Strip the .exe suffix.+ p = strrchr(p, '.');+ if (p != NULL)+ *p = '\0';++ // Make it lowercase.+ for (p = argv[0]; *p != '\0'; ++p)+ if (*p >= 'A' && *p <= 'Z')+ *p = *p - 'A' + 'a';+#endif++ progname = argv[0];+ return;+}
+ cbits/common/tuklib_progname.h view
@@ -0,0 +1,31 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file tuklib_progname.h+/// \brief Program name to be displayed in messages+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef TUKLIB_PROGNAME_H+#define TUKLIB_PROGNAME_H++#include "tuklib_common.h"+#include <errno.h>++TUKLIB_DECLS_BEGIN++#ifdef HAVE_PROGRAM_INVOCATION_NAME+# define progname program_invocation_name+#else+# define progname TUKLIB_SYMBOL(tuklib_progname)+ extern char *progname;+#endif++#define tuklib_progname_init TUKLIB_SYMBOL(tuklib_progname_init)+extern void tuklib_progname_init(char **argv);++TUKLIB_DECLS_END+#endif
+ cbits/config.h.in view
@@ -0,0 +1,625 @@+/* cbits/config.h.in. Generated from configure.ac by autoheader. */++/* Define if building universal (internal helper macro) */+#undef AC_APPLE_UNIVERSAL_BUILD++/* How many MiB of RAM to assume if the real amount cannot be determined. */+#undef ASSUME_RAM++/* Define to 1 if translation of program messages to the user's native+ language is requested. */+#undef ENABLE_NLS++/* Define to 1 if ARM64 CRC32 instruction is supported. See configure.ac for+ details. */+#undef HAVE_ARM64_CRC32++/* Define to 1 if bswap_16 is available. */+#undef HAVE_BSWAP_16++/* Define to 1 if bswap_32 is available. */+#undef HAVE_BSWAP_32++/* Define to 1 if bswap_64 is available. */+#undef HAVE_BSWAP_64++/* Define to 1 if you have the <byteswap.h> header file. */+#undef HAVE_BYTESWAP_H++/* Define to 1 if you have the 'cap_rights_limit' function. */+#undef HAVE_CAP_RIGHTS_LIMIT++/* Define to 1 if the system has the type 'CC_SHA256_CTX'. */+#undef HAVE_CC_SHA256_CTX++/* Define to 1 if you have the 'CC_SHA256_Init' function. */+#undef HAVE_CC_SHA256_INIT++/* Define to 1 if you have the Mac OS X function+ CFLocaleCopyPreferredLanguages in the CoreFoundation framework. */+#undef HAVE_CFLOCALECOPYPREFERREDLANGUAGES++/* Define to 1 if you have the Mac OS X function CFPreferencesCopyAppValue in+ the CoreFoundation framework. */+#undef HAVE_CFPREFERENCESCOPYAPPVALUE++/* Define to 1 if crc32 integrity check is enabled. */+#undef HAVE_CHECK_CRC32++/* Define to 1 if crc64 integrity check is enabled. */+#undef HAVE_CHECK_CRC64++/* Define to 1 if sha256 integrity check is enabled. */+#undef HAVE_CHECK_SHA256++/* Define to 1 if you have the 'clock_gettime' function. */+#undef HAVE_CLOCK_GETTIME++/* Define to 1 if 'CLOCK_MONOTONIC' is declared in <time.h>. */+#undef HAVE_CLOCK_MONOTONIC++/* Define to 1 if you have the <CommonCrypto/CommonDigest.h> header file. */+#undef HAVE_COMMONCRYPTO_COMMONDIGEST_H++/* Define to 1 if you have the <cpuid.h> header file. */+#undef HAVE_CPUID_H++/* Define to 1 if the 32-bit x86 CRC assembly files are used. */+#undef HAVE_CRC_X86_ASM++/* Define if the GNU dcgettext() function is already present or preinstalled.+ */+#undef HAVE_DCGETTEXT++/* Define to 1 if any of HAVE_DECODER_foo have been defined. */+#undef HAVE_DECODERS++/* Define to 1 if arm decoder is enabled. */+#undef HAVE_DECODER_ARM++/* Define to 1 if arm64 decoder is enabled. */+#undef HAVE_DECODER_ARM64++/* Define to 1 if armthumb decoder is enabled. */+#undef HAVE_DECODER_ARMTHUMB++/* Define to 1 if delta decoder is enabled. */+#undef HAVE_DECODER_DELTA++/* Define to 1 if ia64 decoder is enabled. */+#undef HAVE_DECODER_IA64++/* Define to 1 if lzma1 decoder is enabled. */+#undef HAVE_DECODER_LZMA1++/* Define to 1 if lzma2 decoder is enabled. */+#undef HAVE_DECODER_LZMA2++/* Define to 1 if powerpc decoder is enabled. */+#undef HAVE_DECODER_POWERPC++/* Define to 1 if riscv decoder is enabled. */+#undef HAVE_DECODER_RISCV++/* Define to 1 if sparc decoder is enabled. */+#undef HAVE_DECODER_SPARC++/* Define to 1 if x86 decoder is enabled. */+#undef HAVE_DECODER_X86++/* Define to 1 if you have the <dlfcn.h> header file. */+#undef HAVE_DLFCN_H++/* Define to 1 if you have the 'elf_aux_info' function. */+#undef HAVE_ELF_AUX_INFO++/* Define to 1 if any of HAVE_ENCODER_foo have been defined. */+#undef HAVE_ENCODERS++/* Define to 1 if arm encoder is enabled. */+#undef HAVE_ENCODER_ARM++/* Define to 1 if arm64 encoder is enabled. */+#undef HAVE_ENCODER_ARM64++/* Define to 1 if armthumb encoder is enabled. */+#undef HAVE_ENCODER_ARMTHUMB++/* Define to 1 if delta encoder is enabled. */+#undef HAVE_ENCODER_DELTA++/* Define to 1 if ia64 encoder is enabled. */+#undef HAVE_ENCODER_IA64++/* Define to 1 if lzma1 encoder is enabled. */+#undef HAVE_ENCODER_LZMA1++/* Define to 1 if lzma2 encoder is enabled. */+#undef HAVE_ENCODER_LZMA2++/* Define to 1 if powerpc encoder is enabled. */+#undef HAVE_ENCODER_POWERPC++/* Define to 1 if riscv encoder is enabled. */+#undef HAVE_ENCODER_RISCV++/* Define to 1 if sparc encoder is enabled. */+#undef HAVE_ENCODER_SPARC++/* Define to 1 if x86 encoder is enabled. */+#undef HAVE_ENCODER_X86++/* Define to 1 if __attribute__((__constructor__)) is supported for functions.+ */+#undef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR++/* Define to 1 if you have the 'futimens' function. */+#undef HAVE_FUTIMENS++/* Define to 1 if you have the 'futimes' function. */+#undef HAVE_FUTIMES++/* Define to 1 if you have the 'futimesat' function. */+#undef HAVE_FUTIMESAT++/* Define to 1 if you have the 'getauxval' function. */+#undef HAVE_GETAUXVAL++/* Define to 1 if you have the <getopt.h> header file. */+#undef HAVE_GETOPT_H++/* Define to 1 if you have the 'getopt_long' function. */+#undef HAVE_GETOPT_LONG++/* Define if the GNU gettext() function is already present or preinstalled. */+#undef HAVE_GETTEXT++/* Define if you have the iconv() function and it works. */+#undef HAVE_ICONV++/* Define to 1 if you have the <immintrin.h> header file. */+#undef HAVE_IMMINTRIN_H++/* Define to 1 if you have the <inttypes.h> header file. */+#undef HAVE_INTTYPES_H++/* Define to 1 if Linux Landlock is supported. See configure.ac for details.+ */+#undef HAVE_LINUX_LANDLOCK++/* Define to 1 if 64-bit LoongArch CRC32 instructions are supported. */+#undef HAVE_LOONGARCH_CRC32++/* Define to 1 if .lz (lzip) decompression support is enabled. */+#undef HAVE_LZIP_DECODER++/* Define to 1 if mbrtowc and mbstate_t are properly declared. */+#undef HAVE_MBRTOWC++/* Define to 1 to enable bt2 match finder. */+#undef HAVE_MF_BT2++/* Define to 1 to enable bt3 match finder. */+#undef HAVE_MF_BT3++/* Define to 1 to enable bt4 match finder. */+#undef HAVE_MF_BT4++/* Define to 1 to enable hc3 match finder. */+#undef HAVE_MF_HC3++/* Define to 1 to enable hc4 match finder. */+#undef HAVE_MF_HC4++/* Define to 1 if you have the <minix/config.h> header file. */+#undef HAVE_MINIX_CONFIG_H++/* Define to 1 if getopt.h declares extern int optreset. */+#undef HAVE_OPTRESET++/* Define to 1 if you have the 'pledge' function. */+#undef HAVE_PLEDGE++/* Define to 1 if you have the 'posix_fadvise' function. */+#undef HAVE_POSIX_FADVISE++/* Define to 1 if 'program_invocation_name' is declared in <errno.h>. */+#undef HAVE_PROGRAM_INVOCATION_NAME++/* Define to 1 if you have the 'pthread_condattr_setclock' function. */+#undef HAVE_PTHREAD_CONDATTR_SETCLOCK++/* Have PTHREAD_PRIO_INHERIT. */+#undef HAVE_PTHREAD_PRIO_INHERIT++/* Define to 1 if you have the 'SHA256Init' function. */+#undef HAVE_SHA256INIT++/* Define to 1 if the system has the type 'SHA256_CTX'. */+#undef HAVE_SHA256_CTX++/* Define to 1 if you have the <sha256.h> header file. */+#undef HAVE_SHA256_H++/* Define to 1 if you have the 'SHA256_Init' function. */+#undef HAVE_SHA256_INIT++/* Define to 1 if the system has the type 'SHA2_CTX'. */+#undef HAVE_SHA2_CTX++/* Define to 1 if you have the <sha2.h> header file. */+#undef HAVE_SHA2_H++/* Define to 1 if optimizing for size. */+#undef HAVE_SMALL++/* Define to 1 if stdbool.h conforms to C99. */+#undef HAVE_STDBOOL_H++/* Define to 1 if you have the <stdint.h> header file. */+#undef HAVE_STDINT_H++/* Define to 1 if you have the <stdio.h> header file. */+#undef HAVE_STDIO_H++/* Define to 1 if you have the <stdlib.h> header file. */+#undef HAVE_STDLIB_H++/* Define to 1 if you have the <strings.h> header file. */+#undef HAVE_STRINGS_H++/* Define to 1 if you have the <string.h> header file. */+#undef HAVE_STRING_H++/* Define to 1 if 'st_atimensec' is a member of 'struct stat'. */+#undef HAVE_STRUCT_STAT_ST_ATIMENSEC++/* Define to 1 if 'st_atimespec.tv_nsec' is a member of 'struct stat'. */+#undef HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC++/* Define to 1 if 'st_atim.st__tim.tv_nsec' is a member of 'struct stat'. */+#undef HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC++/* Define to 1 if 'st_atim.tv_nsec' is a member of 'struct stat'. */+#undef HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC++/* Define to 1 if 'st_uatime' is a member of 'struct stat'. */+#undef HAVE_STRUCT_STAT_ST_UATIME++/* Define to 1 to if GNU/Linux-specific details are unconditionally wanted for+ symbol versioning. Define to 2 to if these are wanted only if also PIC is+ defined (allows building both shared and static liblzma at the same time+ with Libtool if neither --with-pic nor --without-pic is used). This define+ must be used together with liblzma_linux.map. */+#undef HAVE_SYMBOL_VERSIONS_LINUX++/* Define to 1 if you have the 'sysctlbyname' function. */+#undef HAVE_SYSCTLBYNAME++/* Define to 1 if you have the <sys/byteorder.h> header file. */+#undef HAVE_SYS_BYTEORDER_H++/* Define to 1 if you have the <sys/cdefs.h> header file. */+#undef HAVE_SYS_CDEFS_H++/* Define to 1 if you have the <sys/endian.h> header file. */+#undef HAVE_SYS_ENDIAN_H++/* Define to 1 if you have the <sys/param.h> header file. */+#undef HAVE_SYS_PARAM_H++/* Define to 1 if you have the <sys/stat.h> header file. */+#undef HAVE_SYS_STAT_H++/* Define to 1 if you have the <sys/types.h> header file. */+#undef HAVE_SYS_TYPES_H++/* Define to 1 if the system has the type 'uintptr_t'. */+#undef HAVE_UINTPTR_T++/* Define to 1 if you have the <unistd.h> header file. */+#undef HAVE_UNISTD_H++/* Define to 1 if _mm_set_epi64x and _mm_clmulepi64_si128 are usable. See+ configure.ac for details. */+#undef HAVE_USABLE_CLMUL++/* Define to 1 if you have the 'utime' function. */+#undef HAVE_UTIME++/* Define to 1 if you have the 'utimes' function. */+#undef HAVE_UTIMES++/* Define to 1 or 0, depending whether the compiler supports simple visibility+ declarations. */+#undef HAVE_VISIBILITY++/* Define to 1 if you have the <wchar.h> header file. */+#undef HAVE_WCHAR_H++/* Define to 1 if you have the 'wcwidth' function. */+#undef HAVE_WCWIDTH++/* Define to 1 if the system has the type '_Bool'. */+#undef HAVE__BOOL++/* Define to 1 if you have the '_futime' function. */+#undef HAVE__FUTIME++/* Define to 1 if _mm_movemask_epi8 is available. */+#undef HAVE__MM_MOVEMASK_EPI8++/* Define to 1 if the GNU C extension __builtin_assume_aligned is supported.+ */+#undef HAVE___BUILTIN_ASSUME_ALIGNED++/* Define to 1 if the GNU C extensions __builtin_bswap16/32/64 are supported.+ */+#undef HAVE___BUILTIN_BSWAPXX++/* Define to the sub-directory where libtool stores uninstalled libraries. */+#undef LT_OBJDIR++/* Define to 1 when using POSIX threads (pthreads). */+#undef MYTHREAD_POSIX++/* Define to 1 when using Windows Vista compatible threads. This uses features+ that are not available on Windows XP. */+#undef MYTHREAD_VISTA++/* Define to 1 when using Windows 95 (and thus XP) compatible threads. This+ avoids use of features that were added in Windows Vista. */+#undef MYTHREAD_WIN95++/* Define to 1 to disable debugging code. */+#undef NDEBUG++/* Define to the address where bug reports for this package should be sent. */+#undef PACKAGE_BUGREPORT++/* Define to the full name of this package. */+#undef PACKAGE_NAME++/* Define to the full name and version of this package. */+#undef PACKAGE_STRING++/* Define to the one symbol short name of this package. */+#undef PACKAGE_TARNAME++/* Define to the home page for this package. */+#undef PACKAGE_URL++/* Define to the version of this package. */+#undef PACKAGE_VERSION++/* Define to necessary symbol if this constant uses a non-standard name on+ your system. */+#undef PTHREAD_CREATE_JOINABLE++/* The size of 'size_t', as computed by sizeof. */+#undef SIZEOF_SIZE_T++/* Define to 1 if all of the C89 standard headers exist (not just the ones+ required in a freestanding environment). This macro is provided for+ backward compatibility; new code need not use it. */+#undef STDC_HEADERS++/* Define to 1 if the number of available CPU cores can be detected with+ cpuset(2). */+#undef TUKLIB_CPUCORES_CPUSET++/* Define to 1 if the number of available CPU cores can be detected with+ pstat_getdynamic(). */+#undef TUKLIB_CPUCORES_PSTAT_GETDYNAMIC++/* Define to 1 if the number of available CPU cores can be detected with+ sched_getaffinity() */+#undef TUKLIB_CPUCORES_SCHED_GETAFFINITY++/* Define to 1 if the number of available CPU cores can be detected with+ sysconf(_SC_NPROCESSORS_ONLN) or sysconf(_SC_NPROC_ONLN). */+#undef TUKLIB_CPUCORES_SYSCONF++/* Define to 1 if the number of available CPU cores can be detected with+ sysctl(). */+#undef TUKLIB_CPUCORES_SYSCTL++/* Define to 1 if the system supports fast unaligned access to 16-bit, 32-bit,+ and 64-bit integers. */+#undef TUKLIB_FAST_UNALIGNED_ACCESS++/* Define to 1 if the amount of physical memory can be detected with+ _system_configuration.physmem. */+#undef TUKLIB_PHYSMEM_AIX++/* Define to 1 if the amount of physical memory can be detected with+ getinvent_r(). */+#undef TUKLIB_PHYSMEM_GETINVENT_R++/* Define to 1 if the amount of physical memory can be detected with+ getsysinfo(). */+#undef TUKLIB_PHYSMEM_GETSYSINFO++/* Define to 1 if the amount of physical memory can be detected with+ pstat_getstatic(). */+#undef TUKLIB_PHYSMEM_PSTAT_GETSTATIC++/* Define to 1 if the amount of physical memory can be detected with+ sysconf(_SC_PAGESIZE) and sysconf(_SC_PHYS_PAGES). */+#undef TUKLIB_PHYSMEM_SYSCONF++/* Define to 1 if the amount of physical memory can be detected with sysctl().+ */+#undef TUKLIB_PHYSMEM_SYSCTL++/* Define to 1 if the amount of physical memory can be detected with Linux+ sysinfo(). */+#undef TUKLIB_PHYSMEM_SYSINFO++/* Define to 1 to use unsafe type punning, e.g. char *x = ...; *(int *)x =+ 123; which violates strict aliasing rules and thus is undefined behavior+ and might result in broken code. */+#undef TUKLIB_USE_UNSAFE_TYPE_PUNNING++/* Enable extensions on AIX, Interix, z/OS. */+#ifndef _ALL_SOURCE+# undef _ALL_SOURCE+#endif+/* Enable general extensions on macOS. */+#ifndef _DARWIN_C_SOURCE+# undef _DARWIN_C_SOURCE+#endif+/* Enable general extensions on Solaris. */+#ifndef __EXTENSIONS__+# undef __EXTENSIONS__+#endif+/* Enable GNU extensions on systems that have them. */+#ifndef _GNU_SOURCE+# undef _GNU_SOURCE+#endif+/* Enable X/Open compliant socket functions that do not require linking+ with -lxnet on HP-UX 11.11. */+#ifndef _HPUX_ALT_XOPEN_SOCKET_API+# undef _HPUX_ALT_XOPEN_SOCKET_API+#endif+/* Identify the host operating system as Minix.+ This macro does not affect the system headers' behavior.+ A future release of Autoconf may stop defining this macro. */+#ifndef _MINIX+# undef _MINIX+#endif+/* Enable general extensions on NetBSD.+ Enable NetBSD compatibility extensions on Minix. */+#ifndef _NETBSD_SOURCE+# undef _NETBSD_SOURCE+#endif+/* Enable OpenBSD compatibility extensions on NetBSD.+ Oddly enough, this does nothing on OpenBSD. */+#ifndef _OPENBSD_SOURCE+# undef _OPENBSD_SOURCE+#endif+/* Define to 1 if needed for POSIX-compatible behavior. */+#ifndef _POSIX_SOURCE+# undef _POSIX_SOURCE+#endif+/* Define to 2 if needed for POSIX-compatible behavior. */+#ifndef _POSIX_1_SOURCE+# undef _POSIX_1_SOURCE+#endif+/* Enable POSIX-compatible threading on Solaris. */+#ifndef _POSIX_PTHREAD_SEMANTICS+# undef _POSIX_PTHREAD_SEMANTICS+#endif+/* Enable extensions specified by ISO/IEC TS 18661-5:2014. */+#ifndef __STDC_WANT_IEC_60559_ATTRIBS_EXT__+# undef __STDC_WANT_IEC_60559_ATTRIBS_EXT__+#endif+/* Enable extensions specified by ISO/IEC TS 18661-1:2014. */+#ifndef __STDC_WANT_IEC_60559_BFP_EXT__+# undef __STDC_WANT_IEC_60559_BFP_EXT__+#endif+/* Enable extensions specified by ISO/IEC TS 18661-2:2015. */+#ifndef __STDC_WANT_IEC_60559_DFP_EXT__+# undef __STDC_WANT_IEC_60559_DFP_EXT__+#endif+/* Enable extensions specified by C23 Annex F. */+#ifndef __STDC_WANT_IEC_60559_EXT__+# undef __STDC_WANT_IEC_60559_EXT__+#endif+/* Enable extensions specified by ISO/IEC TS 18661-4:2015. */+#ifndef __STDC_WANT_IEC_60559_FUNCS_EXT__+# undef __STDC_WANT_IEC_60559_FUNCS_EXT__+#endif+/* Enable extensions specified by C23 Annex H and ISO/IEC TS 18661-3:2015. */+#ifndef __STDC_WANT_IEC_60559_TYPES_EXT__+# undef __STDC_WANT_IEC_60559_TYPES_EXT__+#endif+/* Enable extensions specified by ISO/IEC TR 24731-2:2010. */+#ifndef __STDC_WANT_LIB_EXT2__+# undef __STDC_WANT_LIB_EXT2__+#endif+/* Enable extensions specified by ISO/IEC 24747:2009. */+#ifndef __STDC_WANT_MATH_SPEC_FUNCS__+# undef __STDC_WANT_MATH_SPEC_FUNCS__+#endif+/* Enable extensions on HP NonStop. */+#ifndef _TANDEM_SOURCE+# undef _TANDEM_SOURCE+#endif+/* Enable X/Open extensions. Define to 500 only if necessary+ to make mbstate_t available. */+#ifndef _XOPEN_SOURCE+# undef _XOPEN_SOURCE+#endif+++/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most+ significant byte first (like Motorola and SPARC, unlike Intel). */+#if defined AC_APPLE_UNIVERSAL_BUILD+# if defined __BIG_ENDIAN__+# define WORDS_BIGENDIAN 1+# endif+#else+# ifndef WORDS_BIGENDIAN+# undef WORDS_BIGENDIAN+# endif+#endif++/* Number of bits in a file offset, on hosts where this is settable. */+#undef _FILE_OFFSET_BITS++/* Define to 1 on platforms where this makes off_t a 64-bit type. */+#undef _LARGE_FILES++/* Number of bits in time_t, on hosts where this is settable. */+#undef _TIME_BITS++/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the+ #define below would cause a syntax error. */+#undef _UINT32_T++/* Define for Solaris 2.5.1 so the uint64_t typedef from <sys/synch.h>,+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the+ #define below would cause a syntax error. */+#undef _UINT64_T++/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,+ <pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the+ #define below would cause a syntax error. */+#undef _UINT8_T++/* Define to rpl_ if the getopt replacement functions and variables should be+ used. */+#undef __GETOPT_PREFIX++/* Define to 1 on platforms where this makes time_t a 64-bit type. */+#undef __MINGW_USE_VC2005_COMPAT++/* Define to the type of a signed integer type of width exactly 32 bits if+ such a type exists and the standard includes do not define it. */+#undef int32_t++/* Define to the type of a signed integer type of width exactly 64 bits if+ such a type exists and the standard includes do not define it. */+#undef int64_t++/* Define to the type of an unsigned integer type of width exactly 16 bits if+ such a type exists and the standard includes do not define it. */+#undef uint16_t++/* Define to the type of an unsigned integer type of width exactly 32 bits if+ such a type exists and the standard includes do not define it. */+#undef uint32_t++/* Define to the type of an unsigned integer type of width exactly 64 bits if+ such a type exists and the standard includes do not define it. */+#undef uint64_t++/* Define to the type of an unsigned integer type of width exactly 8 bits if+ such a type exists and the standard includes do not define it. */+#undef uint8_t++/* Define to the type of an unsigned integer type wide enough to hold a+ pointer, if such a type exists, and if the system does not define it. */+#undef uintptr_t
+ cbits/liblzma/api/lzma.h view
@@ -0,0 +1,327 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file api/lzma.h+ * \brief The public API of liblzma data compression library+ * \mainpage+ *+ * liblzma is a general-purpose data compression library with a zlib-like API.+ * The native file format is .xz, but also the old .lzma format and raw (no+ * headers) streams are supported. Multiple compression algorithms (filters)+ * are supported. Currently LZMA2 is the primary filter.+ *+ * liblzma is part of XZ Utils <https://tukaani.org/xz/>. XZ Utils+ * includes a gzip-like command line tool named xz and some other tools.+ * XZ Utils is developed and maintained by Lasse Collin.+ *+ * Major parts of liblzma are based on code written by Igor Pavlov,+ * specifically the LZMA SDK <https://7-zip.org/sdk.html>.+ *+ * The SHA-256 implementation in liblzma is based on code written by+ * Wei Dai in Crypto++ Library <https://www.cryptopp.com/>.+ *+ * liblzma is distributed under the BSD Zero Clause License (0BSD).+ */++/*+ * Author: Lasse Collin+ */++#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 already or if LZMA_MANUAL_HEADERS+ * has been defined.+ *+ * 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, in case of incomplete inttypes.h, unsigned int is 32-bit.+ * If the application already takes care of setting up all the types and+ * macros properly (for example by using gnulib's stdint.h or inttypes.h),+ * we try to detect that the macros are already defined and don't include+ * inttypes.h here again. However, you may define LZMA_MANUAL_HEADERS to+ * force this file to never include any system headers.+ *+ * 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 as an 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. sizeof(bool) in C99 isn't+ * necessarily the same as sizeof(bool) in C++.+ */++#ifndef LZMA_MANUAL_HEADERS+ /*+ * I suppose this works portably also in C++. Note that in C++,+ * we need to get size_t into the global namespace.+ */+# include <stddef.h>++ /*+ * Skip inttypes.h if we already have all the required macros. If we+ * have the macros, we assume that we have the matching typedefs too.+ */+# if !defined(UINT32_C) || !defined(UINT64_C) \+ || !defined(UINT32_MAX) || !defined(UINT64_MAX)+ /*+ * MSVC versions older than 2013 have no C99 support, and+ * thus they cannot be used to compile liblzma. Using an+ * existing liblzma.dll with old MSVC can work though(*),+ * but we need to define the required standard integer+ * types here in a MSVC-specific way.+ *+ * (*) If you do this, the existing liblzma.dll probably uses+ * a different runtime library than your MSVC-built+ * application. Mixing runtimes is generally bad, but+ * in this case it should work as long as you avoid+ * the few rarely-needed liblzma functions that allocate+ * memory and expect the caller to free it using free().+ */+# if defined(_WIN32) && defined(_MSC_VER) && _MSC_VER < 1800+ typedef unsigned __int8 uint8_t;+ typedef unsigned __int32 uint32_t;+ typedef unsigned __int64 uint64_t;+# else+ /* Use the standard inttypes.h. */+# ifdef __cplusplus+ /*+ * C99 sections 7.18.2 and 7.18.4 specify+ * that C++ implementations define the limit+ * and constant macros only if specifically+ * requested. Note that if you want the+ * format macros (PRIu64 etc.) 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>+# endif++ /*+ * 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 setup the types manually+ * before including lzma.h.+ */+# ifndef UINT32_C+# if defined(_WIN32) && defined(_MSC_VER)+# define UINT32_C(n) n ## UI32+# else+# define UINT32_C(n) n ## U+# endif+# endif++# ifndef UINT64_C+# if defined(_WIN32) && defined(_MSC_VER)+# define UINT64_C(n) n ## UI64+# else+ /* Get ULONG_MAX. */+# include <limits.h>+# if ULONG_MAX == 4294967295UL+# define UINT64_C(n) n ## ULL+# else+# define UINT64_C(n) n ## UL+# endif+# endif+# endif++# ifndef UINT32_MAX+# define UINT32_MAX (UINT32_C(4294967295))+# endif++# ifndef UINT64_MAX+# define UINT64_MAX (UINT64_C(18446744073709551615))+# endif+# endif+#endif /* ifdef LZMA_MANUAL_HEADERS */+++/******************+ * LZMA_API macro *+ ******************/++/*+ * Some systems require that the functions and function pointers are+ * declared specially in the headers. LZMA_API_IMPORT is for importing+ * symbols and LZMA_API_CALL is to specify the calling convention.+ *+ * By default it is assumed that the application will link dynamically+ * against liblzma. #define LZMA_API_STATIC in your application if you+ * want to link against static liblzma. If you don't care about portability+ * to operating systems like Windows, or at least don't care about linking+ * against static liblzma on them, don't worry about LZMA_API_STATIC. That+ * is, most developers will never need to use LZMA_API_STATIC.+ *+ * The GCC variants are a special case on Windows (Cygwin and MinGW-w64).+ * We rely on GCC doing the right thing with its auto-import feature,+ * and thus don't use __declspec(dllimport). This way developers don't+ * need to worry about LZMA_API_STATIC. Also the calling convention is+ * omitted on Cygwin but not on MinGW-w64.+ */+#ifndef LZMA_API_IMPORT+# if !defined(LZMA_API_STATIC) && defined(_WIN32) && !defined(__GNUC__)+# define LZMA_API_IMPORT __declspec(dllimport)+# else+# define LZMA_API_IMPORT+# endif+#endif++#ifndef LZMA_API_CALL+# if defined(_WIN32) && !defined(__CYGWIN__)+# define LZMA_API_CALL __cdecl+# else+# define LZMA_API_CALL+# endif+#endif++#ifndef LZMA_API+# define LZMA_API(type) LZMA_API_IMPORT type LZMA_API_CALL+#endif+++/***********+ * nothrow *+ ***********/++/*+ * None of the functions in liblzma may throw an exception. Even+ * the functions that use callback functions won't throw exceptions,+ * because liblzma would break if a callback function threw an exception.+ */+#ifndef lzma_nothrow+# if defined(__cplusplus)+# if __cplusplus >= 201103L || (defined(_MSVC_LANG) \+ && _MSVC_LANG >= 201103L)+# define lzma_nothrow noexcept+# else+# define lzma_nothrow throw()+# endif+# elif defined(__GNUC__) && (__GNUC__ > 3 \+ || (__GNUC__ == 3 && __GNUC_MINOR__ >= 3))+# define lzma_nothrow __attribute__((__nothrow__))+# else+# define lzma_nothrow+# endif+#endif+++/********************+ * GNU C extensions *+ ********************/++/*+ * GNU C extensions are used conditionally in the public API. It doesn't+ * break anything if these are sometimes enabled and sometimes not, only+ * affects warnings and optimizations.+ */+#if defined(__GNUC__) && __GNUC__ >= 3+# ifndef lzma_attribute+# define lzma_attribute(attr) __attribute__(attr)+# 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+#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+++/**************+ * Subheaders *+ **************/++#ifdef __cplusplus+extern "C" {+#endif++/*+ * Subheaders check that this is defined. It is to prevent including+ * them directly from applications.+ */+#define LZMA_H_INTERNAL 1++/* Basic features */+#include "lzma/version.h"+#include "lzma/base.h"+#include "lzma/vli.h"+#include "lzma/check.h"++/* Filters */+#include "lzma/filter.h"+#include "lzma/bcj.h"+#include "lzma/delta.h"+#include "lzma/lzma12.h"++/* Container formats */+#include "lzma/container.h"++/* Advanced features */+#include "lzma/stream_flags.h"+#include "lzma/block.h"+#include "lzma/index.h"+#include "lzma/index_hash.h"++/* Hardware information */+#include "lzma/hardware.h"++/*+ * All subheaders included. Undefine LZMA_H_INTERNAL to prevent applications+ * re-including the subheaders.+ */+#undef LZMA_H_INTERNAL++#ifdef __cplusplus+}+#endif++#endif /* ifndef LZMA_H */
+ cbits/liblzma/api/lzma/base.h view
@@ -0,0 +1,747 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/base.h+ * \brief Data types and functions used in many places in liblzma API+ * \note Never include this file directly. Use <lzma.h> instead.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif+++/**+ * \brief Boolean+ *+ * This is here because C89 doesn't have stdbool.h. To set a value for+ * variables having type lzma_bool, you can use+ * - C99's 'true' and 'false' from stdbool.h;+ * - C++'s internal 'true' and 'false'; or+ * - integers one (true) and zero (false).+ */+typedef unsigned char lzma_bool;+++/**+ * \brief Type of reserved enumeration variable in structures+ *+ * To avoid breaking library ABI when new features are added, several+ * structures contain extra variables that may be used in future. Since+ * sizeof(enum) can be different than sizeof(int), and sizeof(enum) may+ * even vary depending on the range of enumeration constants, we specify+ * a separate type to be used for reserved enumeration variables. All+ * enumeration constants in liblzma API will be non-negative and less+ * than 128, which should guarantee that the ABI won't break even when+ * new constants are added to existing enumerations.+ */+typedef enum {+ LZMA_RESERVED_ENUM = 0+} lzma_reserved_enum;+++/**+ * \brief Return values used by several functions in liblzma+ *+ * Check the descriptions of specific functions to find out which return+ * values they can return. With some functions the return values may have+ * more specific meanings than described here; those differences are+ * described per-function basis.+ */+typedef enum {+ LZMA_OK = 0,+ /**<+ * \brief Operation completed successfully+ */++ LZMA_STREAM_END = 1,+ /**<+ * \brief End of stream was reached+ *+ * In encoder, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or+ * LZMA_FINISH was finished. In decoder, this indicates+ * that all the data was successfully decoded.+ *+ * In all cases, when LZMA_STREAM_END is returned, the last+ * output bytes should be picked from strm->next_out.+ */++ LZMA_NO_CHECK = 2,+ /**<+ * \brief Input stream has no integrity check+ *+ * This return value can be returned only if the+ * LZMA_TELL_NO_CHECK flag was used when initializing+ * the decoder. LZMA_NO_CHECK is just a warning, and+ * the decoding can be continued normally.+ *+ * It is possible to call lzma_get_check() immediately after+ * lzma_code has returned LZMA_NO_CHECK. The result will+ * naturally be LZMA_CHECK_NONE, but the possibility to call+ * lzma_get_check() may be convenient in some applications.+ */++ LZMA_UNSUPPORTED_CHECK = 3,+ /**<+ * \brief Cannot calculate the integrity check+ *+ * The usage of this return value is different in encoders+ * and decoders.+ *+ * Encoders can return this value only from the initialization+ * function. If initialization fails with this value, the+ * encoding cannot be done, because there's no way to produce+ * output with the correct integrity check.+ *+ * Decoders can return this value only from lzma_code() and+ * only if the LZMA_TELL_UNSUPPORTED_CHECK flag was used when+ * initializing the decoder. The decoding can still be+ * continued normally even if the check type is unsupported,+ * but naturally the check will not be validated, and possible+ * errors may go undetected.+ *+ * With decoder, it is possible to call lzma_get_check()+ * immediately after lzma_code() has returned+ * LZMA_UNSUPPORTED_CHECK. This way it is possible to find+ * out what the unsupported Check ID was.+ */++ LZMA_GET_CHECK = 4,+ /**<+ * \brief Integrity check type is now available+ *+ * This value can be returned only by the lzma_code() function+ * and only if the decoder was initialized with the+ * LZMA_TELL_ANY_CHECK flag. LZMA_GET_CHECK tells the+ * application that it may now call lzma_get_check() to find+ * out the Check ID. This can be used, for example, to+ * implement a decoder that accepts only files that have+ * strong enough integrity check.+ */++ LZMA_MEM_ERROR = 5,+ /**<+ * \brief Cannot allocate memory+ *+ * Memory allocation failed, or the size of the allocation+ * would be greater than SIZE_MAX.+ *+ * Due to internal implementation reasons, the coding cannot+ * be continued even if more memory were made available after+ * LZMA_MEM_ERROR.+ */++ LZMA_MEMLIMIT_ERROR = 6,+ /**<+ * \brief Memory usage limit was reached+ *+ * Decoder would need more memory than allowed by the+ * specified memory usage limit. To continue decoding,+ * the memory usage limit has to be increased with+ * lzma_memlimit_set().+ *+ * liblzma 5.2.6 and earlier had a bug in single-threaded .xz+ * decoder (lzma_stream_decoder()) which made it impossible+ * to continue decoding after LZMA_MEMLIMIT_ERROR even if+ * the limit was increased using lzma_memlimit_set().+ * Other decoders worked correctly.+ */++ LZMA_FORMAT_ERROR = 7,+ /**<+ * \brief File format not recognized+ *+ * The decoder did not recognize the input as supported file+ * format. This error can occur, for example, when trying to+ * decode .lzma format file with lzma_stream_decoder,+ * because lzma_stream_decoder accepts only the .xz format.+ */++ LZMA_OPTIONS_ERROR = 8,+ /**<+ * \brief Invalid or unsupported options+ *+ * Invalid or unsupported options, for example+ * - unsupported filter(s) or filter options; or+ * - reserved bits set in headers (decoder only).+ *+ * Rebuilding liblzma with more features enabled, or+ * upgrading to a newer version of liblzma may help.+ */++ LZMA_DATA_ERROR = 9,+ /**<+ * \brief Data is corrupt+ *+ * The usage of this return value is different in encoders+ * and decoders. In both encoder and decoder, the coding+ * cannot continue after this error.+ *+ * Encoders return this if size limits of the target file+ * format would be exceeded. These limits are huge, thus+ * getting this error from an encoder is mostly theoretical.+ * For example, the maximum compressed and uncompressed+ * size of a .xz Stream is roughly 8 EiB (2^63 bytes).+ *+ * Decoders return this error if the input data is corrupt.+ * This can mean, for example, invalid CRC32 in headers+ * or invalid check of uncompressed data.+ */++ LZMA_BUF_ERROR = 10,+ /**<+ * \brief No progress is possible+ *+ * This error code is returned when the coder cannot consume+ * any new input and produce any new output. The most common+ * reason for this error is that the input stream being+ * decoded is truncated or corrupt.+ *+ * This error is not fatal. Coding can be continued normally+ * by providing more input and/or more output space, if+ * possible.+ *+ * Typically the first call to lzma_code() that can do no+ * progress returns LZMA_OK instead of LZMA_BUF_ERROR. Only+ * the second consecutive call doing no progress will return+ * LZMA_BUF_ERROR. This is intentional.+ *+ * With zlib, Z_BUF_ERROR may be returned even if the+ * application is doing nothing wrong, so apps will need+ * to handle Z_BUF_ERROR specially. The above hack+ * guarantees that liblzma never returns LZMA_BUF_ERROR+ * to properly written applications unless the input file+ * is truncated or corrupt. This should simplify the+ * applications a little.+ */++ LZMA_PROG_ERROR = 11,+ /**<+ * \brief Programming error+ *+ * This indicates that the arguments given to the function are+ * invalid or the internal state of the decoder is corrupt.+ * - Function arguments are invalid or the structures+ * pointed by the argument pointers are invalid+ * e.g. if strm->next_out has been set to NULL and+ * strm->avail_out > 0 when calling lzma_code().+ * - lzma_* functions have been called in wrong order+ * e.g. lzma_code() was called right after lzma_end().+ * - If errors occur randomly, the reason might be flaky+ * hardware.+ *+ * If you think that your code is correct, this error code+ * can be a sign of a bug in liblzma. See the documentation+ * how to report bugs.+ */++ LZMA_SEEK_NEEDED = 12,+ /**<+ * \brief Request to change the input file position+ *+ * Some coders can do random access in the input file. The+ * initialization functions of these coders take the file size+ * as an argument. No other coders can return LZMA_SEEK_NEEDED.+ *+ * When this value is returned, the application must seek to+ * the file position given in lzma_stream.seek_pos. This value+ * is guaranteed to never exceed the file size that was+ * specified at the coder initialization.+ *+ * After seeking the application should read new input and+ * pass it normally via lzma_stream.next_in and .avail_in.+ */++ /*+ * These enumerations may be used internally by liblzma+ * but they will never be returned to applications.+ */+ LZMA_RET_INTERNAL1 = 101,+ LZMA_RET_INTERNAL2 = 102,+ LZMA_RET_INTERNAL3 = 103,+ LZMA_RET_INTERNAL4 = 104,+ LZMA_RET_INTERNAL5 = 105,+ LZMA_RET_INTERNAL6 = 106,+ LZMA_RET_INTERNAL7 = 107,+ LZMA_RET_INTERNAL8 = 108+} lzma_ret;+++/**+ * \brief The 'action' argument for lzma_code()+ *+ * After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, LZMA_FULL_BARRIER,+ * or LZMA_FINISH, the same 'action' must be used until lzma_code() returns+ * LZMA_STREAM_END. Also, the amount of input (that is, strm->avail_in) must+ * not be modified by the application until lzma_code() returns+ * LZMA_STREAM_END. Changing the 'action' or modifying the amount of input+ * will make lzma_code() return LZMA_PROG_ERROR.+ */+typedef enum {+ LZMA_RUN = 0,+ /**<+ * \brief Continue coding+ *+ * Encoder: Encode as much input as possible. Some internal+ * buffering will probably be done (depends on the filter+ * chain in use), which causes latency: the input used won't+ * usually be decodeable from the output of the same+ * lzma_code() call.+ *+ * Decoder: Decode as much input as possible and produce as+ * much output as possible.+ */++ LZMA_SYNC_FLUSH = 1,+ /**<+ * \brief Make all the input available at output+ *+ * Normally the encoder introduces some latency.+ * LZMA_SYNC_FLUSH forces all the buffered data to be+ * available at output without resetting the internal+ * state of the encoder. This way it is possible to use+ * compressed stream for example for communication over+ * network.+ *+ * Only some filters support LZMA_SYNC_FLUSH. Trying to use+ * LZMA_SYNC_FLUSH with filters that don't support it will+ * make lzma_code() return LZMA_OPTIONS_ERROR. For example,+ * LZMA1 doesn't support LZMA_SYNC_FLUSH but LZMA2 does.+ *+ * Using LZMA_SYNC_FLUSH very often can dramatically reduce+ * the compression ratio. With some filters (for example,+ * LZMA2), fine-tuning the compression options may help+ * mitigate this problem significantly (for example,+ * match finder with LZMA2).+ *+ * Decoders don't support LZMA_SYNC_FLUSH.+ */++ LZMA_FULL_FLUSH = 2,+ /**<+ * \brief Finish encoding of the current Block+ *+ * All the input data going to the current Block must have+ * been given to the encoder (the last bytes can still be+ * pending in *next_in). Call lzma_code() with LZMA_FULL_FLUSH+ * until it returns LZMA_STREAM_END. Then continue normally+ * with LZMA_RUN or finish the Stream with LZMA_FINISH.+ *+ * This action is currently supported only by Stream encoder+ * and easy encoder (which uses Stream encoder). If there is+ * no unfinished Block, no empty Block is created.+ */++ LZMA_FULL_BARRIER = 4,+ /**<+ * \brief Finish encoding of the current Block+ *+ * This is like LZMA_FULL_FLUSH except that this doesn't+ * necessarily wait until all the input has been made+ * available via the output buffer. That is, lzma_code()+ * might return LZMA_STREAM_END as soon as all the input+ * has been consumed (avail_in == 0).+ *+ * LZMA_FULL_BARRIER is useful with a threaded encoder if+ * one wants to split the .xz Stream into Blocks at specific+ * offsets but doesn't care if the output isn't flushed+ * immediately. Using LZMA_FULL_BARRIER allows keeping+ * the threads busy while LZMA_FULL_FLUSH would make+ * lzma_code() wait until all the threads have finished+ * until more data could be passed to the encoder.+ *+ * With a lzma_stream initialized with the single-threaded+ * lzma_stream_encoder() or lzma_easy_encoder(),+ * LZMA_FULL_BARRIER is an alias for LZMA_FULL_FLUSH.+ */++ LZMA_FINISH = 3+ /**<+ * \brief Finish the coding operation+ *+ * All the input data must have been given to the encoder+ * (the last bytes can still be pending in next_in).+ * Call lzma_code() with LZMA_FINISH until it returns+ * LZMA_STREAM_END. Once LZMA_FINISH has been used,+ * the amount of input must no longer be changed by+ * the application.+ *+ * When decoding, using LZMA_FINISH is optional unless the+ * LZMA_CONCATENATED flag was used when the decoder was+ * initialized. When LZMA_CONCATENATED was not used, the only+ * effect of LZMA_FINISH is that the amount of input must not+ * be changed just like in the encoder.+ */+} lzma_action;+++/**+ * \brief Custom functions for memory handling+ *+ * A pointer to lzma_allocator may be passed via lzma_stream structure+ * to liblzma, and some advanced functions take a pointer to lzma_allocator+ * as a separate function argument. The library will use the functions+ * specified in lzma_allocator for memory handling instead of the default+ * malloc() and free(). C++ users should note that the custom memory+ * handling functions must not throw exceptions.+ *+ * Single-threaded mode only: liblzma doesn't make an internal copy of+ * lzma_allocator. Thus, it is OK to change these function pointers in+ * the middle of the coding process, but obviously it must be done+ * carefully to make sure that the replacement 'free' can deallocate+ * memory allocated by the earlier 'alloc' function(s).+ *+ * Multithreaded mode: liblzma might internally store pointers to the+ * lzma_allocator given via the lzma_stream structure. The application+ * must not change the allocator pointer in lzma_stream or the contents+ * of the pointed lzma_allocator structure until lzma_end() has been used+ * to free the memory associated with that lzma_stream. The allocation+ * functions might be called simultaneously from multiple threads, and+ * thus they must be thread safe.+ */+typedef struct {+ /**+ * \brief Pointer to a custom memory allocation function+ *+ * If you don't want a custom allocator, but still want+ * custom free(), set this to NULL and liblzma will use+ * the standard malloc().+ *+ * \param opaque lzma_allocator.opaque (see below)+ * \param nmemb Number of elements like in calloc(). liblzma+ * will always set nmemb to 1, so it is safe to+ * ignore nmemb in a custom allocator if you like.+ * The nmemb argument exists only for+ * compatibility with zlib and libbzip2.+ * \param size Size of an element in bytes.+ * liblzma never sets this to zero.+ *+ * \return Pointer to the beginning of a memory block of+ * 'size' bytes, or NULL if allocation fails+ * for some reason. When allocation fails, functions+ * of liblzma return LZMA_MEM_ERROR.+ *+ * The allocator should not waste time zeroing the allocated buffers.+ * This is not only about speed, but also memory usage, since the+ * operating system kernel doesn't necessarily allocate the requested+ * memory in physical memory until it is actually used. With small+ * input files, liblzma may actually need only a fraction of the+ * memory that it requested for allocation.+ *+ * \note LZMA_MEM_ERROR is also used when the size of the+ * allocation would be greater than SIZE_MAX. Thus,+ * don't assume that the custom allocator must have+ * returned NULL if some function from liblzma+ * returns LZMA_MEM_ERROR.+ */+ void *(LZMA_API_CALL *alloc)(void *opaque, size_t nmemb, size_t size);++ /**+ * \brief Pointer to a custom memory freeing function+ *+ * If you don't want a custom freeing function, but still+ * want a custom allocator, set this to NULL and liblzma+ * will use the standard free().+ *+ * \param opaque lzma_allocator.opaque (see below)+ * \param ptr Pointer returned by lzma_allocator.alloc(),+ * or when it is set to NULL, a pointer returned+ * by the standard malloc().+ */+ void (LZMA_API_CALL *free)(void *opaque, void *ptr);++ /**+ * \brief Pointer passed to .alloc() and .free()+ *+ * opaque is passed as the first argument to lzma_allocator.alloc()+ * and lzma_allocator.free(). This intended to ease implementing+ * custom memory allocation functions for use with liblzma.+ *+ * If you don't need this, you should set this to NULL.+ */+ void *opaque;++} lzma_allocator;+++/**+ * \brief Internal data structure+ *+ * The contents of this structure is not visible outside the library.+ */+typedef struct lzma_internal_s lzma_internal;+++/**+ * \brief Passing data to and from liblzma+ *+ * The lzma_stream structure is used for+ * - passing pointers to input and output buffers to liblzma;+ * - defining custom memory handler functions; and+ * - holding a pointer to coder-specific internal data structures.+ *+ * Typical usage:+ *+ * - After allocating lzma_stream (on stack or with malloc()), it must be+ * initialized to LZMA_STREAM_INIT (see LZMA_STREAM_INIT for details).+ *+ * - Initialize a coder to the lzma_stream, for example by using+ * lzma_easy_encoder() or lzma_auto_decoder(). Some notes:+ * - In contrast to zlib, strm->next_in and strm->next_out are+ * ignored by all initialization functions, thus it is safe+ * to not initialize them yet.+ * - The initialization functions always set strm->total_in and+ * strm->total_out to zero.+ * - If the initialization function fails, no memory is left allocated+ * that would require freeing with lzma_end() even if some memory was+ * associated with the lzma_stream structure when the initialization+ * function was called.+ *+ * - Use lzma_code() to do the actual work.+ *+ * - Once the coding has been finished, the existing lzma_stream can be+ * reused. It is OK to reuse lzma_stream with different initialization+ * function without calling lzma_end() first. Old allocations are+ * automatically freed.+ *+ * - Finally, use lzma_end() to free the allocated memory. lzma_end() never+ * frees the lzma_stream structure itself.+ *+ * Application may modify the values of total_in and total_out as it wants.+ * They are updated by liblzma to match the amount of data read and+ * written but aren't used for anything else except as a possible return+ * values from lzma_get_progress().+ */+typedef struct {+ const uint8_t *next_in; /**< Pointer to the next input byte. */+ size_t avail_in; /**< Number of available input bytes in next_in. */+ uint64_t total_in; /**< Total number of bytes read by liblzma. */++ uint8_t *next_out; /**< Pointer to the next output position. */+ size_t avail_out; /**< Amount of free space in next_out. */+ uint64_t total_out; /**< Total number of bytes written by liblzma. */++ /**+ * \brief Custom memory allocation functions+ *+ * In most cases this is NULL which makes liblzma use+ * the standard malloc() and free().+ *+ * \note In 5.0.x this is not a const pointer.+ */+ const lzma_allocator *allocator;++ /** Internal state is not visible to applications. */+ lzma_internal *internal;++ /*+ * Reserved space to allow possible future extensions without+ * breaking the ABI. Excluding the initialization of this structure,+ * you should not touch these, because the names of these variables+ * may change.+ */++ /** \private Reserved member. */+ void *reserved_ptr1;++ /** \private Reserved member. */+ void *reserved_ptr2;++ /** \private Reserved member. */+ void *reserved_ptr3;++ /** \private Reserved member. */+ void *reserved_ptr4;++ /**+ * \brief New seek input position for LZMA_SEEK_NEEDED+ *+ * When lzma_code() returns LZMA_SEEK_NEEDED, the new input position+ * needed by liblzma will be available seek_pos. The value is+ * guaranteed to not exceed the file size that was specified when+ * this lzma_stream was initialized.+ *+ * In all other situations the value of this variable is undefined.+ */+ uint64_t seek_pos;++ /** \private Reserved member. */+ uint64_t reserved_int2;++ /** \private Reserved member. */+ size_t reserved_int3;++ /** \private Reserved member. */+ size_t reserved_int4;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum1;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum2;++} lzma_stream;+++/**+ * \brief Initialization for lzma_stream+ *+ * When you declare an instance of lzma_stream, you can immediately+ * initialize it so that initialization functions know that no memory+ * has been allocated yet:+ *+ * lzma_stream strm = LZMA_STREAM_INIT;+ *+ * If you need to initialize a dynamically allocated lzma_stream, you can use+ * memset(strm_pointer, 0, sizeof(lzma_stream)). Strictly speaking, this+ * violates the C standard since NULL may have different internal+ * representation than zero, but it should be portable enough in practice.+ * Anyway, for maximum portability, you can use something like this:+ *+ * lzma_stream tmp = LZMA_STREAM_INIT;+ * *strm = tmp;+ */+#define LZMA_STREAM_INIT \+ { NULL, 0, 0, NULL, 0, 0, NULL, NULL, \+ NULL, NULL, NULL, NULL, 0, 0, 0, 0, \+ LZMA_RESERVED_ENUM, LZMA_RESERVED_ENUM }+++/**+ * \brief Encode or decode data+ *+ * Once the lzma_stream has been successfully initialized (e.g. with+ * lzma_stream_encoder()), the actual encoding or decoding is done+ * using this function. The application has to update strm->next_in,+ * strm->avail_in, strm->next_out, and strm->avail_out to pass input+ * to and get output from liblzma.+ *+ * See the description of the coder-specific initialization function to find+ * out what 'action' values are supported by the coder.+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param action Action for this function to take. Must be a valid+ * lzma_action enum value.+ *+ * \return Any valid lzma_ret. See the lzma_ret enum description for more+ * information.+ */+extern LZMA_API(lzma_ret) lzma_code(lzma_stream *strm, lzma_action action)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Free memory allocated for the coder data structures+ *+ * After lzma_end(strm), strm->internal is guaranteed to be NULL. No other+ * members of the lzma_stream structure are touched.+ *+ * \note zlib indicates an error if application end()s unfinished+ * stream structure. liblzma doesn't do this, and assumes that+ * application knows what it is doing.+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ */+extern LZMA_API(void) lzma_end(lzma_stream *strm) lzma_nothrow;+++/**+ * \brief Get progress information+ *+ * In single-threaded mode, applications can get progress information from+ * strm->total_in and strm->total_out. In multi-threaded mode this is less+ * useful because a significant amount of both input and output data gets+ * buffered internally by liblzma. This makes total_in and total_out give+ * misleading information and also makes the progress indicator updates+ * non-smooth.+ *+ * This function gives realistic progress information also in multi-threaded+ * mode by taking into account the progress made by each thread. In+ * single-threaded mode *progress_in and *progress_out are set to+ * strm->total_in and strm->total_out, respectively.+ *+ * \param strm Pointer to lzma_stream that is at least+ * initialized with LZMA_STREAM_INIT.+ * \param[out] progress_in Pointer to the number of input bytes processed.+ * \param[out] progress_out Pointer to the number of output bytes processed.+ */+extern LZMA_API(void) lzma_get_progress(lzma_stream *strm,+ uint64_t *progress_in, uint64_t *progress_out) lzma_nothrow;+++/**+ * \brief Get the memory usage of decoder filter chain+ *+ * This function is currently supported only when *strm has been initialized+ * with a function that takes a memlimit argument. With other functions, you+ * should use e.g. lzma_raw_encoder_memusage() or lzma_raw_decoder_memusage()+ * to estimate the memory requirements.+ *+ * This function is useful e.g. after LZMA_MEMLIMIT_ERROR to find out how big+ * the memory usage limit should have been to decode the input. Note that+ * this may give misleading information if decoding .xz Streams that have+ * multiple Blocks, because each Block can have different memory requirements.+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ *+ * \return How much memory is currently allocated for the filter+ * decoders. If no filter chain is currently allocated,+ * some non-zero value is still returned, which is less than+ * or equal to what any filter chain would indicate as its+ * memory requirement.+ *+ * If this function isn't supported by *strm or some other error+ * occurs, zero is returned.+ */+extern LZMA_API(uint64_t) lzma_memusage(const lzma_stream *strm)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Get the current memory usage limit+ *+ * This function is supported only when *strm has been initialized with+ * a function that takes a memlimit argument.+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ *+ * \return On success, the current memory usage limit is returned+ * (always non-zero). On error, zero is returned.+ */+extern LZMA_API(uint64_t) lzma_memlimit_get(const lzma_stream *strm)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Set the memory usage limit+ *+ * This function is supported only when *strm has been initialized with+ * a function that takes a memlimit argument.+ *+ * liblzma 5.2.3 and earlier has a bug where memlimit value of 0 causes+ * this function to do nothing (leaving the limit unchanged) and still+ * return LZMA_OK. Later versions treat 0 as if 1 had been specified (so+ * lzma_memlimit_get() will return 1 even if you specify 0 here).+ *+ * liblzma 5.2.6 and earlier had a bug in single-threaded .xz decoder+ * (lzma_stream_decoder()) which made it impossible to continue decoding+ * after LZMA_MEMLIMIT_ERROR even if the limit was increased using+ * lzma_memlimit_set(). Other decoders worked correctly.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: New memory usage limit successfully set.+ * - LZMA_MEMLIMIT_ERROR: The new limit is too small.+ * The limit was not changed.+ * - LZMA_PROG_ERROR: Invalid arguments, e.g. *strm doesn't+ * support memory usage limit.+ */+extern LZMA_API(lzma_ret) lzma_memlimit_set(+ lzma_stream *strm, uint64_t memlimit) lzma_nothrow;
+ cbits/liblzma/api/lzma/bcj.h view
@@ -0,0 +1,98 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/bcj.h+ * \brief Branch/Call/Jump conversion filters+ * \note Never include this file directly. Use <lzma.h> instead.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif+++/* Filter IDs for lzma_filter.id */++/**+ * \brief Filter for x86 binaries+ */+#define LZMA_FILTER_X86 LZMA_VLI_C(0x04)++/**+ * \brief Filter for Big endian PowerPC binaries+ */+#define LZMA_FILTER_POWERPC LZMA_VLI_C(0x05)++/**+ * \brief Filter for IA-64 (Itanium) binaries+ */+#define LZMA_FILTER_IA64 LZMA_VLI_C(0x06)++/**+ * \brief Filter for ARM binaries+ */+#define LZMA_FILTER_ARM LZMA_VLI_C(0x07)++/**+ * \brief Filter for ARM-Thumb binaries+ */+#define LZMA_FILTER_ARMTHUMB LZMA_VLI_C(0x08)++/**+ * \brief Filter for SPARC binaries+ */+#define LZMA_FILTER_SPARC LZMA_VLI_C(0x09)++/**+ * \brief Filter for ARM64 binaries+ */+#define LZMA_FILTER_ARM64 LZMA_VLI_C(0x0A)++/**+ * \brief Filter for RISC-V binaries+ */+#define LZMA_FILTER_RISCV LZMA_VLI_C(0x0B)+++/**+ * \brief Options for BCJ filters+ *+ * The BCJ filters never change the size of the data. Specifying options+ * for them is optional: if pointer to options is NULL, default value is+ * used. You probably never need to specify options to BCJ filters, so just+ * set the options pointer to NULL and be happy.+ *+ * If options with non-default values have been specified when encoding,+ * the same options must also be specified when decoding.+ *+ * \note At the moment, none of the BCJ filters support+ * LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified,+ * LZMA_OPTIONS_ERROR will be returned. If there is need,+ * partial support for LZMA_SYNC_FLUSH can be added in future.+ * Partial means that flushing would be possible only at+ * offsets that are multiple of 2, 4, or 16 depending on+ * the filter, except x86 which cannot be made to support+ * LZMA_SYNC_FLUSH predictably.+ */+typedef struct {+ /**+ * \brief Start offset for conversions+ *+ * This setting is useful only when the same filter is used+ * _separately_ for multiple sections of the same executable file,+ * and the sections contain cross-section branch/call/jump+ * instructions. In that case it is beneficial to set the start+ * offset of the non-first sections so that the relative addresses+ * of the cross-section branch/call/jump instructions will use the+ * same absolute addresses as in the first section.+ *+ * When the pointer to options is NULL, the default value (zero)+ * is used.+ */+ uint32_t start_offset;++} lzma_options_bcj;
+ cbits/liblzma/api/lzma/block.h view
@@ -0,0 +1,694 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/block.h+ * \brief .xz Block handling+ * \note Never include this file directly. Use <lzma.h> instead.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif+++/**+ * \brief Options for the Block and Block Header encoders and decoders+ *+ * Different Block handling functions use different parts of this structure.+ * Some read some members, other functions write, and some do both. Only the+ * members listed for reading need to be initialized when the specified+ * functions are called. The members marked for writing will be assigned+ * new values at some point either by calling the given function or by+ * later calls to lzma_code().+ */+typedef struct {+ /**+ * \brief Block format version+ *+ * To prevent API and ABI breakages when new features are needed,+ * a version number is used to indicate which members in this+ * structure are in use:+ * - liblzma >= 5.0.0: version = 0 is supported.+ * - liblzma >= 5.1.4beta: Support for version = 1 was added,+ * which adds the ignore_check member.+ *+ * If version is greater than one, most Block related functions+ * will return LZMA_OPTIONS_ERROR (lzma_block_header_decode() works+ * with any version value).+ *+ * Read by:+ * - lzma_block_header_size()+ * - lzma_block_header_encode()+ * - lzma_block_header_decode()+ * - lzma_block_compressed_size()+ * - lzma_block_unpadded_size()+ * - lzma_block_total_size()+ * - lzma_block_encoder()+ * - lzma_block_decoder()+ * - lzma_block_buffer_encode()+ * - lzma_block_uncomp_encode()+ * - lzma_block_buffer_decode()+ *+ * Written by:+ * - lzma_block_header_decode()+ */+ uint32_t version;++ /**+ * \brief Size of the Block Header field in bytes+ *+ * This is always a multiple of four.+ *+ * Read by:+ * - lzma_block_header_encode()+ * - lzma_block_header_decode()+ * - lzma_block_compressed_size()+ * - lzma_block_unpadded_size()+ * - lzma_block_total_size()+ * - lzma_block_decoder()+ * - lzma_block_buffer_decode()+ *+ * Written by:+ * - lzma_block_header_size()+ * - lzma_block_buffer_encode()+ * - lzma_block_uncomp_encode()+ */+ uint32_t header_size;+# define LZMA_BLOCK_HEADER_SIZE_MIN 8+# define LZMA_BLOCK_HEADER_SIZE_MAX 1024++ /**+ * \brief Type of integrity Check+ *+ * The Check ID is not stored into the Block Header, thus its value+ * must be provided also when decoding.+ *+ * Read by:+ * - lzma_block_header_encode()+ * - lzma_block_header_decode()+ * - lzma_block_compressed_size()+ * - lzma_block_unpadded_size()+ * - lzma_block_total_size()+ * - lzma_block_encoder()+ * - lzma_block_decoder()+ * - lzma_block_buffer_encode()+ * - lzma_block_buffer_decode()+ */+ lzma_check check;++ /**+ * \brief Size of the Compressed Data in bytes+ *+ * Encoding: If this is not LZMA_VLI_UNKNOWN, Block Header encoder+ * will store this value to the Block Header. Block encoder doesn't+ * care about this value, but will set it once the encoding has been+ * finished.+ *+ * Decoding: If this is not LZMA_VLI_UNKNOWN, Block decoder will+ * verify that the size of the Compressed Data field matches+ * compressed_size.+ *+ * Usually you don't know this value when encoding in streamed mode,+ * and thus cannot write this field into the Block Header.+ *+ * In non-streamed mode you can reserve space for this field before+ * encoding the actual Block. After encoding the data, finish the+ * Block by encoding the Block Header. Steps in detail:+ *+ * - Set compressed_size to some big enough value. If you don't know+ * better, use LZMA_VLI_MAX, but remember that bigger values take+ * more space in Block Header.+ *+ * - Call lzma_block_header_size() to see how much space you need to+ * reserve for the Block Header.+ *+ * - Encode the Block using lzma_block_encoder() and lzma_code().+ * It sets compressed_size to the correct value.+ *+ * - Use lzma_block_header_encode() to encode the Block Header.+ * Because space was reserved in the first step, you don't need+ * to call lzma_block_header_size() anymore, because due to+ * reserving, header_size has to be big enough. If it is "too big",+ * lzma_block_header_encode() will add enough Header Padding to+ * make Block Header to match the size specified by header_size.+ *+ * Read by:+ * - lzma_block_header_size()+ * - lzma_block_header_encode()+ * - lzma_block_compressed_size()+ * - lzma_block_unpadded_size()+ * - lzma_block_total_size()+ * - lzma_block_decoder()+ * - lzma_block_buffer_decode()+ *+ * Written by:+ * - lzma_block_header_decode()+ * - lzma_block_compressed_size()+ * - lzma_block_encoder()+ * - lzma_block_decoder()+ * - lzma_block_buffer_encode()+ * - lzma_block_uncomp_encode()+ * - lzma_block_buffer_decode()+ */+ lzma_vli compressed_size;++ /**+ * \brief Uncompressed Size in bytes+ *+ * This is handled very similarly to compressed_size above.+ *+ * uncompressed_size is needed by fewer functions than+ * compressed_size. This is because uncompressed_size isn't+ * needed to validate that Block stays within proper limits.+ *+ * Read by:+ * - lzma_block_header_size()+ * - lzma_block_header_encode()+ * - lzma_block_decoder()+ * - lzma_block_buffer_decode()+ *+ * Written by:+ * - lzma_block_header_decode()+ * - lzma_block_encoder()+ * - lzma_block_decoder()+ * - lzma_block_buffer_encode()+ * - lzma_block_uncomp_encode()+ * - lzma_block_buffer_decode()+ */+ lzma_vli uncompressed_size;++ /**+ * \brief Array of filters+ *+ * There can be 1-4 filters. The end of the array is marked with+ * .id = LZMA_VLI_UNKNOWN.+ *+ * Read by:+ * - lzma_block_header_size()+ * - lzma_block_header_encode()+ * - lzma_block_encoder()+ * - lzma_block_decoder()+ * - lzma_block_buffer_encode()+ * - lzma_block_buffer_decode()+ *+ * Written by:+ * - lzma_block_header_decode(): Note that this does NOT free()+ * the old filter options structures. All unused filters[] will+ * have .id == LZMA_VLI_UNKNOWN and .options == NULL. If+ * decoding fails, all filters[] are guaranteed to be+ * LZMA_VLI_UNKNOWN and NULL.+ *+ * \note Because of the array is terminated with+ * .id = LZMA_VLI_UNKNOWN, the actual array must+ * have LZMA_FILTERS_MAX + 1 members or the Block+ * Header decoder will overflow the buffer.+ */+ lzma_filter *filters;++ /**+ * \brief Raw value stored in the Check field+ *+ * After successful coding, the first lzma_check_size(check) bytes+ * of this array contain the raw value stored in the Check field.+ *+ * Note that CRC32 and CRC64 are stored in little endian byte order.+ * Take it into account if you display the Check values to the user.+ *+ * Written by:+ * - lzma_block_encoder()+ * - lzma_block_decoder()+ * - lzma_block_buffer_encode()+ * - lzma_block_uncomp_encode()+ * - lzma_block_buffer_decode()+ */+ uint8_t raw_check[LZMA_CHECK_SIZE_MAX];++ /*+ * Reserved space to allow possible future extensions without+ * breaking the ABI. You should not touch these, because the names+ * of these variables may change. These are and will never be used+ * with the currently supported options, so it is safe to leave these+ * uninitialized.+ */++ /** \private Reserved member. */+ void *reserved_ptr1;++ /** \private Reserved member. */+ void *reserved_ptr2;++ /** \private Reserved member. */+ void *reserved_ptr3;++ /** \private Reserved member. */+ uint32_t reserved_int1;++ /** \private Reserved member. */+ uint32_t reserved_int2;++ /** \private Reserved member. */+ lzma_vli reserved_int3;++ /** \private Reserved member. */+ lzma_vli reserved_int4;++ /** \private Reserved member. */+ lzma_vli reserved_int5;++ /** \private Reserved member. */+ lzma_vli reserved_int6;++ /** \private Reserved member. */+ lzma_vli reserved_int7;++ /** \private Reserved member. */+ lzma_vli reserved_int8;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum1;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum2;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum3;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum4;++ /**+ * \brief A flag to Block decoder to not verify the Check field+ *+ * This member is supported by liblzma >= 5.1.4beta if .version >= 1.+ *+ * If this is set to true, the integrity check won't be calculated+ * and verified. Unless you know what you are doing, you should+ * leave this to false. (A reason to set this to true is when the+ * file integrity is verified externally anyway and you want to+ * speed up the decompression, which matters mostly when using+ * SHA-256 as the integrity check.)+ *+ * If .version >= 1, read by:+ * - lzma_block_decoder()+ * - lzma_block_buffer_decode()+ *+ * Written by (.version is ignored):+ * - lzma_block_header_decode() always sets this to false+ */+ lzma_bool ignore_check;++ /** \private Reserved member. */+ lzma_bool reserved_bool2;++ /** \private Reserved member. */+ lzma_bool reserved_bool3;++ /** \private Reserved member. */+ lzma_bool reserved_bool4;++ /** \private Reserved member. */+ lzma_bool reserved_bool5;++ /** \private Reserved member. */+ lzma_bool reserved_bool6;++ /** \private Reserved member. */+ lzma_bool reserved_bool7;++ /** \private Reserved member. */+ lzma_bool reserved_bool8;++} lzma_block;+++/**+ * \brief Decode the Block Header Size field+ *+ * To decode Block Header using lzma_block_header_decode(), the size of the+ * Block Header has to be known and stored into lzma_block.header_size.+ * The size can be calculated from the first byte of a Block using this macro.+ * Note that if the first byte is 0x00, it indicates beginning of Index; use+ * this macro only when the byte is not 0x00.+ *+ * There is no encoding macro because lzma_block_header_size() and+ * lzma_block_header_encode() should be used.+ */+#define lzma_block_header_size_decode(b) (((uint32_t)(b) + 1) * 4)+++/**+ * \brief Calculate Block Header Size+ *+ * Calculate the minimum size needed for the Block Header field using the+ * settings specified in the lzma_block structure. Note that it is OK to+ * increase the calculated header_size value as long as it is a multiple of+ * four and doesn't exceed LZMA_BLOCK_HEADER_SIZE_MAX. Increasing header_size+ * just means that lzma_block_header_encode() will add Header Padding.+ *+ * \note This doesn't check that all the options are valid i.e. this+ * may return LZMA_OK even if lzma_block_header_encode() or+ * lzma_block_encoder() would fail. If you want to validate the+ * filter chain, consider using lzma_memlimit_encoder() which as+ * a side-effect validates the filter chain.+ *+ * \param block Block options+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Size calculated successfully and stored to+ * block->header_size.+ * - LZMA_OPTIONS_ERROR: Unsupported version, filters or+ * filter options.+ * - LZMA_PROG_ERROR: Invalid values like compressed_size == 0.+ */+extern LZMA_API(lzma_ret) lzma_block_header_size(lzma_block *block)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Encode Block Header+ *+ * The caller must have calculated the size of the Block Header already with+ * lzma_block_header_size(). If a value larger than the one calculated by+ * lzma_block_header_size() is used, the Block Header will be padded to the+ * specified size.+ *+ * \param block Block options to be encoded.+ * \param[out] out Beginning of the output buffer. This must be+ * at least block->header_size bytes.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Encoding was successful. block->header_size+ * bytes were written to output buffer.+ * - LZMA_OPTIONS_ERROR: Invalid or unsupported options.+ * - LZMA_PROG_ERROR: Invalid arguments, for example+ * block->header_size is invalid or block->filters is NULL.+ */+extern LZMA_API(lzma_ret) lzma_block_header_encode(+ const lzma_block *block, uint8_t *out)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Decode Block Header+ *+ * block->version should (usually) be set to the highest value supported+ * by the application. If the application sets block->version to a value+ * higher than supported by the current liblzma version, this function will+ * downgrade block->version to the highest value supported by it. Thus one+ * should check the value of block->version after calling this function if+ * block->version was set to a non-zero value and the application doesn't+ * otherwise know that the liblzma version being used is new enough to+ * support the specified block->version.+ *+ * The size of the Block Header must have already been decoded with+ * lzma_block_header_size_decode() macro and stored to block->header_size.+ *+ * The integrity check type from Stream Header must have been stored+ * to block->check.+ *+ * block->filters must have been allocated, but they don't need to be+ * initialized (possible existing filter options are not freed).+ *+ * \param[out] block Destination for Block options+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() (and also free()+ * if an error occurs).+ * \param in Beginning of the input buffer. This must be+ * at least block->header_size bytes.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Decoding was successful. block->header_size+ * bytes were read from the input buffer.+ * - LZMA_OPTIONS_ERROR: The Block Header specifies some+ * unsupported options such as unsupported filters. This can+ * happen also if block->version was set to a too low value+ * compared to what would be required to properly represent+ * the information stored in the Block Header.+ * - LZMA_DATA_ERROR: Block Header is corrupt, for example,+ * the CRC32 doesn't match.+ * - LZMA_PROG_ERROR: Invalid arguments, for example+ * block->header_size is invalid or block->filters is NULL.+ */+extern LZMA_API(lzma_ret) lzma_block_header_decode(lzma_block *block,+ const lzma_allocator *allocator, const uint8_t *in)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Validate and set Compressed Size according to Unpadded Size+ *+ * Block Header stores Compressed Size, but Index has Unpadded Size. If the+ * application has already parsed the Index and is now decoding Blocks,+ * it can calculate Compressed Size from Unpadded Size. This function does+ * exactly that with error checking:+ *+ * - Compressed Size calculated from Unpadded Size must be positive integer,+ * that is, Unpadded Size must be big enough that after Block Header and+ * Check fields there's still at least one byte for Compressed Size.+ *+ * - If Compressed Size was present in Block Header, the new value+ * calculated from Unpadded Size is compared against the value+ * from Block Header.+ *+ * \note This function must be called _after_ decoding the Block Header+ * field so that it can properly validate Compressed Size if it+ * was present in Block Header.+ *+ * \param block Block options: block->header_size must+ * already be set with lzma_block_header_size().+ * \param unpadded_size Unpadded Size from the Index field in bytes+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: block->compressed_size was set successfully.+ * - LZMA_DATA_ERROR: unpadded_size is too small compared to+ * block->header_size and lzma_check_size(block->check).+ * - LZMA_PROG_ERROR: Some values are invalid. For example,+ * block->header_size must be a multiple of four and+ * between 8 and 1024 inclusive.+ */+extern LZMA_API(lzma_ret) lzma_block_compressed_size(+ lzma_block *block, lzma_vli unpadded_size)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Calculate Unpadded Size+ *+ * The Index field stores Unpadded Size and Uncompressed Size. The latter+ * can be taken directly from the lzma_block structure after coding a Block,+ * but Unpadded Size needs to be calculated from Block Header Size,+ * Compressed Size, and size of the Check field. This is where this function+ * is needed.+ *+ * \param block Block options: block->header_size must already be+ * set with lzma_block_header_size().+ *+ * \return Unpadded Size on success, or zero on error.+ */+extern LZMA_API(lzma_vli) lzma_block_unpadded_size(const lzma_block *block)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Calculate the total encoded size of a Block+ *+ * This is equivalent to lzma_block_unpadded_size() except that the returned+ * value includes the size of the Block Padding field.+ *+ * \param block Block options: block->header_size must already be+ * set with lzma_block_header_size().+ *+ * \return On success, total encoded size of the Block. On error,+ * zero is returned.+ */+extern LZMA_API(lzma_vli) lzma_block_total_size(const lzma_block *block)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Initialize .xz Block encoder+ *+ * Valid actions for lzma_code() are LZMA_RUN, LZMA_SYNC_FLUSH (only if the+ * filter chain supports it), and LZMA_FINISH.+ *+ * The Block encoder encodes the Block Data, Block Padding, and Check value.+ * It does NOT encode the Block Header which can be encoded with+ * lzma_block_header_encode().+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param block Block options: block->version, block->check,+ * and block->filters must have been initialized.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: All good, continue with lzma_code().+ * - LZMA_MEM_ERROR+ * - LZMA_OPTIONS_ERROR+ * - LZMA_UNSUPPORTED_CHECK: block->check specifies a Check ID+ * that is not supported by this build of liblzma. Initializing+ * the encoder failed.+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_block_encoder(+ lzma_stream *strm, lzma_block *block)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Initialize .xz Block decoder+ *+ * Valid actions for lzma_code() are LZMA_RUN and LZMA_FINISH. Using+ * LZMA_FINISH is not required. It is supported only for convenience.+ *+ * The Block decoder decodes the Block Data, Block Padding, and Check value.+ * It does NOT decode the Block Header which can be decoded with+ * lzma_block_header_decode().+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param block Block options+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: All good, continue with lzma_code().+ * - LZMA_PROG_ERROR+ * - LZMA_MEM_ERROR+ */+extern LZMA_API(lzma_ret) lzma_block_decoder(+ lzma_stream *strm, lzma_block *block)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Calculate maximum output size for single-call Block encoding+ *+ * This is equivalent to lzma_stream_buffer_bound() but for .xz Blocks.+ * See the documentation of lzma_stream_buffer_bound().+ *+ * \param uncompressed_size Size of the data to be encoded with the+ * single-call Block encoder.+ *+ * \return Maximum output size in bytes for single-call Block encoding.+ */+extern LZMA_API(size_t) lzma_block_buffer_bound(size_t uncompressed_size)+ lzma_nothrow;+++/**+ * \brief Single-call .xz Block encoder+ *+ * In contrast to the multi-call encoder initialized with+ * lzma_block_encoder(), this function encodes also the Block Header. This+ * is required to make it possible to write appropriate Block Header also+ * in case the data isn't compressible, and different filter chain has to be+ * used to encode the data in uncompressed form using uncompressed chunks+ * of the LZMA2 filter.+ *+ * When the data isn't compressible, header_size, compressed_size, and+ * uncompressed_size are set just like when the data was compressible, but+ * it is possible that header_size is too small to hold the filter chain+ * specified in block->filters, because that isn't necessarily the filter+ * chain that was actually used to encode the data. lzma_block_unpadded_size()+ * still works normally, because it doesn't read the filters array.+ *+ * \param block Block options: block->version, block->check,+ * and block->filters must have been initialized.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ * \param in Beginning of the input buffer+ * \param in_size Size of the input buffer+ * \param[out] out Beginning of the output buffer+ * \param[out] out_pos The next byte will be written to out[*out_pos].+ * *out_pos is updated only if encoding succeeds.+ * \param out_size Size of the out buffer; the first byte into+ * which no data is written to is out[out_size].+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Encoding was successful.+ * - LZMA_BUF_ERROR: Not enough output buffer space.+ * - LZMA_UNSUPPORTED_CHECK+ * - LZMA_OPTIONS_ERROR+ * - LZMA_MEM_ERROR+ * - LZMA_DATA_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_block_buffer_encode(+ lzma_block *block, const lzma_allocator *allocator,+ const uint8_t *in, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Single-call uncompressed .xz Block encoder+ *+ * This is like lzma_block_buffer_encode() except this doesn't try to+ * compress the data and instead encodes the data using LZMA2 uncompressed+ * chunks. The required output buffer size can be determined with+ * lzma_block_buffer_bound().+ *+ * Since the data won't be compressed, this function ignores block->filters.+ * This function doesn't take lzma_allocator because this function doesn't+ * allocate any memory from the heap.+ *+ * \param block Block options: block->version, block->check,+ * and block->filters must have been initialized.+ * \param in Beginning of the input buffer+ * \param in_size Size of the input buffer+ * \param[out] out Beginning of the output buffer+ * \param[out] out_pos The next byte will be written to out[*out_pos].+ * *out_pos is updated only if encoding succeeds.+ * \param out_size Size of the out buffer; the first byte into+ * which no data is written to is out[out_size].+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Encoding was successful.+ * - LZMA_BUF_ERROR: Not enough output buffer space.+ * - LZMA_UNSUPPORTED_CHECK+ * - LZMA_OPTIONS_ERROR+ * - LZMA_MEM_ERROR+ * - LZMA_DATA_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_block_uncomp_encode(lzma_block *block,+ const uint8_t *in, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Single-call .xz Block decoder+ *+ * This is single-call equivalent of lzma_block_decoder(), and requires that+ * the caller has already decoded Block Header and checked its memory usage.+ *+ * \param block Block options+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ * \param in Beginning of the input buffer+ * \param in_pos The next byte will be read from in[*in_pos].+ * *in_pos is updated only if decoding succeeds.+ * \param in_size Size of the input buffer; the first byte that+ * won't be read is in[in_size].+ * \param[out] out Beginning of the output buffer+ * \param[out] out_pos The next byte will be written to out[*out_pos].+ * *out_pos is updated only if encoding succeeds.+ * \param out_size Size of the out buffer; the first byte into+ * which no data is written to is out[out_size].+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Decoding was successful.+ * - LZMA_OPTIONS_ERROR+ * - LZMA_DATA_ERROR+ * - LZMA_MEM_ERROR+ * - LZMA_BUF_ERROR: Output buffer was too small.+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_block_buffer_decode(+ lzma_block *block, const lzma_allocator *allocator,+ const uint8_t *in, size_t *in_pos, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+ lzma_nothrow;
+ cbits/liblzma/api/lzma/check.h view
@@ -0,0 +1,163 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/check.h+ * \brief Integrity checks+ * \note Never include this file directly. Use <lzma.h> instead.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif+++/**+ * \brief Type of the integrity check (Check ID)+ *+ * The .xz format supports multiple types of checks that are calculated+ * from the uncompressed data. They vary in both speed and ability to+ * detect errors.+ */+typedef enum {+ LZMA_CHECK_NONE = 0,+ /**<+ * No Check is calculated.+ *+ * Size of the Check field: 0 bytes+ */++ LZMA_CHECK_CRC32 = 1,+ /**<+ * CRC32 using the polynomial from the IEEE 802.3 standard+ *+ * Size of the Check field: 4 bytes+ */++ LZMA_CHECK_CRC64 = 4,+ /**<+ * CRC64 using the polynomial from the ECMA-182 standard+ *+ * Size of the Check field: 8 bytes+ */++ LZMA_CHECK_SHA256 = 10+ /**<+ * SHA-256+ *+ * Size of the Check field: 32 bytes+ */+} lzma_check;+++/**+ * \brief Maximum valid Check ID+ *+ * The .xz file format specification specifies 16 Check IDs (0-15). Some+ * of them are only reserved, that is, no actual Check algorithm has been+ * assigned. When decoding, liblzma still accepts unknown Check IDs for+ * future compatibility. If a valid but unsupported Check ID is detected,+ * liblzma can indicate a warning; see the flags LZMA_TELL_NO_CHECK,+ * LZMA_TELL_UNSUPPORTED_CHECK, and LZMA_TELL_ANY_CHECK in container.h.+ */+#define LZMA_CHECK_ID_MAX 15+++/**+ * \brief Test if the given Check ID is supported+ *+ * LZMA_CHECK_NONE and LZMA_CHECK_CRC32 are always supported (even if+ * liblzma is built with limited features).+ *+ * \note It is safe to call this with a value that is not in the+ * range [0, 15]; in that case the return value is always false.+ *+ * \param check Check ID+ *+ * \return lzma_bool:+ * - true if Check ID is supported by this liblzma build.+ * - false otherwise.+ */+extern LZMA_API(lzma_bool) lzma_check_is_supported(lzma_check check)+ lzma_nothrow lzma_attr_const;+++/**+ * \brief Get the size of the Check field with the given Check ID+ *+ * Although not all Check IDs have a check algorithm associated, the size of+ * every Check is already frozen. This function returns the size (in bytes) of+ * the Check field with the specified Check ID. The values are:+ * { 0, 4, 4, 4, 8, 8, 8, 16, 16, 16, 32, 32, 32, 64, 64, 64 }+ *+ * \param check Check ID+ *+ * \return Size of the Check field in bytes. If the argument is not in+ * the range [0, 15], UINT32_MAX is returned.+ */+extern LZMA_API(uint32_t) lzma_check_size(lzma_check check)+ lzma_nothrow lzma_attr_const;+++/**+ * \brief Maximum size of a Check field+ */+#define LZMA_CHECK_SIZE_MAX 64+++/**+ * \brief Calculate CRC32+ *+ * Calculate CRC32 using the polynomial from the IEEE 802.3 standard.+ *+ * \param buf Pointer to the input buffer+ * \param size Size of the input buffer+ * \param crc Previously returned CRC value. This is used to+ * calculate the CRC of a big buffer in smaller chunks.+ * Set to zero when starting a new calculation.+ *+ * \return Updated CRC value, which can be passed to this function+ * again to continue CRC calculation.+ */+extern LZMA_API(uint32_t) lzma_crc32(+ const uint8_t *buf, size_t size, uint32_t crc)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Calculate CRC64+ *+ * Calculate CRC64 using the polynomial from the ECMA-182 standard.+ *+ * This function is used similarly to lzma_crc32().+ *+ * \param buf Pointer to the input buffer+ * \param size Size of the input buffer+ * \param crc Previously returned CRC value. This is used to+ * calculate the CRC of a big buffer in smaller chunks.+ * Set to zero when starting a new calculation.+ *+ * \return Updated CRC value, which can be passed to this function+ * again to continue CRC calculation.+ */+extern LZMA_API(uint64_t) lzma_crc64(+ const uint8_t *buf, size_t size, uint64_t crc)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Get the type of the integrity check+ *+ * This function can be called only immediately after lzma_code() has+ * returned LZMA_NO_CHECK, LZMA_UNSUPPORTED_CHECK, or LZMA_GET_CHECK.+ * Calling this function in any other situation has undefined behavior.+ *+ * \param strm Pointer to lzma_stream meeting the above conditions.+ *+ * \return Check ID in the lzma_stream, or undefined if called improperly.+ */+extern LZMA_API(lzma_check) lzma_get_check(const lzma_stream *strm)+ lzma_nothrow;
+ cbits/liblzma/api/lzma/container.h view
@@ -0,0 +1,995 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/container.h+ * \brief File formats+ * \note Never include this file directly. Use <lzma.h> instead.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif+++/************+ * Encoding *+ ************/++/**+ * \brief Default compression preset+ *+ * It's not straightforward to recommend a default preset, because in some+ * cases keeping the resource usage relatively low is more important that+ * getting the maximum compression ratio.+ */+#define LZMA_PRESET_DEFAULT UINT32_C(6)+++/**+ * \brief Mask for preset level+ *+ * This is useful only if you need to extract the level from the preset+ * variable. That should be rare.+ */+#define LZMA_PRESET_LEVEL_MASK UINT32_C(0x1F)+++/*+ * Preset flags+ *+ * Currently only one flag is defined.+ */++/**+ * \brief Extreme compression preset+ *+ * This flag modifies the preset to make the encoding significantly slower+ * while improving the compression ratio only marginally. This is useful+ * when you don't mind spending time to get as small result as possible.+ *+ * This flag doesn't affect the memory usage requirements of the decoder (at+ * least not significantly). The memory usage of the encoder may be increased+ * a little but only at the lowest preset levels (0-3).+ */+#define LZMA_PRESET_EXTREME (UINT32_C(1) << 31)+++/**+ * \brief Multithreading options+ */+typedef struct {+ /**+ * \brief Flags+ *+ * Set this to zero if no flags are wanted.+ *+ * Encoder: No flags are currently supported.+ *+ * Decoder: Bitwise-or of zero or more of the decoder flags:+ * - LZMA_TELL_NO_CHECK+ * - LZMA_TELL_UNSUPPORTED_CHECK+ * - LZMA_TELL_ANY_CHECK+ * - LZMA_IGNORE_CHECK+ * - LZMA_CONCATENATED+ * - LZMA_FAIL_FAST+ */+ uint32_t flags;++ /**+ * \brief Number of worker threads to use+ */+ uint32_t threads;++ /**+ * \brief Encoder only: Maximum uncompressed size of a Block+ *+ * The encoder will start a new .xz Block every block_size bytes.+ * Using LZMA_FULL_FLUSH or LZMA_FULL_BARRIER with lzma_code()+ * the caller may tell liblzma to start a new Block earlier.+ *+ * With LZMA2, a recommended block size is 2-4 times the LZMA2+ * dictionary size. With very small dictionaries, it is recommended+ * to use at least 1 MiB block size for good compression ratio, even+ * if this is more than four times the dictionary size. Note that+ * these are only recommendations for typical use cases; feel free+ * to use other values. Just keep in mind that using a block size+ * less than the LZMA2 dictionary size is waste of RAM.+ *+ * Set this to 0 to let liblzma choose the block size depending+ * on the compression options. For LZMA2 it will be 3*dict_size+ * or 1 MiB, whichever is more.+ *+ * For each thread, about 3 * block_size bytes of memory will be+ * allocated. This may change in later liblzma versions. If so,+ * the memory usage will probably be reduced, not increased.+ */+ uint64_t block_size;++ /**+ * \brief Timeout to allow lzma_code() to return early+ *+ * Multithreading can make liblzma consume input and produce+ * output in a very bursty way: it may first read a lot of input+ * to fill internal buffers, then no input or output occurs for+ * a while.+ *+ * In single-threaded mode, lzma_code() won't return until it has+ * either consumed all the input or filled the output buffer. If+ * this is done in multithreaded mode, it may cause a call+ * lzma_code() to take even tens of seconds, which isn't acceptable+ * in all applications.+ *+ * To avoid very long blocking times in lzma_code(), a timeout+ * (in milliseconds) may be set here. If lzma_code() would block+ * longer than this number of milliseconds, it will return with+ * LZMA_OK. Reasonable values are 100 ms or more. The xz command+ * line tool uses 300 ms.+ *+ * If long blocking times are acceptable, set timeout to a special+ * value of 0. This will disable the timeout mechanism and will make+ * lzma_code() block until all the input is consumed or the output+ * buffer has been filled.+ *+ * \note Even with a timeout, lzma_code() might sometimes take+ * a long time to return. No timing guarantees are made.+ */+ uint32_t timeout;++ /**+ * \brief Encoder only: Compression preset+ *+ * The preset is set just like with lzma_easy_encoder().+ * The preset is ignored if filters below is non-NULL.+ */+ uint32_t preset;++ /**+ * \brief Encoder only: Filter chain (alternative to a preset)+ *+ * If this is NULL, the preset above is used. Otherwise the preset+ * is ignored and the filter chain specified here is used.+ */+ const lzma_filter *filters;++ /**+ * \brief Encoder only: Integrity check type+ *+ * See check.h for available checks. The xz command line tool+ * defaults to LZMA_CHECK_CRC64, which is a good choice if you+ * are unsure.+ */+ lzma_check check;++ /*+ * Reserved space to allow possible future extensions without+ * breaking the ABI. You should not touch these, because the names+ * of these variables may change. These are and will never be used+ * with the currently supported options, so it is safe to leave these+ * uninitialized.+ */+ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum1;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum2;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum3;++ /** \private Reserved member. */+ uint32_t reserved_int1;++ /** \private Reserved member. */+ uint32_t reserved_int2;++ /** \private Reserved member. */+ uint32_t reserved_int3;++ /** \private Reserved member. */+ uint32_t reserved_int4;++ /**+ * \brief Memory usage limit to reduce the number of threads+ *+ * Encoder: Ignored.+ *+ * Decoder:+ *+ * If the number of threads has been set so high that more than+ * memlimit_threading bytes of memory would be needed, the number+ * of threads will be reduced so that the memory usage will not exceed+ * memlimit_threading bytes. However, if memlimit_threading cannot+ * be met even in single-threaded mode, then decoding will continue+ * in single-threaded mode and memlimit_threading may be exceeded+ * even by a large amount. That is, memlimit_threading will never make+ * lzma_code() return LZMA_MEMLIMIT_ERROR. To truly cap the memory+ * usage, see memlimit_stop below.+ *+ * Setting memlimit_threading to UINT64_MAX or a similar huge value+ * means that liblzma is allowed to keep the whole compressed file+ * and the whole uncompressed file in memory in addition to the memory+ * needed by the decompressor data structures used by each thread!+ * In other words, a reasonable value limit must be set here or it+ * will cause problems sooner or later. If you have no idea what+ * a reasonable value could be, try lzma_physmem() / 4 as a starting+ * point. Setting this limit will never prevent decompression of+ * a file; this will only reduce the number of threads.+ *+ * If memlimit_threading is greater than memlimit_stop, then the value+ * of memlimit_stop will be used for both.+ */+ uint64_t memlimit_threading;++ /**+ * \brief Memory usage limit that should never be exceeded+ *+ * Encoder: Ignored.+ *+ * Decoder: If decompressing will need more than this amount of+ * memory even in the single-threaded mode, then lzma_code() will+ * return LZMA_MEMLIMIT_ERROR.+ */+ uint64_t memlimit_stop;++ /** \private Reserved member. */+ uint64_t reserved_int7;++ /** \private Reserved member. */+ uint64_t reserved_int8;++ /** \private Reserved member. */+ void *reserved_ptr1;++ /** \private Reserved member. */+ void *reserved_ptr2;++ /** \private Reserved member. */+ void *reserved_ptr3;++ /** \private Reserved member. */+ void *reserved_ptr4;++} lzma_mt;+++/**+ * \brief Calculate approximate memory usage of easy encoder+ *+ * This function is a wrapper for lzma_raw_encoder_memusage().+ *+ * \param preset Compression preset (level and possible flags)+ *+ * \return Number of bytes of memory required for the given+ * preset when encoding or UINT64_MAX on error.+ */+extern LZMA_API(uint64_t) lzma_easy_encoder_memusage(uint32_t preset)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Calculate approximate decoder memory usage of a preset+ *+ * This function is a wrapper for lzma_raw_decoder_memusage().+ *+ * \param preset Compression preset (level and possible flags)+ *+ * \return Number of bytes of memory required to decompress a file+ * that was compressed using the given preset or UINT64_MAX+ * on error.+ */+extern LZMA_API(uint64_t) lzma_easy_decoder_memusage(uint32_t preset)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Initialize .xz Stream encoder using a preset number+ *+ * This function is intended for those who just want to use the basic features+ * of liblzma (that is, most developers out there).+ *+ * If initialization fails (return value is not LZMA_OK), all the memory+ * allocated for *strm by liblzma is always freed. Thus, there is no need+ * to call lzma_end() after failed initialization.+ *+ * If initialization succeeds, use lzma_code() to do the actual encoding.+ * Valid values for 'action' (the second argument of lzma_code()) are+ * LZMA_RUN, LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, and LZMA_FINISH. In future,+ * there may be compression levels or flags that don't support LZMA_SYNC_FLUSH.+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param preset Compression preset to use. A preset consist of level+ * number and zero or more flags. Usually flags aren't+ * used, so preset is simply a number [0, 9] which match+ * the options -0 ... -9 of the xz command line tool.+ * Additional flags can be set using bitwise-or with+ * the preset level number, e.g. 6 | LZMA_PRESET_EXTREME.+ * \param check Integrity check type to use. See check.h for available+ * checks. The xz command line tool defaults to+ * LZMA_CHECK_CRC64, which is a good choice if you are+ * unsure. LZMA_CHECK_CRC32 is good too as long as the+ * uncompressed file is not many gigabytes.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Initialization succeeded. Use lzma_code() to+ * encode your data.+ * - LZMA_MEM_ERROR: Memory allocation failed.+ * - LZMA_OPTIONS_ERROR: The given compression preset is not+ * supported by this build of liblzma.+ * - LZMA_UNSUPPORTED_CHECK: The given check type is not+ * supported by this liblzma build.+ * - LZMA_PROG_ERROR: One or more of the parameters have values+ * that will never be valid. For example, strm == NULL.+ */+extern LZMA_API(lzma_ret) lzma_easy_encoder(+ lzma_stream *strm, uint32_t preset, lzma_check check)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Single-call .xz Stream encoding using a preset number+ *+ * The maximum required output buffer size can be calculated with+ * lzma_stream_buffer_bound().+ *+ * \param preset Compression preset to use. See the description+ * in lzma_easy_encoder().+ * \param check Type of the integrity check to calculate from+ * uncompressed data.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ * \param in Beginning of the input buffer+ * \param in_size Size of the input buffer+ * \param[out] out Beginning of the output buffer+ * \param[out] out_pos The next byte will be written to out[*out_pos].+ * *out_pos is updated only if encoding succeeds.+ * \param out_size Size of the out buffer; the first byte into+ * which no data is written to is out[out_size].+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Encoding was successful.+ * - LZMA_BUF_ERROR: Not enough output buffer space.+ * - LZMA_UNSUPPORTED_CHECK+ * - LZMA_OPTIONS_ERROR+ * - LZMA_MEM_ERROR+ * - LZMA_DATA_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_easy_buffer_encode(+ uint32_t preset, lzma_check check,+ const lzma_allocator *allocator,+ const uint8_t *in, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;+++/**+ * \brief Initialize .xz Stream encoder using a custom filter chain+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param filters Array of filters terminated with+ * .id == LZMA_VLI_UNKNOWN. See filters.h for more+ * information.+ * \param check Type of the integrity check to calculate from+ * uncompressed data.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Initialization was successful.+ * - LZMA_MEM_ERROR+ * - LZMA_UNSUPPORTED_CHECK+ * - LZMA_OPTIONS_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_stream_encoder(lzma_stream *strm,+ const lzma_filter *filters, lzma_check check)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Calculate approximate memory usage of multithreaded .xz encoder+ *+ * Since doing the encoding in threaded mode doesn't affect the memory+ * requirements of single-threaded decompressor, you can use+ * lzma_easy_decoder_memusage(options->preset) or+ * lzma_raw_decoder_memusage(options->filters) to calculate+ * the decompressor memory requirements.+ *+ * \param options Compression options+ *+ * \return Number of bytes of memory required for encoding with the+ * given options. If an error occurs, for example due to+ * unsupported preset or filter chain, UINT64_MAX is returned.+ */+extern LZMA_API(uint64_t) lzma_stream_encoder_mt_memusage(+ const lzma_mt *options) lzma_nothrow lzma_attr_pure;+++/**+ * \brief Initialize multithreaded .xz Stream encoder+ *+ * This provides the functionality of lzma_easy_encoder() and+ * lzma_stream_encoder() as a single function for multithreaded use.+ *+ * The supported actions for lzma_code() are LZMA_RUN, LZMA_FULL_FLUSH,+ * LZMA_FULL_BARRIER, and LZMA_FINISH. Support for LZMA_SYNC_FLUSH might be+ * added in the future.+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param options Pointer to multithreaded compression options+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_MEM_ERROR+ * - LZMA_UNSUPPORTED_CHECK+ * - LZMA_OPTIONS_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_stream_encoder_mt(+ lzma_stream *strm, const lzma_mt *options)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Calculate recommended Block size for multithreaded .xz encoder+ *+ * This calculates a recommended Block size for multithreaded encoding given+ * a filter chain. This is used internally by lzma_stream_encoder_mt() to+ * determine the Block size if the block_size member is not set to the+ * special value of 0 in the lzma_mt options struct.+ *+ * If one wishes to change the filters between Blocks, this function is+ * helpful to set the block_size member of the lzma_mt struct before calling+ * lzma_stream_encoder_mt(). Since the block_size member represents the+ * maximum possible Block size for the multithreaded .xz encoder, one can+ * use this function to find the maximum recommended Block size based on+ * all planned filter chains. Otherwise, the multithreaded encoder will+ * base its maximum Block size on the first filter chain used (if the+ * block_size member is not set), which may unnecessarily limit the Block+ * size for a later filter chain.+ *+ * \param filters Array of filters terminated with+ * .id == LZMA_VLI_UNKNOWN.+ *+ * \return Recommended Block size in bytes, or UINT64_MAX if+ * an error occurred.+ */+extern LZMA_API(uint64_t) lzma_mt_block_size(const lzma_filter *filters)+ lzma_nothrow;+++/**+ * \brief Initialize .lzma encoder (legacy file format)+ *+ * The .lzma format is sometimes called the LZMA_Alone format, which is the+ * reason for the name of this function. The .lzma format supports only the+ * LZMA1 filter. There is no support for integrity checks like CRC32.+ *+ * Use this function if and only if you need to create files readable by+ * legacy LZMA tools such as LZMA Utils 4.32.x. Moving to the .xz format+ * is strongly recommended.+ *+ * The valid action values for lzma_code() are LZMA_RUN and LZMA_FINISH.+ * No kind of flushing is supported, because the file format doesn't make+ * it possible.+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param options Pointer to encoder options+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_MEM_ERROR+ * - LZMA_OPTIONS_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_alone_encoder(+ lzma_stream *strm, const lzma_options_lzma *options)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Calculate output buffer size for single-call Stream encoder+ *+ * When trying to compress incompressible data, the encoded size will be+ * slightly bigger than the input data. This function calculates how much+ * output buffer space is required to be sure that lzma_stream_buffer_encode()+ * doesn't return LZMA_BUF_ERROR.+ *+ * The calculated value is not exact, but it is guaranteed to be big enough.+ * The actual maximum output space required may be slightly smaller (up to+ * about 100 bytes). This should not be a problem in practice.+ *+ * If the calculated maximum size doesn't fit into size_t or would make the+ * Stream grow past LZMA_VLI_MAX (which should never happen in practice),+ * zero is returned to indicate the error.+ *+ * \note The limit calculated by this function applies only to+ * single-call encoding. Multi-call encoding may (and probably+ * will) have larger maximum expansion when encoding+ * incompressible data. Currently there is no function to+ * calculate the maximum expansion of multi-call encoding.+ *+ * \param uncompressed_size Size in bytes of the uncompressed+ * input data+ *+ * \return Maximum number of bytes needed to store the compressed data.+ */+extern LZMA_API(size_t) lzma_stream_buffer_bound(size_t uncompressed_size)+ lzma_nothrow;+++/**+ * \brief Single-call .xz Stream encoder+ *+ * \param filters Array of filters terminated with+ * .id == LZMA_VLI_UNKNOWN. See filters.h for more+ * information.+ * \param check Type of the integrity check to calculate from+ * uncompressed data.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ * \param in Beginning of the input buffer+ * \param in_size Size of the input buffer+ * \param[out] out Beginning of the output buffer+ * \param[out] out_pos The next byte will be written to out[*out_pos].+ * *out_pos is updated only if encoding succeeds.+ * \param out_size Size of the out buffer; the first byte into+ * which no data is written to is out[out_size].+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Encoding was successful.+ * - LZMA_BUF_ERROR: Not enough output buffer space.+ * - LZMA_UNSUPPORTED_CHECK+ * - LZMA_OPTIONS_ERROR+ * - LZMA_MEM_ERROR+ * - LZMA_DATA_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_stream_buffer_encode(+ lzma_filter *filters, lzma_check check,+ const lzma_allocator *allocator,+ const uint8_t *in, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief MicroLZMA encoder+ *+ * The MicroLZMA format is a raw LZMA stream whose first byte (always 0x00)+ * has been replaced with bitwise-negation of the LZMA properties (lc/lp/pb).+ * This encoding ensures that the first byte of MicroLZMA stream is never+ * 0x00. There is no end of payload marker and thus the uncompressed size+ * must be stored separately. For the best error detection the dictionary+ * size should be stored separately as well but alternatively one may use+ * the uncompressed size as the dictionary size when decoding.+ *+ * With the MicroLZMA encoder, lzma_code() behaves slightly unusually.+ * The action argument must be LZMA_FINISH and the return value will never be+ * LZMA_OK. Thus the encoding is always done with a single lzma_code() after+ * the initialization. The benefit of the combination of initialization+ * function and lzma_code() is that memory allocations can be re-used for+ * better performance.+ *+ * lzma_code() will try to encode as much input as is possible to fit into+ * the given output buffer. If not all input can be encoded, the stream will+ * be finished without encoding all the input. The caller must check both+ * input and output buffer usage after lzma_code() (total_in and total_out+ * in lzma_stream can be convenient). Often lzma_code() can fill the output+ * buffer completely if there is a lot of input, but sometimes a few bytes+ * may remain unused because the next LZMA symbol would require more space.+ *+ * lzma_stream.avail_out must be at least 6. Otherwise LZMA_PROG_ERROR+ * will be returned.+ *+ * The LZMA dictionary should be reasonably low to speed up the encoder+ * re-initialization. A good value is bigger than the resulting+ * uncompressed size of most of the output chunks. For example, if output+ * size is 4 KiB, dictionary size of 32 KiB or 64 KiB is good. If the+ * data compresses extremely well, even 128 KiB may be useful.+ *+ * The MicroLZMA format and this encoder variant were made with the EROFS+ * file system in mind. This format may be convenient in other embedded+ * uses too where many small streams are needed. XZ Embedded includes a+ * decoder for this format.+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param options Pointer to encoder options+ *+ * \return Possible lzma_ret values:+ * - LZMA_STREAM_END: All good. Check the amounts of input used+ * and output produced. Store the amount of input used+ * (uncompressed size) as it needs to be known to decompress+ * the data.+ * - LZMA_OPTIONS_ERROR+ * - LZMA_MEM_ERROR+ * - LZMA_PROG_ERROR: In addition to the generic reasons for this+ * error code, this may also be returned if there isn't enough+ * output space (6 bytes) to create a valid MicroLZMA stream.+ */+extern LZMA_API(lzma_ret) lzma_microlzma_encoder(+ lzma_stream *strm, const lzma_options_lzma *options)+ lzma_nothrow;+++/************+ * Decoding *+ ************/++/**+ * This flag makes lzma_code() return LZMA_NO_CHECK if the input stream+ * being decoded has no integrity check. Note that when used with+ * lzma_auto_decoder(), all .lzma files will trigger LZMA_NO_CHECK+ * if LZMA_TELL_NO_CHECK is used.+ */+#define LZMA_TELL_NO_CHECK UINT32_C(0x01)+++/**+ * This flag makes lzma_code() return LZMA_UNSUPPORTED_CHECK if the input+ * stream has an integrity check, but the type of the integrity check is not+ * supported by this liblzma version or build. Such files can still be+ * decoded, but the integrity check cannot be verified.+ */+#define LZMA_TELL_UNSUPPORTED_CHECK UINT32_C(0x02)+++/**+ * This flag makes lzma_code() return LZMA_GET_CHECK as soon as the type+ * of the integrity check is known. The type can then be got with+ * lzma_get_check().+ */+#define LZMA_TELL_ANY_CHECK UINT32_C(0x04)+++/**+ * This flag makes lzma_code() not calculate and verify the integrity check+ * of the compressed data in .xz files. This means that invalid integrity+ * check values won't be detected and LZMA_DATA_ERROR won't be returned in+ * such cases.+ *+ * This flag only affects the checks of the compressed data itself; the CRC32+ * values in the .xz headers will still be verified normally.+ *+ * Don't use this flag unless you know what you are doing. Possible reasons+ * to use this flag:+ *+ * - Trying to recover data from a corrupt .xz file.+ *+ * - Speeding up decompression, which matters mostly with SHA-256+ * or with files that have compressed extremely well. It's recommended+ * to not use this flag for this purpose unless the file integrity is+ * verified externally in some other way.+ *+ * Support for this flag was added in liblzma 5.1.4beta.+ */+#define LZMA_IGNORE_CHECK UINT32_C(0x10)+++/**+ * This flag enables decoding of concatenated files with file formats that+ * allow concatenating compressed files as is. From the formats currently+ * supported by liblzma, only the .xz and .lz formats allow concatenated+ * files. Concatenated files are not allowed with the legacy .lzma format.+ *+ * This flag also affects the usage of the 'action' argument for lzma_code().+ * When LZMA_CONCATENATED is used, lzma_code() won't return LZMA_STREAM_END+ * unless LZMA_FINISH is used as 'action'. Thus, the application has to set+ * LZMA_FINISH in the same way as it does when encoding.+ *+ * If LZMA_CONCATENATED is not used, the decoders still accept LZMA_FINISH+ * as 'action' for lzma_code(), but the usage of LZMA_FINISH isn't required.+ */+#define LZMA_CONCATENATED UINT32_C(0x08)+++/**+ * This flag makes the threaded decoder report errors (like LZMA_DATA_ERROR)+ * as soon as they are detected. This saves time when the application has no+ * interest in a partially decompressed truncated or corrupt file. Note that+ * due to timing randomness, if the same truncated or corrupt input is+ * decompressed multiple times with this flag, a different amount of output+ * may be produced by different runs, and even the error code might vary.+ *+ * When using LZMA_FAIL_FAST, it is recommended to use LZMA_FINISH to tell+ * the decoder when no more input will be coming because it can help fast+ * detection and reporting of truncated files. Note that in this situation+ * truncated files might be diagnosed with LZMA_DATA_ERROR instead of+ * LZMA_OK or LZMA_BUF_ERROR!+ *+ * Without this flag the threaded decoder will provide as much output as+ * possible at first and then report the pending error. This default behavior+ * matches the single-threaded decoder and provides repeatable behavior+ * with truncated or corrupt input. There are a few special cases where the+ * behavior can still differ like memory allocation failures (LZMA_MEM_ERROR).+ *+ * Single-threaded decoders currently ignore this flag.+ *+ * Support for this flag was added in liblzma 5.3.3alpha. Note that in older+ * versions this flag isn't supported (LZMA_OPTIONS_ERROR) even by functions+ * that ignore this flag in newer liblzma versions.+ */+#define LZMA_FAIL_FAST UINT32_C(0x20)+++/**+ * \brief Initialize .xz Stream decoder+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param memlimit Memory usage limit as bytes. Use UINT64_MAX+ * to effectively disable the limiter. liblzma+ * 5.2.3 and earlier don't allow 0 here and return+ * LZMA_PROG_ERROR; later versions treat 0 as if 1+ * had been specified.+ * \param flags Bitwise-or of zero or more of the decoder flags:+ * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,+ * LZMA_TELL_ANY_CHECK, LZMA_IGNORE_CHECK,+ * LZMA_CONCATENATED, LZMA_FAIL_FAST+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Initialization was successful.+ * - LZMA_MEM_ERROR: Cannot allocate memory.+ * - LZMA_OPTIONS_ERROR: Unsupported flags+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_stream_decoder(+ lzma_stream *strm, uint64_t memlimit, uint32_t flags)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Initialize multithreaded .xz Stream decoder+ *+ * The decoder can decode multiple Blocks in parallel. This requires that each+ * Block Header contains the Compressed Size and Uncompressed size fields+ * which are added by the multi-threaded encoder, see lzma_stream_encoder_mt().+ *+ * A Stream with one Block will only utilize one thread. A Stream with multiple+ * Blocks but without size information in Block Headers will be processed in+ * single-threaded mode in the same way as done by lzma_stream_decoder().+ * Concatenated Streams are processed one Stream at a time; no inter-Stream+ * parallelization is done.+ *+ * This function behaves like lzma_stream_decoder() when options->threads == 1+ * and options->memlimit_threading <= 1.+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param options Pointer to multithreaded compression options+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Initialization was successful.+ * - LZMA_MEM_ERROR: Cannot allocate memory.+ * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.+ * - LZMA_OPTIONS_ERROR: Unsupported flags.+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_stream_decoder_mt(+ lzma_stream *strm, const lzma_mt *options)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Decode .xz, .lzma, and .lz (lzip) files with autodetection+ *+ * This decoder autodetects between the .xz, .lzma, and .lz file formats,+ * and calls lzma_stream_decoder(), lzma_alone_decoder(), or+ * lzma_lzip_decoder() once the type of the input file has been detected.+ *+ * Support for .lz was added in 5.4.0.+ *+ * If the flag LZMA_CONCATENATED is used and the input is a .lzma file:+ * For historical reasons concatenated .lzma files aren't supported.+ * If there is trailing data after one .lzma stream, lzma_code() will+ * return LZMA_DATA_ERROR. (lzma_alone_decoder() doesn't have such a check+ * as it doesn't support any decoder flags. It will return LZMA_STREAM_END+ * after one .lzma stream.)+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param memlimit Memory usage limit as bytes. Use UINT64_MAX+ * to effectively disable the limiter. liblzma+ * 5.2.3 and earlier don't allow 0 here and return+ * LZMA_PROG_ERROR; later versions treat 0 as if 1+ * had been specified.+ * \param flags Bitwise-or of zero or more of the decoder flags:+ * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,+ * LZMA_TELL_ANY_CHECK, LZMA_IGNORE_CHECK,+ * LZMA_CONCATENATED, LZMA_FAIL_FAST+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Initialization was successful.+ * - LZMA_MEM_ERROR: Cannot allocate memory.+ * - LZMA_OPTIONS_ERROR: Unsupported flags+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_auto_decoder(+ lzma_stream *strm, uint64_t memlimit, uint32_t flags)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Initialize .lzma decoder (legacy file format)+ *+ * Valid 'action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.+ * There is no need to use LZMA_FINISH, but it's allowed because it may+ * simplify certain types of applications.+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param memlimit Memory usage limit as bytes. Use UINT64_MAX+ * to effectively disable the limiter. liblzma+ * 5.2.3 and earlier don't allow 0 here and return+ * LZMA_PROG_ERROR; later versions treat 0 as if 1+ * had been specified.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_MEM_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_alone_decoder(+ lzma_stream *strm, uint64_t memlimit)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Initialize .lz (lzip) decoder (a foreign file format)+ *+ * This decoder supports the .lz format version 0 and the unextended .lz+ * format version 1:+ *+ * - Files in the format version 0 were produced by lzip 1.3 and older.+ * Such files aren't common but may be found from file archives+ * as a few source packages were released in this format. People+ * might have old personal files in this format too. Decompression+ * support for the format version 0 was removed in lzip 1.18.+ *+ * - lzip 1.3 added decompression support for .lz format version 1 files.+ * Compression support was added in lzip 1.4. In lzip 1.6 the .lz format+ * version 1 was extended to support the Sync Flush marker. This extension+ * is not supported by liblzma. lzma_code() will return LZMA_DATA_ERROR+ * at the location of the Sync Flush marker. In practice files with+ * the Sync Flush marker are very rare and thus liblzma can decompress+ * almost all .lz files.+ *+ * Just like with lzma_stream_decoder() for .xz files, LZMA_CONCATENATED+ * should be used when decompressing normal standalone .lz files.+ *+ * The .lz format allows putting non-.lz data at the end of a file after at+ * least one valid .lz member. That is, one can append custom data at the end+ * of a .lz file and the decoder is required to ignore it. In liblzma this+ * is relevant only when LZMA_CONCATENATED is used. In that case lzma_code()+ * will return LZMA_STREAM_END and leave lzma_stream.next_in pointing to+ * the first byte of the non-.lz data. An exception to this is if the first+ * 1-3 bytes of the non-.lz data are identical to the .lz magic bytes+ * (0x4C, 0x5A, 0x49, 0x50; "LZIP" in US-ASCII). In such a case the 1-3 bytes+ * will have been ignored by lzma_code(). If one wishes to locate the non-.lz+ * data reliably, one must ensure that the first byte isn't 0x4C. Actually+ * one should ensure that none of the first four bytes of trailing data are+ * equal to the magic bytes because lzip >= 1.20 requires it by default.+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param memlimit Memory usage limit as bytes. Use UINT64_MAX+ * to effectively disable the limiter.+ * \param flags Bitwise-or of flags, or zero for no flags.+ * All decoder flags listed above are supported+ * although only LZMA_CONCATENATED and (in very rare+ * cases) LZMA_IGNORE_CHECK are actually useful.+ * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,+ * and LZMA_FAIL_FAST do nothing. LZMA_TELL_ANY_CHECK+ * is supported for consistency only as CRC32 is+ * always used in the .lz format.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Initialization was successful.+ * - LZMA_MEM_ERROR: Cannot allocate memory.+ * - LZMA_OPTIONS_ERROR: Unsupported flags+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_lzip_decoder(+ lzma_stream *strm, uint64_t memlimit, uint32_t flags)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Single-call .xz Stream decoder+ *+ * \param memlimit Pointer to how much memory the decoder is allowed+ * to allocate. The value pointed by this pointer is+ * modified if and only if LZMA_MEMLIMIT_ERROR is+ * returned.+ * \param flags Bitwise-or of zero or more of the decoder flags:+ * LZMA_TELL_NO_CHECK, LZMA_TELL_UNSUPPORTED_CHECK,+ * LZMA_IGNORE_CHECK, LZMA_CONCATENATED,+ * LZMA_FAIL_FAST. Note that LZMA_TELL_ANY_CHECK+ * is not allowed and will return LZMA_PROG_ERROR.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ * \param in Beginning of the input buffer+ * \param in_pos The next byte will be read from in[*in_pos].+ * *in_pos is updated only if decoding succeeds.+ * \param in_size Size of the input buffer; the first byte that+ * won't be read is in[in_size].+ * \param[out] out Beginning of the output buffer+ * \param[out] out_pos The next byte will be written to out[*out_pos].+ * *out_pos is updated only if decoding succeeds.+ * \param out_size Size of the out buffer; the first byte into+ * which no data is written to is out[out_size].+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Decoding was successful.+ * - LZMA_FORMAT_ERROR+ * - LZMA_OPTIONS_ERROR+ * - LZMA_DATA_ERROR+ * - LZMA_NO_CHECK: This can be returned only if using+ * the LZMA_TELL_NO_CHECK flag.+ * - LZMA_UNSUPPORTED_CHECK: This can be returned only if using+ * the LZMA_TELL_UNSUPPORTED_CHECK flag.+ * - LZMA_MEM_ERROR+ * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.+ * The minimum required memlimit value was stored to *memlimit.+ * - LZMA_BUF_ERROR: Output buffer was too small.+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_stream_buffer_decode(+ uint64_t *memlimit, uint32_t flags,+ const lzma_allocator *allocator,+ const uint8_t *in, size_t *in_pos, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief MicroLZMA decoder+ *+ * See lzma_microlzma_encoder() for more information.+ *+ * The lzma_code() usage with this decoder is completely normal. The+ * special behavior of lzma_code() applies to lzma_microlzma_encoder() only.+ *+ * \param strm Pointer to lzma_stream that is at least initialized+ * with LZMA_STREAM_INIT.+ * \param comp_size Compressed size of the MicroLZMA stream.+ * The caller must somehow know this exactly.+ * \param uncomp_size Uncompressed size of the MicroLZMA stream.+ * If the exact uncompressed size isn't known, this+ * can be set to a value that is at most as big as+ * the exact uncompressed size would be, but then the+ * next argument uncomp_size_is_exact must be false.+ * \param uncomp_size_is_exact+ * If true, uncomp_size must be exactly correct.+ * This will improve error detection at the end of+ * the stream. If the exact uncompressed size isn't+ * known, this must be false. uncomp_size must still+ * be at most as big as the exact uncompressed size+ * is. Setting this to false when the exact size is+ * known will work but error detection at the end of+ * the stream will be weaker.+ * \param dict_size LZMA dictionary size that was used when+ * compressing the data. It is OK to use a bigger+ * value too but liblzma will then allocate more+ * memory than would actually be required and error+ * detection will be slightly worse. (Note that with+ * the implementation in XZ Embedded it doesn't+ * affect the memory usage if one specifies bigger+ * dictionary than actually required.)+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_MEM_ERROR+ * - LZMA_OPTIONS_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_microlzma_decoder(+ lzma_stream *strm, uint64_t comp_size,+ uint64_t uncomp_size, lzma_bool uncomp_size_is_exact,+ uint32_t dict_size) lzma_nothrow;
+ cbits/liblzma/api/lzma/delta.h view
@@ -0,0 +1,95 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/delta.h+ * \brief Delta filter+ * \note Never include this file directly. Use <lzma.h> instead.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif+++/**+ * \brief Filter ID+ *+ * Filter ID of the Delta filter. This is used as lzma_filter.id.+ */+#define LZMA_FILTER_DELTA LZMA_VLI_C(0x03)+++/**+ * \brief Type of the delta calculation+ *+ * Currently only byte-wise delta is supported. Other possible types could+ * be, for example, delta of 16/32/64-bit little/big endian integers, but+ * these are not currently planned since byte-wise delta is almost as good.+ */+typedef enum {+ LZMA_DELTA_TYPE_BYTE+} lzma_delta_type;+++/**+ * \brief Options for the Delta filter+ *+ * These options are needed by both encoder and decoder.+ */+typedef struct {+ /** For now, this must always be LZMA_DELTA_TYPE_BYTE. */+ lzma_delta_type type;++ /**+ * \brief Delta distance+ *+ * With the only currently supported type, LZMA_DELTA_TYPE_BYTE,+ * the distance is as bytes.+ *+ * Examples:+ * - 16-bit stereo audio: distance = 4 bytes+ * - 24-bit RGB image data: distance = 3 bytes+ */+ uint32_t dist;++ /**+ * \brief Minimum value for lzma_options_delta.dist.+ */+# define LZMA_DELTA_DIST_MIN 1++ /**+ * \brief Maximum value for lzma_options_delta.dist.+ */+# define LZMA_DELTA_DIST_MAX 256++ /*+ * Reserved space to allow possible future extensions without+ * breaking the ABI. You should not touch these, because the names+ * of these variables may change. These are and will never be used+ * when type is LZMA_DELTA_TYPE_BYTE, so it is safe to leave these+ * uninitialized.+ */++ /** \private Reserved member. */+ uint32_t reserved_int1;++ /** \private Reserved member. */+ uint32_t reserved_int2;++ /** \private Reserved member. */+ uint32_t reserved_int3;++ /** \private Reserved member. */+ uint32_t reserved_int4;++ /** \private Reserved member. */+ void *reserved_ptr1;++ /** \private Reserved member. */+ void *reserved_ptr2;++} lzma_options_delta;
+ cbits/liblzma/api/lzma/filter.h view
@@ -0,0 +1,769 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/filter.h+ * \brief Common filter related types and functions+ * \note Never include this file directly. Use <lzma.h> instead.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif+++/**+ * \brief Maximum number of filters in a chain+ *+ * A filter chain can have 1-4 filters, of which three are allowed to change+ * the size of the data. Usually only one or two filters are needed.+ */+#define LZMA_FILTERS_MAX 4+++/**+ * \brief Filter options+ *+ * This structure is used to pass a Filter ID and a pointer to the filter's+ * options to liblzma. A few functions work with a single lzma_filter+ * structure, while most functions expect a filter chain.+ *+ * A filter chain is indicated with an array of lzma_filter structures.+ * The array is terminated with .id = LZMA_VLI_UNKNOWN. Thus, the filter+ * array must have LZMA_FILTERS_MAX + 1 elements (that is, five) to+ * be able to hold any arbitrary filter chain. This is important when+ * using lzma_block_header_decode() from block.h, because a filter array+ * that is too small would make liblzma write past the end of the array.+ */+typedef struct {+ /**+ * \brief Filter ID+ *+ * Use constants whose name begin with 'LZMA_FILTER_' to specify+ * different filters. In an array of lzma_filter structures, use+ * LZMA_VLI_UNKNOWN to indicate end of filters.+ *+ * \note This is not an enum, because on some systems enums+ * cannot be 64-bit.+ */+ lzma_vli id;++ /**+ * \brief Pointer to filter-specific options structure+ *+ * If the filter doesn't need options, set this to NULL. If id is+ * set to LZMA_VLI_UNKNOWN, options is ignored, and thus+ * doesn't need be initialized.+ */+ void *options;++} lzma_filter;+++/**+ * \brief Test if the given Filter ID is supported for encoding+ *+ * \param id Filter ID+ *+ * \return lzma_bool:+ * - true if the Filter ID is supported for encoding by this+ * liblzma build.+ * - false otherwise.+ */+extern LZMA_API(lzma_bool) lzma_filter_encoder_is_supported(lzma_vli id)+ lzma_nothrow lzma_attr_const;+++/**+ * \brief Test if the given Filter ID is supported for decoding+ *+ * \param id Filter ID+ *+ * \return lzma_bool:+ * - true if the Filter ID is supported for decoding by this+ * liblzma build.+ * - false otherwise.+ */+extern LZMA_API(lzma_bool) lzma_filter_decoder_is_supported(lzma_vli id)+ lzma_nothrow lzma_attr_const;+++/**+ * \brief Copy the filters array+ *+ * Copy the Filter IDs and filter-specific options from src to dest.+ * Up to LZMA_FILTERS_MAX filters are copied, plus the terminating+ * .id == LZMA_VLI_UNKNOWN. Thus, dest should have at least+ * LZMA_FILTERS_MAX + 1 elements space unless the caller knows that+ * src is smaller than that.+ *+ * Unless the filter-specific options is NULL, the Filter ID has to be+ * supported by liblzma, because liblzma needs to know the size of every+ * filter-specific options structure. The filter-specific options are not+ * validated. If options is NULL, any unsupported Filter IDs are copied+ * without returning an error.+ *+ * Old filter-specific options in dest are not freed, so dest doesn't+ * need to be initialized by the caller in any way.+ *+ * If an error occurs, memory possibly already allocated by this function+ * is always freed. liblzma versions older than 5.2.7 may modify the dest+ * array and leave its contents in an undefined state if an error occurs.+ * liblzma 5.2.7 and newer only modify the dest array when returning LZMA_OK.+ *+ * \param src Array of filters terminated with+ * .id == LZMA_VLI_UNKNOWN.+ * \param[out] dest Destination filter array+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_MEM_ERROR+ * - LZMA_OPTIONS_ERROR: Unsupported Filter ID and its options+ * is not NULL.+ * - LZMA_PROG_ERROR: src or dest is NULL.+ */+extern LZMA_API(lzma_ret) lzma_filters_copy(+ const lzma_filter *src, lzma_filter *dest,+ const lzma_allocator *allocator)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Free the options in the array of lzma_filter structures+ *+ * This frees the filter chain options. The filters array itself is not freed.+ *+ * The filters array must have at most LZMA_FILTERS_MAX + 1 elements+ * including the terminating element which must have .id = LZMA_VLI_UNKNOWN.+ * For all elements before the terminating element:+ * - options will be freed using the given lzma_allocator or,+ * if allocator is NULL, using free().+ * - options will be set to NULL.+ * - id will be set to LZMA_VLI_UNKNOWN.+ *+ * If filters is NULL, this does nothing. Again, this never frees the+ * filters array itself.+ *+ * \param filters Array of filters terminated with+ * .id == LZMA_VLI_UNKNOWN.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ */+extern LZMA_API(void) lzma_filters_free(+ lzma_filter *filters, const lzma_allocator *allocator)+ lzma_nothrow;+++/**+ * \brief Calculate approximate memory requirements for raw encoder+ *+ * This function can be used to calculate the memory requirements for+ * Block and Stream encoders too because Block and Stream encoders don't+ * need significantly more memory than raw encoder.+ *+ * \param filters Array of filters terminated with+ * .id == LZMA_VLI_UNKNOWN.+ *+ * \return Number of bytes of memory required for the given+ * filter chain when encoding or UINT64_MAX on error.+ */+extern LZMA_API(uint64_t) lzma_raw_encoder_memusage(const lzma_filter *filters)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Calculate approximate memory requirements for raw decoder+ *+ * This function can be used to calculate the memory requirements for+ * Block and Stream decoders too because Block and Stream decoders don't+ * need significantly more memory than raw decoder.+ *+ * \param filters Array of filters terminated with+ * .id == LZMA_VLI_UNKNOWN.+ *+ * \return Number of bytes of memory required for the given+ * filter chain when decoding or UINT64_MAX on error.+ */+extern LZMA_API(uint64_t) lzma_raw_decoder_memusage(const lzma_filter *filters)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Initialize raw encoder+ *+ * This function may be useful when implementing custom file formats.+ *+ * The 'action' with lzma_code() can be LZMA_RUN, LZMA_SYNC_FLUSH (if the+ * filter chain supports it), or LZMA_FINISH.+ *+ * \param strm Pointer to lzma_stream that is at least+ * initialized with LZMA_STREAM_INIT.+ * \param filters Array of filters terminated with+ * .id == LZMA_VLI_UNKNOWN.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_MEM_ERROR+ * - LZMA_OPTIONS_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_raw_encoder(+ lzma_stream *strm, const lzma_filter *filters)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Initialize raw decoder+ *+ * The initialization of raw decoder goes similarly to raw encoder.+ *+ * The 'action' with lzma_code() can be LZMA_RUN or LZMA_FINISH. Using+ * LZMA_FINISH is not required, it is supported just for convenience.+ *+ * \param strm Pointer to lzma_stream that is at least+ * initialized with LZMA_STREAM_INIT.+ * \param filters Array of filters terminated with+ * .id == LZMA_VLI_UNKNOWN.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_MEM_ERROR+ * - LZMA_OPTIONS_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_raw_decoder(+ lzma_stream *strm, const lzma_filter *filters)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Update the filter chain in the encoder+ *+ * This function may be called after lzma_code() has returned LZMA_STREAM_END+ * when LZMA_FULL_BARRIER, LZMA_FULL_FLUSH, or LZMA_SYNC_FLUSH was used:+ *+ * - After LZMA_FULL_BARRIER or LZMA_FULL_FLUSH: Single-threaded .xz Stream+ * encoder (lzma_stream_encoder()) and (since liblzma 5.4.0) multi-threaded+ * Stream encoder (lzma_stream_encoder_mt()) allow setting a new filter+ * chain to be used for the next Block(s).+ *+ * - After LZMA_SYNC_FLUSH: Raw encoder (lzma_raw_encoder()),+ * Block encoder (lzma_block_encoder()), and single-threaded .xz Stream+ * encoder (lzma_stream_encoder()) allow changing certain filter-specific+ * options in the middle of encoding. The actual filters in the chain+ * (Filter IDs) must not be changed! Currently only the lc, lp, and pb+ * options of LZMA2 (not LZMA1) can be changed this way.+ *+ * - In the future some filters might allow changing some of their options+ * without any barrier or flushing but currently such filters don't exist.+ *+ * This function may also be called when no data has been compressed yet+ * although this is rarely useful. In that case, this function will behave+ * as if LZMA_FULL_FLUSH (Stream encoders) or LZMA_SYNC_FLUSH (Raw or Block+ * encoder) had been used right before calling this function.+ *+ * \param strm Pointer to lzma_stream that is at least+ * initialized with LZMA_STREAM_INIT.+ * \param filters Array of filters terminated with+ * .id == LZMA_VLI_UNKNOWN.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_MEM_ERROR+ * - LZMA_MEMLIMIT_ERROR+ * - LZMA_OPTIONS_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_filters_update(+ lzma_stream *strm, const lzma_filter *filters) lzma_nothrow;+++/**+ * \brief Single-call raw encoder+ *+ * \note There is no function to calculate how big output buffer+ * would surely be big enough. (lzma_stream_buffer_bound()+ * works only for lzma_stream_buffer_encode(); raw encoder+ * won't necessarily meet that bound.)+ *+ * \param filters Array of filters terminated with+ * .id == LZMA_VLI_UNKNOWN.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ * \param in Beginning of the input buffer+ * \param in_size Size of the input buffer+ * \param[out] out Beginning of the output buffer+ * \param[out] out_pos The next byte will be written to out[*out_pos].+ * *out_pos is updated only if encoding succeeds.+ * \param out_size Size of the out buffer; the first byte into+ * which no data is written to is out[out_size].+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Encoding was successful.+ * - LZMA_BUF_ERROR: Not enough output buffer space.+ * - LZMA_OPTIONS_ERROR+ * - LZMA_MEM_ERROR+ * - LZMA_DATA_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_raw_buffer_encode(+ const lzma_filter *filters, const lzma_allocator *allocator,+ const uint8_t *in, size_t in_size, uint8_t *out,+ size_t *out_pos, size_t out_size) lzma_nothrow;+++/**+ * \brief Single-call raw decoder+ *+ * \param filters Array of filters terminated with+ * .id == LZMA_VLI_UNKNOWN.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ * \param in Beginning of the input buffer+ * \param in_pos The next byte will be read from in[*in_pos].+ * *in_pos is updated only if decoding succeeds.+ * \param in_size Size of the input buffer; the first byte that+ * won't be read is in[in_size].+ * \param[out] out Beginning of the output buffer+ * \param[out] out_pos The next byte will be written to out[*out_pos].+ * *out_pos is updated only if encoding succeeds.+ * \param out_size Size of the out buffer; the first byte into+ * which no data is written to is out[out_size].+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Decoding was successful.+ * - LZMA_BUF_ERROR: Not enough output buffer space.+ * - LZMA_OPTIONS_ERROR+ * - LZMA_MEM_ERROR+ * - LZMA_DATA_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_raw_buffer_decode(+ const lzma_filter *filters, const lzma_allocator *allocator,+ const uint8_t *in, size_t *in_pos, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;+++/**+ * \brief Get the size of the Filter Properties field+ *+ * This function may be useful when implementing custom file formats+ * using the raw encoder and decoder.+ *+ * \note This function validates the Filter ID, but does not+ * necessarily validate the options. Thus, it is possible+ * that this returns LZMA_OK while the following call to+ * lzma_properties_encode() returns LZMA_OPTIONS_ERROR.+ *+ * \param[out] size Pointer to uint32_t to hold the size of the properties+ * \param filter Filter ID and options (the size of the properties may+ * vary depending on the options)+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_OPTIONS_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_properties_size(+ uint32_t *size, const lzma_filter *filter) lzma_nothrow;+++/**+ * \brief Encode the Filter Properties field+ *+ * \note Even this function won't validate more options than actually+ * necessary. Thus, it is possible that encoding the properties+ * succeeds but using the same options to initialize the encoder+ * will fail.+ *+ * \note If lzma_properties_size() indicated that the size+ * of the Filter Properties field is zero, calling+ * lzma_properties_encode() is not required, but it+ * won't do any harm either.+ *+ * \param filter Filter ID and options+ * \param[out] props Buffer to hold the encoded options. The size of+ * the buffer must have been already determined with+ * lzma_properties_size().+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_properties_encode(+ const lzma_filter *filter, uint8_t *props) lzma_nothrow;+++/**+ * \brief Decode the Filter Properties field+ *+ * \param filter filter->id must have been set to the correct+ * Filter ID. filter->options doesn't need to be+ * initialized (it's not freed by this function). The+ * decoded options will be stored in filter->options;+ * it's application's responsibility to free it when+ * appropriate. filter->options is set to NULL if+ * there are no properties or if an error occurs.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ * and in case of an error, also free().+ * \param props Input buffer containing the properties.+ * \param props_size Size of the properties. This must be the exact+ * size; giving too much or too little input will+ * return LZMA_OPTIONS_ERROR.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_OPTIONS_ERROR+ * - LZMA_MEM_ERROR+ */+extern LZMA_API(lzma_ret) lzma_properties_decode(+ lzma_filter *filter, const lzma_allocator *allocator,+ const uint8_t *props, size_t props_size) lzma_nothrow;+++/**+ * \brief Calculate encoded size of a Filter Flags field+ *+ * Knowing the size of Filter Flags is useful to know when allocating+ * memory to hold the encoded Filter Flags.+ *+ * \note If you need to calculate size of List of Filter Flags,+ * you need to loop over every lzma_filter entry.+ *+ * \param[out] size Pointer to integer to hold the calculated size+ * \param filter Filter ID and associated options whose encoded+ * size is to be calculated+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: *size set successfully. Note that this doesn't+ * guarantee that filter->options is valid, thus+ * lzma_filter_flags_encode() may still fail.+ * - LZMA_OPTIONS_ERROR: Unknown Filter ID or unsupported options.+ * - LZMA_PROG_ERROR: Invalid options+ */+extern LZMA_API(lzma_ret) lzma_filter_flags_size(+ uint32_t *size, const lzma_filter *filter)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Encode Filter Flags into given buffer+ *+ * In contrast to some functions, this doesn't allocate the needed buffer.+ * This is due to how this function is used internally by liblzma.+ *+ * \param filter Filter ID and options to be encoded+ * \param[out] out Beginning of the output buffer+ * \param[out] out_pos out[*out_pos] is the next write position. This+ * is updated by the encoder.+ * \param out_size out[out_size] is the first byte to not write.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Encoding was successful.+ * - LZMA_OPTIONS_ERROR: Invalid or unsupported options.+ * - LZMA_PROG_ERROR: Invalid options or not enough output+ * buffer space (you should have checked it with+ * lzma_filter_flags_size()).+ */+extern LZMA_API(lzma_ret) lzma_filter_flags_encode(const lzma_filter *filter,+ uint8_t *out, size_t *out_pos, size_t out_size)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Decode Filter Flags from given buffer+ *+ * The decoded result is stored into *filter. The old value of+ * filter->options is not free()d. If anything other than LZMA_OK+ * is returned, filter->options is set to NULL.+ *+ * \param[out] filter Destination filter. The decoded Filter ID will+ * be stored in filter->id. If options are needed+ * they will be allocated and the pointer will be+ * stored in filter->options.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ * \param in Beginning of the input buffer+ * \param[out] in_pos The next byte will be read from in[*in_pos].+ * *in_pos is updated only if decoding succeeds.+ * \param in_size Size of the input buffer; the first byte that+ * won't be read is in[in_size].+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_OPTIONS_ERROR+ * - LZMA_MEM_ERROR+ * - LZMA_DATA_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_filter_flags_decode(+ lzma_filter *filter, const lzma_allocator *allocator,+ const uint8_t *in, size_t *in_pos, size_t in_size)+ lzma_nothrow lzma_attr_warn_unused_result;+++/***********+ * Strings *+ ***********/++/**+ * \brief Allow or show all filters+ *+ * By default only the filters supported in the .xz format are accept by+ * lzma_str_to_filters() or shown by lzma_str_list_filters().+ */+#define LZMA_STR_ALL_FILTERS UINT32_C(0x01)+++/**+ * \brief Do not validate the filter chain in lzma_str_to_filters()+ *+ * By default lzma_str_to_filters() can return an error if the filter chain+ * as a whole isn't usable in the .xz format or in the raw encoder or decoder.+ * With this flag, this validation is skipped. This flag doesn't affect the+ * handling of the individual filter options. To allow non-.xz filters also+ * LZMA_STR_ALL_FILTERS is needed.+ */+#define LZMA_STR_NO_VALIDATION UINT32_C(0x02)+++/**+ * \brief Stringify encoder options+ *+ * Show the filter-specific options that the encoder will use.+ * This may be useful for verbose diagnostic messages.+ *+ * Note that if options were decoded from .xz headers then the encoder options+ * may be undefined. This flag shouldn't be used in such a situation.+ */+#define LZMA_STR_ENCODER UINT32_C(0x10)+++/**+ * \brief Stringify decoder options+ *+ * Show the filter-specific options that the decoder will use.+ * This may be useful for showing what filter options were decoded+ * from file headers.+ */+#define LZMA_STR_DECODER UINT32_C(0x20)+++/**+ * \brief Produce xz-compatible getopt_long() syntax+ *+ * That is, "delta:dist=2 lzma2:dict=4MiB,pb=1,lp=1" becomes+ * "--delta=dist=2 --lzma2=dict=4MiB,pb=1,lp=1".+ *+ * This syntax is compatible with xz 5.0.0 as long as the filters and+ * their options are supported too.+ */+#define LZMA_STR_GETOPT_LONG UINT32_C(0x40)+++/**+ * \brief Use two dashes "--" instead of a space to separate filters+ *+ * That is, "delta:dist=2 lzma2:pb=1,lp=1" becomes+ * "delta:dist=2--lzma2:pb=1,lp=1". This looks slightly odd but this+ * kind of strings should be usable on the command line without quoting.+ * However, it is possible that future versions with new filter options+ * might produce strings that require shell quoting anyway as the exact+ * set of possible characters isn't frozen for now.+ *+ * It is guaranteed that the single quote (') will never be used in+ * filter chain strings (even if LZMA_STR_NO_SPACES isn't used).+ */+#define LZMA_STR_NO_SPACES UINT32_C(0x80)+++/**+ * \brief Convert a string to a filter chain+ *+ * This tries to make it easier to write applications that allow users+ * to set custom compression options. This only handles the filter+ * configuration (including presets) but not the number of threads,+ * block size, check type, or memory limits.+ *+ * The input string can be either a preset or a filter chain. Presets+ * begin with a digit 0-9 and may be followed by zero or more flags+ * which are lower-case letters. Currently only "e" is supported, matching+ * LZMA_PRESET_EXTREME. For partial xz command line syntax compatibility,+ * a preset string may start with a single dash "-".+ *+ * A filter chain consists of one or more "filtername:opt1=value1,opt2=value2"+ * strings separated by one or more spaces. Leading and trailing spaces are+ * ignored. All names and values must be lower-case. Extra commas in the+ * option list are ignored. The order of filters is significant: when+ * encoding, the uncompressed input data goes to the leftmost filter first.+ * Normally "lzma2" is the last filter in the chain.+ *+ * If one wishes to avoid spaces, for example, to avoid shell quoting,+ * it is possible to use two dashes "--" instead of spaces to separate+ * the filters.+ *+ * For xz command line compatibility, each filter may be prefixed with+ * two dashes "--" and the colon ":" separating the filter name from+ * the options may be replaced with an equals sign "=".+ *+ * By default, only filters that can be used in the .xz format are accepted.+ * To allow all filters (LZMA1) use the flag LZMA_STR_ALL_FILTERS.+ *+ * By default, very basic validation is done for the filter chain as a whole,+ * for example, that LZMA2 is only used as the last filter in the chain.+ * The validation isn't perfect though and it's possible that this function+ * succeeds but using the filter chain for encoding or decoding will still+ * result in LZMA_OPTIONS_ERROR. To disable this validation, use the flag+ * LZMA_STR_NO_VALIDATION.+ *+ * The available filter names and their options are available via+ * lzma_str_list_filters(). See the xz man page for the description+ * of filter names and options.+ *+ * For command line applications, below is an example how an error message+ * can be displayed. Note the use of an empty string for the field width.+ * If "^" was used there it would create an off-by-one error except at+ * the very beginning of the line.+ *+ * \code{.c}+ * const char *str = ...; // From user+ * lzma_filter filters[LZMA_FILTERS_MAX + 1];+ * int pos;+ * const char *msg = lzma_str_to_filters(str, &pos, filters, 0, NULL);+ * if (msg != NULL) {+ * printf("%s: Error in XZ compression options:\n", argv[0]);+ * printf("%s: %s\n", argv[0], str);+ * printf("%s: %*s^\n", argv[0], errpos, "");+ * printf("%s: %s\n", argv[0], msg);+ * }+ * \endcode+ *+ * \param str User-supplied string describing a preset or+ * a filter chain. If a default value is needed and+ * you don't know what would be good, use "6" since+ * that is the default preset in xz too.+ * \param[out] error_pos If this isn't NULL, this value will be set on+ * both success and on all errors. This tells the+ * location of the error in the string. This is+ * an int to make it straightforward to use this+ * as printf() field width. The value is guaranteed+ * to be in the range [0, INT_MAX] even if strlen(str)+ * somehow was greater than INT_MAX.+ * \param[out] filters An array of lzma_filter structures. There must+ * be LZMA_FILTERS_MAX + 1 (that is, five) elements+ * in the array. The old contents are ignored so it+ * doesn't need to be initialized. This array is+ * modified only if this function returns NULL.+ * Once the allocated filter options are no longer+ * needed, lzma_filters_free() can be used to free the+ * options (it doesn't free the filters array itself).+ * \param flags Bitwise-or of zero or more of the flags+ * LZMA_STR_ALL_FILTERS and LZMA_STR_NO_VALIDATION.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ *+ * \return On success, NULL is returned. On error, a statically-allocated+ * error message is returned which together with the error_pos+ * should give some idea what is wrong.+ */+extern LZMA_API(const char *) lzma_str_to_filters(+ const char *str, int *error_pos, lzma_filter *filters,+ uint32_t flags, const lzma_allocator *allocator)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Convert a filter chain to a string+ *+ * Use cases:+ *+ * - Verbose output showing the full encoder options to the user+ * (use LZMA_STR_ENCODER in flags)+ *+ * - Showing the filters and options that are required to decode a file+ * (use LZMA_STR_DECODER in flags)+ *+ * - Showing the filter names without any options in informational messages+ * where the technical details aren't important (no flags). In this case+ * the .options in the filters array are ignored and may be NULL even if+ * a filter has a mandatory options structure.+ *+ * Note that even if the filter chain was specified using a preset,+ * the resulting filter chain isn't reversed to a preset. So if you+ * specify "6" to lzma_str_to_filters() then lzma_str_from_filters()+ * will produce a string containing "lzma2".+ *+ * \param[out] str On success *str will be set to point to an+ * allocated string describing the given filter+ * chain. Old value is ignored. On error *str is+ * always set to NULL.+ * \param filters Array of filters terminated with+ * .id == LZMA_VLI_UNKNOWN.+ * \param flags Bitwise-or of zero or more of the flags+ * LZMA_STR_ENCODER, LZMA_STR_DECODER,+ * LZMA_STR_GETOPT_LONG, and LZMA_STR_NO_SPACES.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_OPTIONS_ERROR: Empty filter chain+ * (filters[0].id == LZMA_VLI_UNKNOWN) or the filter chain+ * includes a Filter ID that is not supported by this function.+ * - LZMA_MEM_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_str_from_filters(+ char **str, const lzma_filter *filters, uint32_t flags,+ const lzma_allocator *allocator)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief List available filters and/or their options (for help message)+ *+ * If a filter_id is given then only one line is created which contains the+ * filter name. If LZMA_STR_ENCODER or LZMA_STR_DECODER is used then the+ * options read by the encoder or decoder are printed on the same line.+ *+ * If filter_id is LZMA_VLI_UNKNOWN then all supported .xz-compatible filters+ * are listed:+ *+ * - If neither LZMA_STR_ENCODER nor LZMA_STR_DECODER is used then+ * the supported filter names are listed on a single line separated+ * by spaces.+ *+ * - If LZMA_STR_ENCODER or LZMA_STR_DECODER is used then filters and+ * the supported options are listed one filter per line. There won't+ * be a newline after the last filter.+ *+ * - If LZMA_STR_ALL_FILTERS is used then the list will include also+ * those filters that cannot be used in the .xz format (LZMA1).+ *+ * \param str On success *str will be set to point to an+ * allocated string listing the filters and options.+ * Old value is ignored. On error *str is always set+ * to NULL.+ * \param filter_id Filter ID or LZMA_VLI_UNKNOWN.+ * \param flags Bitwise-or of zero or more of the flags+ * LZMA_STR_ALL_FILTERS, LZMA_STR_ENCODER,+ * LZMA_STR_DECODER, and LZMA_STR_GETOPT_LONG.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_OPTIONS_ERROR: Unsupported filter_id or flags+ * - LZMA_MEM_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_str_list_filters(+ char **str, lzma_vli filter_id, uint32_t flags,+ const lzma_allocator *allocator)+ lzma_nothrow lzma_attr_warn_unused_result;
+ cbits/liblzma/api/lzma/hardware.h view
@@ -0,0 +1,62 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/hardware.h+ * \brief Hardware information+ * \note Never include this file directly. Use <lzma.h> instead.+ *+ * Since liblzma can consume a lot of system resources, it also provides+ * ways to limit the resource usage. Applications linking against liblzma+ * need to do the actual decisions how much resources to let liblzma to use.+ * To ease making these decisions, liblzma provides functions to find out+ * the relevant capabilities of the underlying hardware. Currently there+ * is only a function to find out the amount of RAM, but in the future there+ * will be also a function to detect how many concurrent threads the system+ * can run.+ *+ * \note On some operating systems, these function may temporarily+ * load a shared library or open file descriptor(s) to find out+ * the requested hardware information. Unless the application+ * assumes that specific file descriptors are not touched by+ * other threads, this should have no effect on thread safety.+ * Possible operations involving file descriptors will restart+ * the syscalls if they return EINTR.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif+++/**+ * \brief Get the total amount of physical memory (RAM) in bytes+ *+ * This function may be useful when determining a reasonable memory+ * usage limit for decompressing or how much memory it is OK to use+ * for compressing.+ *+ * \return On success, the total amount of physical memory in bytes+ * is returned. If the amount of RAM cannot be determined,+ * zero is returned. This can happen if an error occurs+ * or if there is no code in liblzma to detect the amount+ * of RAM on the specific operating system.+ */+extern LZMA_API(uint64_t) lzma_physmem(void) lzma_nothrow;+++/**+ * \brief Get the number of processor cores or threads+ *+ * This function may be useful when determining how many threads to use.+ * If the hardware supports more than one thread per CPU core, the number+ * of hardware threads is returned if that information is available.+ *+ * \return On success, the number of available CPU threads or cores is+ * returned. If this information isn't available or an error+ * occurs, zero is returned.+ */+extern LZMA_API(uint32_t) lzma_cputhreads(void) lzma_nothrow;
+ cbits/liblzma/api/lzma/index.h view
@@ -0,0 +1,882 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/index.h+ * \brief Handling of .xz Index and related information+ * \note Never include this file directly. Use <lzma.h> instead.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif+++/**+ * \brief Opaque data type to hold the Index(es) and other information+ *+ * lzma_index often holds just one .xz Index and possibly the Stream Flags+ * of the same Stream and size of the Stream Padding field. However,+ * multiple lzma_indexes can be concatenated with lzma_index_cat() and then+ * there may be information about multiple Streams in the same lzma_index.+ *+ * Notes about thread safety: Only one thread may modify lzma_index at+ * a time. All functions that take non-const pointer to lzma_index+ * modify it. As long as no thread is modifying the lzma_index, getting+ * information from the same lzma_index can be done from multiple threads+ * at the same time with functions that take a const pointer to+ * lzma_index or use lzma_index_iter. The same iterator must be used+ * only by one thread at a time, of course, but there can be as many+ * iterators for the same lzma_index as needed.+ */+typedef struct lzma_index_s lzma_index;+++/**+ * \brief Iterator to get information about Blocks and Streams+ */+typedef struct {+ struct {+ /**+ * \brief Pointer to Stream Flags+ *+ * This is NULL if Stream Flags have not been set for+ * this Stream with lzma_index_stream_flags().+ */+ const lzma_stream_flags *flags;++ /** \private Reserved member. */+ const void *reserved_ptr1;++ /** \private Reserved member. */+ const void *reserved_ptr2;++ /** \private Reserved member. */+ const void *reserved_ptr3;++ /**+ * \brief Stream number in the lzma_index+ *+ * The first Stream is 1.+ */+ lzma_vli number;++ /**+ * \brief Number of Blocks in the Stream+ *+ * If this is zero, the block structure below has+ * undefined values.+ */+ lzma_vli block_count;++ /**+ * \brief Compressed start offset of this Stream+ *+ * The offset is relative to the beginning of the lzma_index+ * (i.e. usually the beginning of the .xz file).+ */+ lzma_vli compressed_offset;++ /**+ * \brief Uncompressed start offset of this Stream+ *+ * The offset is relative to the beginning of the lzma_index+ * (i.e. usually the beginning of the .xz file).+ */+ lzma_vli uncompressed_offset;++ /**+ * \brief Compressed size of this Stream+ *+ * This includes all headers except the possible+ * Stream Padding after this Stream.+ */+ lzma_vli compressed_size;++ /**+ * \brief Uncompressed size of this Stream+ */+ lzma_vli uncompressed_size;++ /**+ * \brief Size of Stream Padding after this Stream+ *+ * If it hasn't been set with lzma_index_stream_padding(),+ * this defaults to zero. Stream Padding is always+ * a multiple of four bytes.+ */+ lzma_vli padding;+++ /** \private Reserved member. */+ lzma_vli reserved_vli1;++ /** \private Reserved member. */+ lzma_vli reserved_vli2;++ /** \private Reserved member. */+ lzma_vli reserved_vli3;++ /** \private Reserved member. */+ lzma_vli reserved_vli4;+ } stream;++ struct {+ /**+ * \brief Block number in the file+ *+ * The first Block is 1.+ */+ lzma_vli number_in_file;++ /**+ * \brief Compressed start offset of this Block+ *+ * This offset is relative to the beginning of the+ * lzma_index (i.e. usually the beginning of the .xz file).+ * Normally this is where you should seek in the .xz file+ * to start decompressing this Block.+ */+ lzma_vli compressed_file_offset;++ /**+ * \brief Uncompressed start offset of this Block+ *+ * This offset is relative to the beginning of the lzma_index+ * (i.e. usually the beginning of the .xz file).+ *+ * When doing random-access reading, it is possible that+ * the target offset is not exactly at Block boundary. One+ * will need to compare the target offset against+ * uncompressed_file_offset or uncompressed_stream_offset,+ * and possibly decode and throw away some amount of data+ * before reaching the target offset.+ */+ lzma_vli uncompressed_file_offset;++ /**+ * \brief Block number in this Stream+ *+ * The first Block is 1.+ */+ lzma_vli number_in_stream;++ /**+ * \brief Compressed start offset of this Block+ *+ * This offset is relative to the beginning of the Stream+ * containing this Block.+ */+ lzma_vli compressed_stream_offset;++ /**+ * \brief Uncompressed start offset of this Block+ *+ * This offset is relative to the beginning of the Stream+ * containing this Block.+ */+ lzma_vli uncompressed_stream_offset;++ /**+ * \brief Uncompressed size of this Block+ *+ * You should pass this to the Block decoder if you will+ * decode this Block. It will allow the Block decoder to+ * validate the uncompressed size.+ */+ lzma_vli uncompressed_size;++ /**+ * \brief Unpadded size of this Block+ *+ * You should pass this to the Block decoder if you will+ * decode this Block. It will allow the Block decoder to+ * validate the unpadded size.+ */+ lzma_vli unpadded_size;++ /**+ * \brief Total compressed size+ *+ * This includes all headers and padding in this Block.+ * This is useful if you need to know how many bytes+ * the Block decoder will actually read.+ */+ lzma_vli total_size;++ /** \private Reserved member. */+ lzma_vli reserved_vli1;++ /** \private Reserved member. */+ lzma_vli reserved_vli2;++ /** \private Reserved member. */+ lzma_vli reserved_vli3;++ /** \private Reserved member. */+ lzma_vli reserved_vli4;++ /** \private Reserved member. */+ const void *reserved_ptr1;++ /** \private Reserved member. */+ const void *reserved_ptr2;++ /** \private Reserved member. */+ const void *reserved_ptr3;++ /** \private Reserved member. */+ const void *reserved_ptr4;+ } block;++ /**+ * \private Internal data+ *+ * Internal data which is used to store the state of the iterator.+ * The exact format may vary between liblzma versions, so don't+ * touch these in any way.+ */+ union {+ /** \private Internal member. */+ const void *p;++ /** \private Internal member. */+ size_t s;++ /** \private Internal member. */+ lzma_vli v;+ } internal[6];+} lzma_index_iter;+++/**+ * \brief Operation mode for lzma_index_iter_next()+ */+typedef enum {+ LZMA_INDEX_ITER_ANY = 0,+ /**<+ * \brief Get the next Block or Stream+ *+ * Go to the next Block if the current Stream has at least+ * one Block left. Otherwise go to the next Stream even if+ * it has no Blocks. If the Stream has no Blocks+ * (lzma_index_iter.stream.block_count == 0),+ * lzma_index_iter.block will have undefined values.+ */++ LZMA_INDEX_ITER_STREAM = 1,+ /**<+ * \brief Get the next Stream+ *+ * Go to the next Stream even if the current Stream has+ * unread Blocks left. If the next Stream has at least one+ * Block, the iterator will point to the first Block.+ * If there are no Blocks, lzma_index_iter.block will have+ * undefined values.+ */++ LZMA_INDEX_ITER_BLOCK = 2,+ /**<+ * \brief Get the next Block+ *+ * Go to the next Block if the current Stream has at least+ * one Block left. If the current Stream has no Blocks left,+ * the next Stream with at least one Block is located and+ * the iterator will be made to point to the first Block of+ * that Stream.+ */++ LZMA_INDEX_ITER_NONEMPTY_BLOCK = 3+ /**<+ * \brief Get the next non-empty Block+ *+ * This is like LZMA_INDEX_ITER_BLOCK except that it will+ * skip Blocks whose Uncompressed Size is zero.+ */++} lzma_index_iter_mode;+++/**+ * \brief Mask for return value from lzma_index_checks() for check none+ *+ * \note This and the other CHECK_MASK macros were added in 5.5.1alpha.+ */+#define LZMA_INDEX_CHECK_MASK_NONE (UINT32_C(1) << LZMA_CHECK_NONE)++/**+ * \brief Mask for return value from lzma_index_checks() for check CRC32+ */+#define LZMA_INDEX_CHECK_MASK_CRC32 (UINT32_C(1) << LZMA_CHECK_CRC32)++/**+ * \brief Mask for return value from lzma_index_checks() for check CRC64+ */+#define LZMA_INDEX_CHECK_MASK_CRC64 (UINT32_C(1) << LZMA_CHECK_CRC64)++/**+ * \brief Mask for return value from lzma_index_checks() for check SHA256+ */+#define LZMA_INDEX_CHECK_MASK_SHA256 (UINT32_C(1) << LZMA_CHECK_SHA256)++/**+ * \brief Calculate memory usage of lzma_index+ *+ * On disk, the size of the Index field depends on both the number of Records+ * stored and the size of the Records (due to variable-length integer+ * encoding). When the Index is kept in lzma_index structure, the memory usage+ * depends only on the number of Records/Blocks stored in the Index(es), and+ * in case of concatenated lzma_indexes, the number of Streams. The size in+ * RAM is almost always significantly bigger than in the encoded form on disk.+ *+ * This function calculates an approximate amount of memory needed to hold+ * the given number of Streams and Blocks in lzma_index structure. This+ * value may vary between CPU architectures and also between liblzma versions+ * if the internal implementation is modified.+ *+ * \param streams Number of Streams+ * \param blocks Number of Blocks+ *+ * \return Approximate memory in bytes needed in a lzma_index structure.+ */+extern LZMA_API(uint64_t) lzma_index_memusage(+ lzma_vli streams, lzma_vli blocks) lzma_nothrow;+++/**+ * \brief Calculate the memory usage of an existing lzma_index+ *+ * This is a shorthand for lzma_index_memusage(lzma_index_stream_count(i),+ * lzma_index_block_count(i)).+ *+ * \param i Pointer to lzma_index structure+ *+ * \return Approximate memory in bytes used by the lzma_index structure.+ */+extern LZMA_API(uint64_t) lzma_index_memused(const lzma_index *i)+ lzma_nothrow;+++/**+ * \brief Allocate and initialize a new lzma_index structure+ *+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ *+ * \return On success, a pointer to an empty initialized lzma_index is+ * returned. If allocation fails, NULL is returned.+ */+extern LZMA_API(lzma_index *) lzma_index_init(const lzma_allocator *allocator)+ lzma_nothrow;+++/**+ * \brief Deallocate lzma_index+ *+ * If i is NULL, this does nothing.+ *+ * \param i Pointer to lzma_index structure to deallocate+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ */+extern LZMA_API(void) lzma_index_end(+ lzma_index *i, const lzma_allocator *allocator) lzma_nothrow;+++/**+ * \brief Add a new Block to lzma_index+ *+ * \param i Pointer to a lzma_index structure+ * \param allocator lzma_allocator for custom allocator+ * functions. Set to NULL to use malloc()+ * and free().+ * \param unpadded_size Unpadded Size of a Block. This can be+ * calculated with lzma_block_unpadded_size()+ * after encoding or decoding the Block.+ * \param uncompressed_size Uncompressed Size of a Block. This can be+ * taken directly from lzma_block structure+ * after encoding or decoding the Block.+ *+ * Appending a new Block does not invalidate iterators. For example,+ * if an iterator was pointing to the end of the lzma_index, after+ * lzma_index_append() it is possible to read the next Block with+ * an existing iterator.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_MEM_ERROR+ * - LZMA_DATA_ERROR: Compressed or uncompressed size of the+ * Stream or size of the Index field would grow too big.+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_index_append(+ lzma_index *i, const lzma_allocator *allocator,+ lzma_vli unpadded_size, lzma_vli uncompressed_size)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Set the Stream Flags+ *+ * Set the Stream Flags of the last (and typically the only) Stream+ * in lzma_index. This can be useful when reading information from the+ * lzma_index, because to decode Blocks, knowing the integrity check type+ * is needed.+ *+ * \param i Pointer to lzma_index structure+ * \param stream_flags Pointer to lzma_stream_flags structure. This+ * is copied into the internal preallocated+ * structure, so the caller doesn't need to keep+ * the flags' data available after calling this+ * function.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_OPTIONS_ERROR: Unsupported stream_flags->version.+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_index_stream_flags(+ lzma_index *i, const lzma_stream_flags *stream_flags)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Get the types of integrity Checks+ *+ * If lzma_index_stream_flags() is used to set the Stream Flags for+ * every Stream, lzma_index_checks() can be used to get a bitmask to+ * indicate which Check types have been used. It can be useful e.g. if+ * showing the Check types to the user.+ *+ * The bitmask is 1 << check_id, e.g. CRC32 is 1 << 1 and SHA-256 is 1 << 10.+ * These masks are defined for convenience as LZMA_INDEX_CHECK_MASK_XXX+ *+ * \param i Pointer to lzma_index structure+ *+ * \return Bitmask indicating which Check types are used in the lzma_index+ */+extern LZMA_API(uint32_t) lzma_index_checks(const lzma_index *i)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Set the amount of Stream Padding+ *+ * Set the amount of Stream Padding of the last (and typically the only)+ * Stream in the lzma_index. This is needed when planning to do random-access+ * reading within multiple concatenated Streams.+ *+ * By default, the amount of Stream Padding is assumed to be zero bytes.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_DATA_ERROR: The file size would grow too big.+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_index_stream_padding(+ lzma_index *i, lzma_vli stream_padding)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Get the number of Streams+ *+ * \param i Pointer to lzma_index structure+ *+ * \return Number of Streams in the lzma_index+ */+extern LZMA_API(lzma_vli) lzma_index_stream_count(const lzma_index *i)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Get the number of Blocks+ *+ * This returns the total number of Blocks in lzma_index. To get number+ * of Blocks in individual Streams, use lzma_index_iter.+ *+ * \param i Pointer to lzma_index structure+ *+ * \return Number of blocks in the lzma_index+ */+extern LZMA_API(lzma_vli) lzma_index_block_count(const lzma_index *i)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Get the size of the Index field as bytes+ *+ * This is needed to verify the Backward Size field in the Stream Footer.+ *+ * \param i Pointer to lzma_index structure+ *+ * \return Size in bytes of the Index+ */+extern LZMA_API(lzma_vli) lzma_index_size(const lzma_index *i)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Get the total size of the Stream+ *+ * If multiple lzma_indexes have been combined, this works as if the Blocks+ * were in a single Stream. This is useful if you are going to combine+ * Blocks from multiple Streams into a single new Stream.+ *+ * \param i Pointer to lzma_index structure+ *+ * \return Size in bytes of the Stream (if all Blocks are combined+ * into one Stream).+ */+extern LZMA_API(lzma_vli) lzma_index_stream_size(const lzma_index *i)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Get the total size of the Blocks+ *+ * This doesn't include the Stream Header, Stream Footer, Stream Padding,+ * or Index fields.+ *+ * \param i Pointer to lzma_index structure+ *+ * \return Size in bytes of all Blocks in the Stream(s)+ */+extern LZMA_API(lzma_vli) lzma_index_total_size(const lzma_index *i)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Get the total size of the file+ *+ * When no lzma_indexes have been combined with lzma_index_cat() and there is+ * no Stream Padding, this function is identical to lzma_index_stream_size().+ * If multiple lzma_indexes have been combined, this includes also the headers+ * of each separate Stream and the possible Stream Padding fields.+ *+ * \param i Pointer to lzma_index structure+ *+ * \return Total size of the .xz file in bytes+ */+extern LZMA_API(lzma_vli) lzma_index_file_size(const lzma_index *i)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Get the uncompressed size of the file+ *+ * \param i Pointer to lzma_index structure+ *+ * \return Size in bytes of the uncompressed data in the file+ */+extern LZMA_API(lzma_vli) lzma_index_uncompressed_size(const lzma_index *i)+ lzma_nothrow lzma_attr_pure;+++/**+ * \brief Initialize an iterator+ *+ * This function associates the iterator with the given lzma_index, and calls+ * lzma_index_iter_rewind() on the iterator.+ *+ * This function doesn't allocate any memory, thus there is no+ * lzma_index_iter_end(). The iterator is valid as long as the+ * associated lzma_index is valid, that is, until lzma_index_end() or+ * using it as source in lzma_index_cat(). Specifically, lzma_index doesn't+ * become invalid if new Blocks are added to it with lzma_index_append() or+ * if it is used as the destination in lzma_index_cat().+ *+ * It is safe to make copies of an initialized lzma_index_iter, for example,+ * to easily restart reading at some particular position.+ *+ * \param iter Pointer to a lzma_index_iter structure+ * \param i lzma_index to which the iterator will be associated+ */+extern LZMA_API(void) lzma_index_iter_init(+ lzma_index_iter *iter, const lzma_index *i) lzma_nothrow;+++/**+ * \brief Rewind the iterator+ *+ * Rewind the iterator so that next call to lzma_index_iter_next() will+ * return the first Block or Stream.+ *+ * \param iter Pointer to a lzma_index_iter structure+ */+extern LZMA_API(void) lzma_index_iter_rewind(lzma_index_iter *iter)+ lzma_nothrow;+++/**+ * \brief Get the next Block or Stream+ *+ * \param iter Iterator initialized with lzma_index_iter_init()+ * \param mode Specify what kind of information the caller wants+ * to get. See lzma_index_iter_mode for details.+ *+ * \return lzma_bool:+ * - true if no Block or Stream matching the mode is found.+ * *iter is not updated (failure).+ * - false if the next Block or Stream matching the mode was+ * found. *iter is updated (success).+ */+extern LZMA_API(lzma_bool) lzma_index_iter_next(+ lzma_index_iter *iter, lzma_index_iter_mode mode)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Locate a Block+ *+ * If it is possible to seek in the .xz file, it is possible to parse+ * the Index field(s) and use lzma_index_iter_locate() to do random-access+ * reading with granularity of Block size.+ *+ * If the target is smaller than the uncompressed size of the Stream (can be+ * checked with lzma_index_uncompressed_size()):+ * - Information about the Stream and Block containing the requested+ * uncompressed offset is stored into *iter.+ * - Internal state of the iterator is adjusted so that+ * lzma_index_iter_next() can be used to read subsequent Blocks or Streams.+ *+ * If the target is greater than the uncompressed size of the Stream, *iter+ * is not modified.+ *+ * \param iter Iterator that was earlier initialized with+ * lzma_index_iter_init().+ * \param target Uncompressed target offset which the caller would+ * like to locate from the Stream+ *+ * \return lzma_bool:+ * - true if the target is greater than or equal to the+ * uncompressed size of the Stream (failure)+ * - false if the target is smaller than the uncompressed size+ * of the Stream (success)+ */+extern LZMA_API(lzma_bool) lzma_index_iter_locate(+ lzma_index_iter *iter, lzma_vli target) lzma_nothrow;+++/**+ * \brief Concatenate lzma_indexes+ *+ * Concatenating lzma_indexes is useful when doing random-access reading in+ * multi-Stream .xz file, or when combining multiple Streams into single+ * Stream.+ *+ * \param[out] dest lzma_index after which src is appended+ * \param src lzma_index to be appended after dest. If this+ * function succeeds, the memory allocated for src+ * is freed or moved to be part of dest, and all+ * iterators pointing to src will become invalid.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: lzma_indexes were concatenated successfully.+ * src is now a dangling pointer.+ * - LZMA_DATA_ERROR: *dest would grow too big.+ * - LZMA_MEM_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_index_cat(lzma_index *dest, lzma_index *src,+ const lzma_allocator *allocator)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Duplicate lzma_index+ *+ * \param i Pointer to lzma_index structure to be duplicated+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ *+ * \return A copy of the lzma_index, or NULL if memory allocation failed.+ */+extern LZMA_API(lzma_index *) lzma_index_dup(+ const lzma_index *i, const lzma_allocator *allocator)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Initialize .xz Index encoder+ *+ * \param strm Pointer to properly prepared lzma_stream+ * \param i Pointer to lzma_index which should be encoded.+ *+ * The valid 'action' values for lzma_code() are LZMA_RUN and LZMA_FINISH.+ * It is enough to use only one of them (you can choose freely).+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Initialization succeeded, continue with lzma_code().+ * - LZMA_MEM_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_index_encoder(+ lzma_stream *strm, const lzma_index *i)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Initialize .xz Index decoder+ *+ * \param strm Pointer to properly prepared lzma_stream+ * \param[out] i The decoded Index will be made available via+ * this pointer. Initially this function will+ * set *i to NULL (the old value is ignored). If+ * decoding succeeds (lzma_code() returns+ * LZMA_STREAM_END), *i will be set to point+ * to a new lzma_index, which the application+ * has to later free with lzma_index_end().+ * \param memlimit How much memory the resulting lzma_index is+ * allowed to require. liblzma 5.2.3 and earlier+ * don't allow 0 here and return LZMA_PROG_ERROR;+ * later versions treat 0 as if 1 had been specified.+ *+ * Valid 'action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.+ * There is no need to use LZMA_FINISH, but it's allowed because it may+ * simplify certain types of applications.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Initialization succeeded, continue with lzma_code().+ * - LZMA_MEM_ERROR+ * - LZMA_PROG_ERROR+ *+ * \note liblzma 5.2.3 and older list also LZMA_MEMLIMIT_ERROR here+ * but that error code has never been possible from this+ * initialization function.+ */+extern LZMA_API(lzma_ret) lzma_index_decoder(+ lzma_stream *strm, lzma_index **i, uint64_t memlimit)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Single-call .xz Index encoder+ *+ * \note This function doesn't take allocator argument since all+ * the internal data is allocated on stack.+ *+ * \param i lzma_index to be encoded+ * \param[out] out Beginning of the output buffer+ * \param[out] out_pos The next byte will be written to out[*out_pos].+ * *out_pos is updated only if encoding succeeds.+ * \param out_size Size of the out buffer; the first byte into+ * which no data is written to is out[out_size].+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Encoding was successful.+ * - LZMA_BUF_ERROR: Output buffer is too small. Use+ * lzma_index_size() to find out how much output+ * space is needed.+ * - LZMA_PROG_ERROR+ *+ */+extern LZMA_API(lzma_ret) lzma_index_buffer_encode(const lzma_index *i,+ uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;+++/**+ * \brief Single-call .xz Index decoder+ *+ * \param[out] i If decoding succeeds, *i will point to a new+ * lzma_index, which the application has to+ * later free with lzma_index_end(). If an error+ * occurs, *i will be NULL. The old value of *i+ * is always ignored and thus doesn't need to be+ * initialized by the caller.+ * \param[out] memlimit Pointer to how much memory the resulting+ * lzma_index is allowed to require. The value+ * pointed by this pointer is modified if and only+ * if LZMA_MEMLIMIT_ERROR is returned.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ * \param in Beginning of the input buffer+ * \param in_pos The next byte will be read from in[*in_pos].+ * *in_pos is updated only if decoding succeeds.+ * \param in_size Size of the input buffer; the first byte that+ * won't be read is in[in_size].+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Decoding was successful.+ * - LZMA_MEM_ERROR+ * - LZMA_MEMLIMIT_ERROR: Memory usage limit was reached.+ * The minimum required memlimit value was stored to *memlimit.+ * - LZMA_DATA_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_index_buffer_decode(lzma_index **i,+ uint64_t *memlimit, const lzma_allocator *allocator,+ const uint8_t *in, size_t *in_pos, size_t in_size)+ lzma_nothrow;+++/**+ * \brief Initialize a .xz file information decoder+ *+ * This decoder decodes the Stream Header, Stream Footer, Index, and+ * Stream Padding field(s) from the input .xz file and stores the resulting+ * combined index in *dest_index. This information can be used to get the+ * uncompressed file size with lzma_index_uncompressed_size(*dest_index) or,+ * for example, to implement random access reading by locating the Blocks+ * in the Streams.+ *+ * To get the required information from the .xz file, lzma_code() may ask+ * the application to seek in the input file by returning LZMA_SEEK_NEEDED+ * and having the target file position specified in lzma_stream.seek_pos.+ * The number of seeks required depends on the input file and how big buffers+ * the application provides. When possible, the decoder will seek backward+ * and forward in the given buffer to avoid useless seek requests. Thus, if+ * the application provides the whole file at once, no external seeking will+ * be required (that is, lzma_code() won't return LZMA_SEEK_NEEDED).+ *+ * The value in lzma_stream.total_in can be used to estimate how much data+ * liblzma had to read to get the file information. However, due to seeking+ * and the way total_in is updated, the value of total_in will be somewhat+ * inaccurate (a little too big). Thus, total_in is a good estimate but don't+ * expect to see the same exact value for the same file if you change the+ * input buffer size or switch to a different liblzma version.+ *+ * Valid 'action' arguments to lzma_code() are LZMA_RUN and LZMA_FINISH.+ * You only need to use LZMA_RUN; LZMA_FINISH is only supported because it+ * might be convenient for some applications. If you use LZMA_FINISH and if+ * lzma_code() asks the application to seek, remember to reset 'action' back+ * to LZMA_RUN unless you hit the end of the file again.+ *+ * Possible return values from lzma_code():+ * - LZMA_OK: All OK so far, more input needed+ * - LZMA_SEEK_NEEDED: Provide more input starting from the absolute+ * file position strm->seek_pos+ * - LZMA_STREAM_END: Decoding was successful, *dest_index has been set+ * - LZMA_FORMAT_ERROR: The input file is not in the .xz format (the+ * expected magic bytes were not found from the beginning of the file)+ * - LZMA_OPTIONS_ERROR: File looks valid but contains headers that aren't+ * supported by this version of liblzma+ * - LZMA_DATA_ERROR: File is corrupt+ * - LZMA_BUF_ERROR+ * - LZMA_MEM_ERROR+ * - LZMA_MEMLIMIT_ERROR+ * - LZMA_PROG_ERROR+ *+ * \param strm Pointer to a properly prepared lzma_stream+ * \param[out] dest_index Pointer to a pointer where the decoder will put+ * the decoded lzma_index. The old value+ * of *dest_index is ignored (not freed).+ * \param memlimit How much memory the resulting lzma_index is+ * allowed to require. Use UINT64_MAX to+ * effectively disable the limiter.+ * \param file_size Size of the input .xz file+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_MEM_ERROR+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_file_info_decoder(+ lzma_stream *strm, lzma_index **dest_index,+ uint64_t memlimit, uint64_t file_size)+ lzma_nothrow;
+ cbits/liblzma/api/lzma/index_hash.h view
@@ -0,0 +1,123 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/index_hash.h+ * \brief Validate Index by using a hash function+ * \note Never include this file directly. Use <lzma.h> instead.+ *+ * Hashing makes it possible to use constant amount of memory to validate+ * Index of arbitrary size.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif++/**+ * \brief Opaque data type to hold the Index hash+ */+typedef struct lzma_index_hash_s lzma_index_hash;+++/**+ * \brief Allocate and initialize a new lzma_index_hash structure+ *+ * If index_hash is NULL, this function allocates and initializes a new+ * lzma_index_hash structure and returns a pointer to it. If allocation+ * fails, NULL is returned.+ *+ * If index_hash is non-NULL, this function reinitializes the lzma_index_hash+ * structure and returns the same pointer. In this case, return value cannot+ * be NULL or a different pointer than the index_hash that was given as+ * an argument.+ *+ * \param index_hash Pointer to a lzma_index_hash structure or NULL.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ *+ * \return Initialized lzma_index_hash structure on success or+ * NULL on failure.+ */+extern LZMA_API(lzma_index_hash *) lzma_index_hash_init(+ lzma_index_hash *index_hash, const lzma_allocator *allocator)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Deallocate lzma_index_hash structure+ *+ * \param index_hash Pointer to a lzma_index_hash structure to free.+ * \param allocator lzma_allocator for custom allocator functions.+ * Set to NULL to use malloc() and free().+ */+extern LZMA_API(void) lzma_index_hash_end(+ lzma_index_hash *index_hash, const lzma_allocator *allocator)+ lzma_nothrow;+++/**+ * \brief Add a new Record to an Index hash+ *+ * \param index_hash Pointer to a lzma_index_hash structure+ * \param unpadded_size Unpadded Size of a Block+ * \param uncompressed_size Uncompressed Size of a Block+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK+ * - LZMA_DATA_ERROR: Compressed or uncompressed size of the+ * Stream or size of the Index field would grow too big.+ * - LZMA_PROG_ERROR: Invalid arguments or this function is being+ * used when lzma_index_hash_decode() has already been used.+ */+extern LZMA_API(lzma_ret) lzma_index_hash_append(lzma_index_hash *index_hash,+ lzma_vli unpadded_size, lzma_vli uncompressed_size)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Decode and validate the Index field+ *+ * After telling the sizes of all Blocks with lzma_index_hash_append(),+ * the actual Index field is decoded with this function. Specifically,+ * once decoding of the Index field has been started, no more Records+ * can be added using lzma_index_hash_append().+ *+ * This function doesn't use lzma_stream structure to pass the input data.+ * Instead, the input buffer is specified using three arguments. This is+ * because it matches better the internal APIs of liblzma.+ *+ * \param index_hash Pointer to a lzma_index_hash structure+ * \param in Pointer to the beginning of the input buffer+ * \param[out] in_pos in[*in_pos] is the next byte to process+ * \param in_size in[in_size] is the first byte not to process+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: So far good, but more input is needed.+ * - LZMA_STREAM_END: Index decoded successfully and it matches+ * the Records given with lzma_index_hash_append().+ * - LZMA_DATA_ERROR: Index is corrupt or doesn't match the+ * information given with lzma_index_hash_append().+ * - LZMA_BUF_ERROR: Cannot progress because *in_pos >= in_size.+ * - LZMA_PROG_ERROR+ */+extern LZMA_API(lzma_ret) lzma_index_hash_decode(lzma_index_hash *index_hash,+ const uint8_t *in, size_t *in_pos, size_t in_size)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Get the size of the Index field as bytes+ *+ * This is needed to verify the Backward Size field in the Stream Footer.+ *+ * \param index_hash Pointer to a lzma_index_hash structure+ *+ * \return Size of the Index field in bytes.+ */+extern LZMA_API(lzma_vli) lzma_index_hash_size(+ const lzma_index_hash *index_hash)+ lzma_nothrow lzma_attr_pure;
+ cbits/liblzma/api/lzma/lzma12.h view
@@ -0,0 +1,568 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/lzma12.h+ * \brief LZMA1 and LZMA2 filters+ * \note Never include this file directly. Use <lzma.h> instead.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif+++/**+ * \brief LZMA1 Filter ID (for raw encoder/decoder only, not in .xz)+ *+ * LZMA1 is the very same thing as what was called just LZMA in LZMA Utils,+ * 7-Zip, and LZMA SDK. It's called LZMA1 here to prevent developers from+ * accidentally using LZMA when they actually want LZMA2.+ */+#define LZMA_FILTER_LZMA1 LZMA_VLI_C(0x4000000000000001)++/**+ * \brief LZMA1 Filter ID with extended options (for raw encoder/decoder)+ *+ * This is like LZMA_FILTER_LZMA1 but with this ID a few extra options+ * are supported in the lzma_options_lzma structure:+ *+ * - A flag to tell the encoder if the end of payload marker (EOPM) alias+ * end of stream (EOS) marker must be written at the end of the stream.+ * In contrast, LZMA_FILTER_LZMA1 always writes the end marker.+ *+ * - Decoder needs to be told the uncompressed size of the stream+ * or that it is unknown (using the special value UINT64_MAX).+ * If the size is known, a flag can be set to allow the presence of+ * the end marker anyway. In contrast, LZMA_FILTER_LZMA1 always+ * behaves as if the uncompressed size was unknown.+ *+ * This allows handling file formats where LZMA1 streams are used but where+ * the end marker isn't allowed or where it might not (always) be present.+ * This extended LZMA1 functionality is provided as a Filter ID for raw+ * encoder and decoder instead of adding new encoder and decoder initialization+ * functions because this way it is possible to also use extra filters,+ * for example, LZMA_FILTER_X86 in a filter chain with LZMA_FILTER_LZMA1EXT,+ * which might be needed to handle some file formats.+ */+#define LZMA_FILTER_LZMA1EXT LZMA_VLI_C(0x4000000000000002)++/**+ * \brief LZMA2 Filter ID+ *+ * Usually you want this instead of LZMA1. Compared to LZMA1, LZMA2 adds+ * support for LZMA_SYNC_FLUSH, uncompressed chunks (smaller expansion+ * when trying to compress incompressible data), possibility to change+ * lc/lp/pb in the middle of encoding, and some other internal improvements.+ */+#define LZMA_FILTER_LZMA2 LZMA_VLI_C(0x21)+++/**+ * \brief Match finders+ *+ * Match finder has major effect on both speed and compression ratio.+ * Usually hash chains are faster than binary trees.+ *+ * If you will use LZMA_SYNC_FLUSH often, the hash chains may be a better+ * choice, because binary trees get much higher compression ratio penalty+ * with LZMA_SYNC_FLUSH.+ *+ * The memory usage formulas are only rough estimates, which are closest to+ * reality when dict_size is a power of two. The formulas are more complex+ * in reality, and can also change a little between liblzma versions. Use+ * lzma_raw_encoder_memusage() to get more accurate estimate of memory usage.+ */+typedef enum {+ LZMA_MF_HC3 = 0x03,+ /**<+ * \brief Hash Chain with 2- and 3-byte hashing+ *+ * Minimum nice_len: 3+ *+ * Memory usage:+ * - dict_size <= 16 MiB: dict_size * 7.5+ * - dict_size > 16 MiB: dict_size * 5.5 + 64 MiB+ */++ LZMA_MF_HC4 = 0x04,+ /**<+ * \brief Hash Chain with 2-, 3-, and 4-byte hashing+ *+ * Minimum nice_len: 4+ *+ * Memory usage:+ * - dict_size <= 32 MiB: dict_size * 7.5+ * - dict_size > 32 MiB: dict_size * 6.5+ */++ LZMA_MF_BT2 = 0x12,+ /**<+ * \brief Binary Tree with 2-byte hashing+ *+ * Minimum nice_len: 2+ *+ * Memory usage: dict_size * 9.5+ */++ LZMA_MF_BT3 = 0x13,+ /**<+ * \brief Binary Tree with 2- and 3-byte hashing+ *+ * Minimum nice_len: 3+ *+ * Memory usage:+ * - dict_size <= 16 MiB: dict_size * 11.5+ * - dict_size > 16 MiB: dict_size * 9.5 + 64 MiB+ */++ LZMA_MF_BT4 = 0x14+ /**<+ * \brief Binary Tree with 2-, 3-, and 4-byte hashing+ *+ * Minimum nice_len: 4+ *+ * Memory usage:+ * - dict_size <= 32 MiB: dict_size * 11.5+ * - dict_size > 32 MiB: dict_size * 10.5+ */+} lzma_match_finder;+++/**+ * \brief Test if given match finder is supported+ *+ * It is safe to call this with a value that isn't listed in+ * lzma_match_finder enumeration; the return value will be false.+ *+ * There is no way to list which match finders are available in this+ * particular liblzma version and build. It would be useless, because+ * a new match finder, which the application developer wasn't aware,+ * could require giving additional options to the encoder that the older+ * match finders don't need.+ *+ * \param match_finder Match finder ID+ *+ * \return lzma_bool:+ * - true if the match finder is supported by this liblzma build.+ * - false otherwise.+ */+extern LZMA_API(lzma_bool) lzma_mf_is_supported(lzma_match_finder match_finder)+ lzma_nothrow lzma_attr_const;+++/**+ * \brief Compression modes+ *+ * This selects the function used to analyze the data produced by the match+ * finder.+ */+typedef enum {+ LZMA_MODE_FAST = 1,+ /**<+ * \brief Fast compression+ *+ * Fast mode is usually at its best when combined with+ * a hash chain match finder.+ */++ LZMA_MODE_NORMAL = 2+ /**<+ * \brief Normal compression+ *+ * This is usually notably slower than fast mode. Use this+ * together with binary tree match finders to expose the+ * full potential of the LZMA1 or LZMA2 encoder.+ */+} lzma_mode;+++/**+ * \brief Test if given compression mode is supported+ *+ * It is safe to call this with a value that isn't listed in lzma_mode+ * enumeration; the return value will be false.+ *+ * There is no way to list which modes are available in this particular+ * liblzma version and build. It would be useless, because a new compression+ * mode, which the application developer wasn't aware, could require giving+ * additional options to the encoder that the older modes don't need.+ *+ * \param mode Mode ID.+ *+ * \return lzma_bool:+ * - true if the compression mode is supported by this liblzma+ * build.+ * - false otherwise.+ */+extern LZMA_API(lzma_bool) lzma_mode_is_supported(lzma_mode mode)+ lzma_nothrow lzma_attr_const;+++/**+ * \brief Options specific to the LZMA1 and LZMA2 filters+ *+ * Since LZMA1 and LZMA2 share most of the code, it's simplest to share+ * the options structure too. For encoding, all but the reserved variables+ * need to be initialized unless specifically mentioned otherwise.+ * lzma_lzma_preset() can be used to get a good starting point.+ *+ * For raw decoding, both LZMA1 and LZMA2 need dict_size, preset_dict, and+ * preset_dict_size (if preset_dict != NULL). LZMA1 needs also lc, lp, and pb.+ */+typedef struct {+ /**+ * \brief Dictionary size in bytes+ *+ * Dictionary size indicates how many bytes of the recently processed+ * uncompressed data is kept in memory. One method to reduce size of+ * the uncompressed data is to store distance-length pairs, which+ * indicate what data to repeat from the dictionary buffer. Thus,+ * the bigger the dictionary, the better the compression ratio+ * usually is.+ *+ * Maximum size of the dictionary depends on multiple things:+ * - Memory usage limit+ * - Available address space (not a problem on 64-bit systems)+ * - Selected match finder (encoder only)+ *+ * Currently the maximum dictionary size for encoding is 1.5 GiB+ * (i.e. (UINT32_C(1) << 30) + (UINT32_C(1) << 29)) even on 64-bit+ * systems for certain match finder implementation reasons. In the+ * future, there may be match finders that support bigger+ * dictionaries.+ *+ * Decoder already supports dictionaries up to 4 GiB - 1 B (i.e.+ * UINT32_MAX), so increasing the maximum dictionary size of the+ * encoder won't cause problems for old decoders.+ *+ * Because extremely small dictionaries sizes would have unneeded+ * overhead in the decoder, the minimum dictionary size is 4096 bytes.+ *+ * \note When decoding, too big dictionary does no other harm+ * than wasting memory.+ */+ uint32_t dict_size;+# define LZMA_DICT_SIZE_MIN UINT32_C(4096)+# define LZMA_DICT_SIZE_DEFAULT (UINT32_C(1) << 23)++ /**+ * \brief Pointer to an initial dictionary+ *+ * It is possible to initialize the LZ77 history window using+ * a preset dictionary. It is useful when compressing many+ * similar, relatively small chunks of data independently from+ * each other. The preset dictionary should contain typical+ * strings that occur in the files being compressed. The most+ * probable strings should be near the end of the preset dictionary.+ *+ * This feature should be used only in special situations. For+ * now, it works correctly only with raw encoding and decoding.+ * Currently none of the container formats supported by+ * liblzma allow preset dictionary when decoding, thus if+ * you create a .xz or .lzma file with preset dictionary, it+ * cannot be decoded with the regular decoder functions. In the+ * future, the .xz format will likely get support for preset+ * dictionary though.+ */+ const uint8_t *preset_dict;++ /**+ * \brief Size of the preset dictionary+ *+ * Specifies the size of the preset dictionary. If the size is+ * bigger than dict_size, only the last dict_size bytes are+ * processed.+ *+ * This variable is read only when preset_dict is not NULL.+ * If preset_dict is not NULL but preset_dict_size is zero,+ * no preset dictionary is used (identical to only setting+ * preset_dict to NULL).+ */+ uint32_t preset_dict_size;++ /**+ * \brief Number of literal context bits+ *+ * How many of the highest bits of the previous uncompressed+ * eight-bit byte (also known as 'literal') are taken into+ * account when predicting the bits of the next literal.+ *+ * E.g. in typical English text, an upper-case letter is+ * often followed by a lower-case letter, and a lower-case+ * letter is usually followed by another lower-case letter.+ * In the US-ASCII character set, the highest three bits are 010+ * for upper-case letters and 011 for lower-case letters.+ * When lc is at least 3, the literal coding can take advantage of+ * this property in the uncompressed data.+ *+ * There is a limit that applies to literal context bits and literal+ * position bits together: lc + lp <= 4. Without this limit the+ * decoding could become very slow, which could have security related+ * results in some cases like email servers doing virus scanning.+ * This limit also simplifies the internal implementation in liblzma.+ *+ * There may be LZMA1 streams that have lc + lp > 4 (maximum possible+ * lc would be 8). It is not possible to decode such streams with+ * liblzma.+ */+ uint32_t lc;+# define LZMA_LCLP_MIN 0+# define LZMA_LCLP_MAX 4+# define LZMA_LC_DEFAULT 3++ /**+ * \brief Number of literal position bits+ *+ * lp affects what kind of alignment in the uncompressed data is+ * assumed when encoding literals. A literal is a single 8-bit byte.+ * See pb below for more information about alignment.+ */+ uint32_t lp;+# define LZMA_LP_DEFAULT 0++ /**+ * \brief Number of position bits+ *+ * pb affects what kind of alignment in the uncompressed data is+ * assumed in general. The default means four-byte alignment+ * (2^ pb =2^2=4), which is often a good choice when there's+ * no better guess.+ *+ * When the alignment is known, setting pb accordingly may reduce+ * the file size a little. E.g. with text files having one-byte+ * alignment (US-ASCII, ISO-8859-*, UTF-8), setting pb=0 can+ * improve compression slightly. For UTF-16 text, pb=1 is a good+ * choice. If the alignment is an odd number like 3 bytes, pb=0+ * might be the best choice.+ *+ * Even though the assumed alignment can be adjusted with pb and+ * lp, LZMA1 and LZMA2 still slightly favor 16-byte alignment.+ * It might be worth taking into account when designing file formats+ * that are likely to be often compressed with LZMA1 or LZMA2.+ */+ uint32_t pb;+# define LZMA_PB_MIN 0+# define LZMA_PB_MAX 4+# define LZMA_PB_DEFAULT 2++ /** Compression mode */+ lzma_mode mode;++ /**+ * \brief Nice length of a match+ *+ * This determines how many bytes the encoder compares from the match+ * candidates when looking for the best match. Once a match of at+ * least nice_len bytes long is found, the encoder stops looking for+ * better candidates and encodes the match. (Naturally, if the found+ * match is actually longer than nice_len, the actual length is+ * encoded; it's not truncated to nice_len.)+ *+ * Bigger values usually increase the compression ratio and+ * compression time. For most files, 32 to 128 is a good value,+ * which gives very good compression ratio at good speed.+ *+ * The exact minimum value depends on the match finder. The maximum+ * is 273, which is the maximum length of a match that LZMA1 and+ * LZMA2 can encode.+ */+ uint32_t nice_len;++ /** Match finder ID */+ lzma_match_finder mf;++ /**+ * \brief Maximum search depth in the match finder+ *+ * For every input byte, match finder searches through the hash chain+ * or binary tree in a loop, each iteration going one step deeper in+ * the chain or tree. The searching stops if+ * - a match of at least nice_len bytes long is found;+ * - all match candidates from the hash chain or binary tree have+ * been checked; or+ * - maximum search depth is reached.+ *+ * Maximum search depth is needed to prevent the match finder from+ * wasting too much time in case there are lots of short match+ * candidates. On the other hand, stopping the search before all+ * candidates have been checked can reduce compression ratio.+ *+ * Setting depth to zero tells liblzma to use an automatic default+ * value, that depends on the selected match finder and nice_len.+ * The default is in the range [4, 200] or so (it may vary between+ * liblzma versions).+ *+ * Using a bigger depth value than the default can increase+ * compression ratio in some cases. There is no strict maximum value,+ * but high values (thousands or millions) should be used with care:+ * the encoder could remain fast enough with typical input, but+ * malicious input could cause the match finder to slow down+ * dramatically, possibly creating a denial of service attack.+ */+ uint32_t depth;++ /**+ * \brief For LZMA_FILTER_LZMA1EXT: Extended flags+ *+ * This is used only with LZMA_FILTER_LZMA1EXT.+ *+ * Currently only one flag is supported, LZMA_LZMA1EXT_ALLOW_EOPM:+ *+ * - Encoder: If the flag is set, then end marker is written just+ * like it is with LZMA_FILTER_LZMA1. Without this flag the+ * end marker isn't written and the application has to store+ * the uncompressed size somewhere outside the compressed stream.+ * To decompress streams without the end marker, the application+ * has to set the correct uncompressed size in ext_size_low and+ * ext_size_high.+ *+ * - Decoder: If the uncompressed size in ext_size_low and+ * ext_size_high is set to the special value UINT64_MAX+ * (indicating unknown uncompressed size) then this flag is+ * ignored and the end marker must always be present, that is,+ * the behavior is identical to LZMA_FILTER_LZMA1.+ *+ * Otherwise, if this flag isn't set, then the input stream+ * must not have the end marker; if the end marker is detected+ * then it will result in LZMA_DATA_ERROR. This is useful when+ * it is known that the stream must not have the end marker and+ * strict validation is wanted.+ *+ * If this flag is set, then it is autodetected if the end marker+ * is present after the specified number of uncompressed bytes+ * has been decompressed (ext_size_low and ext_size_high). The+ * end marker isn't allowed in any other position. This behavior+ * is useful when uncompressed size is known but the end marker+ * may or may not be present. This is the case, for example,+ * in .7z files (valid .7z files that have the end marker in+ * LZMA1 streams are rare but they do exist).+ */+ uint32_t ext_flags;+# define LZMA_LZMA1EXT_ALLOW_EOPM UINT32_C(0x01)++ /**+ * \brief For LZMA_FILTER_LZMA1EXT: Uncompressed size (low bits)+ *+ * The 64-bit uncompressed size is needed for decompression with+ * LZMA_FILTER_LZMA1EXT. The size is ignored by the encoder.+ *+ * The special value UINT64_MAX indicates that the uncompressed size+ * is unknown and that the end of payload marker (also known as+ * end of stream marker) must be present to indicate the end of+ * the LZMA1 stream. Any other value indicates the expected+ * uncompressed size of the LZMA1 stream. (If LZMA1 was used together+ * with filters that change the size of the data then the uncompressed+ * size of the LZMA1 stream could be different than the final+ * uncompressed size of the filtered stream.)+ *+ * ext_size_low holds the least significant 32 bits of the+ * uncompressed size. The most significant 32 bits must be set+ * in ext_size_high. The macro lzma_ext_size_set(opt_lzma, u64size)+ * can be used to set these members.+ *+ * The 64-bit uncompressed size is split into two uint32_t variables+ * because there were no reserved uint64_t members and using the+ * same options structure for LZMA_FILTER_LZMA1, LZMA_FILTER_LZMA1EXT,+ * and LZMA_FILTER_LZMA2 was otherwise more convenient than having+ * a new options structure for LZMA_FILTER_LZMA1EXT. (Replacing two+ * uint32_t members with one uint64_t changes the ABI on some systems+ * as the alignment of this struct can increase from 4 bytes to 8.)+ */+ uint32_t ext_size_low;++ /**+ * \brief For LZMA_FILTER_LZMA1EXT: Uncompressed size (high bits)+ *+ * This holds the most significant 32 bits of the uncompressed size.+ */+ uint32_t ext_size_high;++ /*+ * Reserved space to allow possible future extensions without+ * breaking the ABI. You should not touch these, because the names+ * of these variables may change. These are and will never be used+ * with the currently supported options, so it is safe to leave these+ * uninitialized.+ */++ /** \private Reserved member. */+ uint32_t reserved_int4;++ /** \private Reserved member. */+ uint32_t reserved_int5;++ /** \private Reserved member. */+ uint32_t reserved_int6;++ /** \private Reserved member. */+ uint32_t reserved_int7;++ /** \private Reserved member. */+ uint32_t reserved_int8;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum1;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum2;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum3;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum4;++ /** \private Reserved member. */+ void *reserved_ptr1;++ /** \private Reserved member. */+ void *reserved_ptr2;++} lzma_options_lzma;+++/**+ * \brief Macro to set the 64-bit uncompressed size in ext_size_*+ *+ * This might be convenient when decoding using LZMA_FILTER_LZMA1EXT.+ * This isn't used with LZMA_FILTER_LZMA1 or LZMA_FILTER_LZMA2.+ */+#define lzma_set_ext_size(opt_lzma2, u64size) \+do { \+ (opt_lzma2).ext_size_low = (uint32_t)(u64size); \+ (opt_lzma2).ext_size_high = (uint32_t)((uint64_t)(u64size) >> 32); \+} while (0)+++/**+ * \brief Set a compression preset to lzma_options_lzma structure+ *+ * 0 is the fastest and 9 is the slowest. These match the switches -0 .. -9+ * of the xz command line tool. In addition, it is possible to bitwise-or+ * flags to the preset. Currently only LZMA_PRESET_EXTREME is supported.+ * The flags are defined in container.h, because the flags are used also+ * with lzma_easy_encoder().+ *+ * The preset levels are subject to changes between liblzma versions.+ *+ * This function is available only if LZMA1 or LZMA2 encoder has been enabled+ * when building liblzma.+ *+ * If features (like certain match finders) have been disabled at build time,+ * then the function may return success (false) even though the resulting+ * LZMA1/LZMA2 options may not be usable for encoder initialization+ * (LZMA_OPTIONS_ERROR).+ *+ * \param[out] options Pointer to LZMA1 or LZMA2 options to be filled+ * \param preset Preset level bitwse-ORed with preset flags+ *+ * \return lzma_bool:+ * - true if the preset is not supported (failure).+ * - false otherwise (success).+ */+extern LZMA_API(lzma_bool) lzma_lzma_preset(+ lzma_options_lzma *options, uint32_t preset) lzma_nothrow;
+ cbits/liblzma/api/lzma/stream_flags.h view
@@ -0,0 +1,265 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/stream_flags.h+ * \brief .xz Stream Header and Stream Footer encoder and decoder+ * \note Never include this file directly. Use <lzma.h> instead.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif+++/**+ * \brief Size of Stream Header and Stream Footer+ *+ * Stream Header and Stream Footer have the same size and they are not+ * going to change even if a newer version of the .xz file format is+ * developed in future.+ */+#define LZMA_STREAM_HEADER_SIZE 12+++/**+ * \brief Options for encoding/decoding Stream Header and Stream Footer+ */+typedef struct {+ /**+ * \brief Stream Flags format version+ *+ * To prevent API and ABI breakages if new features are needed in+ * Stream Header or Stream Footer, a version number is used to+ * indicate which members in this structure are in use. For now,+ * version must always be zero. With non-zero version, the+ * lzma_stream_header_encode() and lzma_stream_footer_encode()+ * will return LZMA_OPTIONS_ERROR.+ *+ * lzma_stream_header_decode() and lzma_stream_footer_decode()+ * will always set this to the lowest value that supports all the+ * features indicated by the Stream Flags field. The application+ * must check that the version number set by the decoding functions+ * is supported by the application. Otherwise it is possible that+ * the application will decode the Stream incorrectly.+ */+ uint32_t version;++ /**+ * \brief Backward Size+ *+ * Backward Size must be a multiple of four bytes. In this Stream+ * format version, Backward Size is the size of the Index field.+ *+ * Backward Size isn't actually part of the Stream Flags field, but+ * it is convenient to include in this structure anyway. Backward+ * Size is present only in the Stream Footer. There is no need to+ * initialize backward_size when encoding Stream Header.+ *+ * lzma_stream_header_decode() always sets backward_size to+ * LZMA_VLI_UNKNOWN so that it is convenient to use+ * lzma_stream_flags_compare() when both Stream Header and Stream+ * Footer have been decoded.+ */+ lzma_vli backward_size;++ /**+ * \brief Minimum value for lzma_stream_flags.backward_size+ */+# define LZMA_BACKWARD_SIZE_MIN 4++ /**+ * \brief Maximum value for lzma_stream_flags.backward_size+ */+# define LZMA_BACKWARD_SIZE_MAX (LZMA_VLI_C(1) << 34)++ /**+ * \brief Check ID+ *+ * This indicates the type of the integrity check calculated from+ * uncompressed data.+ */+ lzma_check check;++ /*+ * Reserved space to allow possible future extensions without+ * breaking the ABI. You should not touch these, because the+ * names of these variables may change.+ *+ * (We will never be able to use all of these since Stream Flags+ * is just two bytes plus Backward Size of four bytes. But it's+ * nice to have the proper types when they are needed.)+ */++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum1;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum2;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum3;++ /** \private Reserved member. */+ lzma_reserved_enum reserved_enum4;++ /** \private Reserved member. */+ lzma_bool reserved_bool1;++ /** \private Reserved member. */+ lzma_bool reserved_bool2;++ /** \private Reserved member. */+ lzma_bool reserved_bool3;++ /** \private Reserved member. */+ lzma_bool reserved_bool4;++ /** \private Reserved member. */+ lzma_bool reserved_bool5;++ /** \private Reserved member. */+ lzma_bool reserved_bool6;++ /** \private Reserved member. */+ lzma_bool reserved_bool7;++ /** \private Reserved member. */+ lzma_bool reserved_bool8;++ /** \private Reserved member. */+ uint32_t reserved_int1;++ /** \private Reserved member. */+ uint32_t reserved_int2;++} lzma_stream_flags;+++/**+ * \brief Encode Stream Header+ *+ * \param options Stream Header options to be encoded.+ * options->backward_size is ignored and doesn't+ * need to be initialized.+ * \param[out] out Beginning of the output buffer of+ * LZMA_STREAM_HEADER_SIZE bytes.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Encoding was successful.+ * - LZMA_OPTIONS_ERROR: options->version is not supported by+ * this liblzma version.+ * - LZMA_PROG_ERROR: Invalid options.+ */+extern LZMA_API(lzma_ret) lzma_stream_header_encode(+ const lzma_stream_flags *options, uint8_t *out)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Encode Stream Footer+ *+ * \param options Stream Footer options to be encoded.+ * \param[out] out Beginning of the output buffer of+ * LZMA_STREAM_HEADER_SIZE bytes.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Encoding was successful.+ * - LZMA_OPTIONS_ERROR: options->version is not supported by+ * this liblzma version.+ * - LZMA_PROG_ERROR: Invalid options.+ */+extern LZMA_API(lzma_ret) lzma_stream_footer_encode(+ const lzma_stream_flags *options, uint8_t *out)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Decode Stream Header+ *+ * options->backward_size is always set to LZMA_VLI_UNKNOWN. This is to+ * help comparing Stream Flags from Stream Header and Stream Footer with+ * lzma_stream_flags_compare().+ *+ * \note When decoding .xz files that contain multiple Streams, it may+ * make sense to print "file format not recognized" only if+ * decoding of the Stream Header of the \a first Stream gives+ * LZMA_FORMAT_ERROR. If non-first Stream Header gives+ * LZMA_FORMAT_ERROR, the message used for LZMA_DATA_ERROR is+ * probably more appropriate.+ * For example, the Stream decoder in liblzma uses+ * LZMA_DATA_ERROR if LZMA_FORMAT_ERROR is returned by+ * lzma_stream_header_decode() when decoding non-first Stream.+ *+ * \param[out] options Target for the decoded Stream Header options.+ * \param in Beginning of the input buffer of+ * LZMA_STREAM_HEADER_SIZE bytes.+ *+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Decoding was successful.+ * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given+ * buffer cannot be Stream Header.+ * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the header+ * is corrupt.+ * - LZMA_OPTIONS_ERROR: Unsupported options are present+ * in the header.+ */+extern LZMA_API(lzma_ret) lzma_stream_header_decode(+ lzma_stream_flags *options, const uint8_t *in)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Decode Stream Footer+ *+ * \note If Stream Header was already decoded successfully, but+ * decoding Stream Footer returns LZMA_FORMAT_ERROR, the+ * application should probably report some other error message+ * than "file format not recognized". The file likely+ * is corrupt (possibly truncated). The Stream decoder in liblzma+ * uses LZMA_DATA_ERROR in this situation.+ *+ * \param[out] options Target for the decoded Stream Footer options.+ * \param in Beginning of the input buffer of+ * LZMA_STREAM_HEADER_SIZE bytes.+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Decoding was successful.+ * - LZMA_FORMAT_ERROR: Magic bytes don't match, thus the given+ * buffer cannot be Stream Footer.+ * - LZMA_DATA_ERROR: CRC32 doesn't match, thus the Stream Footer+ * is corrupt.+ * - LZMA_OPTIONS_ERROR: Unsupported options are present+ * in Stream Footer.+ */+extern LZMA_API(lzma_ret) lzma_stream_footer_decode(+ lzma_stream_flags *options, const uint8_t *in)+ lzma_nothrow lzma_attr_warn_unused_result;+++/**+ * \brief Compare two lzma_stream_flags structures+ *+ * backward_size values are compared only if both are not+ * LZMA_VLI_UNKNOWN.+ *+ * \param a Pointer to lzma_stream_flags structure+ * \param b Pointer to lzma_stream_flags structure+ *+ * \return Possible lzma_ret values:+ * - LZMA_OK: Both are equal. If either had backward_size set+ * to LZMA_VLI_UNKNOWN, backward_size values were not+ * compared or validated.+ * - LZMA_DATA_ERROR: The structures differ.+ * - LZMA_OPTIONS_ERROR: version in either structure is greater+ * than the maximum supported version (currently zero).+ * - LZMA_PROG_ERROR: Invalid value, e.g. invalid check or+ * backward_size.+ */+extern LZMA_API(lzma_ret) lzma_stream_flags_compare(+ const lzma_stream_flags *a, const lzma_stream_flags *b)+ lzma_nothrow lzma_attr_pure;
+ cbits/liblzma/api/lzma/version.h view
@@ -0,0 +1,134 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/version.h+ * \brief Version number+ * \note Never include this file directly. Use <lzma.h> instead.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif+++/** \brief Major version number of the liblzma release. */+#define LZMA_VERSION_MAJOR 5++/** \brief Minor version number of the liblzma release. */+#define LZMA_VERSION_MINOR 6++/** \brief Patch version number of the liblzma release. */+#define LZMA_VERSION_PATCH 3++/**+ * \brief Version stability marker+ *+ * This will always be one of three values:+ * - LZMA_VERSION_STABILITY_ALPHA+ * - LZMA_VERSION_STABILITY_BETA+ * - LZMA_VERSION_STABILITY_STABLE+ */+#define LZMA_VERSION_STABILITY LZMA_VERSION_STABILITY_STABLE++/** \brief Commit version number of the liblzma release */+#ifndef LZMA_VERSION_COMMIT+# define LZMA_VERSION_COMMIT ""+#endif+++/*+ * Map symbolic stability levels to integers.+ */+#define LZMA_VERSION_STABILITY_ALPHA 0+#define LZMA_VERSION_STABILITY_BETA 1+#define LZMA_VERSION_STABILITY_STABLE 2+++/**+ * \brief Compile-time version number+ *+ * The version number is of format xyyyzzzs where+ * - x = major+ * - yyy = minor+ * - zzz = revision+ * - s indicates stability: 0 = alpha, 1 = beta, 2 = stable+ *+ * The same xyyyzzz triplet is never reused with different stability levels.+ * For example, if 5.1.0alpha has been released, there will never be 5.1.0beta+ * or 5.1.0 stable.+ *+ * \note The version number of liblzma has nothing to with+ * the version number of Igor Pavlov's LZMA SDK.+ */+#define LZMA_VERSION (LZMA_VERSION_MAJOR * UINT32_C(10000000) \+ + LZMA_VERSION_MINOR * UINT32_C(10000) \+ + LZMA_VERSION_PATCH * UINT32_C(10) \+ + LZMA_VERSION_STABILITY)+++/*+ * Macros to construct the compile-time version string+ */+#if LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_ALPHA+# define LZMA_VERSION_STABILITY_STRING "alpha"+#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_BETA+# define LZMA_VERSION_STABILITY_STRING "beta"+#elif LZMA_VERSION_STABILITY == LZMA_VERSION_STABILITY_STABLE+# define LZMA_VERSION_STABILITY_STRING ""+#else+# error Incorrect LZMA_VERSION_STABILITY+#endif++#define LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit) \+ #major "." #minor "." #patch stability commit++#define LZMA_VERSION_STRING_C(major, minor, patch, stability, commit) \+ LZMA_VERSION_STRING_C_(major, minor, patch, stability, commit)+++/**+ * \brief Compile-time version as a string+ *+ * This can be for example "4.999.5alpha", "4.999.8beta", or "5.0.0" (stable+ * versions don't have any "stable" suffix). In future, a snapshot built+ * from source code repository may include an additional suffix, for example+ * "4.999.8beta-21-g1d92". The commit ID won't be available in numeric form+ * in LZMA_VERSION macro.+ */+#define LZMA_VERSION_STRING LZMA_VERSION_STRING_C( \+ LZMA_VERSION_MAJOR, LZMA_VERSION_MINOR, \+ LZMA_VERSION_PATCH, LZMA_VERSION_STABILITY_STRING, \+ LZMA_VERSION_COMMIT)+++/* #ifndef is needed for use with windres (MinGW-w64 or Cygwin). */+#ifndef LZMA_H_INTERNAL_RC++/**+ * \brief Run-time version number as an integer+ *+ * This allows an application to compare if it was built against the same,+ * older, or newer version of liblzma that is currently running.+ *+ * \return The value of LZMA_VERSION macro at the compile time of liblzma+ */+extern LZMA_API(uint32_t) lzma_version_number(void)+ lzma_nothrow lzma_attr_const;+++/**+ * \brief Run-time version as a string+ *+ * This function may be useful to display which version of liblzma an+ * application is currently using.+ *+ * \return Run-time version of liblzma+ */+extern LZMA_API(const char *) lzma_version_string(void)+ lzma_nothrow lzma_attr_const;++#endif
+ cbits/liblzma/api/lzma/vli.h view
@@ -0,0 +1,166 @@+/* SPDX-License-Identifier: 0BSD */++/**+ * \file lzma/vli.h+ * \brief Variable-length integer handling+ * \note Never include this file directly. Use <lzma.h> instead.+ *+ * In the .xz format, most integers are encoded in a variable-length+ * representation, which is sometimes called little endian base-128 encoding.+ * This saves space when smaller values are more likely than bigger values.+ *+ * The encoding scheme encodes seven bits to every byte, using minimum+ * number of bytes required to represent the given value. Encodings that use+ * non-minimum number of bytes are invalid, thus every integer has exactly+ * one encoded representation. The maximum number of bits in a VLI is 63,+ * thus the vli argument must be less than or equal to UINT64_MAX / 2. You+ * should use LZMA_VLI_MAX for clarity.+ */++/*+ * Author: Lasse Collin+ */++#ifndef LZMA_H_INTERNAL+# error Never include this file directly. Use <lzma.h> instead.+#endif+++/**+ * \brief Maximum supported value of a variable-length integer+ */+#define LZMA_VLI_MAX (UINT64_MAX / 2)++/**+ * \brief VLI value to denote that the value is unknown+ */+#define LZMA_VLI_UNKNOWN UINT64_MAX++/**+ * \brief Maximum supported encoded length of variable length integers+ */+#define LZMA_VLI_BYTES_MAX 9++/**+ * \brief VLI constant suffix+ */+#define LZMA_VLI_C(n) UINT64_C(n)+++/**+ * \brief Variable-length integer type+ *+ * Valid VLI values are in the range [0, LZMA_VLI_MAX]. Unknown value is+ * indicated with LZMA_VLI_UNKNOWN, which is the maximum value of the+ * underlying integer type.+ *+ * lzma_vli will be uint64_t for the foreseeable future. If a bigger size+ * is needed in the future, it is guaranteed that 2 * LZMA_VLI_MAX will+ * not overflow lzma_vli. This simplifies integer overflow detection.+ */+typedef uint64_t lzma_vli;+++/**+ * \brief Validate a variable-length integer+ *+ * This is useful to test that application has given acceptable values+ * for example in the uncompressed_size and compressed_size variables.+ *+ * \return True if the integer is representable as a VLI or if it+ * indicates an unknown value. False otherwise.+ */+#define lzma_vli_is_valid(vli) \+ ((vli) <= LZMA_VLI_MAX || (vli) == LZMA_VLI_UNKNOWN)+++/**+ * \brief Encode a variable-length integer+ *+ * This function has two modes: single-call and multi-call. Single-call mode+ * encodes the whole integer at once; it is an error if the output buffer is+ * too small. Multi-call mode saves the position in *vli_pos, and thus it is+ * possible to continue encoding if the buffer becomes full before the whole+ * integer has been encoded.+ *+ * \param vli Integer to be encoded+ * \param[out] vli_pos How many VLI-encoded bytes have already been written+ * out. When starting to encode a new integer in+ * multi-call mode, *vli_pos must be set to zero.+ * To use single-call encoding, set vli_pos to NULL.+ * \param[out] out Beginning of the output buffer+ * \param[out] out_pos The next byte will be written to out[*out_pos].+ * \param out_size Size of the out buffer; the first byte into+ * which no data is written to is out[out_size].+ *+ * \return Slightly different return values are used in multi-call and+ * single-call modes.+ *+ * Single-call (vli_pos == NULL):+ * - LZMA_OK: Integer successfully encoded.+ * - LZMA_PROG_ERROR: Arguments are not sane. This can be due+ * to too little output space; single-call mode doesn't use+ * LZMA_BUF_ERROR, since the application should have checked+ * the encoded size with lzma_vli_size().+ *+ * Multi-call (vli_pos != NULL):+ * - LZMA_OK: So far all OK, but the integer is not+ * completely written out yet.+ * - LZMA_STREAM_END: Integer successfully encoded.+ * - LZMA_BUF_ERROR: No output space was provided.+ * - LZMA_PROG_ERROR: Arguments are not sane.+ */+extern LZMA_API(lzma_ret) lzma_vli_encode(lzma_vli vli, size_t *vli_pos,+ uint8_t *out, size_t *out_pos, size_t out_size) lzma_nothrow;+++/**+ * \brief Decode a variable-length integer+ *+ * Like lzma_vli_encode(), this function has single-call and multi-call modes.+ *+ * \param[out] vli Pointer to decoded integer. The decoder will+ * initialize it to zero when *vli_pos == 0, so+ * application isn't required to initialize *vli.+ * \param[out] vli_pos How many bytes have already been decoded. When+ * starting to decode a new integer in multi-call+ * mode, *vli_pos must be initialized to zero. To+ * use single-call decoding, set vli_pos to NULL.+ * \param in Beginning of the input buffer+ * \param[out] in_pos The next byte will be read from in[*in_pos].+ * \param in_size Size of the input buffer; the first byte that+ * won't be read is in[in_size].+ *+ * \return Slightly different return values are used in multi-call and+ * single-call modes.+ *+ * Single-call (vli_pos == NULL):+ * - LZMA_OK: Integer successfully decoded.+ * - LZMA_DATA_ERROR: Integer is corrupt. This includes hitting+ * the end of the input buffer before the whole integer was+ * decoded; providing no input at all will use LZMA_DATA_ERROR.+ * - LZMA_PROG_ERROR: Arguments are not sane.+ *+ * Multi-call (vli_pos != NULL):+ * - LZMA_OK: So far all OK, but the integer is not+ * completely decoded yet.+ * - LZMA_STREAM_END: Integer successfully decoded.+ * - LZMA_DATA_ERROR: Integer is corrupt.+ * - LZMA_BUF_ERROR: No input was provided.+ * - LZMA_PROG_ERROR: Arguments are not sane.+ */+extern LZMA_API(lzma_ret) lzma_vli_decode(lzma_vli *vli, size_t *vli_pos,+ const uint8_t *in, size_t *in_pos, size_t in_size)+ lzma_nothrow;+++/**+ * \brief Get the number of bytes required to encode a VLI+ *+ * \param vli Integer whose encoded size is to be determined+ *+ * \return Number of bytes on success (1-9). If vli isn't valid,+ * zero is returned.+ */+extern LZMA_API(uint32_t) lzma_vli_size(lzma_vli vli)+ lzma_nothrow lzma_attr_pure;
+ cbits/liblzma/check/check.c view
@@ -0,0 +1,173 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file check.c+/// \brief Single API to access different integrity checks+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "check.h"+++extern LZMA_API(lzma_bool)+lzma_check_is_supported(lzma_check type)+{+ if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)+ return false;++ static const lzma_bool available_checks[LZMA_CHECK_ID_MAX + 1] = {+ true, // LZMA_CHECK_NONE++#ifdef HAVE_CHECK_CRC32+ true,+#else+ false,+#endif++ false, // Reserved+ false, // Reserved++#ifdef HAVE_CHECK_CRC64+ true,+#else+ false,+#endif++ false, // Reserved+ false, // Reserved+ false, // Reserved+ false, // Reserved+ false, // Reserved++#ifdef HAVE_CHECK_SHA256+ true,+#else+ false,+#endif++ false, // Reserved+ false, // Reserved+ false, // Reserved+ false, // Reserved+ false, // Reserved+ };++ return available_checks[(unsigned int)(type)];+}+++extern LZMA_API(uint32_t)+lzma_check_size(lzma_check type)+{+ if ((unsigned int)(type) > LZMA_CHECK_ID_MAX)+ return UINT32_MAX;++ // See file-format.txt section 2.1.1.2.+ static const uint8_t check_sizes[LZMA_CHECK_ID_MAX + 1] = {+ 0,+ 4, 4, 4,+ 8, 8, 8,+ 16, 16, 16,+ 32, 32, 32,+ 64, 64, 64+ };++ return check_sizes[(unsigned int)(type)];+}+++extern void+lzma_check_init(lzma_check_state *check, lzma_check type)+{+ switch (type) {+ case LZMA_CHECK_NONE:+ break;++#ifdef HAVE_CHECK_CRC32+ case LZMA_CHECK_CRC32:+ check->state.crc32 = 0;+ break;+#endif++#ifdef HAVE_CHECK_CRC64+ case LZMA_CHECK_CRC64:+ check->state.crc64 = 0;+ break;+#endif++#ifdef HAVE_CHECK_SHA256+ case LZMA_CHECK_SHA256:+ lzma_sha256_init(check);+ break;+#endif++ default:+ break;+ }++ return;+}+++extern void+lzma_check_update(lzma_check_state *check, lzma_check type,+ const uint8_t *buf, size_t size)+{+ switch (type) {+#ifdef HAVE_CHECK_CRC32+ case LZMA_CHECK_CRC32:+ check->state.crc32 = lzma_crc32(buf, size, check->state.crc32);+ break;+#endif++#ifdef HAVE_CHECK_CRC64+ case LZMA_CHECK_CRC64:+ check->state.crc64 = lzma_crc64(buf, size, check->state.crc64);+ break;+#endif++#ifdef HAVE_CHECK_SHA256+ case LZMA_CHECK_SHA256:+ lzma_sha256_update(buf, size, check);+ break;+#endif++ default:+ break;+ }++ return;+}+++extern void+lzma_check_finish(lzma_check_state *check, lzma_check type)+{+ switch (type) {+#ifdef HAVE_CHECK_CRC32+ case LZMA_CHECK_CRC32:+ check->buffer.u32[0] = conv32le(check->state.crc32);+ break;+#endif++#ifdef HAVE_CHECK_CRC64+ case LZMA_CHECK_CRC64:+ check->buffer.u64[0] = conv64le(check->state.crc64);+ break;+#endif++#ifdef HAVE_CHECK_SHA256+ case LZMA_CHECK_SHA256:+ lzma_sha256_finish(check);+ break;+#endif++ default:+ break;+ }++ return;+}
+ cbits/liblzma/check/check.h view
@@ -0,0 +1,174 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file check.h+/// \brief Internal API to different integrity check functions+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_CHECK_H+#define LZMA_CHECK_H++#include "common.h"++// If the function for external SHA-256 is missing, use the internal SHA-256+// code. Due to how configure works, these defines can only get defined when+// both a usable header and a type have already been found.+#if !(defined(HAVE_CC_SHA256_INIT) \+ || defined(HAVE_SHA256_INIT) \+ || defined(HAVE_SHA256INIT))+# define HAVE_INTERNAL_SHA256 1+#endif++#if defined(HAVE_INTERNAL_SHA256)+// Nothing+#elif defined(HAVE_COMMONCRYPTO_COMMONDIGEST_H)+# include <CommonCrypto/CommonDigest.h>+#elif defined(HAVE_SHA256_H)+# include <sys/types.h>+# include <sha256.h>+#elif defined(HAVE_SHA2_H)+# include <sys/types.h>+# include <sha2.h>+#endif++#if defined(HAVE_INTERNAL_SHA256)+/// State for the internal SHA-256 implementation+typedef struct {+ /// Internal state+ uint32_t state[8];++ /// Size of the message excluding padding+ uint64_t size;+} lzma_sha256_state;+#elif defined(HAVE_CC_SHA256_CTX)+typedef CC_SHA256_CTX lzma_sha256_state;+#elif defined(HAVE_SHA256_CTX)+typedef SHA256_CTX lzma_sha256_state;+#elif defined(HAVE_SHA2_CTX)+typedef SHA2_CTX lzma_sha256_state;+#endif++#if defined(HAVE_INTERNAL_SHA256)+// Nothing+#elif defined(HAVE_CC_SHA256_INIT)+# define LZMA_SHA256FUNC(x) CC_SHA256_ ## x+#elif defined(HAVE_SHA256_INIT)+# define LZMA_SHA256FUNC(x) SHA256_ ## x+#elif defined(HAVE_SHA256INIT)+# define LZMA_SHA256FUNC(x) SHA256 ## x+#endif++// Index hashing needs the best possible hash function (preferably+// a cryptographic hash) for maximum reliability.+#if defined(HAVE_CHECK_SHA256)+# define LZMA_CHECK_BEST LZMA_CHECK_SHA256+#elif defined(HAVE_CHECK_CRC64)+# define LZMA_CHECK_BEST LZMA_CHECK_CRC64+#else+# define LZMA_CHECK_BEST LZMA_CHECK_CRC32+#endif+++/// \brief Structure to hold internal state of the check being calculated+///+/// \note This is not in the public API because this structure may+/// change in future if new integrity check algorithms are added.+typedef struct {+ /// Buffer to hold the final result and a temporary buffer for SHA256.+ union {+ uint8_t u8[64];+ uint32_t u32[16];+ uint64_t u64[8];+ } buffer;++ /// Check-specific data+ union {+ uint32_t crc32;+ uint64_t crc64;+ lzma_sha256_state sha256;+ } state;++} lzma_check_state;+++/// lzma_crc32_table[0] is needed by LZ encoder so we need to keep+/// the array two-dimensional.+#ifdef HAVE_SMALL+lzma_attr_visibility_hidden+extern uint32_t lzma_crc32_table[1][256];++extern void lzma_crc32_init(void);++#else++lzma_attr_visibility_hidden+extern const uint32_t lzma_crc32_table[8][256];++lzma_attr_visibility_hidden+extern const uint64_t lzma_crc64_table[4][256];+#endif+++/// \brief Initialize *check depending on type+extern void lzma_check_init(lzma_check_state *check, lzma_check type);++/// Update the check state+extern void lzma_check_update(lzma_check_state *check, lzma_check type,+ const uint8_t *buf, size_t size);++/// Finish the check calculation and store the result to check->buffer.u8.+extern void lzma_check_finish(lzma_check_state *check, lzma_check type);+++#ifndef LZMA_SHA256FUNC++/// Prepare SHA-256 state for new input.+extern void lzma_sha256_init(lzma_check_state *check);++/// Update the SHA-256 hash state+extern void lzma_sha256_update(+ const uint8_t *buf, size_t size, lzma_check_state *check);++/// Finish the SHA-256 calculation and store the result to check->buffer.u8.+extern void lzma_sha256_finish(lzma_check_state *check);+++#else++static inline void+lzma_sha256_init(lzma_check_state *check)+{+ LZMA_SHA256FUNC(Init)(&check->state.sha256);+}+++static inline void+lzma_sha256_update(const uint8_t *buf, size_t size, lzma_check_state *check)+{+#if defined(HAVE_CC_SHA256_INIT) && SIZE_MAX > UINT32_MAX+ // Darwin's CC_SHA256_Update takes uint32_t as the buffer size,+ // so use a loop to support size_t.+ while (size > UINT32_MAX) {+ LZMA_SHA256FUNC(Update)(&check->state.sha256, buf, UINT32_MAX);+ buf += UINT32_MAX;+ size -= UINT32_MAX;+ }+#endif++ LZMA_SHA256FUNC(Update)(&check->state.sha256, buf, size);+}+++static inline void+lzma_sha256_finish(lzma_check_state *check)+{+ LZMA_SHA256FUNC(Final)(check->buffer.u8, &check->state.sha256);+}++#endif++#endif
+ cbits/liblzma/check/crc32_arm64.h view
@@ -0,0 +1,122 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file crc32_arm64.h+/// \brief CRC32 calculation with ARM64 optimization+//+// Authors: Chenxi Mao+// Jia Tan+// Hans Jansen+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_CRC32_ARM64_H+#define LZMA_CRC32_ARM64_H++// MSVC always has the CRC intrinsics available when building for ARM64+// there is no need to include any header files.+#ifndef _MSC_VER+# include <arm_acle.h>+#endif++// If both versions are going to be built, we need runtime detection+// to check if the instructions are supported.+#if defined(CRC32_GENERIC) && defined(CRC32_ARCH_OPTIMIZED)+# if defined(HAVE_GETAUXVAL) || defined(HAVE_ELF_AUX_INFO)+# include <sys/auxv.h>+# elif defined(_WIN32)+# include <processthreadsapi.h>+# elif defined(__APPLE__) && defined(HAVE_SYSCTLBYNAME)+# include <sys/sysctl.h>+# endif+#endif++// Some EDG-based compilers support ARM64 and define __GNUC__+// (such as Nvidia's nvcc), but do not support function attributes.+//+// NOTE: Build systems check for this too, keep them in sync with this.+#if (defined(__GNUC__) || defined(__clang__)) && !defined(__EDG__)+# define crc_attr_target __attribute__((__target__("+crc")))+#else+# define crc_attr_target+#endif+++crc_attr_target+static uint32_t+crc32_arch_optimized(const uint8_t *buf, size_t size, uint32_t crc)+{+ crc = ~crc;++ // Align the input buffer because this was shown to be+ // significantly faster than unaligned accesses.+ const size_t align_amount = my_min(size, (0U - (uintptr_t)buf) & 7);++ for (const uint8_t *limit = buf + align_amount; buf < limit; ++buf)+ crc = __crc32b(crc, *buf);++ size -= align_amount;++ // Process 8 bytes at a time. The end point is determined by+ // ignoring the least significant three bits of size to ensure+ // we do not process past the bounds of the buffer. This guarantees+ // that limit is a multiple of 8 and is strictly less than size.+ for (const uint8_t *limit = buf + (size & ~(size_t)7);+ buf < limit; buf += 8)+ crc = __crc32d(crc, aligned_read64le(buf));++ // Process the remaining bytes that are not 8 byte aligned.+ for (const uint8_t *limit = buf + (size & 7); buf < limit; ++buf)+ crc = __crc32b(crc, *buf);++ return ~crc;+}+++#if defined(CRC32_GENERIC) && defined(CRC32_ARCH_OPTIMIZED)+static inline bool+is_arch_extension_supported(void)+{+#if defined(HAVE_GETAUXVAL)+ return (getauxval(AT_HWCAP) & HWCAP_CRC32) != 0;++#elif defined(HAVE_ELF_AUX_INFO)+ unsigned long feature_flags;++ if (elf_aux_info(AT_HWCAP, &feature_flags, sizeof(feature_flags)) != 0)+ return false;++ return (feature_flags & HWCAP_CRC32) != 0;++#elif defined(_WIN32)+ return IsProcessorFeaturePresent(+ PF_ARM_V8_CRC32_INSTRUCTIONS_AVAILABLE);++#elif defined(__APPLE__) && defined(HAVE_SYSCTLBYNAME)+ int has_crc32 = 0;+ size_t size = sizeof(has_crc32);++ // The sysctlbyname() function requires a string identifier for the+ // CPU feature it tests. The Apple documentation lists the string+ // "hw.optional.armv8_crc32", which can be found here:+ // https://developer.apple.com/documentation/kernel/1387446-sysctlbyname/determining_instruction_set_characteristics#3915619+ if (sysctlbyname("hw.optional.armv8_crc32", &has_crc32,+ &size, NULL, 0) != 0)+ return false;++ return has_crc32;++#else+ // If a runtime detection method cannot be found, then this must+ // be a compile time error. The checks in crc_common.h should ensure+ // a runtime detection method is always found if this function is+ // built. It would be possible to just return false here, but this+ // is inefficient for binary size and runtime since only the generic+ // method could ever be used.+# error Runtime detection method unavailable.+#endif+}+#endif++#endif // LZMA_CRC32_ARM64_H
+ cbits/liblzma/check/crc32_fast.c view
@@ -0,0 +1,204 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file crc32.c+/// \brief CRC32 calculation+//+// Authors: Lasse Collin+// Ilya Kurdyukov+// Hans Jansen+//+///////////////////////////////////////////////////////////////////////////////++#include "check.h"+#include "crc_common.h"++#if defined(CRC_X86_CLMUL)+# define BUILDING_CRC32_CLMUL+# include "crc_x86_clmul.h"+#elif defined(CRC32_ARM64)+# include "crc32_arm64.h"+#endif+++#ifdef CRC32_GENERIC++///////////////////+// Generic CRC32 //+///////////////////++static uint32_t+crc32_generic(const uint8_t *buf, size_t size, uint32_t crc)+{+ crc = ~crc;++#ifdef WORDS_BIGENDIAN+ crc = byteswap32(crc);+#endif++ if (size > 8) {+ // Fix the alignment, if needed. The if statement above+ // ensures that this won't read past the end of buf[].+ while ((uintptr_t)(buf) & 7) {+ crc = lzma_crc32_table[0][*buf++ ^ A(crc)] ^ S8(crc);+ --size;+ }++ // Calculate the position where to stop.+ const uint8_t *const limit = buf + (size & ~(size_t)(7));++ // Calculate how many bytes must be calculated separately+ // before returning the result.+ size &= (size_t)(7);++ // Calculate the CRC32 using the slice-by-eight algorithm.+ while (buf < limit) {+ crc ^= aligned_read32ne(buf);+ buf += 4;++ crc = lzma_crc32_table[7][A(crc)]+ ^ lzma_crc32_table[6][B(crc)]+ ^ lzma_crc32_table[5][C(crc)]+ ^ lzma_crc32_table[4][D(crc)];++ const uint32_t tmp = aligned_read32ne(buf);+ buf += 4;++ // At least with some compilers, it is critical for+ // performance, that the crc variable is XORed+ // between the two table-lookup pairs.+ crc = lzma_crc32_table[3][A(tmp)]+ ^ lzma_crc32_table[2][B(tmp)]+ ^ crc+ ^ lzma_crc32_table[1][C(tmp)]+ ^ lzma_crc32_table[0][D(tmp)];+ }+ }++ while (size-- != 0)+ crc = lzma_crc32_table[0][*buf++ ^ A(crc)] ^ S8(crc);++#ifdef WORDS_BIGENDIAN+ crc = byteswap32(crc);+#endif++ return ~crc;+}+#endif+++#if defined(CRC32_GENERIC) && defined(CRC32_ARCH_OPTIMIZED)++//////////////////////////+// Function dispatching //+//////////////////////////++// If both the generic and arch-optimized implementations are built, then+// the function to use is selected at runtime because the system running+// the binary might not have the arch-specific instruction set extension(s)+// available. The dispatch methods in order of priority:+//+// 1. Constructor. This method uses __attribute__((__constructor__)) to+// set crc32_func at load time. This avoids extra computation (and any+// unlikely threading bugs) on the first call to lzma_crc32() to decide+// which implementation should be used.+//+// 2. First Call Resolution. On the very first call to lzma_crc32(), the+// call will be directed to crc32_dispatch() instead. This will set the+// appropriate implementation function and will not be called again.+// This method does not use any kind of locking but is safe because if+// multiple threads run the dispatcher simultaneously then they will all+// set crc32_func to the same value.++typedef uint32_t (*crc32_func_type)(+ const uint8_t *buf, size_t size, uint32_t crc);++// This resolver is shared between all dispatch methods.+static crc32_func_type+crc32_resolve(void)+{+ return is_arch_extension_supported()+ ? &crc32_arch_optimized : &crc32_generic;+}+++#ifdef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR+// Constructor method.+# define CRC32_SET_FUNC_ATTR __attribute__((__constructor__))+static crc32_func_type crc32_func;+#else+// First Call Resolution method.+# define CRC32_SET_FUNC_ATTR+static uint32_t crc32_dispatch(const uint8_t *buf, size_t size, uint32_t crc);+static crc32_func_type crc32_func = &crc32_dispatch;+#endif++CRC32_SET_FUNC_ATTR+static void+crc32_set_func(void)+{+ crc32_func = crc32_resolve();+ return;+}++#ifndef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR+static uint32_t+crc32_dispatch(const uint8_t *buf, size_t size, uint32_t crc)+{+ // When __attribute__((__constructor__)) isn't supported, set the+ // function pointer without any locking. If multiple threads run+ // the detection code in parallel, they will all end up setting+ // the pointer to the same value. This avoids the use of+ // mythread_once() on every call to lzma_crc32() but this likely+ // isn't strictly standards compliant. Let's change it if it breaks.+ crc32_set_func();+ return crc32_func(buf, size, crc);+}++#endif+#endif+++extern LZMA_API(uint32_t)+lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)+{+#if defined(CRC32_GENERIC) && defined(CRC32_ARCH_OPTIMIZED)+ // On x86-64, if CLMUL is available, it is the best for non-tiny+ // inputs, being over twice as fast as the generic slice-by-four+ // version. However, for size <= 16 it's different. In the extreme+ // case of size == 1 the generic version can be five times faster.+ // At size >= 8 the CLMUL starts to become reasonable. It+ // varies depending on the alignment of buf too.+ //+ // The above doesn't include the overhead of mythread_once().+ // At least on x86-64 GNU/Linux, pthread_once() is very fast but+ // it still makes lzma_crc32(buf, 1, crc) 50-100 % slower. When+ // size reaches 12-16 bytes the overhead becomes negligible.+ //+ // So using the generic version for size <= 16 may give better+ // performance with tiny inputs but if such inputs happen rarely+ // it's not so obvious because then the lookup table of the+ // generic version may not be in the processor cache.+#ifdef CRC_USE_GENERIC_FOR_SMALL_INPUTS+ if (size <= 16)+ return crc32_generic(buf, size, crc);+#endif++/*+#ifndef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR+ // See crc32_dispatch(). This would be the alternative which uses+ // locking and doesn't use crc32_dispatch(). Note that on Windows+ // this method needs Vista threads.+ mythread_once(crc64_set_func);+#endif+*/+ return crc32_func(buf, size, crc);++#elif defined(CRC32_ARCH_OPTIMIZED)+ return crc32_arch_optimized(buf, size, crc);++#else+ return crc32_generic(buf, size, crc);+#endif+}
+ cbits/liblzma/check/crc32_small.c view
@@ -0,0 +1,67 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file crc32_small.c+/// \brief CRC32 calculation (size-optimized)+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "check.h"+++uint32_t lzma_crc32_table[1][256];+++#ifdef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR+__attribute__((__constructor__))+#endif+static void+crc32_init(void)+{+ static const uint32_t poly32 = UINT32_C(0xEDB88320);++ for (size_t b = 0; b < 256; ++b) {+ uint32_t r = b;+ for (size_t i = 0; i < 8; ++i) {+ if (r & 1)+ r = (r >> 1) ^ poly32;+ else+ r >>= 1;+ }++ lzma_crc32_table[0][b] = r;+ }++ return;+}+++#ifndef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR+extern void+lzma_crc32_init(void)+{+ mythread_once(crc32_init);+ return;+}+#endif+++extern LZMA_API(uint32_t)+lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc)+{+#ifndef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR+ lzma_crc32_init();+#endif++ crc = ~crc;++ while (size != 0) {+ crc = lzma_crc32_table[0][*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);+ --size;+ }++ return ~crc;+}
+ cbits/liblzma/check/crc32_table.c view
@@ -0,0 +1,42 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file crc32_table.c+/// \brief Precalculated CRC32 table with correct endianness+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+++// FIXME: Compared to crc_common.h this has to check for __x86_64__ too+// so that in 32-bit builds crc32_x86.S won't break due to a missing table.+#if defined(HAVE_USABLE_CLMUL) && ((defined(__x86_64__) && defined(__SSSE3__) \+ && defined(__SSE4_1__) && defined(__PCLMUL__)) \+ || (defined(__e2k__) && __iset__ >= 6))+# define NO_CRC32_TABLE++#elif defined(HAVE_ARM64_CRC32) \+ && !defined(WORDS_BIGENDIAN) \+ && defined(__ARM_FEATURE_CRC32)+# define NO_CRC32_TABLE+#endif+++#if !defined(HAVE_ENCODERS) && defined(NO_CRC32_TABLE)+// No table needed. Use a typedef to avoid an empty translation unit.+typedef void lzma_crc32_dummy;++#else+// Having the declaration here silences clang -Wmissing-variable-declarations.+extern const uint32_t lzma_crc32_table[8][256];++# ifdef WORDS_BIGENDIAN+# include "crc32_table_be.h"+# else+# include "crc32_table_le.h"+# endif+#endif
+ cbits/liblzma/check/crc32_table_be.h view
@@ -0,0 +1,527 @@+// SPDX-License-Identifier: 0BSD++// This file has been generated by crc32_tablegen.c.++const uint32_t lzma_crc32_table[8][256] = {+ {+ 0x00000000, 0x96300777, 0x2C610EEE, 0xBA510999,+ 0x19C46D07, 0x8FF46A70, 0x35A563E9, 0xA395649E,+ 0x3288DB0E, 0xA4B8DC79, 0x1EE9D5E0, 0x88D9D297,+ 0x2B4CB609, 0xBD7CB17E, 0x072DB8E7, 0x911DBF90,+ 0x6410B71D, 0xF220B06A, 0x4871B9F3, 0xDE41BE84,+ 0x7DD4DA1A, 0xEBE4DD6D, 0x51B5D4F4, 0xC785D383,+ 0x56986C13, 0xC0A86B64, 0x7AF962FD, 0xECC9658A,+ 0x4F5C0114, 0xD96C0663, 0x633D0FFA, 0xF50D088D,+ 0xC8206E3B, 0x5E10694C, 0xE44160D5, 0x727167A2,+ 0xD1E4033C, 0x47D4044B, 0xFD850DD2, 0x6BB50AA5,+ 0xFAA8B535, 0x6C98B242, 0xD6C9BBDB, 0x40F9BCAC,+ 0xE36CD832, 0x755CDF45, 0xCF0DD6DC, 0x593DD1AB,+ 0xAC30D926, 0x3A00DE51, 0x8051D7C8, 0x1661D0BF,+ 0xB5F4B421, 0x23C4B356, 0x9995BACF, 0x0FA5BDB8,+ 0x9EB80228, 0x0888055F, 0xB2D90CC6, 0x24E90BB1,+ 0x877C6F2F, 0x114C6858, 0xAB1D61C1, 0x3D2D66B6,+ 0x9041DC76, 0x0671DB01, 0xBC20D298, 0x2A10D5EF,+ 0x8985B171, 0x1FB5B606, 0xA5E4BF9F, 0x33D4B8E8,+ 0xA2C90778, 0x34F9000F, 0x8EA80996, 0x18980EE1,+ 0xBB0D6A7F, 0x2D3D6D08, 0x976C6491, 0x015C63E6,+ 0xF4516B6B, 0x62616C1C, 0xD8306585, 0x4E0062F2,+ 0xED95066C, 0x7BA5011B, 0xC1F40882, 0x57C40FF5,+ 0xC6D9B065, 0x50E9B712, 0xEAB8BE8B, 0x7C88B9FC,+ 0xDF1DDD62, 0x492DDA15, 0xF37CD38C, 0x654CD4FB,+ 0x5861B24D, 0xCE51B53A, 0x7400BCA3, 0xE230BBD4,+ 0x41A5DF4A, 0xD795D83D, 0x6DC4D1A4, 0xFBF4D6D3,+ 0x6AE96943, 0xFCD96E34, 0x468867AD, 0xD0B860DA,+ 0x732D0444, 0xE51D0333, 0x5F4C0AAA, 0xC97C0DDD,+ 0x3C710550, 0xAA410227, 0x10100BBE, 0x86200CC9,+ 0x25B56857, 0xB3856F20, 0x09D466B9, 0x9FE461CE,+ 0x0EF9DE5E, 0x98C9D929, 0x2298D0B0, 0xB4A8D7C7,+ 0x173DB359, 0x810DB42E, 0x3B5CBDB7, 0xAD6CBAC0,+ 0x2083B8ED, 0xB6B3BF9A, 0x0CE2B603, 0x9AD2B174,+ 0x3947D5EA, 0xAF77D29D, 0x1526DB04, 0x8316DC73,+ 0x120B63E3, 0x843B6494, 0x3E6A6D0D, 0xA85A6A7A,+ 0x0BCF0EE4, 0x9DFF0993, 0x27AE000A, 0xB19E077D,+ 0x44930FF0, 0xD2A30887, 0x68F2011E, 0xFEC20669,+ 0x5D5762F7, 0xCB676580, 0x71366C19, 0xE7066B6E,+ 0x761BD4FE, 0xE02BD389, 0x5A7ADA10, 0xCC4ADD67,+ 0x6FDFB9F9, 0xF9EFBE8E, 0x43BEB717, 0xD58EB060,+ 0xE8A3D6D6, 0x7E93D1A1, 0xC4C2D838, 0x52F2DF4F,+ 0xF167BBD1, 0x6757BCA6, 0xDD06B53F, 0x4B36B248,+ 0xDA2B0DD8, 0x4C1B0AAF, 0xF64A0336, 0x607A0441,+ 0xC3EF60DF, 0x55DF67A8, 0xEF8E6E31, 0x79BE6946,+ 0x8CB361CB, 0x1A8366BC, 0xA0D26F25, 0x36E26852,+ 0x95770CCC, 0x03470BBB, 0xB9160222, 0x2F260555,+ 0xBE3BBAC5, 0x280BBDB2, 0x925AB42B, 0x046AB35C,+ 0xA7FFD7C2, 0x31CFD0B5, 0x8B9ED92C, 0x1DAEDE5B,+ 0xB0C2649B, 0x26F263EC, 0x9CA36A75, 0x0A936D02,+ 0xA906099C, 0x3F360EEB, 0x85670772, 0x13570005,+ 0x824ABF95, 0x147AB8E2, 0xAE2BB17B, 0x381BB60C,+ 0x9B8ED292, 0x0DBED5E5, 0xB7EFDC7C, 0x21DFDB0B,+ 0xD4D2D386, 0x42E2D4F1, 0xF8B3DD68, 0x6E83DA1F,+ 0xCD16BE81, 0x5B26B9F6, 0xE177B06F, 0x7747B718,+ 0xE65A0888, 0x706A0FFF, 0xCA3B0666, 0x5C0B0111,+ 0xFF9E658F, 0x69AE62F8, 0xD3FF6B61, 0x45CF6C16,+ 0x78E20AA0, 0xEED20DD7, 0x5483044E, 0xC2B30339,+ 0x612667A7, 0xF71660D0, 0x4D476949, 0xDB776E3E,+ 0x4A6AD1AE, 0xDC5AD6D9, 0x660BDF40, 0xF03BD837,+ 0x53AEBCA9, 0xC59EBBDE, 0x7FCFB247, 0xE9FFB530,+ 0x1CF2BDBD, 0x8AC2BACA, 0x3093B353, 0xA6A3B424,+ 0x0536D0BA, 0x9306D7CD, 0x2957DE54, 0xBF67D923,+ 0x2E7A66B3, 0xB84A61C4, 0x021B685D, 0x942B6F2A,+ 0x37BE0BB4, 0xA18E0CC3, 0x1BDF055A, 0x8DEF022D+ }, {+ 0x00000000, 0x41311B19, 0x82623632, 0xC3532D2B,+ 0x04C56C64, 0x45F4777D, 0x86A75A56, 0xC796414F,+ 0x088AD9C8, 0x49BBC2D1, 0x8AE8EFFA, 0xCBD9F4E3,+ 0x0C4FB5AC, 0x4D7EAEB5, 0x8E2D839E, 0xCF1C9887,+ 0x5112C24A, 0x1023D953, 0xD370F478, 0x9241EF61,+ 0x55D7AE2E, 0x14E6B537, 0xD7B5981C, 0x96848305,+ 0x59981B82, 0x18A9009B, 0xDBFA2DB0, 0x9ACB36A9,+ 0x5D5D77E6, 0x1C6C6CFF, 0xDF3F41D4, 0x9E0E5ACD,+ 0xA2248495, 0xE3159F8C, 0x2046B2A7, 0x6177A9BE,+ 0xA6E1E8F1, 0xE7D0F3E8, 0x2483DEC3, 0x65B2C5DA,+ 0xAAAE5D5D, 0xEB9F4644, 0x28CC6B6F, 0x69FD7076,+ 0xAE6B3139, 0xEF5A2A20, 0x2C09070B, 0x6D381C12,+ 0xF33646DF, 0xB2075DC6, 0x715470ED, 0x30656BF4,+ 0xF7F32ABB, 0xB6C231A2, 0x75911C89, 0x34A00790,+ 0xFBBC9F17, 0xBA8D840E, 0x79DEA925, 0x38EFB23C,+ 0xFF79F373, 0xBE48E86A, 0x7D1BC541, 0x3C2ADE58,+ 0x054F79F0, 0x447E62E9, 0x872D4FC2, 0xC61C54DB,+ 0x018A1594, 0x40BB0E8D, 0x83E823A6, 0xC2D938BF,+ 0x0DC5A038, 0x4CF4BB21, 0x8FA7960A, 0xCE968D13,+ 0x0900CC5C, 0x4831D745, 0x8B62FA6E, 0xCA53E177,+ 0x545DBBBA, 0x156CA0A3, 0xD63F8D88, 0x970E9691,+ 0x5098D7DE, 0x11A9CCC7, 0xD2FAE1EC, 0x93CBFAF5,+ 0x5CD76272, 0x1DE6796B, 0xDEB55440, 0x9F844F59,+ 0x58120E16, 0x1923150F, 0xDA703824, 0x9B41233D,+ 0xA76BFD65, 0xE65AE67C, 0x2509CB57, 0x6438D04E,+ 0xA3AE9101, 0xE29F8A18, 0x21CCA733, 0x60FDBC2A,+ 0xAFE124AD, 0xEED03FB4, 0x2D83129F, 0x6CB20986,+ 0xAB2448C9, 0xEA1553D0, 0x29467EFB, 0x687765E2,+ 0xF6793F2F, 0xB7482436, 0x741B091D, 0x352A1204,+ 0xF2BC534B, 0xB38D4852, 0x70DE6579, 0x31EF7E60,+ 0xFEF3E6E7, 0xBFC2FDFE, 0x7C91D0D5, 0x3DA0CBCC,+ 0xFA368A83, 0xBB07919A, 0x7854BCB1, 0x3965A7A8,+ 0x4B98833B, 0x0AA99822, 0xC9FAB509, 0x88CBAE10,+ 0x4F5DEF5F, 0x0E6CF446, 0xCD3FD96D, 0x8C0EC274,+ 0x43125AF3, 0x022341EA, 0xC1706CC1, 0x804177D8,+ 0x47D73697, 0x06E62D8E, 0xC5B500A5, 0x84841BBC,+ 0x1A8A4171, 0x5BBB5A68, 0x98E87743, 0xD9D96C5A,+ 0x1E4F2D15, 0x5F7E360C, 0x9C2D1B27, 0xDD1C003E,+ 0x120098B9, 0x533183A0, 0x9062AE8B, 0xD153B592,+ 0x16C5F4DD, 0x57F4EFC4, 0x94A7C2EF, 0xD596D9F6,+ 0xE9BC07AE, 0xA88D1CB7, 0x6BDE319C, 0x2AEF2A85,+ 0xED796BCA, 0xAC4870D3, 0x6F1B5DF8, 0x2E2A46E1,+ 0xE136DE66, 0xA007C57F, 0x6354E854, 0x2265F34D,+ 0xE5F3B202, 0xA4C2A91B, 0x67918430, 0x26A09F29,+ 0xB8AEC5E4, 0xF99FDEFD, 0x3ACCF3D6, 0x7BFDE8CF,+ 0xBC6BA980, 0xFD5AB299, 0x3E099FB2, 0x7F3884AB,+ 0xB0241C2C, 0xF1150735, 0x32462A1E, 0x73773107,+ 0xB4E17048, 0xF5D06B51, 0x3683467A, 0x77B25D63,+ 0x4ED7FACB, 0x0FE6E1D2, 0xCCB5CCF9, 0x8D84D7E0,+ 0x4A1296AF, 0x0B238DB6, 0xC870A09D, 0x8941BB84,+ 0x465D2303, 0x076C381A, 0xC43F1531, 0x850E0E28,+ 0x42984F67, 0x03A9547E, 0xC0FA7955, 0x81CB624C,+ 0x1FC53881, 0x5EF42398, 0x9DA70EB3, 0xDC9615AA,+ 0x1B0054E5, 0x5A314FFC, 0x996262D7, 0xD85379CE,+ 0x174FE149, 0x567EFA50, 0x952DD77B, 0xD41CCC62,+ 0x138A8D2D, 0x52BB9634, 0x91E8BB1F, 0xD0D9A006,+ 0xECF37E5E, 0xADC26547, 0x6E91486C, 0x2FA05375,+ 0xE836123A, 0xA9070923, 0x6A542408, 0x2B653F11,+ 0xE479A796, 0xA548BC8F, 0x661B91A4, 0x272A8ABD,+ 0xE0BCCBF2, 0xA18DD0EB, 0x62DEFDC0, 0x23EFE6D9,+ 0xBDE1BC14, 0xFCD0A70D, 0x3F838A26, 0x7EB2913F,+ 0xB924D070, 0xF815CB69, 0x3B46E642, 0x7A77FD5B,+ 0xB56B65DC, 0xF45A7EC5, 0x370953EE, 0x763848F7,+ 0xB1AE09B8, 0xF09F12A1, 0x33CC3F8A, 0x72FD2493+ }, {+ 0x00000000, 0x376AC201, 0x6ED48403, 0x59BE4602,+ 0xDCA80907, 0xEBC2CB06, 0xB27C8D04, 0x85164F05,+ 0xB851130E, 0x8F3BD10F, 0xD685970D, 0xE1EF550C,+ 0x64F91A09, 0x5393D808, 0x0A2D9E0A, 0x3D475C0B,+ 0x70A3261C, 0x47C9E41D, 0x1E77A21F, 0x291D601E,+ 0xAC0B2F1B, 0x9B61ED1A, 0xC2DFAB18, 0xF5B56919,+ 0xC8F23512, 0xFF98F713, 0xA626B111, 0x914C7310,+ 0x145A3C15, 0x2330FE14, 0x7A8EB816, 0x4DE47A17,+ 0xE0464D38, 0xD72C8F39, 0x8E92C93B, 0xB9F80B3A,+ 0x3CEE443F, 0x0B84863E, 0x523AC03C, 0x6550023D,+ 0x58175E36, 0x6F7D9C37, 0x36C3DA35, 0x01A91834,+ 0x84BF5731, 0xB3D59530, 0xEA6BD332, 0xDD011133,+ 0x90E56B24, 0xA78FA925, 0xFE31EF27, 0xC95B2D26,+ 0x4C4D6223, 0x7B27A022, 0x2299E620, 0x15F32421,+ 0x28B4782A, 0x1FDEBA2B, 0x4660FC29, 0x710A3E28,+ 0xF41C712D, 0xC376B32C, 0x9AC8F52E, 0xADA2372F,+ 0xC08D9A70, 0xF7E75871, 0xAE591E73, 0x9933DC72,+ 0x1C259377, 0x2B4F5176, 0x72F11774, 0x459BD575,+ 0x78DC897E, 0x4FB64B7F, 0x16080D7D, 0x2162CF7C,+ 0xA4748079, 0x931E4278, 0xCAA0047A, 0xFDCAC67B,+ 0xB02EBC6C, 0x87447E6D, 0xDEFA386F, 0xE990FA6E,+ 0x6C86B56B, 0x5BEC776A, 0x02523168, 0x3538F369,+ 0x087FAF62, 0x3F156D63, 0x66AB2B61, 0x51C1E960,+ 0xD4D7A665, 0xE3BD6464, 0xBA032266, 0x8D69E067,+ 0x20CBD748, 0x17A11549, 0x4E1F534B, 0x7975914A,+ 0xFC63DE4F, 0xCB091C4E, 0x92B75A4C, 0xA5DD984D,+ 0x989AC446, 0xAFF00647, 0xF64E4045, 0xC1248244,+ 0x4432CD41, 0x73580F40, 0x2AE64942, 0x1D8C8B43,+ 0x5068F154, 0x67023355, 0x3EBC7557, 0x09D6B756,+ 0x8CC0F853, 0xBBAA3A52, 0xE2147C50, 0xD57EBE51,+ 0xE839E25A, 0xDF53205B, 0x86ED6659, 0xB187A458,+ 0x3491EB5D, 0x03FB295C, 0x5A456F5E, 0x6D2FAD5F,+ 0x801B35E1, 0xB771F7E0, 0xEECFB1E2, 0xD9A573E3,+ 0x5CB33CE6, 0x6BD9FEE7, 0x3267B8E5, 0x050D7AE4,+ 0x384A26EF, 0x0F20E4EE, 0x569EA2EC, 0x61F460ED,+ 0xE4E22FE8, 0xD388EDE9, 0x8A36ABEB, 0xBD5C69EA,+ 0xF0B813FD, 0xC7D2D1FC, 0x9E6C97FE, 0xA90655FF,+ 0x2C101AFA, 0x1B7AD8FB, 0x42C49EF9, 0x75AE5CF8,+ 0x48E900F3, 0x7F83C2F2, 0x263D84F0, 0x115746F1,+ 0x944109F4, 0xA32BCBF5, 0xFA958DF7, 0xCDFF4FF6,+ 0x605D78D9, 0x5737BAD8, 0x0E89FCDA, 0x39E33EDB,+ 0xBCF571DE, 0x8B9FB3DF, 0xD221F5DD, 0xE54B37DC,+ 0xD80C6BD7, 0xEF66A9D6, 0xB6D8EFD4, 0x81B22DD5,+ 0x04A462D0, 0x33CEA0D1, 0x6A70E6D3, 0x5D1A24D2,+ 0x10FE5EC5, 0x27949CC4, 0x7E2ADAC6, 0x494018C7,+ 0xCC5657C2, 0xFB3C95C3, 0xA282D3C1, 0x95E811C0,+ 0xA8AF4DCB, 0x9FC58FCA, 0xC67BC9C8, 0xF1110BC9,+ 0x740744CC, 0x436D86CD, 0x1AD3C0CF, 0x2DB902CE,+ 0x4096AF91, 0x77FC6D90, 0x2E422B92, 0x1928E993,+ 0x9C3EA696, 0xAB546497, 0xF2EA2295, 0xC580E094,+ 0xF8C7BC9F, 0xCFAD7E9E, 0x9613389C, 0xA179FA9D,+ 0x246FB598, 0x13057799, 0x4ABB319B, 0x7DD1F39A,+ 0x3035898D, 0x075F4B8C, 0x5EE10D8E, 0x698BCF8F,+ 0xEC9D808A, 0xDBF7428B, 0x82490489, 0xB523C688,+ 0x88649A83, 0xBF0E5882, 0xE6B01E80, 0xD1DADC81,+ 0x54CC9384, 0x63A65185, 0x3A181787, 0x0D72D586,+ 0xA0D0E2A9, 0x97BA20A8, 0xCE0466AA, 0xF96EA4AB,+ 0x7C78EBAE, 0x4B1229AF, 0x12AC6FAD, 0x25C6ADAC,+ 0x1881F1A7, 0x2FEB33A6, 0x765575A4, 0x413FB7A5,+ 0xC429F8A0, 0xF3433AA1, 0xAAFD7CA3, 0x9D97BEA2,+ 0xD073C4B5, 0xE71906B4, 0xBEA740B6, 0x89CD82B7,+ 0x0CDBCDB2, 0x3BB10FB3, 0x620F49B1, 0x55658BB0,+ 0x6822D7BB, 0x5F4815BA, 0x06F653B8, 0x319C91B9,+ 0xB48ADEBC, 0x83E01CBD, 0xDA5E5ABF, 0xED3498BE+ }, {+ 0x00000000, 0x6567BCB8, 0x8BC809AA, 0xEEAFB512,+ 0x5797628F, 0x32F0DE37, 0xDC5F6B25, 0xB938D79D,+ 0xEF28B4C5, 0x8A4F087D, 0x64E0BD6F, 0x018701D7,+ 0xB8BFD64A, 0xDDD86AF2, 0x3377DFE0, 0x56106358,+ 0x9F571950, 0xFA30A5E8, 0x149F10FA, 0x71F8AC42,+ 0xC8C07BDF, 0xADA7C767, 0x43087275, 0x266FCECD,+ 0x707FAD95, 0x1518112D, 0xFBB7A43F, 0x9ED01887,+ 0x27E8CF1A, 0x428F73A2, 0xAC20C6B0, 0xC9477A08,+ 0x3EAF32A0, 0x5BC88E18, 0xB5673B0A, 0xD00087B2,+ 0x6938502F, 0x0C5FEC97, 0xE2F05985, 0x8797E53D,+ 0xD1878665, 0xB4E03ADD, 0x5A4F8FCF, 0x3F283377,+ 0x8610E4EA, 0xE3775852, 0x0DD8ED40, 0x68BF51F8,+ 0xA1F82BF0, 0xC49F9748, 0x2A30225A, 0x4F579EE2,+ 0xF66F497F, 0x9308F5C7, 0x7DA740D5, 0x18C0FC6D,+ 0x4ED09F35, 0x2BB7238D, 0xC518969F, 0xA07F2A27,+ 0x1947FDBA, 0x7C204102, 0x928FF410, 0xF7E848A8,+ 0x3D58149B, 0x583FA823, 0xB6901D31, 0xD3F7A189,+ 0x6ACF7614, 0x0FA8CAAC, 0xE1077FBE, 0x8460C306,+ 0xD270A05E, 0xB7171CE6, 0x59B8A9F4, 0x3CDF154C,+ 0x85E7C2D1, 0xE0807E69, 0x0E2FCB7B, 0x6B4877C3,+ 0xA20F0DCB, 0xC768B173, 0x29C70461, 0x4CA0B8D9,+ 0xF5986F44, 0x90FFD3FC, 0x7E5066EE, 0x1B37DA56,+ 0x4D27B90E, 0x284005B6, 0xC6EFB0A4, 0xA3880C1C,+ 0x1AB0DB81, 0x7FD76739, 0x9178D22B, 0xF41F6E93,+ 0x03F7263B, 0x66909A83, 0x883F2F91, 0xED589329,+ 0x546044B4, 0x3107F80C, 0xDFA84D1E, 0xBACFF1A6,+ 0xECDF92FE, 0x89B82E46, 0x67179B54, 0x027027EC,+ 0xBB48F071, 0xDE2F4CC9, 0x3080F9DB, 0x55E74563,+ 0x9CA03F6B, 0xF9C783D3, 0x176836C1, 0x720F8A79,+ 0xCB375DE4, 0xAE50E15C, 0x40FF544E, 0x2598E8F6,+ 0x73888BAE, 0x16EF3716, 0xF8408204, 0x9D273EBC,+ 0x241FE921, 0x41785599, 0xAFD7E08B, 0xCAB05C33,+ 0x3BB659ED, 0x5ED1E555, 0xB07E5047, 0xD519ECFF,+ 0x6C213B62, 0x094687DA, 0xE7E932C8, 0x828E8E70,+ 0xD49EED28, 0xB1F95190, 0x5F56E482, 0x3A31583A,+ 0x83098FA7, 0xE66E331F, 0x08C1860D, 0x6DA63AB5,+ 0xA4E140BD, 0xC186FC05, 0x2F294917, 0x4A4EF5AF,+ 0xF3762232, 0x96119E8A, 0x78BE2B98, 0x1DD99720,+ 0x4BC9F478, 0x2EAE48C0, 0xC001FDD2, 0xA566416A,+ 0x1C5E96F7, 0x79392A4F, 0x97969F5D, 0xF2F123E5,+ 0x05196B4D, 0x607ED7F5, 0x8ED162E7, 0xEBB6DE5F,+ 0x528E09C2, 0x37E9B57A, 0xD9460068, 0xBC21BCD0,+ 0xEA31DF88, 0x8F566330, 0x61F9D622, 0x049E6A9A,+ 0xBDA6BD07, 0xD8C101BF, 0x366EB4AD, 0x53090815,+ 0x9A4E721D, 0xFF29CEA5, 0x11867BB7, 0x74E1C70F,+ 0xCDD91092, 0xA8BEAC2A, 0x46111938, 0x2376A580,+ 0x7566C6D8, 0x10017A60, 0xFEAECF72, 0x9BC973CA,+ 0x22F1A457, 0x479618EF, 0xA939ADFD, 0xCC5E1145,+ 0x06EE4D76, 0x6389F1CE, 0x8D2644DC, 0xE841F864,+ 0x51792FF9, 0x341E9341, 0xDAB12653, 0xBFD69AEB,+ 0xE9C6F9B3, 0x8CA1450B, 0x620EF019, 0x07694CA1,+ 0xBE519B3C, 0xDB362784, 0x35999296, 0x50FE2E2E,+ 0x99B95426, 0xFCDEE89E, 0x12715D8C, 0x7716E134,+ 0xCE2E36A9, 0xAB498A11, 0x45E63F03, 0x208183BB,+ 0x7691E0E3, 0x13F65C5B, 0xFD59E949, 0x983E55F1,+ 0x2106826C, 0x44613ED4, 0xAACE8BC6, 0xCFA9377E,+ 0x38417FD6, 0x5D26C36E, 0xB389767C, 0xD6EECAC4,+ 0x6FD61D59, 0x0AB1A1E1, 0xE41E14F3, 0x8179A84B,+ 0xD769CB13, 0xB20E77AB, 0x5CA1C2B9, 0x39C67E01,+ 0x80FEA99C, 0xE5991524, 0x0B36A036, 0x6E511C8E,+ 0xA7166686, 0xC271DA3E, 0x2CDE6F2C, 0x49B9D394,+ 0xF0810409, 0x95E6B8B1, 0x7B490DA3, 0x1E2EB11B,+ 0x483ED243, 0x2D596EFB, 0xC3F6DBE9, 0xA6916751,+ 0x1FA9B0CC, 0x7ACE0C74, 0x9461B966, 0xF10605DE+ }, {+ 0x00000000, 0xB029603D, 0x6053C07A, 0xD07AA047,+ 0xC0A680F5, 0x708FE0C8, 0xA0F5408F, 0x10DC20B2,+ 0xC14B7030, 0x7162100D, 0xA118B04A, 0x1131D077,+ 0x01EDF0C5, 0xB1C490F8, 0x61BE30BF, 0xD1975082,+ 0x8297E060, 0x32BE805D, 0xE2C4201A, 0x52ED4027,+ 0x42316095, 0xF21800A8, 0x2262A0EF, 0x924BC0D2,+ 0x43DC9050, 0xF3F5F06D, 0x238F502A, 0x93A63017,+ 0x837A10A5, 0x33537098, 0xE329D0DF, 0x5300B0E2,+ 0x042FC1C1, 0xB406A1FC, 0x647C01BB, 0xD4556186,+ 0xC4894134, 0x74A02109, 0xA4DA814E, 0x14F3E173,+ 0xC564B1F1, 0x754DD1CC, 0xA537718B, 0x151E11B6,+ 0x05C23104, 0xB5EB5139, 0x6591F17E, 0xD5B89143,+ 0x86B821A1, 0x3691419C, 0xE6EBE1DB, 0x56C281E6,+ 0x461EA154, 0xF637C169, 0x264D612E, 0x96640113,+ 0x47F35191, 0xF7DA31AC, 0x27A091EB, 0x9789F1D6,+ 0x8755D164, 0x377CB159, 0xE706111E, 0x572F7123,+ 0x4958F358, 0xF9719365, 0x290B3322, 0x9922531F,+ 0x89FE73AD, 0x39D71390, 0xE9ADB3D7, 0x5984D3EA,+ 0x88138368, 0x383AE355, 0xE8404312, 0x5869232F,+ 0x48B5039D, 0xF89C63A0, 0x28E6C3E7, 0x98CFA3DA,+ 0xCBCF1338, 0x7BE67305, 0xAB9CD342, 0x1BB5B37F,+ 0x0B6993CD, 0xBB40F3F0, 0x6B3A53B7, 0xDB13338A,+ 0x0A846308, 0xBAAD0335, 0x6AD7A372, 0xDAFEC34F,+ 0xCA22E3FD, 0x7A0B83C0, 0xAA712387, 0x1A5843BA,+ 0x4D773299, 0xFD5E52A4, 0x2D24F2E3, 0x9D0D92DE,+ 0x8DD1B26C, 0x3DF8D251, 0xED827216, 0x5DAB122B,+ 0x8C3C42A9, 0x3C152294, 0xEC6F82D3, 0x5C46E2EE,+ 0x4C9AC25C, 0xFCB3A261, 0x2CC90226, 0x9CE0621B,+ 0xCFE0D2F9, 0x7FC9B2C4, 0xAFB31283, 0x1F9A72BE,+ 0x0F46520C, 0xBF6F3231, 0x6F159276, 0xDF3CF24B,+ 0x0EABA2C9, 0xBE82C2F4, 0x6EF862B3, 0xDED1028E,+ 0xCE0D223C, 0x7E244201, 0xAE5EE246, 0x1E77827B,+ 0x92B0E6B1, 0x2299868C, 0xF2E326CB, 0x42CA46F6,+ 0x52166644, 0xE23F0679, 0x3245A63E, 0x826CC603,+ 0x53FB9681, 0xE3D2F6BC, 0x33A856FB, 0x838136C6,+ 0x935D1674, 0x23747649, 0xF30ED60E, 0x4327B633,+ 0x102706D1, 0xA00E66EC, 0x7074C6AB, 0xC05DA696,+ 0xD0818624, 0x60A8E619, 0xB0D2465E, 0x00FB2663,+ 0xD16C76E1, 0x614516DC, 0xB13FB69B, 0x0116D6A6,+ 0x11CAF614, 0xA1E39629, 0x7199366E, 0xC1B05653,+ 0x969F2770, 0x26B6474D, 0xF6CCE70A, 0x46E58737,+ 0x5639A785, 0xE610C7B8, 0x366A67FF, 0x864307C2,+ 0x57D45740, 0xE7FD377D, 0x3787973A, 0x87AEF707,+ 0x9772D7B5, 0x275BB788, 0xF72117CF, 0x470877F2,+ 0x1408C710, 0xA421A72D, 0x745B076A, 0xC4726757,+ 0xD4AE47E5, 0x648727D8, 0xB4FD879F, 0x04D4E7A2,+ 0xD543B720, 0x656AD71D, 0xB510775A, 0x05391767,+ 0x15E537D5, 0xA5CC57E8, 0x75B6F7AF, 0xC59F9792,+ 0xDBE815E9, 0x6BC175D4, 0xBBBBD593, 0x0B92B5AE,+ 0x1B4E951C, 0xAB67F521, 0x7B1D5566, 0xCB34355B,+ 0x1AA365D9, 0xAA8A05E4, 0x7AF0A5A3, 0xCAD9C59E,+ 0xDA05E52C, 0x6A2C8511, 0xBA562556, 0x0A7F456B,+ 0x597FF589, 0xE95695B4, 0x392C35F3, 0x890555CE,+ 0x99D9757C, 0x29F01541, 0xF98AB506, 0x49A3D53B,+ 0x983485B9, 0x281DE584, 0xF86745C3, 0x484E25FE,+ 0x5892054C, 0xE8BB6571, 0x38C1C536, 0x88E8A50B,+ 0xDFC7D428, 0x6FEEB415, 0xBF941452, 0x0FBD746F,+ 0x1F6154DD, 0xAF4834E0, 0x7F3294A7, 0xCF1BF49A,+ 0x1E8CA418, 0xAEA5C425, 0x7EDF6462, 0xCEF6045F,+ 0xDE2A24ED, 0x6E0344D0, 0xBE79E497, 0x0E5084AA,+ 0x5D503448, 0xED795475, 0x3D03F432, 0x8D2A940F,+ 0x9DF6B4BD, 0x2DDFD480, 0xFDA574C7, 0x4D8C14FA,+ 0x9C1B4478, 0x2C322445, 0xFC488402, 0x4C61E43F,+ 0x5CBDC48D, 0xEC94A4B0, 0x3CEE04F7, 0x8CC764CA+ }, {+ 0x00000000, 0xA5D35CCB, 0x0BA1C84D, 0xAE729486,+ 0x1642919B, 0xB391CD50, 0x1DE359D6, 0xB830051D,+ 0x6D8253EC, 0xC8510F27, 0x66239BA1, 0xC3F0C76A,+ 0x7BC0C277, 0xDE139EBC, 0x70610A3A, 0xD5B256F1,+ 0x9B02D603, 0x3ED18AC8, 0x90A31E4E, 0x35704285,+ 0x8D404798, 0x28931B53, 0x86E18FD5, 0x2332D31E,+ 0xF68085EF, 0x5353D924, 0xFD214DA2, 0x58F21169,+ 0xE0C21474, 0x451148BF, 0xEB63DC39, 0x4EB080F2,+ 0x3605AC07, 0x93D6F0CC, 0x3DA4644A, 0x98773881,+ 0x20473D9C, 0x85946157, 0x2BE6F5D1, 0x8E35A91A,+ 0x5B87FFEB, 0xFE54A320, 0x502637A6, 0xF5F56B6D,+ 0x4DC56E70, 0xE81632BB, 0x4664A63D, 0xE3B7FAF6,+ 0xAD077A04, 0x08D426CF, 0xA6A6B249, 0x0375EE82,+ 0xBB45EB9F, 0x1E96B754, 0xB0E423D2, 0x15377F19,+ 0xC08529E8, 0x65567523, 0xCB24E1A5, 0x6EF7BD6E,+ 0xD6C7B873, 0x7314E4B8, 0xDD66703E, 0x78B52CF5,+ 0x6C0A580F, 0xC9D904C4, 0x67AB9042, 0xC278CC89,+ 0x7A48C994, 0xDF9B955F, 0x71E901D9, 0xD43A5D12,+ 0x01880BE3, 0xA45B5728, 0x0A29C3AE, 0xAFFA9F65,+ 0x17CA9A78, 0xB219C6B3, 0x1C6B5235, 0xB9B80EFE,+ 0xF7088E0C, 0x52DBD2C7, 0xFCA94641, 0x597A1A8A,+ 0xE14A1F97, 0x4499435C, 0xEAEBD7DA, 0x4F388B11,+ 0x9A8ADDE0, 0x3F59812B, 0x912B15AD, 0x34F84966,+ 0x8CC84C7B, 0x291B10B0, 0x87698436, 0x22BAD8FD,+ 0x5A0FF408, 0xFFDCA8C3, 0x51AE3C45, 0xF47D608E,+ 0x4C4D6593, 0xE99E3958, 0x47ECADDE, 0xE23FF115,+ 0x378DA7E4, 0x925EFB2F, 0x3C2C6FA9, 0x99FF3362,+ 0x21CF367F, 0x841C6AB4, 0x2A6EFE32, 0x8FBDA2F9,+ 0xC10D220B, 0x64DE7EC0, 0xCAACEA46, 0x6F7FB68D,+ 0xD74FB390, 0x729CEF5B, 0xDCEE7BDD, 0x793D2716,+ 0xAC8F71E7, 0x095C2D2C, 0xA72EB9AA, 0x02FDE561,+ 0xBACDE07C, 0x1F1EBCB7, 0xB16C2831, 0x14BF74FA,+ 0xD814B01E, 0x7DC7ECD5, 0xD3B57853, 0x76662498,+ 0xCE562185, 0x6B857D4E, 0xC5F7E9C8, 0x6024B503,+ 0xB596E3F2, 0x1045BF39, 0xBE372BBF, 0x1BE47774,+ 0xA3D47269, 0x06072EA2, 0xA875BA24, 0x0DA6E6EF,+ 0x4316661D, 0xE6C53AD6, 0x48B7AE50, 0xED64F29B,+ 0x5554F786, 0xF087AB4D, 0x5EF53FCB, 0xFB266300,+ 0x2E9435F1, 0x8B47693A, 0x2535FDBC, 0x80E6A177,+ 0x38D6A46A, 0x9D05F8A1, 0x33776C27, 0x96A430EC,+ 0xEE111C19, 0x4BC240D2, 0xE5B0D454, 0x4063889F,+ 0xF8538D82, 0x5D80D149, 0xF3F245CF, 0x56211904,+ 0x83934FF5, 0x2640133E, 0x883287B8, 0x2DE1DB73,+ 0x95D1DE6E, 0x300282A5, 0x9E701623, 0x3BA34AE8,+ 0x7513CA1A, 0xD0C096D1, 0x7EB20257, 0xDB615E9C,+ 0x63515B81, 0xC682074A, 0x68F093CC, 0xCD23CF07,+ 0x189199F6, 0xBD42C53D, 0x133051BB, 0xB6E30D70,+ 0x0ED3086D, 0xAB0054A6, 0x0572C020, 0xA0A19CEB,+ 0xB41EE811, 0x11CDB4DA, 0xBFBF205C, 0x1A6C7C97,+ 0xA25C798A, 0x078F2541, 0xA9FDB1C7, 0x0C2EED0C,+ 0xD99CBBFD, 0x7C4FE736, 0xD23D73B0, 0x77EE2F7B,+ 0xCFDE2A66, 0x6A0D76AD, 0xC47FE22B, 0x61ACBEE0,+ 0x2F1C3E12, 0x8ACF62D9, 0x24BDF65F, 0x816EAA94,+ 0x395EAF89, 0x9C8DF342, 0x32FF67C4, 0x972C3B0F,+ 0x429E6DFE, 0xE74D3135, 0x493FA5B3, 0xECECF978,+ 0x54DCFC65, 0xF10FA0AE, 0x5F7D3428, 0xFAAE68E3,+ 0x821B4416, 0x27C818DD, 0x89BA8C5B, 0x2C69D090,+ 0x9459D58D, 0x318A8946, 0x9FF81DC0, 0x3A2B410B,+ 0xEF9917FA, 0x4A4A4B31, 0xE438DFB7, 0x41EB837C,+ 0xF9DB8661, 0x5C08DAAA, 0xF27A4E2C, 0x57A912E7,+ 0x19199215, 0xBCCACEDE, 0x12B85A58, 0xB76B0693,+ 0x0F5B038E, 0xAA885F45, 0x04FACBC3, 0xA1299708,+ 0x749BC1F9, 0xD1489D32, 0x7F3A09B4, 0xDAE9557F,+ 0x62D95062, 0xC70A0CA9, 0x6978982F, 0xCCABC4E4+ }, {+ 0x00000000, 0xB40B77A6, 0x29119F97, 0x9D1AE831,+ 0x13244FF4, 0xA72F3852, 0x3A35D063, 0x8E3EA7C5,+ 0x674EEF33, 0xD3459895, 0x4E5F70A4, 0xFA540702,+ 0x746AA0C7, 0xC061D761, 0x5D7B3F50, 0xE97048F6,+ 0xCE9CDE67, 0x7A97A9C1, 0xE78D41F0, 0x53863656,+ 0xDDB89193, 0x69B3E635, 0xF4A90E04, 0x40A279A2,+ 0xA9D23154, 0x1DD946F2, 0x80C3AEC3, 0x34C8D965,+ 0xBAF67EA0, 0x0EFD0906, 0x93E7E137, 0x27EC9691,+ 0x9C39BDCF, 0x2832CA69, 0xB5282258, 0x012355FE,+ 0x8F1DF23B, 0x3B16859D, 0xA60C6DAC, 0x12071A0A,+ 0xFB7752FC, 0x4F7C255A, 0xD266CD6B, 0x666DBACD,+ 0xE8531D08, 0x5C586AAE, 0xC142829F, 0x7549F539,+ 0x52A563A8, 0xE6AE140E, 0x7BB4FC3F, 0xCFBF8B99,+ 0x41812C5C, 0xF58A5BFA, 0x6890B3CB, 0xDC9BC46D,+ 0x35EB8C9B, 0x81E0FB3D, 0x1CFA130C, 0xA8F164AA,+ 0x26CFC36F, 0x92C4B4C9, 0x0FDE5CF8, 0xBBD52B5E,+ 0x79750B44, 0xCD7E7CE2, 0x506494D3, 0xE46FE375,+ 0x6A5144B0, 0xDE5A3316, 0x4340DB27, 0xF74BAC81,+ 0x1E3BE477, 0xAA3093D1, 0x372A7BE0, 0x83210C46,+ 0x0D1FAB83, 0xB914DC25, 0x240E3414, 0x900543B2,+ 0xB7E9D523, 0x03E2A285, 0x9EF84AB4, 0x2AF33D12,+ 0xA4CD9AD7, 0x10C6ED71, 0x8DDC0540, 0x39D772E6,+ 0xD0A73A10, 0x64AC4DB6, 0xF9B6A587, 0x4DBDD221,+ 0xC38375E4, 0x77880242, 0xEA92EA73, 0x5E999DD5,+ 0xE54CB68B, 0x5147C12D, 0xCC5D291C, 0x78565EBA,+ 0xF668F97F, 0x42638ED9, 0xDF7966E8, 0x6B72114E,+ 0x820259B8, 0x36092E1E, 0xAB13C62F, 0x1F18B189,+ 0x9126164C, 0x252D61EA, 0xB83789DB, 0x0C3CFE7D,+ 0x2BD068EC, 0x9FDB1F4A, 0x02C1F77B, 0xB6CA80DD,+ 0x38F42718, 0x8CFF50BE, 0x11E5B88F, 0xA5EECF29,+ 0x4C9E87DF, 0xF895F079, 0x658F1848, 0xD1846FEE,+ 0x5FBAC82B, 0xEBB1BF8D, 0x76AB57BC, 0xC2A0201A,+ 0xF2EA1688, 0x46E1612E, 0xDBFB891F, 0x6FF0FEB9,+ 0xE1CE597C, 0x55C52EDA, 0xC8DFC6EB, 0x7CD4B14D,+ 0x95A4F9BB, 0x21AF8E1D, 0xBCB5662C, 0x08BE118A,+ 0x8680B64F, 0x328BC1E9, 0xAF9129D8, 0x1B9A5E7E,+ 0x3C76C8EF, 0x887DBF49, 0x15675778, 0xA16C20DE,+ 0x2F52871B, 0x9B59F0BD, 0x0643188C, 0xB2486F2A,+ 0x5B3827DC, 0xEF33507A, 0x7229B84B, 0xC622CFED,+ 0x481C6828, 0xFC171F8E, 0x610DF7BF, 0xD5068019,+ 0x6ED3AB47, 0xDAD8DCE1, 0x47C234D0, 0xF3C94376,+ 0x7DF7E4B3, 0xC9FC9315, 0x54E67B24, 0xE0ED0C82,+ 0x099D4474, 0xBD9633D2, 0x208CDBE3, 0x9487AC45,+ 0x1AB90B80, 0xAEB27C26, 0x33A89417, 0x87A3E3B1,+ 0xA04F7520, 0x14440286, 0x895EEAB7, 0x3D559D11,+ 0xB36B3AD4, 0x07604D72, 0x9A7AA543, 0x2E71D2E5,+ 0xC7019A13, 0x730AEDB5, 0xEE100584, 0x5A1B7222,+ 0xD425D5E7, 0x602EA241, 0xFD344A70, 0x493F3DD6,+ 0x8B9F1DCC, 0x3F946A6A, 0xA28E825B, 0x1685F5FD,+ 0x98BB5238, 0x2CB0259E, 0xB1AACDAF, 0x05A1BA09,+ 0xECD1F2FF, 0x58DA8559, 0xC5C06D68, 0x71CB1ACE,+ 0xFFF5BD0B, 0x4BFECAAD, 0xD6E4229C, 0x62EF553A,+ 0x4503C3AB, 0xF108B40D, 0x6C125C3C, 0xD8192B9A,+ 0x56278C5F, 0xE22CFBF9, 0x7F3613C8, 0xCB3D646E,+ 0x224D2C98, 0x96465B3E, 0x0B5CB30F, 0xBF57C4A9,+ 0x3169636C, 0x856214CA, 0x1878FCFB, 0xAC738B5D,+ 0x17A6A003, 0xA3ADD7A5, 0x3EB73F94, 0x8ABC4832,+ 0x0482EFF7, 0xB0899851, 0x2D937060, 0x999807C6,+ 0x70E84F30, 0xC4E33896, 0x59F9D0A7, 0xEDF2A701,+ 0x63CC00C4, 0xD7C77762, 0x4ADD9F53, 0xFED6E8F5,+ 0xD93A7E64, 0x6D3109C2, 0xF02BE1F3, 0x44209655,+ 0xCA1E3190, 0x7E154636, 0xE30FAE07, 0x5704D9A1,+ 0xBE749157, 0x0A7FE6F1, 0x97650EC0, 0x236E7966,+ 0xAD50DEA3, 0x195BA905, 0x84414134, 0x304A3692+ }, {+ 0x00000000, 0x9E00AACC, 0x7D072542, 0xE3078F8E,+ 0xFA0E4A84, 0x640EE048, 0x87096FC6, 0x1909C50A,+ 0xB51BE5D3, 0x2B1B4F1F, 0xC81CC091, 0x561C6A5D,+ 0x4F15AF57, 0xD115059B, 0x32128A15, 0xAC1220D9,+ 0x2B31BB7C, 0xB53111B0, 0x56369E3E, 0xC83634F2,+ 0xD13FF1F8, 0x4F3F5B34, 0xAC38D4BA, 0x32387E76,+ 0x9E2A5EAF, 0x002AF463, 0xE32D7BED, 0x7D2DD121,+ 0x6424142B, 0xFA24BEE7, 0x19233169, 0x87239BA5,+ 0x566276F9, 0xC862DC35, 0x2B6553BB, 0xB565F977,+ 0xAC6C3C7D, 0x326C96B1, 0xD16B193F, 0x4F6BB3F3,+ 0xE379932A, 0x7D7939E6, 0x9E7EB668, 0x007E1CA4,+ 0x1977D9AE, 0x87777362, 0x6470FCEC, 0xFA705620,+ 0x7D53CD85, 0xE3536749, 0x0054E8C7, 0x9E54420B,+ 0x875D8701, 0x195D2DCD, 0xFA5AA243, 0x645A088F,+ 0xC8482856, 0x5648829A, 0xB54F0D14, 0x2B4FA7D8,+ 0x324662D2, 0xAC46C81E, 0x4F414790, 0xD141ED5C,+ 0xEDC29D29, 0x73C237E5, 0x90C5B86B, 0x0EC512A7,+ 0x17CCD7AD, 0x89CC7D61, 0x6ACBF2EF, 0xF4CB5823,+ 0x58D978FA, 0xC6D9D236, 0x25DE5DB8, 0xBBDEF774,+ 0xA2D7327E, 0x3CD798B2, 0xDFD0173C, 0x41D0BDF0,+ 0xC6F32655, 0x58F38C99, 0xBBF40317, 0x25F4A9DB,+ 0x3CFD6CD1, 0xA2FDC61D, 0x41FA4993, 0xDFFAE35F,+ 0x73E8C386, 0xEDE8694A, 0x0EEFE6C4, 0x90EF4C08,+ 0x89E68902, 0x17E623CE, 0xF4E1AC40, 0x6AE1068C,+ 0xBBA0EBD0, 0x25A0411C, 0xC6A7CE92, 0x58A7645E,+ 0x41AEA154, 0xDFAE0B98, 0x3CA98416, 0xA2A92EDA,+ 0x0EBB0E03, 0x90BBA4CF, 0x73BC2B41, 0xEDBC818D,+ 0xF4B54487, 0x6AB5EE4B, 0x89B261C5, 0x17B2CB09,+ 0x909150AC, 0x0E91FA60, 0xED9675EE, 0x7396DF22,+ 0x6A9F1A28, 0xF49FB0E4, 0x17983F6A, 0x899895A6,+ 0x258AB57F, 0xBB8A1FB3, 0x588D903D, 0xC68D3AF1,+ 0xDF84FFFB, 0x41845537, 0xA283DAB9, 0x3C837075,+ 0xDA853B53, 0x4485919F, 0xA7821E11, 0x3982B4DD,+ 0x208B71D7, 0xBE8BDB1B, 0x5D8C5495, 0xC38CFE59,+ 0x6F9EDE80, 0xF19E744C, 0x1299FBC2, 0x8C99510E,+ 0x95909404, 0x0B903EC8, 0xE897B146, 0x76971B8A,+ 0xF1B4802F, 0x6FB42AE3, 0x8CB3A56D, 0x12B30FA1,+ 0x0BBACAAB, 0x95BA6067, 0x76BDEFE9, 0xE8BD4525,+ 0x44AF65FC, 0xDAAFCF30, 0x39A840BE, 0xA7A8EA72,+ 0xBEA12F78, 0x20A185B4, 0xC3A60A3A, 0x5DA6A0F6,+ 0x8CE74DAA, 0x12E7E766, 0xF1E068E8, 0x6FE0C224,+ 0x76E9072E, 0xE8E9ADE2, 0x0BEE226C, 0x95EE88A0,+ 0x39FCA879, 0xA7FC02B5, 0x44FB8D3B, 0xDAFB27F7,+ 0xC3F2E2FD, 0x5DF24831, 0xBEF5C7BF, 0x20F56D73,+ 0xA7D6F6D6, 0x39D65C1A, 0xDAD1D394, 0x44D17958,+ 0x5DD8BC52, 0xC3D8169E, 0x20DF9910, 0xBEDF33DC,+ 0x12CD1305, 0x8CCDB9C9, 0x6FCA3647, 0xF1CA9C8B,+ 0xE8C35981, 0x76C3F34D, 0x95C47CC3, 0x0BC4D60F,+ 0x3747A67A, 0xA9470CB6, 0x4A408338, 0xD44029F4,+ 0xCD49ECFE, 0x53494632, 0xB04EC9BC, 0x2E4E6370,+ 0x825C43A9, 0x1C5CE965, 0xFF5B66EB, 0x615BCC27,+ 0x7852092D, 0xE652A3E1, 0x05552C6F, 0x9B5586A3,+ 0x1C761D06, 0x8276B7CA, 0x61713844, 0xFF719288,+ 0xE6785782, 0x7878FD4E, 0x9B7F72C0, 0x057FD80C,+ 0xA96DF8D5, 0x376D5219, 0xD46ADD97, 0x4A6A775B,+ 0x5363B251, 0xCD63189D, 0x2E649713, 0xB0643DDF,+ 0x6125D083, 0xFF257A4F, 0x1C22F5C1, 0x82225F0D,+ 0x9B2B9A07, 0x052B30CB, 0xE62CBF45, 0x782C1589,+ 0xD43E3550, 0x4A3E9F9C, 0xA9391012, 0x3739BADE,+ 0x2E307FD4, 0xB030D518, 0x53375A96, 0xCD37F05A,+ 0x4A146BFF, 0xD414C133, 0x37134EBD, 0xA913E471,+ 0xB01A217B, 0x2E1A8BB7, 0xCD1D0439, 0x531DAEF5,+ 0xFF0F8E2C, 0x610F24E0, 0x8208AB6E, 0x1C0801A2,+ 0x0501C4A8, 0x9B016E64, 0x7806E1EA, 0xE6064B26+ }+};
+ cbits/liblzma/check/crc32_table_le.h view
@@ -0,0 +1,527 @@+// SPDX-License-Identifier: 0BSD++// This file has been generated by crc32_tablegen.c.++const uint32_t lzma_crc32_table[8][256] = {+ {+ 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,+ 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,+ 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,+ 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,+ 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,+ 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,+ 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,+ 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,+ 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,+ 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,+ 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,+ 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,+ 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,+ 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,+ 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,+ 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,+ 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,+ 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,+ 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,+ 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,+ 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,+ 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,+ 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,+ 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,+ 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,+ 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,+ 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,+ 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,+ 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,+ 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,+ 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,+ 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,+ 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,+ 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,+ 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,+ 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,+ 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,+ 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,+ 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,+ 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,+ 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,+ 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,+ 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,+ 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,+ 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,+ 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,+ 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,+ 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,+ 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,+ 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,+ 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,+ 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,+ 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,+ 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,+ 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,+ 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,+ 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,+ 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,+ 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,+ 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,+ 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,+ 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,+ 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,+ 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D+ }, {+ 0x00000000, 0x191B3141, 0x32366282, 0x2B2D53C3,+ 0x646CC504, 0x7D77F445, 0x565AA786, 0x4F4196C7,+ 0xC8D98A08, 0xD1C2BB49, 0xFAEFE88A, 0xE3F4D9CB,+ 0xACB54F0C, 0xB5AE7E4D, 0x9E832D8E, 0x87981CCF,+ 0x4AC21251, 0x53D92310, 0x78F470D3, 0x61EF4192,+ 0x2EAED755, 0x37B5E614, 0x1C98B5D7, 0x05838496,+ 0x821B9859, 0x9B00A918, 0xB02DFADB, 0xA936CB9A,+ 0xE6775D5D, 0xFF6C6C1C, 0xD4413FDF, 0xCD5A0E9E,+ 0x958424A2, 0x8C9F15E3, 0xA7B24620, 0xBEA97761,+ 0xF1E8E1A6, 0xE8F3D0E7, 0xC3DE8324, 0xDAC5B265,+ 0x5D5DAEAA, 0x44469FEB, 0x6F6BCC28, 0x7670FD69,+ 0x39316BAE, 0x202A5AEF, 0x0B07092C, 0x121C386D,+ 0xDF4636F3, 0xC65D07B2, 0xED705471, 0xF46B6530,+ 0xBB2AF3F7, 0xA231C2B6, 0x891C9175, 0x9007A034,+ 0x179FBCFB, 0x0E848DBA, 0x25A9DE79, 0x3CB2EF38,+ 0x73F379FF, 0x6AE848BE, 0x41C51B7D, 0x58DE2A3C,+ 0xF0794F05, 0xE9627E44, 0xC24F2D87, 0xDB541CC6,+ 0x94158A01, 0x8D0EBB40, 0xA623E883, 0xBF38D9C2,+ 0x38A0C50D, 0x21BBF44C, 0x0A96A78F, 0x138D96CE,+ 0x5CCC0009, 0x45D73148, 0x6EFA628B, 0x77E153CA,+ 0xBABB5D54, 0xA3A06C15, 0x888D3FD6, 0x91960E97,+ 0xDED79850, 0xC7CCA911, 0xECE1FAD2, 0xF5FACB93,+ 0x7262D75C, 0x6B79E61D, 0x4054B5DE, 0x594F849F,+ 0x160E1258, 0x0F152319, 0x243870DA, 0x3D23419B,+ 0x65FD6BA7, 0x7CE65AE6, 0x57CB0925, 0x4ED03864,+ 0x0191AEA3, 0x188A9FE2, 0x33A7CC21, 0x2ABCFD60,+ 0xAD24E1AF, 0xB43FD0EE, 0x9F12832D, 0x8609B26C,+ 0xC94824AB, 0xD05315EA, 0xFB7E4629, 0xE2657768,+ 0x2F3F79F6, 0x362448B7, 0x1D091B74, 0x04122A35,+ 0x4B53BCF2, 0x52488DB3, 0x7965DE70, 0x607EEF31,+ 0xE7E6F3FE, 0xFEFDC2BF, 0xD5D0917C, 0xCCCBA03D,+ 0x838A36FA, 0x9A9107BB, 0xB1BC5478, 0xA8A76539,+ 0x3B83984B, 0x2298A90A, 0x09B5FAC9, 0x10AECB88,+ 0x5FEF5D4F, 0x46F46C0E, 0x6DD93FCD, 0x74C20E8C,+ 0xF35A1243, 0xEA412302, 0xC16C70C1, 0xD8774180,+ 0x9736D747, 0x8E2DE606, 0xA500B5C5, 0xBC1B8484,+ 0x71418A1A, 0x685ABB5B, 0x4377E898, 0x5A6CD9D9,+ 0x152D4F1E, 0x0C367E5F, 0x271B2D9C, 0x3E001CDD,+ 0xB9980012, 0xA0833153, 0x8BAE6290, 0x92B553D1,+ 0xDDF4C516, 0xC4EFF457, 0xEFC2A794, 0xF6D996D5,+ 0xAE07BCE9, 0xB71C8DA8, 0x9C31DE6B, 0x852AEF2A,+ 0xCA6B79ED, 0xD37048AC, 0xF85D1B6F, 0xE1462A2E,+ 0x66DE36E1, 0x7FC507A0, 0x54E85463, 0x4DF36522,+ 0x02B2F3E5, 0x1BA9C2A4, 0x30849167, 0x299FA026,+ 0xE4C5AEB8, 0xFDDE9FF9, 0xD6F3CC3A, 0xCFE8FD7B,+ 0x80A96BBC, 0x99B25AFD, 0xB29F093E, 0xAB84387F,+ 0x2C1C24B0, 0x350715F1, 0x1E2A4632, 0x07317773,+ 0x4870E1B4, 0x516BD0F5, 0x7A468336, 0x635DB277,+ 0xCBFAD74E, 0xD2E1E60F, 0xF9CCB5CC, 0xE0D7848D,+ 0xAF96124A, 0xB68D230B, 0x9DA070C8, 0x84BB4189,+ 0x03235D46, 0x1A386C07, 0x31153FC4, 0x280E0E85,+ 0x674F9842, 0x7E54A903, 0x5579FAC0, 0x4C62CB81,+ 0x8138C51F, 0x9823F45E, 0xB30EA79D, 0xAA1596DC,+ 0xE554001B, 0xFC4F315A, 0xD7626299, 0xCE7953D8,+ 0x49E14F17, 0x50FA7E56, 0x7BD72D95, 0x62CC1CD4,+ 0x2D8D8A13, 0x3496BB52, 0x1FBBE891, 0x06A0D9D0,+ 0x5E7EF3EC, 0x4765C2AD, 0x6C48916E, 0x7553A02F,+ 0x3A1236E8, 0x230907A9, 0x0824546A, 0x113F652B,+ 0x96A779E4, 0x8FBC48A5, 0xA4911B66, 0xBD8A2A27,+ 0xF2CBBCE0, 0xEBD08DA1, 0xC0FDDE62, 0xD9E6EF23,+ 0x14BCE1BD, 0x0DA7D0FC, 0x268A833F, 0x3F91B27E,+ 0x70D024B9, 0x69CB15F8, 0x42E6463B, 0x5BFD777A,+ 0xDC656BB5, 0xC57E5AF4, 0xEE530937, 0xF7483876,+ 0xB809AEB1, 0xA1129FF0, 0x8A3FCC33, 0x9324FD72+ }, {+ 0x00000000, 0x01C26A37, 0x0384D46E, 0x0246BE59,+ 0x0709A8DC, 0x06CBC2EB, 0x048D7CB2, 0x054F1685,+ 0x0E1351B8, 0x0FD13B8F, 0x0D9785D6, 0x0C55EFE1,+ 0x091AF964, 0x08D89353, 0x0A9E2D0A, 0x0B5C473D,+ 0x1C26A370, 0x1DE4C947, 0x1FA2771E, 0x1E601D29,+ 0x1B2F0BAC, 0x1AED619B, 0x18ABDFC2, 0x1969B5F5,+ 0x1235F2C8, 0x13F798FF, 0x11B126A6, 0x10734C91,+ 0x153C5A14, 0x14FE3023, 0x16B88E7A, 0x177AE44D,+ 0x384D46E0, 0x398F2CD7, 0x3BC9928E, 0x3A0BF8B9,+ 0x3F44EE3C, 0x3E86840B, 0x3CC03A52, 0x3D025065,+ 0x365E1758, 0x379C7D6F, 0x35DAC336, 0x3418A901,+ 0x3157BF84, 0x3095D5B3, 0x32D36BEA, 0x331101DD,+ 0x246BE590, 0x25A98FA7, 0x27EF31FE, 0x262D5BC9,+ 0x23624D4C, 0x22A0277B, 0x20E69922, 0x2124F315,+ 0x2A78B428, 0x2BBADE1F, 0x29FC6046, 0x283E0A71,+ 0x2D711CF4, 0x2CB376C3, 0x2EF5C89A, 0x2F37A2AD,+ 0x709A8DC0, 0x7158E7F7, 0x731E59AE, 0x72DC3399,+ 0x7793251C, 0x76514F2B, 0x7417F172, 0x75D59B45,+ 0x7E89DC78, 0x7F4BB64F, 0x7D0D0816, 0x7CCF6221,+ 0x798074A4, 0x78421E93, 0x7A04A0CA, 0x7BC6CAFD,+ 0x6CBC2EB0, 0x6D7E4487, 0x6F38FADE, 0x6EFA90E9,+ 0x6BB5866C, 0x6A77EC5B, 0x68315202, 0x69F33835,+ 0x62AF7F08, 0x636D153F, 0x612BAB66, 0x60E9C151,+ 0x65A6D7D4, 0x6464BDE3, 0x662203BA, 0x67E0698D,+ 0x48D7CB20, 0x4915A117, 0x4B531F4E, 0x4A917579,+ 0x4FDE63FC, 0x4E1C09CB, 0x4C5AB792, 0x4D98DDA5,+ 0x46C49A98, 0x4706F0AF, 0x45404EF6, 0x448224C1,+ 0x41CD3244, 0x400F5873, 0x4249E62A, 0x438B8C1D,+ 0x54F16850, 0x55330267, 0x5775BC3E, 0x56B7D609,+ 0x53F8C08C, 0x523AAABB, 0x507C14E2, 0x51BE7ED5,+ 0x5AE239E8, 0x5B2053DF, 0x5966ED86, 0x58A487B1,+ 0x5DEB9134, 0x5C29FB03, 0x5E6F455A, 0x5FAD2F6D,+ 0xE1351B80, 0xE0F771B7, 0xE2B1CFEE, 0xE373A5D9,+ 0xE63CB35C, 0xE7FED96B, 0xE5B86732, 0xE47A0D05,+ 0xEF264A38, 0xEEE4200F, 0xECA29E56, 0xED60F461,+ 0xE82FE2E4, 0xE9ED88D3, 0xEBAB368A, 0xEA695CBD,+ 0xFD13B8F0, 0xFCD1D2C7, 0xFE976C9E, 0xFF5506A9,+ 0xFA1A102C, 0xFBD87A1B, 0xF99EC442, 0xF85CAE75,+ 0xF300E948, 0xF2C2837F, 0xF0843D26, 0xF1465711,+ 0xF4094194, 0xF5CB2BA3, 0xF78D95FA, 0xF64FFFCD,+ 0xD9785D60, 0xD8BA3757, 0xDAFC890E, 0xDB3EE339,+ 0xDE71F5BC, 0xDFB39F8B, 0xDDF521D2, 0xDC374BE5,+ 0xD76B0CD8, 0xD6A966EF, 0xD4EFD8B6, 0xD52DB281,+ 0xD062A404, 0xD1A0CE33, 0xD3E6706A, 0xD2241A5D,+ 0xC55EFE10, 0xC49C9427, 0xC6DA2A7E, 0xC7184049,+ 0xC25756CC, 0xC3953CFB, 0xC1D382A2, 0xC011E895,+ 0xCB4DAFA8, 0xCA8FC59F, 0xC8C97BC6, 0xC90B11F1,+ 0xCC440774, 0xCD866D43, 0xCFC0D31A, 0xCE02B92D,+ 0x91AF9640, 0x906DFC77, 0x922B422E, 0x93E92819,+ 0x96A63E9C, 0x976454AB, 0x9522EAF2, 0x94E080C5,+ 0x9FBCC7F8, 0x9E7EADCF, 0x9C381396, 0x9DFA79A1,+ 0x98B56F24, 0x99770513, 0x9B31BB4A, 0x9AF3D17D,+ 0x8D893530, 0x8C4B5F07, 0x8E0DE15E, 0x8FCF8B69,+ 0x8A809DEC, 0x8B42F7DB, 0x89044982, 0x88C623B5,+ 0x839A6488, 0x82580EBF, 0x801EB0E6, 0x81DCDAD1,+ 0x8493CC54, 0x8551A663, 0x8717183A, 0x86D5720D,+ 0xA9E2D0A0, 0xA820BA97, 0xAA6604CE, 0xABA46EF9,+ 0xAEEB787C, 0xAF29124B, 0xAD6FAC12, 0xACADC625,+ 0xA7F18118, 0xA633EB2F, 0xA4755576, 0xA5B73F41,+ 0xA0F829C4, 0xA13A43F3, 0xA37CFDAA, 0xA2BE979D,+ 0xB5C473D0, 0xB40619E7, 0xB640A7BE, 0xB782CD89,+ 0xB2CDDB0C, 0xB30FB13B, 0xB1490F62, 0xB08B6555,+ 0xBBD72268, 0xBA15485F, 0xB853F606, 0xB9919C31,+ 0xBCDE8AB4, 0xBD1CE083, 0xBF5A5EDA, 0xBE9834ED+ }, {+ 0x00000000, 0xB8BC6765, 0xAA09C88B, 0x12B5AFEE,+ 0x8F629757, 0x37DEF032, 0x256B5FDC, 0x9DD738B9,+ 0xC5B428EF, 0x7D084F8A, 0x6FBDE064, 0xD7018701,+ 0x4AD6BFB8, 0xF26AD8DD, 0xE0DF7733, 0x58631056,+ 0x5019579F, 0xE8A530FA, 0xFA109F14, 0x42ACF871,+ 0xDF7BC0C8, 0x67C7A7AD, 0x75720843, 0xCDCE6F26,+ 0x95AD7F70, 0x2D111815, 0x3FA4B7FB, 0x8718D09E,+ 0x1ACFE827, 0xA2738F42, 0xB0C620AC, 0x087A47C9,+ 0xA032AF3E, 0x188EC85B, 0x0A3B67B5, 0xB28700D0,+ 0x2F503869, 0x97EC5F0C, 0x8559F0E2, 0x3DE59787,+ 0x658687D1, 0xDD3AE0B4, 0xCF8F4F5A, 0x7733283F,+ 0xEAE41086, 0x525877E3, 0x40EDD80D, 0xF851BF68,+ 0xF02BF8A1, 0x48979FC4, 0x5A22302A, 0xE29E574F,+ 0x7F496FF6, 0xC7F50893, 0xD540A77D, 0x6DFCC018,+ 0x359FD04E, 0x8D23B72B, 0x9F9618C5, 0x272A7FA0,+ 0xBAFD4719, 0x0241207C, 0x10F48F92, 0xA848E8F7,+ 0x9B14583D, 0x23A83F58, 0x311D90B6, 0x89A1F7D3,+ 0x1476CF6A, 0xACCAA80F, 0xBE7F07E1, 0x06C36084,+ 0x5EA070D2, 0xE61C17B7, 0xF4A9B859, 0x4C15DF3C,+ 0xD1C2E785, 0x697E80E0, 0x7BCB2F0E, 0xC377486B,+ 0xCB0D0FA2, 0x73B168C7, 0x6104C729, 0xD9B8A04C,+ 0x446F98F5, 0xFCD3FF90, 0xEE66507E, 0x56DA371B,+ 0x0EB9274D, 0xB6054028, 0xA4B0EFC6, 0x1C0C88A3,+ 0x81DBB01A, 0x3967D77F, 0x2BD27891, 0x936E1FF4,+ 0x3B26F703, 0x839A9066, 0x912F3F88, 0x299358ED,+ 0xB4446054, 0x0CF80731, 0x1E4DA8DF, 0xA6F1CFBA,+ 0xFE92DFEC, 0x462EB889, 0x549B1767, 0xEC277002,+ 0x71F048BB, 0xC94C2FDE, 0xDBF98030, 0x6345E755,+ 0x6B3FA09C, 0xD383C7F9, 0xC1366817, 0x798A0F72,+ 0xE45D37CB, 0x5CE150AE, 0x4E54FF40, 0xF6E89825,+ 0xAE8B8873, 0x1637EF16, 0x048240F8, 0xBC3E279D,+ 0x21E91F24, 0x99557841, 0x8BE0D7AF, 0x335CB0CA,+ 0xED59B63B, 0x55E5D15E, 0x47507EB0, 0xFFEC19D5,+ 0x623B216C, 0xDA874609, 0xC832E9E7, 0x708E8E82,+ 0x28ED9ED4, 0x9051F9B1, 0x82E4565F, 0x3A58313A,+ 0xA78F0983, 0x1F336EE6, 0x0D86C108, 0xB53AA66D,+ 0xBD40E1A4, 0x05FC86C1, 0x1749292F, 0xAFF54E4A,+ 0x322276F3, 0x8A9E1196, 0x982BBE78, 0x2097D91D,+ 0x78F4C94B, 0xC048AE2E, 0xD2FD01C0, 0x6A4166A5,+ 0xF7965E1C, 0x4F2A3979, 0x5D9F9697, 0xE523F1F2,+ 0x4D6B1905, 0xF5D77E60, 0xE762D18E, 0x5FDEB6EB,+ 0xC2098E52, 0x7AB5E937, 0x680046D9, 0xD0BC21BC,+ 0x88DF31EA, 0x3063568F, 0x22D6F961, 0x9A6A9E04,+ 0x07BDA6BD, 0xBF01C1D8, 0xADB46E36, 0x15080953,+ 0x1D724E9A, 0xA5CE29FF, 0xB77B8611, 0x0FC7E174,+ 0x9210D9CD, 0x2AACBEA8, 0x38191146, 0x80A57623,+ 0xD8C66675, 0x607A0110, 0x72CFAEFE, 0xCA73C99B,+ 0x57A4F122, 0xEF189647, 0xFDAD39A9, 0x45115ECC,+ 0x764DEE06, 0xCEF18963, 0xDC44268D, 0x64F841E8,+ 0xF92F7951, 0x41931E34, 0x5326B1DA, 0xEB9AD6BF,+ 0xB3F9C6E9, 0x0B45A18C, 0x19F00E62, 0xA14C6907,+ 0x3C9B51BE, 0x842736DB, 0x96929935, 0x2E2EFE50,+ 0x2654B999, 0x9EE8DEFC, 0x8C5D7112, 0x34E11677,+ 0xA9362ECE, 0x118A49AB, 0x033FE645, 0xBB838120,+ 0xE3E09176, 0x5B5CF613, 0x49E959FD, 0xF1553E98,+ 0x6C820621, 0xD43E6144, 0xC68BCEAA, 0x7E37A9CF,+ 0xD67F4138, 0x6EC3265D, 0x7C7689B3, 0xC4CAEED6,+ 0x591DD66F, 0xE1A1B10A, 0xF3141EE4, 0x4BA87981,+ 0x13CB69D7, 0xAB770EB2, 0xB9C2A15C, 0x017EC639,+ 0x9CA9FE80, 0x241599E5, 0x36A0360B, 0x8E1C516E,+ 0x866616A7, 0x3EDA71C2, 0x2C6FDE2C, 0x94D3B949,+ 0x090481F0, 0xB1B8E695, 0xA30D497B, 0x1BB12E1E,+ 0x43D23E48, 0xFB6E592D, 0xE9DBF6C3, 0x516791A6,+ 0xCCB0A91F, 0x740CCE7A, 0x66B96194, 0xDE0506F1+ }, {+ 0x00000000, 0x3D6029B0, 0x7AC05360, 0x47A07AD0,+ 0xF580A6C0, 0xC8E08F70, 0x8F40F5A0, 0xB220DC10,+ 0x30704BC1, 0x0D106271, 0x4AB018A1, 0x77D03111,+ 0xC5F0ED01, 0xF890C4B1, 0xBF30BE61, 0x825097D1,+ 0x60E09782, 0x5D80BE32, 0x1A20C4E2, 0x2740ED52,+ 0x95603142, 0xA80018F2, 0xEFA06222, 0xD2C04B92,+ 0x5090DC43, 0x6DF0F5F3, 0x2A508F23, 0x1730A693,+ 0xA5107A83, 0x98705333, 0xDFD029E3, 0xE2B00053,+ 0xC1C12F04, 0xFCA106B4, 0xBB017C64, 0x866155D4,+ 0x344189C4, 0x0921A074, 0x4E81DAA4, 0x73E1F314,+ 0xF1B164C5, 0xCCD14D75, 0x8B7137A5, 0xB6111E15,+ 0x0431C205, 0x3951EBB5, 0x7EF19165, 0x4391B8D5,+ 0xA121B886, 0x9C419136, 0xDBE1EBE6, 0xE681C256,+ 0x54A11E46, 0x69C137F6, 0x2E614D26, 0x13016496,+ 0x9151F347, 0xAC31DAF7, 0xEB91A027, 0xD6F18997,+ 0x64D15587, 0x59B17C37, 0x1E1106E7, 0x23712F57,+ 0x58F35849, 0x659371F9, 0x22330B29, 0x1F532299,+ 0xAD73FE89, 0x9013D739, 0xD7B3ADE9, 0xEAD38459,+ 0x68831388, 0x55E33A38, 0x124340E8, 0x2F236958,+ 0x9D03B548, 0xA0639CF8, 0xE7C3E628, 0xDAA3CF98,+ 0x3813CFCB, 0x0573E67B, 0x42D39CAB, 0x7FB3B51B,+ 0xCD93690B, 0xF0F340BB, 0xB7533A6B, 0x8A3313DB,+ 0x0863840A, 0x3503ADBA, 0x72A3D76A, 0x4FC3FEDA,+ 0xFDE322CA, 0xC0830B7A, 0x872371AA, 0xBA43581A,+ 0x9932774D, 0xA4525EFD, 0xE3F2242D, 0xDE920D9D,+ 0x6CB2D18D, 0x51D2F83D, 0x167282ED, 0x2B12AB5D,+ 0xA9423C8C, 0x9422153C, 0xD3826FEC, 0xEEE2465C,+ 0x5CC29A4C, 0x61A2B3FC, 0x2602C92C, 0x1B62E09C,+ 0xF9D2E0CF, 0xC4B2C97F, 0x8312B3AF, 0xBE729A1F,+ 0x0C52460F, 0x31326FBF, 0x7692156F, 0x4BF23CDF,+ 0xC9A2AB0E, 0xF4C282BE, 0xB362F86E, 0x8E02D1DE,+ 0x3C220DCE, 0x0142247E, 0x46E25EAE, 0x7B82771E,+ 0xB1E6B092, 0x8C869922, 0xCB26E3F2, 0xF646CA42,+ 0x44661652, 0x79063FE2, 0x3EA64532, 0x03C66C82,+ 0x8196FB53, 0xBCF6D2E3, 0xFB56A833, 0xC6368183,+ 0x74165D93, 0x49767423, 0x0ED60EF3, 0x33B62743,+ 0xD1062710, 0xEC660EA0, 0xABC67470, 0x96A65DC0,+ 0x248681D0, 0x19E6A860, 0x5E46D2B0, 0x6326FB00,+ 0xE1766CD1, 0xDC164561, 0x9BB63FB1, 0xA6D61601,+ 0x14F6CA11, 0x2996E3A1, 0x6E369971, 0x5356B0C1,+ 0x70279F96, 0x4D47B626, 0x0AE7CCF6, 0x3787E546,+ 0x85A73956, 0xB8C710E6, 0xFF676A36, 0xC2074386,+ 0x4057D457, 0x7D37FDE7, 0x3A978737, 0x07F7AE87,+ 0xB5D77297, 0x88B75B27, 0xCF1721F7, 0xF2770847,+ 0x10C70814, 0x2DA721A4, 0x6A075B74, 0x576772C4,+ 0xE547AED4, 0xD8278764, 0x9F87FDB4, 0xA2E7D404,+ 0x20B743D5, 0x1DD76A65, 0x5A7710B5, 0x67173905,+ 0xD537E515, 0xE857CCA5, 0xAFF7B675, 0x92979FC5,+ 0xE915E8DB, 0xD475C16B, 0x93D5BBBB, 0xAEB5920B,+ 0x1C954E1B, 0x21F567AB, 0x66551D7B, 0x5B3534CB,+ 0xD965A31A, 0xE4058AAA, 0xA3A5F07A, 0x9EC5D9CA,+ 0x2CE505DA, 0x11852C6A, 0x562556BA, 0x6B457F0A,+ 0x89F57F59, 0xB49556E9, 0xF3352C39, 0xCE550589,+ 0x7C75D999, 0x4115F029, 0x06B58AF9, 0x3BD5A349,+ 0xB9853498, 0x84E51D28, 0xC34567F8, 0xFE254E48,+ 0x4C059258, 0x7165BBE8, 0x36C5C138, 0x0BA5E888,+ 0x28D4C7DF, 0x15B4EE6F, 0x521494BF, 0x6F74BD0F,+ 0xDD54611F, 0xE03448AF, 0xA794327F, 0x9AF41BCF,+ 0x18A48C1E, 0x25C4A5AE, 0x6264DF7E, 0x5F04F6CE,+ 0xED242ADE, 0xD044036E, 0x97E479BE, 0xAA84500E,+ 0x4834505D, 0x755479ED, 0x32F4033D, 0x0F942A8D,+ 0xBDB4F69D, 0x80D4DF2D, 0xC774A5FD, 0xFA148C4D,+ 0x78441B9C, 0x4524322C, 0x028448FC, 0x3FE4614C,+ 0x8DC4BD5C, 0xB0A494EC, 0xF704EE3C, 0xCA64C78C+ }, {+ 0x00000000, 0xCB5CD3A5, 0x4DC8A10B, 0x869472AE,+ 0x9B914216, 0x50CD91B3, 0xD659E31D, 0x1D0530B8,+ 0xEC53826D, 0x270F51C8, 0xA19B2366, 0x6AC7F0C3,+ 0x77C2C07B, 0xBC9E13DE, 0x3A0A6170, 0xF156B2D5,+ 0x03D6029B, 0xC88AD13E, 0x4E1EA390, 0x85427035,+ 0x9847408D, 0x531B9328, 0xD58FE186, 0x1ED33223,+ 0xEF8580F6, 0x24D95353, 0xA24D21FD, 0x6911F258,+ 0x7414C2E0, 0xBF481145, 0x39DC63EB, 0xF280B04E,+ 0x07AC0536, 0xCCF0D693, 0x4A64A43D, 0x81387798,+ 0x9C3D4720, 0x57619485, 0xD1F5E62B, 0x1AA9358E,+ 0xEBFF875B, 0x20A354FE, 0xA6372650, 0x6D6BF5F5,+ 0x706EC54D, 0xBB3216E8, 0x3DA66446, 0xF6FAB7E3,+ 0x047A07AD, 0xCF26D408, 0x49B2A6A6, 0x82EE7503,+ 0x9FEB45BB, 0x54B7961E, 0xD223E4B0, 0x197F3715,+ 0xE82985C0, 0x23755665, 0xA5E124CB, 0x6EBDF76E,+ 0x73B8C7D6, 0xB8E41473, 0x3E7066DD, 0xF52CB578,+ 0x0F580A6C, 0xC404D9C9, 0x4290AB67, 0x89CC78C2,+ 0x94C9487A, 0x5F959BDF, 0xD901E971, 0x125D3AD4,+ 0xE30B8801, 0x28575BA4, 0xAEC3290A, 0x659FFAAF,+ 0x789ACA17, 0xB3C619B2, 0x35526B1C, 0xFE0EB8B9,+ 0x0C8E08F7, 0xC7D2DB52, 0x4146A9FC, 0x8A1A7A59,+ 0x971F4AE1, 0x5C439944, 0xDAD7EBEA, 0x118B384F,+ 0xE0DD8A9A, 0x2B81593F, 0xAD152B91, 0x6649F834,+ 0x7B4CC88C, 0xB0101B29, 0x36846987, 0xFDD8BA22,+ 0x08F40F5A, 0xC3A8DCFF, 0x453CAE51, 0x8E607DF4,+ 0x93654D4C, 0x58399EE9, 0xDEADEC47, 0x15F13FE2,+ 0xE4A78D37, 0x2FFB5E92, 0xA96F2C3C, 0x6233FF99,+ 0x7F36CF21, 0xB46A1C84, 0x32FE6E2A, 0xF9A2BD8F,+ 0x0B220DC1, 0xC07EDE64, 0x46EAACCA, 0x8DB67F6F,+ 0x90B34FD7, 0x5BEF9C72, 0xDD7BEEDC, 0x16273D79,+ 0xE7718FAC, 0x2C2D5C09, 0xAAB92EA7, 0x61E5FD02,+ 0x7CE0CDBA, 0xB7BC1E1F, 0x31286CB1, 0xFA74BF14,+ 0x1EB014D8, 0xD5ECC77D, 0x5378B5D3, 0x98246676,+ 0x852156CE, 0x4E7D856B, 0xC8E9F7C5, 0x03B52460,+ 0xF2E396B5, 0x39BF4510, 0xBF2B37BE, 0x7477E41B,+ 0x6972D4A3, 0xA22E0706, 0x24BA75A8, 0xEFE6A60D,+ 0x1D661643, 0xD63AC5E6, 0x50AEB748, 0x9BF264ED,+ 0x86F75455, 0x4DAB87F0, 0xCB3FF55E, 0x006326FB,+ 0xF135942E, 0x3A69478B, 0xBCFD3525, 0x77A1E680,+ 0x6AA4D638, 0xA1F8059D, 0x276C7733, 0xEC30A496,+ 0x191C11EE, 0xD240C24B, 0x54D4B0E5, 0x9F886340,+ 0x828D53F8, 0x49D1805D, 0xCF45F2F3, 0x04192156,+ 0xF54F9383, 0x3E134026, 0xB8873288, 0x73DBE12D,+ 0x6EDED195, 0xA5820230, 0x2316709E, 0xE84AA33B,+ 0x1ACA1375, 0xD196C0D0, 0x5702B27E, 0x9C5E61DB,+ 0x815B5163, 0x4A0782C6, 0xCC93F068, 0x07CF23CD,+ 0xF6999118, 0x3DC542BD, 0xBB513013, 0x700DE3B6,+ 0x6D08D30E, 0xA65400AB, 0x20C07205, 0xEB9CA1A0,+ 0x11E81EB4, 0xDAB4CD11, 0x5C20BFBF, 0x977C6C1A,+ 0x8A795CA2, 0x41258F07, 0xC7B1FDA9, 0x0CED2E0C,+ 0xFDBB9CD9, 0x36E74F7C, 0xB0733DD2, 0x7B2FEE77,+ 0x662ADECF, 0xAD760D6A, 0x2BE27FC4, 0xE0BEAC61,+ 0x123E1C2F, 0xD962CF8A, 0x5FF6BD24, 0x94AA6E81,+ 0x89AF5E39, 0x42F38D9C, 0xC467FF32, 0x0F3B2C97,+ 0xFE6D9E42, 0x35314DE7, 0xB3A53F49, 0x78F9ECEC,+ 0x65FCDC54, 0xAEA00FF1, 0x28347D5F, 0xE368AEFA,+ 0x16441B82, 0xDD18C827, 0x5B8CBA89, 0x90D0692C,+ 0x8DD55994, 0x46898A31, 0xC01DF89F, 0x0B412B3A,+ 0xFA1799EF, 0x314B4A4A, 0xB7DF38E4, 0x7C83EB41,+ 0x6186DBF9, 0xAADA085C, 0x2C4E7AF2, 0xE712A957,+ 0x15921919, 0xDECECABC, 0x585AB812, 0x93066BB7,+ 0x8E035B0F, 0x455F88AA, 0xC3CBFA04, 0x089729A1,+ 0xF9C19B74, 0x329D48D1, 0xB4093A7F, 0x7F55E9DA,+ 0x6250D962, 0xA90C0AC7, 0x2F987869, 0xE4C4ABCC+ }, {+ 0x00000000, 0xA6770BB4, 0x979F1129, 0x31E81A9D,+ 0xF44F2413, 0x52382FA7, 0x63D0353A, 0xC5A73E8E,+ 0x33EF4E67, 0x959845D3, 0xA4705F4E, 0x020754FA,+ 0xC7A06A74, 0x61D761C0, 0x503F7B5D, 0xF64870E9,+ 0x67DE9CCE, 0xC1A9977A, 0xF0418DE7, 0x56368653,+ 0x9391B8DD, 0x35E6B369, 0x040EA9F4, 0xA279A240,+ 0x5431D2A9, 0xF246D91D, 0xC3AEC380, 0x65D9C834,+ 0xA07EF6BA, 0x0609FD0E, 0x37E1E793, 0x9196EC27,+ 0xCFBD399C, 0x69CA3228, 0x582228B5, 0xFE552301,+ 0x3BF21D8F, 0x9D85163B, 0xAC6D0CA6, 0x0A1A0712,+ 0xFC5277FB, 0x5A257C4F, 0x6BCD66D2, 0xCDBA6D66,+ 0x081D53E8, 0xAE6A585C, 0x9F8242C1, 0x39F54975,+ 0xA863A552, 0x0E14AEE6, 0x3FFCB47B, 0x998BBFCF,+ 0x5C2C8141, 0xFA5B8AF5, 0xCBB39068, 0x6DC49BDC,+ 0x9B8CEB35, 0x3DFBE081, 0x0C13FA1C, 0xAA64F1A8,+ 0x6FC3CF26, 0xC9B4C492, 0xF85CDE0F, 0x5E2BD5BB,+ 0x440B7579, 0xE27C7ECD, 0xD3946450, 0x75E36FE4,+ 0xB044516A, 0x16335ADE, 0x27DB4043, 0x81AC4BF7,+ 0x77E43B1E, 0xD19330AA, 0xE07B2A37, 0x460C2183,+ 0x83AB1F0D, 0x25DC14B9, 0x14340E24, 0xB2430590,+ 0x23D5E9B7, 0x85A2E203, 0xB44AF89E, 0x123DF32A,+ 0xD79ACDA4, 0x71EDC610, 0x4005DC8D, 0xE672D739,+ 0x103AA7D0, 0xB64DAC64, 0x87A5B6F9, 0x21D2BD4D,+ 0xE47583C3, 0x42028877, 0x73EA92EA, 0xD59D995E,+ 0x8BB64CE5, 0x2DC14751, 0x1C295DCC, 0xBA5E5678,+ 0x7FF968F6, 0xD98E6342, 0xE86679DF, 0x4E11726B,+ 0xB8590282, 0x1E2E0936, 0x2FC613AB, 0x89B1181F,+ 0x4C162691, 0xEA612D25, 0xDB8937B8, 0x7DFE3C0C,+ 0xEC68D02B, 0x4A1FDB9F, 0x7BF7C102, 0xDD80CAB6,+ 0x1827F438, 0xBE50FF8C, 0x8FB8E511, 0x29CFEEA5,+ 0xDF879E4C, 0x79F095F8, 0x48188F65, 0xEE6F84D1,+ 0x2BC8BA5F, 0x8DBFB1EB, 0xBC57AB76, 0x1A20A0C2,+ 0x8816EAF2, 0x2E61E146, 0x1F89FBDB, 0xB9FEF06F,+ 0x7C59CEE1, 0xDA2EC555, 0xEBC6DFC8, 0x4DB1D47C,+ 0xBBF9A495, 0x1D8EAF21, 0x2C66B5BC, 0x8A11BE08,+ 0x4FB68086, 0xE9C18B32, 0xD82991AF, 0x7E5E9A1B,+ 0xEFC8763C, 0x49BF7D88, 0x78576715, 0xDE206CA1,+ 0x1B87522F, 0xBDF0599B, 0x8C184306, 0x2A6F48B2,+ 0xDC27385B, 0x7A5033EF, 0x4BB82972, 0xEDCF22C6,+ 0x28681C48, 0x8E1F17FC, 0xBFF70D61, 0x198006D5,+ 0x47ABD36E, 0xE1DCD8DA, 0xD034C247, 0x7643C9F3,+ 0xB3E4F77D, 0x1593FCC9, 0x247BE654, 0x820CEDE0,+ 0x74449D09, 0xD23396BD, 0xE3DB8C20, 0x45AC8794,+ 0x800BB91A, 0x267CB2AE, 0x1794A833, 0xB1E3A387,+ 0x20754FA0, 0x86024414, 0xB7EA5E89, 0x119D553D,+ 0xD43A6BB3, 0x724D6007, 0x43A57A9A, 0xE5D2712E,+ 0x139A01C7, 0xB5ED0A73, 0x840510EE, 0x22721B5A,+ 0xE7D525D4, 0x41A22E60, 0x704A34FD, 0xD63D3F49,+ 0xCC1D9F8B, 0x6A6A943F, 0x5B828EA2, 0xFDF58516,+ 0x3852BB98, 0x9E25B02C, 0xAFCDAAB1, 0x09BAA105,+ 0xFFF2D1EC, 0x5985DA58, 0x686DC0C5, 0xCE1ACB71,+ 0x0BBDF5FF, 0xADCAFE4B, 0x9C22E4D6, 0x3A55EF62,+ 0xABC30345, 0x0DB408F1, 0x3C5C126C, 0x9A2B19D8,+ 0x5F8C2756, 0xF9FB2CE2, 0xC813367F, 0x6E643DCB,+ 0x982C4D22, 0x3E5B4696, 0x0FB35C0B, 0xA9C457BF,+ 0x6C636931, 0xCA146285, 0xFBFC7818, 0x5D8B73AC,+ 0x03A0A617, 0xA5D7ADA3, 0x943FB73E, 0x3248BC8A,+ 0xF7EF8204, 0x519889B0, 0x6070932D, 0xC6079899,+ 0x304FE870, 0x9638E3C4, 0xA7D0F959, 0x01A7F2ED,+ 0xC400CC63, 0x6277C7D7, 0x539FDD4A, 0xF5E8D6FE,+ 0x647E3AD9, 0xC209316D, 0xF3E12BF0, 0x55962044,+ 0x90311ECA, 0x3646157E, 0x07AE0FE3, 0xA1D90457,+ 0x579174BE, 0xF1E67F0A, 0xC00E6597, 0x66796E23,+ 0xA3DE50AD, 0x05A95B19, 0x34414184, 0x92364A30+ }, {+ 0x00000000, 0xCCAA009E, 0x4225077D, 0x8E8F07E3,+ 0x844A0EFA, 0x48E00E64, 0xC66F0987, 0x0AC50919,+ 0xD3E51BB5, 0x1F4F1B2B, 0x91C01CC8, 0x5D6A1C56,+ 0x57AF154F, 0x9B0515D1, 0x158A1232, 0xD92012AC,+ 0x7CBB312B, 0xB01131B5, 0x3E9E3656, 0xF23436C8,+ 0xF8F13FD1, 0x345B3F4F, 0xBAD438AC, 0x767E3832,+ 0xAF5E2A9E, 0x63F42A00, 0xED7B2DE3, 0x21D12D7D,+ 0x2B142464, 0xE7BE24FA, 0x69312319, 0xA59B2387,+ 0xF9766256, 0x35DC62C8, 0xBB53652B, 0x77F965B5,+ 0x7D3C6CAC, 0xB1966C32, 0x3F196BD1, 0xF3B36B4F,+ 0x2A9379E3, 0xE639797D, 0x68B67E9E, 0xA41C7E00,+ 0xAED97719, 0x62737787, 0xECFC7064, 0x205670FA,+ 0x85CD537D, 0x496753E3, 0xC7E85400, 0x0B42549E,+ 0x01875D87, 0xCD2D5D19, 0x43A25AFA, 0x8F085A64,+ 0x562848C8, 0x9A824856, 0x140D4FB5, 0xD8A74F2B,+ 0xD2624632, 0x1EC846AC, 0x9047414F, 0x5CED41D1,+ 0x299DC2ED, 0xE537C273, 0x6BB8C590, 0xA712C50E,+ 0xADD7CC17, 0x617DCC89, 0xEFF2CB6A, 0x2358CBF4,+ 0xFA78D958, 0x36D2D9C6, 0xB85DDE25, 0x74F7DEBB,+ 0x7E32D7A2, 0xB298D73C, 0x3C17D0DF, 0xF0BDD041,+ 0x5526F3C6, 0x998CF358, 0x1703F4BB, 0xDBA9F425,+ 0xD16CFD3C, 0x1DC6FDA2, 0x9349FA41, 0x5FE3FADF,+ 0x86C3E873, 0x4A69E8ED, 0xC4E6EF0E, 0x084CEF90,+ 0x0289E689, 0xCE23E617, 0x40ACE1F4, 0x8C06E16A,+ 0xD0EBA0BB, 0x1C41A025, 0x92CEA7C6, 0x5E64A758,+ 0x54A1AE41, 0x980BAEDF, 0x1684A93C, 0xDA2EA9A2,+ 0x030EBB0E, 0xCFA4BB90, 0x412BBC73, 0x8D81BCED,+ 0x8744B5F4, 0x4BEEB56A, 0xC561B289, 0x09CBB217,+ 0xAC509190, 0x60FA910E, 0xEE7596ED, 0x22DF9673,+ 0x281A9F6A, 0xE4B09FF4, 0x6A3F9817, 0xA6959889,+ 0x7FB58A25, 0xB31F8ABB, 0x3D908D58, 0xF13A8DC6,+ 0xFBFF84DF, 0x37558441, 0xB9DA83A2, 0x7570833C,+ 0x533B85DA, 0x9F918544, 0x111E82A7, 0xDDB48239,+ 0xD7718B20, 0x1BDB8BBE, 0x95548C5D, 0x59FE8CC3,+ 0x80DE9E6F, 0x4C749EF1, 0xC2FB9912, 0x0E51998C,+ 0x04949095, 0xC83E900B, 0x46B197E8, 0x8A1B9776,+ 0x2F80B4F1, 0xE32AB46F, 0x6DA5B38C, 0xA10FB312,+ 0xABCABA0B, 0x6760BA95, 0xE9EFBD76, 0x2545BDE8,+ 0xFC65AF44, 0x30CFAFDA, 0xBE40A839, 0x72EAA8A7,+ 0x782FA1BE, 0xB485A120, 0x3A0AA6C3, 0xF6A0A65D,+ 0xAA4DE78C, 0x66E7E712, 0xE868E0F1, 0x24C2E06F,+ 0x2E07E976, 0xE2ADE9E8, 0x6C22EE0B, 0xA088EE95,+ 0x79A8FC39, 0xB502FCA7, 0x3B8DFB44, 0xF727FBDA,+ 0xFDE2F2C3, 0x3148F25D, 0xBFC7F5BE, 0x736DF520,+ 0xD6F6D6A7, 0x1A5CD639, 0x94D3D1DA, 0x5879D144,+ 0x52BCD85D, 0x9E16D8C3, 0x1099DF20, 0xDC33DFBE,+ 0x0513CD12, 0xC9B9CD8C, 0x4736CA6F, 0x8B9CCAF1,+ 0x8159C3E8, 0x4DF3C376, 0xC37CC495, 0x0FD6C40B,+ 0x7AA64737, 0xB60C47A9, 0x3883404A, 0xF42940D4,+ 0xFEEC49CD, 0x32464953, 0xBCC94EB0, 0x70634E2E,+ 0xA9435C82, 0x65E95C1C, 0xEB665BFF, 0x27CC5B61,+ 0x2D095278, 0xE1A352E6, 0x6F2C5505, 0xA386559B,+ 0x061D761C, 0xCAB77682, 0x44387161, 0x889271FF,+ 0x825778E6, 0x4EFD7878, 0xC0727F9B, 0x0CD87F05,+ 0xD5F86DA9, 0x19526D37, 0x97DD6AD4, 0x5B776A4A,+ 0x51B26353, 0x9D1863CD, 0x1397642E, 0xDF3D64B0,+ 0x83D02561, 0x4F7A25FF, 0xC1F5221C, 0x0D5F2282,+ 0x079A2B9B, 0xCB302B05, 0x45BF2CE6, 0x89152C78,+ 0x50353ED4, 0x9C9F3E4A, 0x121039A9, 0xDEBA3937,+ 0xD47F302E, 0x18D530B0, 0x965A3753, 0x5AF037CD,+ 0xFF6B144A, 0x33C114D4, 0xBD4E1337, 0x71E413A9,+ 0x7B211AB0, 0xB78B1A2E, 0x39041DCD, 0xF5AE1D53,+ 0x2C8E0FFF, 0xE0240F61, 0x6EAB0882, 0xA201081C,+ 0xA8C40105, 0x646E019B, 0xEAE10678, 0x264B06E6+ }+};
+ cbits/liblzma/check/crc32_tablegen.c view
@@ -0,0 +1,120 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file crc32_tablegen.c+/// \brief Generate crc32_table_le.h and crc32_table_be.h+///+/// Compiling: gcc -std=c99 -o crc32_tablegen crc32_tablegen.c+/// Add -DWORDS_BIGENDIAN to generate big endian table.+/// Add -DLZ_HASH_TABLE to generate lz_encoder_hash_table.h (little endian).+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include <stdio.h>+#include "../../common/tuklib_integer.h"+++static uint32_t crc32_table[8][256];+++static void+init_crc32_table(void)+{+ static const uint32_t poly32 = UINT32_C(0xEDB88320);++ for (size_t s = 0; s < 8; ++s) {+ for (size_t b = 0; b < 256; ++b) {+ uint32_t r = s == 0 ? b : crc32_table[s - 1][b];++ for (size_t i = 0; i < 8; ++i) {+ if (r & 1)+ r = (r >> 1) ^ poly32;+ else+ r >>= 1;+ }++ crc32_table[s][b] = r;+ }+ }++#ifdef WORDS_BIGENDIAN+ for (size_t s = 0; s < 8; ++s)+ for (size_t b = 0; b < 256; ++b)+ crc32_table[s][b] = byteswap32(crc32_table[s][b]);+#endif++ return;+}+++static void+print_crc32_table(void)+{+ // Split the SPDX string so that it won't accidentally match+ // when tools search for the string.+ printf("// SPDX" "-License-Identifier" ": 0BSD\n\n"+ "// This file has been generated by crc32_tablegen.c.\n\n"+ "const uint32_t lzma_crc32_table[8][256] = {\n\t{");++ for (size_t s = 0; s < 8; ++s) {+ for (size_t b = 0; b < 256; ++b) {+ if ((b % 4) == 0)+ printf("\n\t\t");++ printf("0x%08" PRIX32, crc32_table[s][b]);++ if (b != 255)+ printf(",%s", (b+1) % 4 == 0 ? "" : " ");+ }++ if (s == 7)+ printf("\n\t}\n};\n");+ else+ printf("\n\t}, {");+ }++ return;+}+++static void+print_lz_table(void)+{+ // Split the SPDX string so that it won't accidentally match+ // when tools search for the string.+ printf("// SPDX" "-License-Identifier" ": 0BSD\n\n"+ "// This file has been generated by crc32_tablegen.c.\n\n"+ "const uint32_t lzma_lz_hash_table[256] = {");++ for (size_t b = 0; b < 256; ++b) {+ if ((b % 4) == 0)+ printf("\n\t");++ printf("0x%08" PRIX32, crc32_table[0][b]);++ if (b != 255)+ printf(",%s", (b+1) % 4 == 0 ? "" : " ");+ }++ printf("\n};\n");++ return;+}+++int+main(void)+{+ init_crc32_table();++#ifdef LZ_HASH_TABLE+ print_lz_table();+#else+ print_crc32_table();+#endif++ return 0;+}
+ cbits/liblzma/check/crc64_fast.c view
@@ -0,0 +1,156 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file crc64.c+/// \brief CRC64 calculation+//+// Authors: Lasse Collin+// Ilya Kurdyukov+//+///////////////////////////////////////////////////////////////////////////////++#include "check.h"+#include "crc_common.h"++#if defined(CRC_X86_CLMUL)+# define BUILDING_CRC64_CLMUL+# include "crc_x86_clmul.h"+#endif+++#ifdef CRC64_GENERIC++/////////////////////////////////+// Generic slice-by-four CRC64 //+/////////////////////////////////++#ifdef WORDS_BIGENDIAN+# define A1(x) ((x) >> 56)+#else+# define A1 A+#endif+++// See the comments in crc32_fast.c. They aren't duplicated here.+static uint64_t+crc64_generic(const uint8_t *buf, size_t size, uint64_t crc)+{+ crc = ~crc;++#ifdef WORDS_BIGENDIAN+ crc = byteswap64(crc);+#endif++ if (size > 4) {+ while ((uintptr_t)(buf) & 3) {+ crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);+ --size;+ }++ const uint8_t *const limit = buf + (size & ~(size_t)(3));+ size &= (size_t)(3);++ while (buf < limit) {+#ifdef WORDS_BIGENDIAN+ const uint32_t tmp = (uint32_t)(crc >> 32)+ ^ aligned_read32ne(buf);+#else+ const uint32_t tmp = (uint32_t)crc+ ^ aligned_read32ne(buf);+#endif+ buf += 4;++ crc = lzma_crc64_table[3][A(tmp)]+ ^ lzma_crc64_table[2][B(tmp)]+ ^ S32(crc)+ ^ lzma_crc64_table[1][C(tmp)]+ ^ lzma_crc64_table[0][D(tmp)];+ }+ }++ while (size-- != 0)+ crc = lzma_crc64_table[0][*buf++ ^ A1(crc)] ^ S8(crc);++#ifdef WORDS_BIGENDIAN+ crc = byteswap64(crc);+#endif++ return ~crc;+}+#endif+++#if defined(CRC64_GENERIC) && defined(CRC64_ARCH_OPTIMIZED)++//////////////////////////+// Function dispatching //+//////////////////////////++// If both the generic and arch-optimized implementations are usable, then+// the function that is used is selected at runtime. See crc32_fast.c.++typedef uint64_t (*crc64_func_type)(+ const uint8_t *buf, size_t size, uint64_t crc);++static crc64_func_type+crc64_resolve(void)+{+ return is_arch_extension_supported()+ ? &crc64_arch_optimized : &crc64_generic;+}++#ifdef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR+# define CRC64_SET_FUNC_ATTR __attribute__((__constructor__))+static crc64_func_type crc64_func;+#else+# define CRC64_SET_FUNC_ATTR+static uint64_t crc64_dispatch(const uint8_t *buf, size_t size, uint64_t crc);+static crc64_func_type crc64_func = &crc64_dispatch;+#endif+++CRC64_SET_FUNC_ATTR+static void+crc64_set_func(void)+{+ crc64_func = crc64_resolve();+ return;+}+++#ifndef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR+static uint64_t+crc64_dispatch(const uint8_t *buf, size_t size, uint64_t crc)+{+ crc64_set_func();+ return crc64_func(buf, size, crc);+}+#endif+#endif+++extern LZMA_API(uint64_t)+lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)+{+#if defined(CRC64_GENERIC) && defined(CRC64_ARCH_OPTIMIZED)++#ifdef CRC_USE_GENERIC_FOR_SMALL_INPUTS+ if (size <= 16)+ return crc64_generic(buf, size, crc);+#endif+ return crc64_func(buf, size, crc);++#elif defined(CRC64_ARCH_OPTIMIZED)+ // If arch-optimized version is used unconditionally without runtime+ // CPU detection then omitting the generic version and its 8 KiB+ // lookup table makes the library smaller.+ //+ // FIXME: Lookup table isn't currently omitted on 32-bit x86,+ // see crc64_table.c.+ return crc64_arch_optimized(buf, size, crc);++#else+ return crc64_generic(buf, size, crc);+#endif+}
+ cbits/liblzma/check/crc64_small.c view
@@ -0,0 +1,57 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file crc64_small.c+/// \brief CRC64 calculation (size-optimized)+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "check.h"+++static uint64_t crc64_table[256];+++#ifdef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR+__attribute__((__constructor__))+#endif+static void+crc64_init(void)+{+ static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42);++ for (size_t b = 0; b < 256; ++b) {+ uint64_t r = b;+ for (size_t i = 0; i < 8; ++i) {+ if (r & 1)+ r = (r >> 1) ^ poly64;+ else+ r >>= 1;+ }++ crc64_table[b] = r;+ }++ return;+}+++extern LZMA_API(uint64_t)+lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc)+{+#ifndef HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR+ mythread_once(crc64_init);+#endif++ crc = ~crc;++ while (size != 0) {+ crc = crc64_table[*buf++ ^ (crc & 0xFF)] ^ (crc >> 8);+ --size;+ }++ return ~crc;+}
+ cbits/liblzma/check/crc64_table.c view
@@ -0,0 +1,37 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file crc64_table.c+/// \brief Precalculated CRC64 table with correct endianness+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+++// FIXME: Compared to crc_common.h this has to check for __x86_64__ too+// so that in 32-bit builds crc64_x86.S won't break due to a missing table.+#if defined(HAVE_USABLE_CLMUL) && ((defined(__x86_64__) && defined(__SSSE3__) \+ && defined(__SSE4_1__) && defined(__PCLMUL__)) \+ || (defined(__e2k__) && __iset__ >= 6))+# define NO_CRC64_TABLE+#endif+++#ifdef NO_CRC64_TABLE+// No table needed. Use a typedef to avoid an empty translation unit.+typedef void lzma_crc64_dummy;++#else+// Having the declaration here silences clang -Wmissing-variable-declarations.+extern const uint64_t lzma_crc64_table[4][256];++# if defined(WORDS_BIGENDIAN)+# include "crc64_table_be.h"+# else+# include "crc64_table_le.h"+# endif+#endif
+ cbits/liblzma/check/crc64_table_be.h view
@@ -0,0 +1,523 @@+// SPDX-License-Identifier: 0BSD++// This file has been generated by crc64_tablegen.c.++const uint64_t lzma_crc64_table[4][256] = {+ {+ UINT64_C(0x0000000000000000), UINT64_C(0x6F5FA703BE4C2EB3),+ UINT64_C(0x5BA040A8573684F4), UINT64_C(0x34FFE7ABE97AAA47),+ UINT64_C(0x335E8FFF84C3D07B), UINT64_C(0x5C0128FC3A8FFEC8),+ UINT64_C(0x68FECF57D3F5548F), UINT64_C(0x07A168546DB97A3C),+ UINT64_C(0x66BC1EFF0987A1F7), UINT64_C(0x09E3B9FCB7CB8F44),+ UINT64_C(0x3D1C5E575EB12503), UINT64_C(0x5243F954E0FD0BB0),+ UINT64_C(0x55E291008D44718C), UINT64_C(0x3ABD360333085F3F),+ UINT64_C(0x0E42D1A8DA72F578), UINT64_C(0x611D76AB643EDBCB),+ UINT64_C(0x4966335138A19B7D), UINT64_C(0x2639945286EDB5CE),+ UINT64_C(0x12C673F96F971F89), UINT64_C(0x7D99D4FAD1DB313A),+ UINT64_C(0x7A38BCAEBC624B06), UINT64_C(0x15671BAD022E65B5),+ UINT64_C(0x2198FC06EB54CFF2), UINT64_C(0x4EC75B055518E141),+ UINT64_C(0x2FDA2DAE31263A8A), UINT64_C(0x40858AAD8F6A1439),+ UINT64_C(0x747A6D066610BE7E), UINT64_C(0x1B25CA05D85C90CD),+ UINT64_C(0x1C84A251B5E5EAF1), UINT64_C(0x73DB05520BA9C442),+ UINT64_C(0x4724E2F9E2D36E05), UINT64_C(0x287B45FA5C9F40B6),+ UINT64_C(0x92CC66A2704237FB), UINT64_C(0xFD93C1A1CE0E1948),+ UINT64_C(0xC96C260A2774B30F), UINT64_C(0xA633810999389DBC),+ UINT64_C(0xA192E95DF481E780), UINT64_C(0xCECD4E5E4ACDC933),+ UINT64_C(0xFA32A9F5A3B76374), UINT64_C(0x956D0EF61DFB4DC7),+ UINT64_C(0xF470785D79C5960C), UINT64_C(0x9B2FDF5EC789B8BF),+ UINT64_C(0xAFD038F52EF312F8), UINT64_C(0xC08F9FF690BF3C4B),+ UINT64_C(0xC72EF7A2FD064677), UINT64_C(0xA87150A1434A68C4),+ UINT64_C(0x9C8EB70AAA30C283), UINT64_C(0xF3D11009147CEC30),+ UINT64_C(0xDBAA55F348E3AC86), UINT64_C(0xB4F5F2F0F6AF8235),+ UINT64_C(0x800A155B1FD52872), UINT64_C(0xEF55B258A19906C1),+ UINT64_C(0xE8F4DA0CCC207CFD), UINT64_C(0x87AB7D0F726C524E),+ UINT64_C(0xB3549AA49B16F809), UINT64_C(0xDC0B3DA7255AD6BA),+ UINT64_C(0xBD164B0C41640D71), UINT64_C(0xD249EC0FFF2823C2),+ UINT64_C(0xE6B60BA416528985), UINT64_C(0x89E9ACA7A81EA736),+ UINT64_C(0x8E48C4F3C5A7DD0A), UINT64_C(0xE11763F07BEBF3B9),+ UINT64_C(0xD5E8845B929159FE), UINT64_C(0xBAB723582CDD774D),+ UINT64_C(0xA187C3EBCA2BB664), UINT64_C(0xCED864E8746798D7),+ UINT64_C(0xFA2783439D1D3290), UINT64_C(0x9578244023511C23),+ UINT64_C(0x92D94C144EE8661F), UINT64_C(0xFD86EB17F0A448AC),+ UINT64_C(0xC9790CBC19DEE2EB), UINT64_C(0xA626ABBFA792CC58),+ UINT64_C(0xC73BDD14C3AC1793), UINT64_C(0xA8647A177DE03920),+ UINT64_C(0x9C9B9DBC949A9367), UINT64_C(0xF3C43ABF2AD6BDD4),+ UINT64_C(0xF46552EB476FC7E8), UINT64_C(0x9B3AF5E8F923E95B),+ UINT64_C(0xAFC512431059431C), UINT64_C(0xC09AB540AE156DAF),+ UINT64_C(0xE8E1F0BAF28A2D19), UINT64_C(0x87BE57B94CC603AA),+ UINT64_C(0xB341B012A5BCA9ED), UINT64_C(0xDC1E17111BF0875E),+ UINT64_C(0xDBBF7F457649FD62), UINT64_C(0xB4E0D846C805D3D1),+ UINT64_C(0x801F3FED217F7996), UINT64_C(0xEF4098EE9F335725),+ UINT64_C(0x8E5DEE45FB0D8CEE), UINT64_C(0xE10249464541A25D),+ UINT64_C(0xD5FDAEEDAC3B081A), UINT64_C(0xBAA209EE127726A9),+ UINT64_C(0xBD0361BA7FCE5C95), UINT64_C(0xD25CC6B9C1827226),+ UINT64_C(0xE6A3211228F8D861), UINT64_C(0x89FC861196B4F6D2),+ UINT64_C(0x334BA549BA69819F), UINT64_C(0x5C14024A0425AF2C),+ UINT64_C(0x68EBE5E1ED5F056B), UINT64_C(0x07B442E253132BD8),+ UINT64_C(0x00152AB63EAA51E4), UINT64_C(0x6F4A8DB580E67F57),+ UINT64_C(0x5BB56A1E699CD510), UINT64_C(0x34EACD1DD7D0FBA3),+ UINT64_C(0x55F7BBB6B3EE2068), UINT64_C(0x3AA81CB50DA20EDB),+ UINT64_C(0x0E57FB1EE4D8A49C), UINT64_C(0x61085C1D5A948A2F),+ UINT64_C(0x66A93449372DF013), UINT64_C(0x09F6934A8961DEA0),+ UINT64_C(0x3D0974E1601B74E7), UINT64_C(0x5256D3E2DE575A54),+ UINT64_C(0x7A2D961882C81AE2), UINT64_C(0x1572311B3C843451),+ UINT64_C(0x218DD6B0D5FE9E16), UINT64_C(0x4ED271B36BB2B0A5),+ UINT64_C(0x497319E7060BCA99), UINT64_C(0x262CBEE4B847E42A),+ UINT64_C(0x12D3594F513D4E6D), UINT64_C(0x7D8CFE4CEF7160DE),+ UINT64_C(0x1C9188E78B4FBB15), UINT64_C(0x73CE2FE4350395A6),+ UINT64_C(0x4731C84FDC793FE1), UINT64_C(0x286E6F4C62351152),+ UINT64_C(0x2FCF07180F8C6B6E), UINT64_C(0x4090A01BB1C045DD),+ UINT64_C(0x746F47B058BAEF9A), UINT64_C(0x1B30E0B3E6F6C129),+ UINT64_C(0x420F87D795576CC9), UINT64_C(0x2D5020D42B1B427A),+ UINT64_C(0x19AFC77FC261E83D), UINT64_C(0x76F0607C7C2DC68E),+ UINT64_C(0x715108281194BCB2), UINT64_C(0x1E0EAF2BAFD89201),+ UINT64_C(0x2AF1488046A23846), UINT64_C(0x45AEEF83F8EE16F5),+ UINT64_C(0x24B399289CD0CD3E), UINT64_C(0x4BEC3E2B229CE38D),+ UINT64_C(0x7F13D980CBE649CA), UINT64_C(0x104C7E8375AA6779),+ UINT64_C(0x17ED16D718131D45), UINT64_C(0x78B2B1D4A65F33F6),+ UINT64_C(0x4C4D567F4F2599B1), UINT64_C(0x2312F17CF169B702),+ UINT64_C(0x0B69B486ADF6F7B4), UINT64_C(0x6436138513BAD907),+ UINT64_C(0x50C9F42EFAC07340), UINT64_C(0x3F96532D448C5DF3),+ UINT64_C(0x38373B79293527CF), UINT64_C(0x57689C7A9779097C),+ UINT64_C(0x63977BD17E03A33B), UINT64_C(0x0CC8DCD2C04F8D88),+ UINT64_C(0x6DD5AA79A4715643), UINT64_C(0x028A0D7A1A3D78F0),+ UINT64_C(0x3675EAD1F347D2B7), UINT64_C(0x592A4DD24D0BFC04),+ UINT64_C(0x5E8B258620B28638), UINT64_C(0x31D482859EFEA88B),+ UINT64_C(0x052B652E778402CC), UINT64_C(0x6A74C22DC9C82C7F),+ UINT64_C(0xD0C3E175E5155B32), UINT64_C(0xBF9C46765B597581),+ UINT64_C(0x8B63A1DDB223DFC6), UINT64_C(0xE43C06DE0C6FF175),+ UINT64_C(0xE39D6E8A61D68B49), UINT64_C(0x8CC2C989DF9AA5FA),+ UINT64_C(0xB83D2E2236E00FBD), UINT64_C(0xD762892188AC210E),+ UINT64_C(0xB67FFF8AEC92FAC5), UINT64_C(0xD920588952DED476),+ UINT64_C(0xEDDFBF22BBA47E31), UINT64_C(0x8280182105E85082),+ UINT64_C(0x8521707568512ABE), UINT64_C(0xEA7ED776D61D040D),+ UINT64_C(0xDE8130DD3F67AE4A), UINT64_C(0xB1DE97DE812B80F9),+ UINT64_C(0x99A5D224DDB4C04F), UINT64_C(0xF6FA752763F8EEFC),+ UINT64_C(0xC205928C8A8244BB), UINT64_C(0xAD5A358F34CE6A08),+ UINT64_C(0xAAFB5DDB59771034), UINT64_C(0xC5A4FAD8E73B3E87),+ UINT64_C(0xF15B1D730E4194C0), UINT64_C(0x9E04BA70B00DBA73),+ UINT64_C(0xFF19CCDBD43361B8), UINT64_C(0x90466BD86A7F4F0B),+ UINT64_C(0xA4B98C738305E54C), UINT64_C(0xCBE62B703D49CBFF),+ UINT64_C(0xCC47432450F0B1C3), UINT64_C(0xA318E427EEBC9F70),+ UINT64_C(0x97E7038C07C63537), UINT64_C(0xF8B8A48FB98A1B84),+ UINT64_C(0xE388443C5F7CDAAD), UINT64_C(0x8CD7E33FE130F41E),+ UINT64_C(0xB8280494084A5E59), UINT64_C(0xD777A397B60670EA),+ UINT64_C(0xD0D6CBC3DBBF0AD6), UINT64_C(0xBF896CC065F32465),+ UINT64_C(0x8B768B6B8C898E22), UINT64_C(0xE4292C6832C5A091),+ UINT64_C(0x85345AC356FB7B5A), UINT64_C(0xEA6BFDC0E8B755E9),+ UINT64_C(0xDE941A6B01CDFFAE), UINT64_C(0xB1CBBD68BF81D11D),+ UINT64_C(0xB66AD53CD238AB21), UINT64_C(0xD935723F6C748592),+ UINT64_C(0xEDCA9594850E2FD5), UINT64_C(0x829532973B420166),+ UINT64_C(0xAAEE776D67DD41D0), UINT64_C(0xC5B1D06ED9916F63),+ UINT64_C(0xF14E37C530EBC524), UINT64_C(0x9E1190C68EA7EB97),+ UINT64_C(0x99B0F892E31E91AB), UINT64_C(0xF6EF5F915D52BF18),+ UINT64_C(0xC210B83AB428155F), UINT64_C(0xAD4F1F390A643BEC),+ UINT64_C(0xCC5269926E5AE027), UINT64_C(0xA30DCE91D016CE94),+ UINT64_C(0x97F2293A396C64D3), UINT64_C(0xF8AD8E3987204A60),+ UINT64_C(0xFF0CE66DEA99305C), UINT64_C(0x9053416E54D51EEF),+ UINT64_C(0xA4ACA6C5BDAFB4A8), UINT64_C(0xCBF301C603E39A1B),+ UINT64_C(0x7144229E2F3EED56), UINT64_C(0x1E1B859D9172C3E5),+ UINT64_C(0x2AE46236780869A2), UINT64_C(0x45BBC535C6444711),+ UINT64_C(0x421AAD61ABFD3D2D), UINT64_C(0x2D450A6215B1139E),+ UINT64_C(0x19BAEDC9FCCBB9D9), UINT64_C(0x76E54ACA4287976A),+ UINT64_C(0x17F83C6126B94CA1), UINT64_C(0x78A79B6298F56212),+ UINT64_C(0x4C587CC9718FC855), UINT64_C(0x2307DBCACFC3E6E6),+ UINT64_C(0x24A6B39EA27A9CDA), UINT64_C(0x4BF9149D1C36B269),+ UINT64_C(0x7F06F336F54C182E), UINT64_C(0x105954354B00369D),+ UINT64_C(0x382211CF179F762B), UINT64_C(0x577DB6CCA9D35898),+ UINT64_C(0x6382516740A9F2DF), UINT64_C(0x0CDDF664FEE5DC6C),+ UINT64_C(0x0B7C9E30935CA650), UINT64_C(0x642339332D1088E3),+ UINT64_C(0x50DCDE98C46A22A4), UINT64_C(0x3F83799B7A260C17),+ UINT64_C(0x5E9E0F301E18D7DC), UINT64_C(0x31C1A833A054F96F),+ UINT64_C(0x053E4F98492E5328), UINT64_C(0x6A61E89BF7627D9B),+ UINT64_C(0x6DC080CF9ADB07A7), UINT64_C(0x029F27CC24972914),+ UINT64_C(0x3660C067CDED8353), UINT64_C(0x593F676473A1ADE0)+ }, {+ UINT64_C(0x0000000000000000), UINT64_C(0x0DF1D05C9279E954),+ UINT64_C(0x1AE2A1B924F3D2A9), UINT64_C(0x171371E5B68A3BFD),+ UINT64_C(0xB1DA4DDC62497DC1), UINT64_C(0xBC2B9D80F0309495),+ UINT64_C(0xAB38EC6546BAAF68), UINT64_C(0xA6C93C39D4C3463C),+ UINT64_C(0xE7AB9517EE3D2210), UINT64_C(0xEA5A454B7C44CB44),+ UINT64_C(0xFD4934AECACEF0B9), UINT64_C(0xF0B8E4F258B719ED),+ UINT64_C(0x5671D8CB8C745FD1), UINT64_C(0x5B8008971E0DB685),+ UINT64_C(0x4C937972A8878D78), UINT64_C(0x4162A92E3AFE642C),+ UINT64_C(0xCE572B2FDC7B4420), UINT64_C(0xC3A6FB734E02AD74),+ UINT64_C(0xD4B58A96F8889689), UINT64_C(0xD9445ACA6AF17FDD),+ UINT64_C(0x7F8D66F3BE3239E1), UINT64_C(0x727CB6AF2C4BD0B5),+ UINT64_C(0x656FC74A9AC1EB48), UINT64_C(0x689E171608B8021C),+ UINT64_C(0x29FCBE3832466630), UINT64_C(0x240D6E64A03F8F64),+ UINT64_C(0x331E1F8116B5B499), UINT64_C(0x3EEFCFDD84CC5DCD),+ UINT64_C(0x9826F3E4500F1BF1), UINT64_C(0x95D723B8C276F2A5),+ UINT64_C(0x82C4525D74FCC958), UINT64_C(0x8F358201E685200C),+ UINT64_C(0x9CAF565EB8F78840), UINT64_C(0x915E86022A8E6114),+ UINT64_C(0x864DF7E79C045AE9), UINT64_C(0x8BBC27BB0E7DB3BD),+ UINT64_C(0x2D751B82DABEF581), UINT64_C(0x2084CBDE48C71CD5),+ UINT64_C(0x3797BA3BFE4D2728), UINT64_C(0x3A666A676C34CE7C),+ UINT64_C(0x7B04C34956CAAA50), UINT64_C(0x76F51315C4B34304),+ UINT64_C(0x61E662F0723978F9), UINT64_C(0x6C17B2ACE04091AD),+ UINT64_C(0xCADE8E953483D791), UINT64_C(0xC72F5EC9A6FA3EC5),+ UINT64_C(0xD03C2F2C10700538), UINT64_C(0xDDCDFF708209EC6C),+ UINT64_C(0x52F87D71648CCC60), UINT64_C(0x5F09AD2DF6F52534),+ UINT64_C(0x481ADCC8407F1EC9), UINT64_C(0x45EB0C94D206F79D),+ UINT64_C(0xE32230AD06C5B1A1), UINT64_C(0xEED3E0F194BC58F5),+ UINT64_C(0xF9C0911422366308), UINT64_C(0xF4314148B04F8A5C),+ UINT64_C(0xB553E8668AB1EE70), UINT64_C(0xB8A2383A18C80724),+ UINT64_C(0xAFB149DFAE423CD9), UINT64_C(0xA24099833C3BD58D),+ UINT64_C(0x0489A5BAE8F893B1), UINT64_C(0x097875E67A817AE5),+ UINT64_C(0x1E6B0403CC0B4118), UINT64_C(0x139AD45F5E72A84C),+ UINT64_C(0x385FADBC70EF1181), UINT64_C(0x35AE7DE0E296F8D5),+ UINT64_C(0x22BD0C05541CC328), UINT64_C(0x2F4CDC59C6652A7C),+ UINT64_C(0x8985E06012A66C40), UINT64_C(0x8474303C80DF8514),+ UINT64_C(0x936741D93655BEE9), UINT64_C(0x9E969185A42C57BD),+ UINT64_C(0xDFF438AB9ED23391), UINT64_C(0xD205E8F70CABDAC5),+ UINT64_C(0xC5169912BA21E138), UINT64_C(0xC8E7494E2858086C),+ UINT64_C(0x6E2E7577FC9B4E50), UINT64_C(0x63DFA52B6EE2A704),+ UINT64_C(0x74CCD4CED8689CF9), UINT64_C(0x793D04924A1175AD),+ UINT64_C(0xF6088693AC9455A1), UINT64_C(0xFBF956CF3EEDBCF5),+ UINT64_C(0xECEA272A88678708), UINT64_C(0xE11BF7761A1E6E5C),+ UINT64_C(0x47D2CB4FCEDD2860), UINT64_C(0x4A231B135CA4C134),+ UINT64_C(0x5D306AF6EA2EFAC9), UINT64_C(0x50C1BAAA7857139D),+ UINT64_C(0x11A3138442A977B1), UINT64_C(0x1C52C3D8D0D09EE5),+ UINT64_C(0x0B41B23D665AA518), UINT64_C(0x06B06261F4234C4C),+ UINT64_C(0xA0795E5820E00A70), UINT64_C(0xAD888E04B299E324),+ UINT64_C(0xBA9BFFE10413D8D9), UINT64_C(0xB76A2FBD966A318D),+ UINT64_C(0xA4F0FBE2C81899C1), UINT64_C(0xA9012BBE5A617095),+ UINT64_C(0xBE125A5BECEB4B68), UINT64_C(0xB3E38A077E92A23C),+ UINT64_C(0x152AB63EAA51E400), UINT64_C(0x18DB666238280D54),+ UINT64_C(0x0FC817878EA236A9), UINT64_C(0x0239C7DB1CDBDFFD),+ UINT64_C(0x435B6EF52625BBD1), UINT64_C(0x4EAABEA9B45C5285),+ UINT64_C(0x59B9CF4C02D66978), UINT64_C(0x54481F1090AF802C),+ UINT64_C(0xF2812329446CC610), UINT64_C(0xFF70F375D6152F44),+ UINT64_C(0xE8638290609F14B9), UINT64_C(0xE59252CCF2E6FDED),+ UINT64_C(0x6AA7D0CD1463DDE1), UINT64_C(0x67560091861A34B5),+ UINT64_C(0x7045717430900F48), UINT64_C(0x7DB4A128A2E9E61C),+ UINT64_C(0xDB7D9D11762AA020), UINT64_C(0xD68C4D4DE4534974),+ UINT64_C(0xC19F3CA852D97289), UINT64_C(0xCC6EECF4C0A09BDD),+ UINT64_C(0x8D0C45DAFA5EFFF1), UINT64_C(0x80FD9586682716A5),+ UINT64_C(0x97EEE463DEAD2D58), UINT64_C(0x9A1F343F4CD4C40C),+ UINT64_C(0x3CD6080698178230), UINT64_C(0x3127D85A0A6E6B64),+ UINT64_C(0x2634A9BFBCE45099), UINT64_C(0x2BC579E32E9DB9CD),+ UINT64_C(0xF5A054D6CA71FB90), UINT64_C(0xF851848A580812C4),+ UINT64_C(0xEF42F56FEE822939), UINT64_C(0xE2B325337CFBC06D),+ UINT64_C(0x447A190AA8388651), UINT64_C(0x498BC9563A416F05),+ UINT64_C(0x5E98B8B38CCB54F8), UINT64_C(0x536968EF1EB2BDAC),+ UINT64_C(0x120BC1C1244CD980), UINT64_C(0x1FFA119DB63530D4),+ UINT64_C(0x08E9607800BF0B29), UINT64_C(0x0518B02492C6E27D),+ UINT64_C(0xA3D18C1D4605A441), UINT64_C(0xAE205C41D47C4D15),+ UINT64_C(0xB9332DA462F676E8), UINT64_C(0xB4C2FDF8F08F9FBC),+ UINT64_C(0x3BF77FF9160ABFB0), UINT64_C(0x3606AFA5847356E4),+ UINT64_C(0x2115DE4032F96D19), UINT64_C(0x2CE40E1CA080844D),+ UINT64_C(0x8A2D32257443C271), UINT64_C(0x87DCE279E63A2B25),+ UINT64_C(0x90CF939C50B010D8), UINT64_C(0x9D3E43C0C2C9F98C),+ UINT64_C(0xDC5CEAEEF8379DA0), UINT64_C(0xD1AD3AB26A4E74F4),+ UINT64_C(0xC6BE4B57DCC44F09), UINT64_C(0xCB4F9B0B4EBDA65D),+ UINT64_C(0x6D86A7329A7EE061), UINT64_C(0x6077776E08070935),+ UINT64_C(0x7764068BBE8D32C8), UINT64_C(0x7A95D6D72CF4DB9C),+ UINT64_C(0x690F0288728673D0), UINT64_C(0x64FED2D4E0FF9A84),+ UINT64_C(0x73EDA3315675A179), UINT64_C(0x7E1C736DC40C482D),+ UINT64_C(0xD8D54F5410CF0E11), UINT64_C(0xD5249F0882B6E745),+ UINT64_C(0xC237EEED343CDCB8), UINT64_C(0xCFC63EB1A64535EC),+ UINT64_C(0x8EA4979F9CBB51C0), UINT64_C(0x835547C30EC2B894),+ UINT64_C(0x94463626B8488369), UINT64_C(0x99B7E67A2A316A3D),+ UINT64_C(0x3F7EDA43FEF22C01), UINT64_C(0x328F0A1F6C8BC555),+ UINT64_C(0x259C7BFADA01FEA8), UINT64_C(0x286DABA6487817FC),+ UINT64_C(0xA75829A7AEFD37F0), UINT64_C(0xAAA9F9FB3C84DEA4),+ UINT64_C(0xBDBA881E8A0EE559), UINT64_C(0xB04B584218770C0D),+ UINT64_C(0x1682647BCCB44A31), UINT64_C(0x1B73B4275ECDA365),+ UINT64_C(0x0C60C5C2E8479898), UINT64_C(0x0191159E7A3E71CC),+ UINT64_C(0x40F3BCB040C015E0), UINT64_C(0x4D026CECD2B9FCB4),+ UINT64_C(0x5A111D096433C749), UINT64_C(0x57E0CD55F64A2E1D),+ UINT64_C(0xF129F16C22896821), UINT64_C(0xFCD82130B0F08175),+ UINT64_C(0xEBCB50D5067ABA88), UINT64_C(0xE63A8089940353DC),+ UINT64_C(0xCDFFF96ABA9EEA11), UINT64_C(0xC00E293628E70345),+ UINT64_C(0xD71D58D39E6D38B8), UINT64_C(0xDAEC888F0C14D1EC),+ UINT64_C(0x7C25B4B6D8D797D0), UINT64_C(0x71D464EA4AAE7E84),+ UINT64_C(0x66C7150FFC244579), UINT64_C(0x6B36C5536E5DAC2D),+ UINT64_C(0x2A546C7D54A3C801), UINT64_C(0x27A5BC21C6DA2155),+ UINT64_C(0x30B6CDC470501AA8), UINT64_C(0x3D471D98E229F3FC),+ UINT64_C(0x9B8E21A136EAB5C0), UINT64_C(0x967FF1FDA4935C94),+ UINT64_C(0x816C801812196769), UINT64_C(0x8C9D504480608E3D),+ UINT64_C(0x03A8D24566E5AE31), UINT64_C(0x0E590219F49C4765),+ UINT64_C(0x194A73FC42167C98), UINT64_C(0x14BBA3A0D06F95CC),+ UINT64_C(0xB2729F9904ACD3F0), UINT64_C(0xBF834FC596D53AA4),+ UINT64_C(0xA8903E20205F0159), UINT64_C(0xA561EE7CB226E80D),+ UINT64_C(0xE403475288D88C21), UINT64_C(0xE9F2970E1AA16575),+ UINT64_C(0xFEE1E6EBAC2B5E88), UINT64_C(0xF31036B73E52B7DC),+ UINT64_C(0x55D90A8EEA91F1E0), UINT64_C(0x5828DAD278E818B4),+ UINT64_C(0x4F3BAB37CE622349), UINT64_C(0x42CA7B6B5C1BCA1D),+ UINT64_C(0x5150AF3402696251), UINT64_C(0x5CA17F6890108B05),+ UINT64_C(0x4BB20E8D269AB0F8), UINT64_C(0x4643DED1B4E359AC),+ UINT64_C(0xE08AE2E860201F90), UINT64_C(0xED7B32B4F259F6C4),+ UINT64_C(0xFA68435144D3CD39), UINT64_C(0xF799930DD6AA246D),+ UINT64_C(0xB6FB3A23EC544041), UINT64_C(0xBB0AEA7F7E2DA915),+ UINT64_C(0xAC199B9AC8A792E8), UINT64_C(0xA1E84BC65ADE7BBC),+ UINT64_C(0x072177FF8E1D3D80), UINT64_C(0x0AD0A7A31C64D4D4),+ UINT64_C(0x1DC3D646AAEEEF29), UINT64_C(0x1032061A3897067D),+ UINT64_C(0x9F07841BDE122671), UINT64_C(0x92F654474C6BCF25),+ UINT64_C(0x85E525A2FAE1F4D8), UINT64_C(0x8814F5FE68981D8C),+ UINT64_C(0x2EDDC9C7BC5B5BB0), UINT64_C(0x232C199B2E22B2E4),+ UINT64_C(0x343F687E98A88919), UINT64_C(0x39CEB8220AD1604D),+ UINT64_C(0x78AC110C302F0461), UINT64_C(0x755DC150A256ED35),+ UINT64_C(0x624EB0B514DCD6C8), UINT64_C(0x6FBF60E986A53F9C),+ UINT64_C(0xC9765CD0526679A0), UINT64_C(0xC4878C8CC01F90F4),+ UINT64_C(0xD394FD697695AB09), UINT64_C(0xDE652D35E4EC425D)+ }, {+ UINT64_C(0x0000000000000000), UINT64_C(0xCB6D6A914AE10B3F),+ UINT64_C(0x96DBD42295C2177E), UINT64_C(0x5DB6BEB3DF231C41),+ UINT64_C(0x2CB7A9452A852FFC), UINT64_C(0xE7DAC3D4606424C3),+ UINT64_C(0xBA6C7D67BF473882), UINT64_C(0x710117F6F5A633BD),+ UINT64_C(0xDD705D247FA5876A), UINT64_C(0x161D37B535448C55),+ UINT64_C(0x4BAB8906EA679014), UINT64_C(0x80C6E397A0869B2B),+ UINT64_C(0xF1C7F4615520A896), UINT64_C(0x3AAA9EF01FC1A3A9),+ UINT64_C(0x671C2043C0E2BFE8), UINT64_C(0xAC714AD28A03B4D7),+ UINT64_C(0xBAE1BA48FE4A0FD5), UINT64_C(0x718CD0D9B4AB04EA),+ UINT64_C(0x2C3A6E6A6B8818AB), UINT64_C(0xE75704FB21691394),+ UINT64_C(0x9656130DD4CF2029), UINT64_C(0x5D3B799C9E2E2B16),+ UINT64_C(0x008DC72F410D3757), UINT64_C(0xCBE0ADBE0BEC3C68),+ UINT64_C(0x6791E76C81EF88BF), UINT64_C(0xACFC8DFDCB0E8380),+ UINT64_C(0xF14A334E142D9FC1), UINT64_C(0x3A2759DF5ECC94FE),+ UINT64_C(0x4B264E29AB6AA743), UINT64_C(0x804B24B8E18BAC7C),+ UINT64_C(0xDDFD9A0B3EA8B03D), UINT64_C(0x1690F09A7449BB02),+ UINT64_C(0xF1DD7B3ED73AC638), UINT64_C(0x3AB011AF9DDBCD07),+ UINT64_C(0x6706AF1C42F8D146), UINT64_C(0xAC6BC58D0819DA79),+ UINT64_C(0xDD6AD27BFDBFE9C4), UINT64_C(0x1607B8EAB75EE2FB),+ UINT64_C(0x4BB10659687DFEBA), UINT64_C(0x80DC6CC8229CF585),+ UINT64_C(0x2CAD261AA89F4152), UINT64_C(0xE7C04C8BE27E4A6D),+ UINT64_C(0xBA76F2383D5D562C), UINT64_C(0x711B98A977BC5D13),+ UINT64_C(0x001A8F5F821A6EAE), UINT64_C(0xCB77E5CEC8FB6591),+ UINT64_C(0x96C15B7D17D879D0), UINT64_C(0x5DAC31EC5D3972EF),+ UINT64_C(0x4B3CC1762970C9ED), UINT64_C(0x8051ABE76391C2D2),+ UINT64_C(0xDDE71554BCB2DE93), UINT64_C(0x168A7FC5F653D5AC),+ UINT64_C(0x678B683303F5E611), UINT64_C(0xACE602A24914ED2E),+ UINT64_C(0xF150BC119637F16F), UINT64_C(0x3A3DD680DCD6FA50),+ UINT64_C(0x964C9C5256D54E87), UINT64_C(0x5D21F6C31C3445B8),+ UINT64_C(0x00974870C31759F9), UINT64_C(0xCBFA22E189F652C6),+ UINT64_C(0xBAFB35177C50617B), UINT64_C(0x71965F8636B16A44),+ UINT64_C(0x2C20E135E9927605), UINT64_C(0xE74D8BA4A3737D3A),+ UINT64_C(0xE2BBF77CAE758C71), UINT64_C(0x29D69DEDE494874E),+ UINT64_C(0x7460235E3BB79B0F), UINT64_C(0xBF0D49CF71569030),+ UINT64_C(0xCE0C5E3984F0A38D), UINT64_C(0x056134A8CE11A8B2),+ UINT64_C(0x58D78A1B1132B4F3), UINT64_C(0x93BAE08A5BD3BFCC),+ UINT64_C(0x3FCBAA58D1D00B1B), UINT64_C(0xF4A6C0C99B310024),+ UINT64_C(0xA9107E7A44121C65), UINT64_C(0x627D14EB0EF3175A),+ UINT64_C(0x137C031DFB5524E7), UINT64_C(0xD811698CB1B42FD8),+ UINT64_C(0x85A7D73F6E973399), UINT64_C(0x4ECABDAE247638A6),+ UINT64_C(0x585A4D34503F83A4), UINT64_C(0x933727A51ADE889B),+ UINT64_C(0xCE819916C5FD94DA), UINT64_C(0x05ECF3878F1C9FE5),+ UINT64_C(0x74EDE4717ABAAC58), UINT64_C(0xBF808EE0305BA767),+ UINT64_C(0xE2363053EF78BB26), UINT64_C(0x295B5AC2A599B019),+ UINT64_C(0x852A10102F9A04CE), UINT64_C(0x4E477A81657B0FF1),+ UINT64_C(0x13F1C432BA5813B0), UINT64_C(0xD89CAEA3F0B9188F),+ UINT64_C(0xA99DB955051F2B32), UINT64_C(0x62F0D3C44FFE200D),+ UINT64_C(0x3F466D7790DD3C4C), UINT64_C(0xF42B07E6DA3C3773),+ UINT64_C(0x13668C42794F4A49), UINT64_C(0xD80BE6D333AE4176),+ UINT64_C(0x85BD5860EC8D5D37), UINT64_C(0x4ED032F1A66C5608),+ UINT64_C(0x3FD1250753CA65B5), UINT64_C(0xF4BC4F96192B6E8A),+ UINT64_C(0xA90AF125C60872CB), UINT64_C(0x62679BB48CE979F4),+ UINT64_C(0xCE16D16606EACD23), UINT64_C(0x057BBBF74C0BC61C),+ UINT64_C(0x58CD05449328DA5D), UINT64_C(0x93A06FD5D9C9D162),+ UINT64_C(0xE2A178232C6FE2DF), UINT64_C(0x29CC12B2668EE9E0),+ UINT64_C(0x747AAC01B9ADF5A1), UINT64_C(0xBF17C690F34CFE9E),+ UINT64_C(0xA987360A8705459C), UINT64_C(0x62EA5C9BCDE44EA3),+ UINT64_C(0x3F5CE22812C752E2), UINT64_C(0xF43188B9582659DD),+ UINT64_C(0x85309F4FAD806A60), UINT64_C(0x4E5DF5DEE761615F),+ UINT64_C(0x13EB4B6D38427D1E), UINT64_C(0xD88621FC72A37621),+ UINT64_C(0x74F76B2EF8A0C2F6), UINT64_C(0xBF9A01BFB241C9C9),+ UINT64_C(0xE22CBF0C6D62D588), UINT64_C(0x2941D59D2783DEB7),+ UINT64_C(0x5840C26BD225ED0A), UINT64_C(0x932DA8FA98C4E635),+ UINT64_C(0xCE9B164947E7FA74), UINT64_C(0x05F67CD80D06F14B),+ UINT64_C(0xC477EFF95CEB18E3), UINT64_C(0x0F1A8568160A13DC),+ UINT64_C(0x52AC3BDBC9290F9D), UINT64_C(0x99C1514A83C804A2),+ UINT64_C(0xE8C046BC766E371F), UINT64_C(0x23AD2C2D3C8F3C20),+ UINT64_C(0x7E1B929EE3AC2061), UINT64_C(0xB576F80FA94D2B5E),+ UINT64_C(0x1907B2DD234E9F89), UINT64_C(0xD26AD84C69AF94B6),+ UINT64_C(0x8FDC66FFB68C88F7), UINT64_C(0x44B10C6EFC6D83C8),+ UINT64_C(0x35B01B9809CBB075), UINT64_C(0xFEDD7109432ABB4A),+ UINT64_C(0xA36BCFBA9C09A70B), UINT64_C(0x6806A52BD6E8AC34),+ UINT64_C(0x7E9655B1A2A11736), UINT64_C(0xB5FB3F20E8401C09),+ UINT64_C(0xE84D819337630048), UINT64_C(0x2320EB027D820B77),+ UINT64_C(0x5221FCF4882438CA), UINT64_C(0x994C9665C2C533F5),+ UINT64_C(0xC4FA28D61DE62FB4), UINT64_C(0x0F9742475707248B),+ UINT64_C(0xA3E60895DD04905C), UINT64_C(0x688B620497E59B63),+ UINT64_C(0x353DDCB748C68722), UINT64_C(0xFE50B62602278C1D),+ UINT64_C(0x8F51A1D0F781BFA0), UINT64_C(0x443CCB41BD60B49F),+ UINT64_C(0x198A75F26243A8DE), UINT64_C(0xD2E71F6328A2A3E1),+ UINT64_C(0x35AA94C78BD1DEDB), UINT64_C(0xFEC7FE56C130D5E4),+ UINT64_C(0xA37140E51E13C9A5), UINT64_C(0x681C2A7454F2C29A),+ UINT64_C(0x191D3D82A154F127), UINT64_C(0xD2705713EBB5FA18),+ UINT64_C(0x8FC6E9A03496E659), UINT64_C(0x44AB83317E77ED66),+ UINT64_C(0xE8DAC9E3F47459B1), UINT64_C(0x23B7A372BE95528E),+ UINT64_C(0x7E011DC161B64ECF), UINT64_C(0xB56C77502B5745F0),+ UINT64_C(0xC46D60A6DEF1764D), UINT64_C(0x0F000A3794107D72),+ UINT64_C(0x52B6B4844B336133), UINT64_C(0x99DBDE1501D26A0C),+ UINT64_C(0x8F4B2E8F759BD10E), UINT64_C(0x4426441E3F7ADA31),+ UINT64_C(0x1990FAADE059C670), UINT64_C(0xD2FD903CAAB8CD4F),+ UINT64_C(0xA3FC87CA5F1EFEF2), UINT64_C(0x6891ED5B15FFF5CD),+ UINT64_C(0x352753E8CADCE98C), UINT64_C(0xFE4A3979803DE2B3),+ UINT64_C(0x523B73AB0A3E5664), UINT64_C(0x9956193A40DF5D5B),+ UINT64_C(0xC4E0A7899FFC411A), UINT64_C(0x0F8DCD18D51D4A25),+ UINT64_C(0x7E8CDAEE20BB7998), UINT64_C(0xB5E1B07F6A5A72A7),+ UINT64_C(0xE8570ECCB5796EE6), UINT64_C(0x233A645DFF9865D9),+ UINT64_C(0x26CC1885F29E9492), UINT64_C(0xEDA17214B87F9FAD),+ UINT64_C(0xB017CCA7675C83EC), UINT64_C(0x7B7AA6362DBD88D3),+ UINT64_C(0x0A7BB1C0D81BBB6E), UINT64_C(0xC116DB5192FAB051),+ UINT64_C(0x9CA065E24DD9AC10), UINT64_C(0x57CD0F730738A72F),+ UINT64_C(0xFBBC45A18D3B13F8), UINT64_C(0x30D12F30C7DA18C7),+ UINT64_C(0x6D67918318F90486), UINT64_C(0xA60AFB1252180FB9),+ UINT64_C(0xD70BECE4A7BE3C04), UINT64_C(0x1C668675ED5F373B),+ UINT64_C(0x41D038C6327C2B7A), UINT64_C(0x8ABD5257789D2045),+ UINT64_C(0x9C2DA2CD0CD49B47), UINT64_C(0x5740C85C46359078),+ UINT64_C(0x0AF676EF99168C39), UINT64_C(0xC19B1C7ED3F78706),+ UINT64_C(0xB09A0B882651B4BB), UINT64_C(0x7BF761196CB0BF84),+ UINT64_C(0x2641DFAAB393A3C5), UINT64_C(0xED2CB53BF972A8FA),+ UINT64_C(0x415DFFE973711C2D), UINT64_C(0x8A30957839901712),+ UINT64_C(0xD7862BCBE6B30B53), UINT64_C(0x1CEB415AAC52006C),+ UINT64_C(0x6DEA56AC59F433D1), UINT64_C(0xA6873C3D131538EE),+ UINT64_C(0xFB31828ECC3624AF), UINT64_C(0x305CE81F86D72F90),+ UINT64_C(0xD71163BB25A452AA), UINT64_C(0x1C7C092A6F455995),+ UINT64_C(0x41CAB799B06645D4), UINT64_C(0x8AA7DD08FA874EEB),+ UINT64_C(0xFBA6CAFE0F217D56), UINT64_C(0x30CBA06F45C07669),+ UINT64_C(0x6D7D1EDC9AE36A28), UINT64_C(0xA610744DD0026117),+ UINT64_C(0x0A613E9F5A01D5C0), UINT64_C(0xC10C540E10E0DEFF),+ UINT64_C(0x9CBAEABDCFC3C2BE), UINT64_C(0x57D7802C8522C981),+ UINT64_C(0x26D697DA7084FA3C), UINT64_C(0xEDBBFD4B3A65F103),+ UINT64_C(0xB00D43F8E546ED42), UINT64_C(0x7B602969AFA7E67D),+ UINT64_C(0x6DF0D9F3DBEE5D7F), UINT64_C(0xA69DB362910F5640),+ UINT64_C(0xFB2B0DD14E2C4A01), UINT64_C(0x3046674004CD413E),+ UINT64_C(0x414770B6F16B7283), UINT64_C(0x8A2A1A27BB8A79BC),+ UINT64_C(0xD79CA49464A965FD), UINT64_C(0x1CF1CE052E486EC2),+ UINT64_C(0xB08084D7A44BDA15), UINT64_C(0x7BEDEE46EEAAD12A),+ UINT64_C(0x265B50F53189CD6B), UINT64_C(0xED363A647B68C654),+ UINT64_C(0x9C372D928ECEF5E9), UINT64_C(0x575A4703C42FFED6),+ UINT64_C(0x0AECF9B01B0CE297), UINT64_C(0xC181932151EDE9A8)+ }, {+ UINT64_C(0x0000000000000000), UINT64_C(0xDCA12C225E8AEE1D),+ UINT64_C(0xB8435944BC14DD3B), UINT64_C(0x64E27566E29E3326),+ UINT64_C(0x7087B2887829BA77), UINT64_C(0xAC269EAA26A3546A),+ UINT64_C(0xC8C4EBCCC43D674C), UINT64_C(0x1465C7EE9AB78951),+ UINT64_C(0xE00E6511F15274EF), UINT64_C(0x3CAF4933AFD89AF2),+ UINT64_C(0x584D3C554D46A9D4), UINT64_C(0x84EC107713CC47C9),+ UINT64_C(0x9089D799897BCE98), UINT64_C(0x4C28FBBBD7F12085),+ UINT64_C(0x28CA8EDD356F13A3), UINT64_C(0xF46BA2FF6BE5FDBE),+ UINT64_C(0x4503C48DC90A304C), UINT64_C(0x99A2E8AF9780DE51),+ UINT64_C(0xFD409DC9751EED77), UINT64_C(0x21E1B1EB2B94036A),+ UINT64_C(0x35847605B1238A3B), UINT64_C(0xE9255A27EFA96426),+ UINT64_C(0x8DC72F410D375700), UINT64_C(0x5166036353BDB91D),+ UINT64_C(0xA50DA19C385844A3), UINT64_C(0x79AC8DBE66D2AABE),+ UINT64_C(0x1D4EF8D8844C9998), UINT64_C(0xC1EFD4FADAC67785),+ UINT64_C(0xD58A13144071FED4), UINT64_C(0x092B3F361EFB10C9),+ UINT64_C(0x6DC94A50FC6523EF), UINT64_C(0xB1686672A2EFCDF2),+ UINT64_C(0x8A06881B93156098), UINT64_C(0x56A7A439CD9F8E85),+ UINT64_C(0x3245D15F2F01BDA3), UINT64_C(0xEEE4FD7D718B53BE),+ UINT64_C(0xFA813A93EB3CDAEF), UINT64_C(0x262016B1B5B634F2),+ UINT64_C(0x42C263D7572807D4), UINT64_C(0x9E634FF509A2E9C9),+ UINT64_C(0x6A08ED0A62471477), UINT64_C(0xB6A9C1283CCDFA6A),+ UINT64_C(0xD24BB44EDE53C94C), UINT64_C(0x0EEA986C80D92751),+ UINT64_C(0x1A8F5F821A6EAE00), UINT64_C(0xC62E73A044E4401D),+ UINT64_C(0xA2CC06C6A67A733B), UINT64_C(0x7E6D2AE4F8F09D26),+ UINT64_C(0xCF054C965A1F50D4), UINT64_C(0x13A460B40495BEC9),+ UINT64_C(0x774615D2E60B8DEF), UINT64_C(0xABE739F0B88163F2),+ UINT64_C(0xBF82FE1E2236EAA3), UINT64_C(0x6323D23C7CBC04BE),+ UINT64_C(0x07C1A75A9E223798), UINT64_C(0xDB608B78C0A8D985),+ UINT64_C(0x2F0B2987AB4D243B), UINT64_C(0xF3AA05A5F5C7CA26),+ UINT64_C(0x974870C31759F900), UINT64_C(0x4BE95CE149D3171D),+ UINT64_C(0x5F8C9B0FD3649E4C), UINT64_C(0x832DB72D8DEE7051),+ UINT64_C(0xE7CFC24B6F704377), UINT64_C(0x3B6EEE6931FAAD6A),+ UINT64_C(0x91131E980D8418A2), UINT64_C(0x4DB232BA530EF6BF),+ UINT64_C(0x295047DCB190C599), UINT64_C(0xF5F16BFEEF1A2B84),+ UINT64_C(0xE194AC1075ADA2D5), UINT64_C(0x3D3580322B274CC8),+ UINT64_C(0x59D7F554C9B97FEE), UINT64_C(0x8576D976973391F3),+ UINT64_C(0x711D7B89FCD66C4D), UINT64_C(0xADBC57ABA25C8250),+ UINT64_C(0xC95E22CD40C2B176), UINT64_C(0x15FF0EEF1E485F6B),+ UINT64_C(0x019AC90184FFD63A), UINT64_C(0xDD3BE523DA753827),+ UINT64_C(0xB9D9904538EB0B01), UINT64_C(0x6578BC676661E51C),+ UINT64_C(0xD410DA15C48E28EE), UINT64_C(0x08B1F6379A04C6F3),+ UINT64_C(0x6C538351789AF5D5), UINT64_C(0xB0F2AF7326101BC8),+ UINT64_C(0xA497689DBCA79299), UINT64_C(0x783644BFE22D7C84),+ UINT64_C(0x1CD431D900B34FA2), UINT64_C(0xC0751DFB5E39A1BF),+ UINT64_C(0x341EBF0435DC5C01), UINT64_C(0xE8BF93266B56B21C),+ UINT64_C(0x8C5DE64089C8813A), UINT64_C(0x50FCCA62D7426F27),+ UINT64_C(0x44990D8C4DF5E676), UINT64_C(0x983821AE137F086B),+ UINT64_C(0xFCDA54C8F1E13B4D), UINT64_C(0x207B78EAAF6BD550),+ UINT64_C(0x1B1596839E91783A), UINT64_C(0xC7B4BAA1C01B9627),+ UINT64_C(0xA356CFC72285A501), UINT64_C(0x7FF7E3E57C0F4B1C),+ UINT64_C(0x6B92240BE6B8C24D), UINT64_C(0xB7330829B8322C50),+ UINT64_C(0xD3D17D4F5AAC1F76), UINT64_C(0x0F70516D0426F16B),+ UINT64_C(0xFB1BF3926FC30CD5), UINT64_C(0x27BADFB03149E2C8),+ UINT64_C(0x4358AAD6D3D7D1EE), UINT64_C(0x9FF986F48D5D3FF3),+ UINT64_C(0x8B9C411A17EAB6A2), UINT64_C(0x573D6D38496058BF),+ UINT64_C(0x33DF185EABFE6B99), UINT64_C(0xEF7E347CF5748584),+ UINT64_C(0x5E16520E579B4876), UINT64_C(0x82B77E2C0911A66B),+ UINT64_C(0xE6550B4AEB8F954D), UINT64_C(0x3AF42768B5057B50),+ UINT64_C(0x2E91E0862FB2F201), UINT64_C(0xF230CCA471381C1C),+ UINT64_C(0x96D2B9C293A62F3A), UINT64_C(0x4A7395E0CD2CC127),+ UINT64_C(0xBE18371FA6C93C99), UINT64_C(0x62B91B3DF843D284),+ UINT64_C(0x065B6E5B1ADDE1A2), UINT64_C(0xDAFA427944570FBF),+ UINT64_C(0xCE9F8597DEE086EE), UINT64_C(0x123EA9B5806A68F3),+ UINT64_C(0x76DCDCD362F45BD5), UINT64_C(0xAA7DF0F13C7EB5C8),+ UINT64_C(0xA739329F30A7E9D6), UINT64_C(0x7B981EBD6E2D07CB),+ UINT64_C(0x1F7A6BDB8CB334ED), UINT64_C(0xC3DB47F9D239DAF0),+ UINT64_C(0xD7BE8017488E53A1), UINT64_C(0x0B1FAC351604BDBC),+ UINT64_C(0x6FFDD953F49A8E9A), UINT64_C(0xB35CF571AA106087),+ UINT64_C(0x4737578EC1F59D39), UINT64_C(0x9B967BAC9F7F7324),+ UINT64_C(0xFF740ECA7DE14002), UINT64_C(0x23D522E8236BAE1F),+ UINT64_C(0x37B0E506B9DC274E), UINT64_C(0xEB11C924E756C953),+ UINT64_C(0x8FF3BC4205C8FA75), UINT64_C(0x535290605B421468),+ UINT64_C(0xE23AF612F9ADD99A), UINT64_C(0x3E9BDA30A7273787),+ UINT64_C(0x5A79AF5645B904A1), UINT64_C(0x86D883741B33EABC),+ UINT64_C(0x92BD449A818463ED), UINT64_C(0x4E1C68B8DF0E8DF0),+ UINT64_C(0x2AFE1DDE3D90BED6), UINT64_C(0xF65F31FC631A50CB),+ UINT64_C(0x0234930308FFAD75), UINT64_C(0xDE95BF2156754368),+ UINT64_C(0xBA77CA47B4EB704E), UINT64_C(0x66D6E665EA619E53),+ UINT64_C(0x72B3218B70D61702), UINT64_C(0xAE120DA92E5CF91F),+ UINT64_C(0xCAF078CFCCC2CA39), UINT64_C(0x165154ED92482424),+ UINT64_C(0x2D3FBA84A3B2894E), UINT64_C(0xF19E96A6FD386753),+ UINT64_C(0x957CE3C01FA65475), UINT64_C(0x49DDCFE2412CBA68),+ UINT64_C(0x5DB8080CDB9B3339), UINT64_C(0x8119242E8511DD24),+ UINT64_C(0xE5FB5148678FEE02), UINT64_C(0x395A7D6A3905001F),+ UINT64_C(0xCD31DF9552E0FDA1), UINT64_C(0x1190F3B70C6A13BC),+ UINT64_C(0x757286D1EEF4209A), UINT64_C(0xA9D3AAF3B07ECE87),+ UINT64_C(0xBDB66D1D2AC947D6), UINT64_C(0x6117413F7443A9CB),+ UINT64_C(0x05F5345996DD9AED), UINT64_C(0xD954187BC85774F0),+ UINT64_C(0x683C7E096AB8B902), UINT64_C(0xB49D522B3432571F),+ UINT64_C(0xD07F274DD6AC6439), UINT64_C(0x0CDE0B6F88268A24),+ UINT64_C(0x18BBCC8112910375), UINT64_C(0xC41AE0A34C1BED68),+ UINT64_C(0xA0F895C5AE85DE4E), UINT64_C(0x7C59B9E7F00F3053),+ UINT64_C(0x88321B189BEACDED), UINT64_C(0x5493373AC56023F0),+ UINT64_C(0x3071425C27FE10D6), UINT64_C(0xECD06E7E7974FECB),+ UINT64_C(0xF8B5A990E3C3779A), UINT64_C(0x241485B2BD499987),+ UINT64_C(0x40F6F0D45FD7AAA1), UINT64_C(0x9C57DCF6015D44BC),+ UINT64_C(0x362A2C073D23F174), UINT64_C(0xEA8B002563A91F69),+ UINT64_C(0x8E69754381372C4F), UINT64_C(0x52C85961DFBDC252),+ UINT64_C(0x46AD9E8F450A4B03), UINT64_C(0x9A0CB2AD1B80A51E),+ UINT64_C(0xFEEEC7CBF91E9638), UINT64_C(0x224FEBE9A7947825),+ UINT64_C(0xD6244916CC71859B), UINT64_C(0x0A85653492FB6B86),+ UINT64_C(0x6E671052706558A0), UINT64_C(0xB2C63C702EEFB6BD),+ UINT64_C(0xA6A3FB9EB4583FEC), UINT64_C(0x7A02D7BCEAD2D1F1),+ UINT64_C(0x1EE0A2DA084CE2D7), UINT64_C(0xC2418EF856C60CCA),+ UINT64_C(0x7329E88AF429C138), UINT64_C(0xAF88C4A8AAA32F25),+ UINT64_C(0xCB6AB1CE483D1C03), UINT64_C(0x17CB9DEC16B7F21E),+ UINT64_C(0x03AE5A028C007B4F), UINT64_C(0xDF0F7620D28A9552),+ UINT64_C(0xBBED03463014A674), UINT64_C(0x674C2F646E9E4869),+ UINT64_C(0x93278D9B057BB5D7), UINT64_C(0x4F86A1B95BF15BCA),+ UINT64_C(0x2B64D4DFB96F68EC), UINT64_C(0xF7C5F8FDE7E586F1),+ UINT64_C(0xE3A03F137D520FA0), UINT64_C(0x3F01133123D8E1BD),+ UINT64_C(0x5BE36657C146D29B), UINT64_C(0x87424A759FCC3C86),+ UINT64_C(0xBC2CA41CAE3691EC), UINT64_C(0x608D883EF0BC7FF1),+ UINT64_C(0x046FFD5812224CD7), UINT64_C(0xD8CED17A4CA8A2CA),+ UINT64_C(0xCCAB1694D61F2B9B), UINT64_C(0x100A3AB68895C586),+ UINT64_C(0x74E84FD06A0BF6A0), UINT64_C(0xA84963F2348118BD),+ UINT64_C(0x5C22C10D5F64E503), UINT64_C(0x8083ED2F01EE0B1E),+ UINT64_C(0xE4619849E3703838), UINT64_C(0x38C0B46BBDFAD625),+ UINT64_C(0x2CA57385274D5F74), UINT64_C(0xF0045FA779C7B169),+ UINT64_C(0x94E62AC19B59824F), UINT64_C(0x484706E3C5D36C52),+ UINT64_C(0xF92F6091673CA1A0), UINT64_C(0x258E4CB339B64FBD),+ UINT64_C(0x416C39D5DB287C9B), UINT64_C(0x9DCD15F785A29286),+ UINT64_C(0x89A8D2191F151BD7), UINT64_C(0x5509FE3B419FF5CA),+ UINT64_C(0x31EB8B5DA301C6EC), UINT64_C(0xED4AA77FFD8B28F1),+ UINT64_C(0x19210580966ED54F), UINT64_C(0xC58029A2C8E43B52),+ UINT64_C(0xA1625CC42A7A0874), UINT64_C(0x7DC370E674F0E669),+ UINT64_C(0x69A6B708EE476F38), UINT64_C(0xB5079B2AB0CD8125),+ UINT64_C(0xD1E5EE4C5253B203), UINT64_C(0x0D44C26E0CD95C1E)+ }+};
+ cbits/liblzma/check/crc64_table_le.h view
@@ -0,0 +1,523 @@+// SPDX-License-Identifier: 0BSD++// This file has been generated by crc64_tablegen.c.++const uint64_t lzma_crc64_table[4][256] = {+ {+ UINT64_C(0x0000000000000000), UINT64_C(0xB32E4CBE03A75F6F),+ UINT64_C(0xF4843657A840A05B), UINT64_C(0x47AA7AE9ABE7FF34),+ UINT64_C(0x7BD0C384FF8F5E33), UINT64_C(0xC8FE8F3AFC28015C),+ UINT64_C(0x8F54F5D357CFFE68), UINT64_C(0x3C7AB96D5468A107),+ UINT64_C(0xF7A18709FF1EBC66), UINT64_C(0x448FCBB7FCB9E309),+ UINT64_C(0x0325B15E575E1C3D), UINT64_C(0xB00BFDE054F94352),+ UINT64_C(0x8C71448D0091E255), UINT64_C(0x3F5F08330336BD3A),+ UINT64_C(0x78F572DAA8D1420E), UINT64_C(0xCBDB3E64AB761D61),+ UINT64_C(0x7D9BA13851336649), UINT64_C(0xCEB5ED8652943926),+ UINT64_C(0x891F976FF973C612), UINT64_C(0x3A31DBD1FAD4997D),+ UINT64_C(0x064B62BCAEBC387A), UINT64_C(0xB5652E02AD1B6715),+ UINT64_C(0xF2CF54EB06FC9821), UINT64_C(0x41E11855055BC74E),+ UINT64_C(0x8A3A2631AE2DDA2F), UINT64_C(0x39146A8FAD8A8540),+ UINT64_C(0x7EBE1066066D7A74), UINT64_C(0xCD905CD805CA251B),+ UINT64_C(0xF1EAE5B551A2841C), UINT64_C(0x42C4A90B5205DB73),+ UINT64_C(0x056ED3E2F9E22447), UINT64_C(0xB6409F5CFA457B28),+ UINT64_C(0xFB374270A266CC92), UINT64_C(0x48190ECEA1C193FD),+ UINT64_C(0x0FB374270A266CC9), UINT64_C(0xBC9D3899098133A6),+ UINT64_C(0x80E781F45DE992A1), UINT64_C(0x33C9CD4A5E4ECDCE),+ UINT64_C(0x7463B7A3F5A932FA), UINT64_C(0xC74DFB1DF60E6D95),+ UINT64_C(0x0C96C5795D7870F4), UINT64_C(0xBFB889C75EDF2F9B),+ UINT64_C(0xF812F32EF538D0AF), UINT64_C(0x4B3CBF90F69F8FC0),+ UINT64_C(0x774606FDA2F72EC7), UINT64_C(0xC4684A43A15071A8),+ UINT64_C(0x83C230AA0AB78E9C), UINT64_C(0x30EC7C140910D1F3),+ UINT64_C(0x86ACE348F355AADB), UINT64_C(0x3582AFF6F0F2F5B4),+ UINT64_C(0x7228D51F5B150A80), UINT64_C(0xC10699A158B255EF),+ UINT64_C(0xFD7C20CC0CDAF4E8), UINT64_C(0x4E526C720F7DAB87),+ UINT64_C(0x09F8169BA49A54B3), UINT64_C(0xBAD65A25A73D0BDC),+ UINT64_C(0x710D64410C4B16BD), UINT64_C(0xC22328FF0FEC49D2),+ UINT64_C(0x85895216A40BB6E6), UINT64_C(0x36A71EA8A7ACE989),+ UINT64_C(0x0ADDA7C5F3C4488E), UINT64_C(0xB9F3EB7BF06317E1),+ UINT64_C(0xFE5991925B84E8D5), UINT64_C(0x4D77DD2C5823B7BA),+ UINT64_C(0x64B62BCAEBC387A1), UINT64_C(0xD7986774E864D8CE),+ UINT64_C(0x90321D9D438327FA), UINT64_C(0x231C512340247895),+ UINT64_C(0x1F66E84E144CD992), UINT64_C(0xAC48A4F017EB86FD),+ UINT64_C(0xEBE2DE19BC0C79C9), UINT64_C(0x58CC92A7BFAB26A6),+ UINT64_C(0x9317ACC314DD3BC7), UINT64_C(0x2039E07D177A64A8),+ UINT64_C(0x67939A94BC9D9B9C), UINT64_C(0xD4BDD62ABF3AC4F3),+ UINT64_C(0xE8C76F47EB5265F4), UINT64_C(0x5BE923F9E8F53A9B),+ UINT64_C(0x1C4359104312C5AF), UINT64_C(0xAF6D15AE40B59AC0),+ UINT64_C(0x192D8AF2BAF0E1E8), UINT64_C(0xAA03C64CB957BE87),+ UINT64_C(0xEDA9BCA512B041B3), UINT64_C(0x5E87F01B11171EDC),+ UINT64_C(0x62FD4976457FBFDB), UINT64_C(0xD1D305C846D8E0B4),+ UINT64_C(0x96797F21ED3F1F80), UINT64_C(0x2557339FEE9840EF),+ UINT64_C(0xEE8C0DFB45EE5D8E), UINT64_C(0x5DA24145464902E1),+ UINT64_C(0x1A083BACEDAEFDD5), UINT64_C(0xA9267712EE09A2BA),+ UINT64_C(0x955CCE7FBA6103BD), UINT64_C(0x267282C1B9C65CD2),+ UINT64_C(0x61D8F8281221A3E6), UINT64_C(0xD2F6B4961186FC89),+ UINT64_C(0x9F8169BA49A54B33), UINT64_C(0x2CAF25044A02145C),+ UINT64_C(0x6B055FEDE1E5EB68), UINT64_C(0xD82B1353E242B407),+ UINT64_C(0xE451AA3EB62A1500), UINT64_C(0x577FE680B58D4A6F),+ UINT64_C(0x10D59C691E6AB55B), UINT64_C(0xA3FBD0D71DCDEA34),+ UINT64_C(0x6820EEB3B6BBF755), UINT64_C(0xDB0EA20DB51CA83A),+ UINT64_C(0x9CA4D8E41EFB570E), UINT64_C(0x2F8A945A1D5C0861),+ UINT64_C(0x13F02D374934A966), UINT64_C(0xA0DE61894A93F609),+ UINT64_C(0xE7741B60E174093D), UINT64_C(0x545A57DEE2D35652),+ UINT64_C(0xE21AC88218962D7A), UINT64_C(0x5134843C1B317215),+ UINT64_C(0x169EFED5B0D68D21), UINT64_C(0xA5B0B26BB371D24E),+ UINT64_C(0x99CA0B06E7197349), UINT64_C(0x2AE447B8E4BE2C26),+ UINT64_C(0x6D4E3D514F59D312), UINT64_C(0xDE6071EF4CFE8C7D),+ UINT64_C(0x15BB4F8BE788911C), UINT64_C(0xA6950335E42FCE73),+ UINT64_C(0xE13F79DC4FC83147), UINT64_C(0x521135624C6F6E28),+ UINT64_C(0x6E6B8C0F1807CF2F), UINT64_C(0xDD45C0B11BA09040),+ UINT64_C(0x9AEFBA58B0476F74), UINT64_C(0x29C1F6E6B3E0301B),+ UINT64_C(0xC96C5795D7870F42), UINT64_C(0x7A421B2BD420502D),+ UINT64_C(0x3DE861C27FC7AF19), UINT64_C(0x8EC62D7C7C60F076),+ UINT64_C(0xB2BC941128085171), UINT64_C(0x0192D8AF2BAF0E1E),+ UINT64_C(0x4638A2468048F12A), UINT64_C(0xF516EEF883EFAE45),+ UINT64_C(0x3ECDD09C2899B324), UINT64_C(0x8DE39C222B3EEC4B),+ UINT64_C(0xCA49E6CB80D9137F), UINT64_C(0x7967AA75837E4C10),+ UINT64_C(0x451D1318D716ED17), UINT64_C(0xF6335FA6D4B1B278),+ UINT64_C(0xB199254F7F564D4C), UINT64_C(0x02B769F17CF11223),+ UINT64_C(0xB4F7F6AD86B4690B), UINT64_C(0x07D9BA1385133664),+ UINT64_C(0x4073C0FA2EF4C950), UINT64_C(0xF35D8C442D53963F),+ UINT64_C(0xCF273529793B3738), UINT64_C(0x7C0979977A9C6857),+ UINT64_C(0x3BA3037ED17B9763), UINT64_C(0x888D4FC0D2DCC80C),+ UINT64_C(0x435671A479AAD56D), UINT64_C(0xF0783D1A7A0D8A02),+ UINT64_C(0xB7D247F3D1EA7536), UINT64_C(0x04FC0B4DD24D2A59),+ UINT64_C(0x3886B22086258B5E), UINT64_C(0x8BA8FE9E8582D431),+ UINT64_C(0xCC0284772E652B05), UINT64_C(0x7F2CC8C92DC2746A),+ UINT64_C(0x325B15E575E1C3D0), UINT64_C(0x8175595B76469CBF),+ UINT64_C(0xC6DF23B2DDA1638B), UINT64_C(0x75F16F0CDE063CE4),+ UINT64_C(0x498BD6618A6E9DE3), UINT64_C(0xFAA59ADF89C9C28C),+ UINT64_C(0xBD0FE036222E3DB8), UINT64_C(0x0E21AC88218962D7),+ UINT64_C(0xC5FA92EC8AFF7FB6), UINT64_C(0x76D4DE52895820D9),+ UINT64_C(0x317EA4BB22BFDFED), UINT64_C(0x8250E80521188082),+ UINT64_C(0xBE2A516875702185), UINT64_C(0x0D041DD676D77EEA),+ UINT64_C(0x4AAE673FDD3081DE), UINT64_C(0xF9802B81DE97DEB1),+ UINT64_C(0x4FC0B4DD24D2A599), UINT64_C(0xFCEEF8632775FAF6),+ UINT64_C(0xBB44828A8C9205C2), UINT64_C(0x086ACE348F355AAD),+ UINT64_C(0x34107759DB5DFBAA), UINT64_C(0x873E3BE7D8FAA4C5),+ UINT64_C(0xC094410E731D5BF1), UINT64_C(0x73BA0DB070BA049E),+ UINT64_C(0xB86133D4DBCC19FF), UINT64_C(0x0B4F7F6AD86B4690),+ UINT64_C(0x4CE50583738CB9A4), UINT64_C(0xFFCB493D702BE6CB),+ UINT64_C(0xC3B1F050244347CC), UINT64_C(0x709FBCEE27E418A3),+ UINT64_C(0x3735C6078C03E797), UINT64_C(0x841B8AB98FA4B8F8),+ UINT64_C(0xADDA7C5F3C4488E3), UINT64_C(0x1EF430E13FE3D78C),+ UINT64_C(0x595E4A08940428B8), UINT64_C(0xEA7006B697A377D7),+ UINT64_C(0xD60ABFDBC3CBD6D0), UINT64_C(0x6524F365C06C89BF),+ UINT64_C(0x228E898C6B8B768B), UINT64_C(0x91A0C532682C29E4),+ UINT64_C(0x5A7BFB56C35A3485), UINT64_C(0xE955B7E8C0FD6BEA),+ UINT64_C(0xAEFFCD016B1A94DE), UINT64_C(0x1DD181BF68BDCBB1),+ UINT64_C(0x21AB38D23CD56AB6), UINT64_C(0x9285746C3F7235D9),+ UINT64_C(0xD52F0E859495CAED), UINT64_C(0x6601423B97329582),+ UINT64_C(0xD041DD676D77EEAA), UINT64_C(0x636F91D96ED0B1C5),+ UINT64_C(0x24C5EB30C5374EF1), UINT64_C(0x97EBA78EC690119E),+ UINT64_C(0xAB911EE392F8B099), UINT64_C(0x18BF525D915FEFF6),+ UINT64_C(0x5F1528B43AB810C2), UINT64_C(0xEC3B640A391F4FAD),+ UINT64_C(0x27E05A6E926952CC), UINT64_C(0x94CE16D091CE0DA3),+ UINT64_C(0xD3646C393A29F297), UINT64_C(0x604A2087398EADF8),+ UINT64_C(0x5C3099EA6DE60CFF), UINT64_C(0xEF1ED5546E415390),+ UINT64_C(0xA8B4AFBDC5A6ACA4), UINT64_C(0x1B9AE303C601F3CB),+ UINT64_C(0x56ED3E2F9E224471), UINT64_C(0xE5C372919D851B1E),+ UINT64_C(0xA26908783662E42A), UINT64_C(0x114744C635C5BB45),+ UINT64_C(0x2D3DFDAB61AD1A42), UINT64_C(0x9E13B115620A452D),+ UINT64_C(0xD9B9CBFCC9EDBA19), UINT64_C(0x6A978742CA4AE576),+ UINT64_C(0xA14CB926613CF817), UINT64_C(0x1262F598629BA778),+ UINT64_C(0x55C88F71C97C584C), UINT64_C(0xE6E6C3CFCADB0723),+ UINT64_C(0xDA9C7AA29EB3A624), UINT64_C(0x69B2361C9D14F94B),+ UINT64_C(0x2E184CF536F3067F), UINT64_C(0x9D36004B35545910),+ UINT64_C(0x2B769F17CF112238), UINT64_C(0x9858D3A9CCB67D57),+ UINT64_C(0xDFF2A94067518263), UINT64_C(0x6CDCE5FE64F6DD0C),+ UINT64_C(0x50A65C93309E7C0B), UINT64_C(0xE388102D33392364),+ UINT64_C(0xA4226AC498DEDC50), UINT64_C(0x170C267A9B79833F),+ UINT64_C(0xDCD7181E300F9E5E), UINT64_C(0x6FF954A033A8C131),+ UINT64_C(0x28532E49984F3E05), UINT64_C(0x9B7D62F79BE8616A),+ UINT64_C(0xA707DB9ACF80C06D), UINT64_C(0x14299724CC279F02),+ UINT64_C(0x5383EDCD67C06036), UINT64_C(0xE0ADA17364673F59)+ }, {+ UINT64_C(0x0000000000000000), UINT64_C(0x54E979925CD0F10D),+ UINT64_C(0xA9D2F324B9A1E21A), UINT64_C(0xFD3B8AB6E5711317),+ UINT64_C(0xC17D4962DC4DDAB1), UINT64_C(0x959430F0809D2BBC),+ UINT64_C(0x68AFBA4665EC38AB), UINT64_C(0x3C46C3D4393CC9A6),+ UINT64_C(0x10223DEE1795ABE7), UINT64_C(0x44CB447C4B455AEA),+ UINT64_C(0xB9F0CECAAE3449FD), UINT64_C(0xED19B758F2E4B8F0),+ UINT64_C(0xD15F748CCBD87156), UINT64_C(0x85B60D1E9708805B),+ UINT64_C(0x788D87A87279934C), UINT64_C(0x2C64FE3A2EA96241),+ UINT64_C(0x20447BDC2F2B57CE), UINT64_C(0x74AD024E73FBA6C3),+ UINT64_C(0x899688F8968AB5D4), UINT64_C(0xDD7FF16ACA5A44D9),+ UINT64_C(0xE13932BEF3668D7F), UINT64_C(0xB5D04B2CAFB67C72),+ UINT64_C(0x48EBC19A4AC76F65), UINT64_C(0x1C02B80816179E68),+ UINT64_C(0x3066463238BEFC29), UINT64_C(0x648F3FA0646E0D24),+ UINT64_C(0x99B4B516811F1E33), UINT64_C(0xCD5DCC84DDCFEF3E),+ UINT64_C(0xF11B0F50E4F32698), UINT64_C(0xA5F276C2B823D795),+ UINT64_C(0x58C9FC745D52C482), UINT64_C(0x0C2085E60182358F),+ UINT64_C(0x4088F7B85E56AF9C), UINT64_C(0x14618E2A02865E91),+ UINT64_C(0xE95A049CE7F74D86), UINT64_C(0xBDB37D0EBB27BC8B),+ UINT64_C(0x81F5BEDA821B752D), UINT64_C(0xD51CC748DECB8420),+ UINT64_C(0x28274DFE3BBA9737), UINT64_C(0x7CCE346C676A663A),+ UINT64_C(0x50AACA5649C3047B), UINT64_C(0x0443B3C41513F576),+ UINT64_C(0xF9783972F062E661), UINT64_C(0xAD9140E0ACB2176C),+ UINT64_C(0x91D78334958EDECA), UINT64_C(0xC53EFAA6C95E2FC7),+ UINT64_C(0x380570102C2F3CD0), UINT64_C(0x6CEC098270FFCDDD),+ UINT64_C(0x60CC8C64717DF852), UINT64_C(0x3425F5F62DAD095F),+ UINT64_C(0xC91E7F40C8DC1A48), UINT64_C(0x9DF706D2940CEB45),+ UINT64_C(0xA1B1C506AD3022E3), UINT64_C(0xF558BC94F1E0D3EE),+ UINT64_C(0x086336221491C0F9), UINT64_C(0x5C8A4FB0484131F4),+ UINT64_C(0x70EEB18A66E853B5), UINT64_C(0x2407C8183A38A2B8),+ UINT64_C(0xD93C42AEDF49B1AF), UINT64_C(0x8DD53B3C839940A2),+ UINT64_C(0xB193F8E8BAA58904), UINT64_C(0xE57A817AE6757809),+ UINT64_C(0x18410BCC03046B1E), UINT64_C(0x4CA8725E5FD49A13),+ UINT64_C(0x8111EF70BCAD5F38), UINT64_C(0xD5F896E2E07DAE35),+ UINT64_C(0x28C31C54050CBD22), UINT64_C(0x7C2A65C659DC4C2F),+ UINT64_C(0x406CA61260E08589), UINT64_C(0x1485DF803C307484),+ UINT64_C(0xE9BE5536D9416793), UINT64_C(0xBD572CA48591969E),+ UINT64_C(0x9133D29EAB38F4DF), UINT64_C(0xC5DAAB0CF7E805D2),+ UINT64_C(0x38E121BA129916C5), UINT64_C(0x6C0858284E49E7C8),+ UINT64_C(0x504E9BFC77752E6E), UINT64_C(0x04A7E26E2BA5DF63),+ UINT64_C(0xF99C68D8CED4CC74), UINT64_C(0xAD75114A92043D79),+ UINT64_C(0xA15594AC938608F6), UINT64_C(0xF5BCED3ECF56F9FB),+ UINT64_C(0x088767882A27EAEC), UINT64_C(0x5C6E1E1A76F71BE1),+ UINT64_C(0x6028DDCE4FCBD247), UINT64_C(0x34C1A45C131B234A),+ UINT64_C(0xC9FA2EEAF66A305D), UINT64_C(0x9D135778AABAC150),+ UINT64_C(0xB177A9428413A311), UINT64_C(0xE59ED0D0D8C3521C),+ UINT64_C(0x18A55A663DB2410B), UINT64_C(0x4C4C23F46162B006),+ UINT64_C(0x700AE020585E79A0), UINT64_C(0x24E399B2048E88AD),+ UINT64_C(0xD9D81304E1FF9BBA), UINT64_C(0x8D316A96BD2F6AB7),+ UINT64_C(0xC19918C8E2FBF0A4), UINT64_C(0x9570615ABE2B01A9),+ UINT64_C(0x684BEBEC5B5A12BE), UINT64_C(0x3CA2927E078AE3B3),+ UINT64_C(0x00E451AA3EB62A15), UINT64_C(0x540D28386266DB18),+ UINT64_C(0xA936A28E8717C80F), UINT64_C(0xFDDFDB1CDBC73902),+ UINT64_C(0xD1BB2526F56E5B43), UINT64_C(0x85525CB4A9BEAA4E),+ UINT64_C(0x7869D6024CCFB959), UINT64_C(0x2C80AF90101F4854),+ UINT64_C(0x10C66C44292381F2), UINT64_C(0x442F15D675F370FF),+ UINT64_C(0xB9149F60908263E8), UINT64_C(0xEDFDE6F2CC5292E5),+ UINT64_C(0xE1DD6314CDD0A76A), UINT64_C(0xB5341A8691005667),+ UINT64_C(0x480F903074714570), UINT64_C(0x1CE6E9A228A1B47D),+ UINT64_C(0x20A02A76119D7DDB), UINT64_C(0x744953E44D4D8CD6),+ UINT64_C(0x8972D952A83C9FC1), UINT64_C(0xDD9BA0C0F4EC6ECC),+ UINT64_C(0xF1FF5EFADA450C8D), UINT64_C(0xA51627688695FD80),+ UINT64_C(0x582DADDE63E4EE97), UINT64_C(0x0CC4D44C3F341F9A),+ UINT64_C(0x308217980608D63C), UINT64_C(0x646B6E0A5AD82731),+ UINT64_C(0x9950E4BCBFA93426), UINT64_C(0xCDB99D2EE379C52B),+ UINT64_C(0x90FB71CAD654A0F5), UINT64_C(0xC41208588A8451F8),+ UINT64_C(0x392982EE6FF542EF), UINT64_C(0x6DC0FB7C3325B3E2),+ UINT64_C(0x518638A80A197A44), UINT64_C(0x056F413A56C98B49),+ UINT64_C(0xF854CB8CB3B8985E), UINT64_C(0xACBDB21EEF686953),+ UINT64_C(0x80D94C24C1C10B12), UINT64_C(0xD43035B69D11FA1F),+ UINT64_C(0x290BBF007860E908), UINT64_C(0x7DE2C69224B01805),+ UINT64_C(0x41A405461D8CD1A3), UINT64_C(0x154D7CD4415C20AE),+ UINT64_C(0xE876F662A42D33B9), UINT64_C(0xBC9F8FF0F8FDC2B4),+ UINT64_C(0xB0BF0A16F97FF73B), UINT64_C(0xE4567384A5AF0636),+ UINT64_C(0x196DF93240DE1521), UINT64_C(0x4D8480A01C0EE42C),+ UINT64_C(0x71C2437425322D8A), UINT64_C(0x252B3AE679E2DC87),+ UINT64_C(0xD810B0509C93CF90), UINT64_C(0x8CF9C9C2C0433E9D),+ UINT64_C(0xA09D37F8EEEA5CDC), UINT64_C(0xF4744E6AB23AADD1),+ UINT64_C(0x094FC4DC574BBEC6), UINT64_C(0x5DA6BD4E0B9B4FCB),+ UINT64_C(0x61E07E9A32A7866D), UINT64_C(0x350907086E777760),+ UINT64_C(0xC8328DBE8B066477), UINT64_C(0x9CDBF42CD7D6957A),+ UINT64_C(0xD073867288020F69), UINT64_C(0x849AFFE0D4D2FE64),+ UINT64_C(0x79A1755631A3ED73), UINT64_C(0x2D480CC46D731C7E),+ UINT64_C(0x110ECF10544FD5D8), UINT64_C(0x45E7B682089F24D5),+ UINT64_C(0xB8DC3C34EDEE37C2), UINT64_C(0xEC3545A6B13EC6CF),+ UINT64_C(0xC051BB9C9F97A48E), UINT64_C(0x94B8C20EC3475583),+ UINT64_C(0x698348B826364694), UINT64_C(0x3D6A312A7AE6B799),+ UINT64_C(0x012CF2FE43DA7E3F), UINT64_C(0x55C58B6C1F0A8F32),+ UINT64_C(0xA8FE01DAFA7B9C25), UINT64_C(0xFC177848A6AB6D28),+ UINT64_C(0xF037FDAEA72958A7), UINT64_C(0xA4DE843CFBF9A9AA),+ UINT64_C(0x59E50E8A1E88BABD), UINT64_C(0x0D0C771842584BB0),+ UINT64_C(0x314AB4CC7B648216), UINT64_C(0x65A3CD5E27B4731B),+ UINT64_C(0x989847E8C2C5600C), UINT64_C(0xCC713E7A9E159101),+ UINT64_C(0xE015C040B0BCF340), UINT64_C(0xB4FCB9D2EC6C024D),+ UINT64_C(0x49C73364091D115A), UINT64_C(0x1D2E4AF655CDE057),+ UINT64_C(0x216889226CF129F1), UINT64_C(0x7581F0B03021D8FC),+ UINT64_C(0x88BA7A06D550CBEB), UINT64_C(0xDC53039489803AE6),+ UINT64_C(0x11EA9EBA6AF9FFCD), UINT64_C(0x4503E72836290EC0),+ UINT64_C(0xB8386D9ED3581DD7), UINT64_C(0xECD1140C8F88ECDA),+ UINT64_C(0xD097D7D8B6B4257C), UINT64_C(0x847EAE4AEA64D471),+ UINT64_C(0x794524FC0F15C766), UINT64_C(0x2DAC5D6E53C5366B),+ UINT64_C(0x01C8A3547D6C542A), UINT64_C(0x5521DAC621BCA527),+ UINT64_C(0xA81A5070C4CDB630), UINT64_C(0xFCF329E2981D473D),+ UINT64_C(0xC0B5EA36A1218E9B), UINT64_C(0x945C93A4FDF17F96),+ UINT64_C(0x6967191218806C81), UINT64_C(0x3D8E608044509D8C),+ UINT64_C(0x31AEE56645D2A803), UINT64_C(0x65479CF41902590E),+ UINT64_C(0x987C1642FC734A19), UINT64_C(0xCC956FD0A0A3BB14),+ UINT64_C(0xF0D3AC04999F72B2), UINT64_C(0xA43AD596C54F83BF),+ UINT64_C(0x59015F20203E90A8), UINT64_C(0x0DE826B27CEE61A5),+ UINT64_C(0x218CD888524703E4), UINT64_C(0x7565A11A0E97F2E9),+ UINT64_C(0x885E2BACEBE6E1FE), UINT64_C(0xDCB7523EB73610F3),+ UINT64_C(0xE0F191EA8E0AD955), UINT64_C(0xB418E878D2DA2858),+ UINT64_C(0x492362CE37AB3B4F), UINT64_C(0x1DCA1B5C6B7BCA42),+ UINT64_C(0x5162690234AF5051), UINT64_C(0x058B1090687FA15C),+ UINT64_C(0xF8B09A268D0EB24B), UINT64_C(0xAC59E3B4D1DE4346),+ UINT64_C(0x901F2060E8E28AE0), UINT64_C(0xC4F659F2B4327BED),+ UINT64_C(0x39CDD344514368FA), UINT64_C(0x6D24AAD60D9399F7),+ UINT64_C(0x414054EC233AFBB6), UINT64_C(0x15A92D7E7FEA0ABB),+ UINT64_C(0xE892A7C89A9B19AC), UINT64_C(0xBC7BDE5AC64BE8A1),+ UINT64_C(0x803D1D8EFF772107), UINT64_C(0xD4D4641CA3A7D00A),+ UINT64_C(0x29EFEEAA46D6C31D), UINT64_C(0x7D0697381A063210),+ UINT64_C(0x712612DE1B84079F), UINT64_C(0x25CF6B4C4754F692),+ UINT64_C(0xD8F4E1FAA225E585), UINT64_C(0x8C1D9868FEF51488),+ UINT64_C(0xB05B5BBCC7C9DD2E), UINT64_C(0xE4B2222E9B192C23),+ UINT64_C(0x1989A8987E683F34), UINT64_C(0x4D60D10A22B8CE39),+ UINT64_C(0x61042F300C11AC78), UINT64_C(0x35ED56A250C15D75),+ UINT64_C(0xC8D6DC14B5B04E62), UINT64_C(0x9C3FA586E960BF6F),+ UINT64_C(0xA0796652D05C76C9), UINT64_C(0xF4901FC08C8C87C4),+ UINT64_C(0x09AB957669FD94D3), UINT64_C(0x5D42ECE4352D65DE)+ }, {+ UINT64_C(0x0000000000000000), UINT64_C(0x3F0BE14A916A6DCB),+ UINT64_C(0x7E17C29522D4DB96), UINT64_C(0x411C23DFB3BEB65D),+ UINT64_C(0xFC2F852A45A9B72C), UINT64_C(0xC3246460D4C3DAE7),+ UINT64_C(0x823847BF677D6CBA), UINT64_C(0xBD33A6F5F6170171),+ UINT64_C(0x6A87A57F245D70DD), UINT64_C(0x558C4435B5371D16),+ UINT64_C(0x149067EA0689AB4B), UINT64_C(0x2B9B86A097E3C680),+ UINT64_C(0x96A8205561F4C7F1), UINT64_C(0xA9A3C11FF09EAA3A),+ UINT64_C(0xE8BFE2C043201C67), UINT64_C(0xD7B4038AD24A71AC),+ UINT64_C(0xD50F4AFE48BAE1BA), UINT64_C(0xEA04ABB4D9D08C71),+ UINT64_C(0xAB18886B6A6E3A2C), UINT64_C(0x94136921FB0457E7),+ UINT64_C(0x2920CFD40D135696), UINT64_C(0x162B2E9E9C793B5D),+ UINT64_C(0x57370D412FC78D00), UINT64_C(0x683CEC0BBEADE0CB),+ UINT64_C(0xBF88EF816CE79167), UINT64_C(0x80830ECBFD8DFCAC),+ UINT64_C(0xC19F2D144E334AF1), UINT64_C(0xFE94CC5EDF59273A),+ UINT64_C(0x43A76AAB294E264B), UINT64_C(0x7CAC8BE1B8244B80),+ UINT64_C(0x3DB0A83E0B9AFDDD), UINT64_C(0x02BB49749AF09016),+ UINT64_C(0x38C63AD73E7BDDF1), UINT64_C(0x07CDDB9DAF11B03A),+ UINT64_C(0x46D1F8421CAF0667), UINT64_C(0x79DA19088DC56BAC),+ UINT64_C(0xC4E9BFFD7BD26ADD), UINT64_C(0xFBE25EB7EAB80716),+ UINT64_C(0xBAFE7D685906B14B), UINT64_C(0x85F59C22C86CDC80),+ UINT64_C(0x52419FA81A26AD2C), UINT64_C(0x6D4A7EE28B4CC0E7),+ UINT64_C(0x2C565D3D38F276BA), UINT64_C(0x135DBC77A9981B71),+ UINT64_C(0xAE6E1A825F8F1A00), UINT64_C(0x9165FBC8CEE577CB),+ UINT64_C(0xD079D8177D5BC196), UINT64_C(0xEF72395DEC31AC5D),+ UINT64_C(0xEDC9702976C13C4B), UINT64_C(0xD2C29163E7AB5180),+ UINT64_C(0x93DEB2BC5415E7DD), UINT64_C(0xACD553F6C57F8A16),+ UINT64_C(0x11E6F50333688B67), UINT64_C(0x2EED1449A202E6AC),+ UINT64_C(0x6FF1379611BC50F1), UINT64_C(0x50FAD6DC80D63D3A),+ UINT64_C(0x874ED556529C4C96), UINT64_C(0xB845341CC3F6215D),+ UINT64_C(0xF95917C370489700), UINT64_C(0xC652F689E122FACB),+ UINT64_C(0x7B61507C1735FBBA), UINT64_C(0x446AB136865F9671),+ UINT64_C(0x057692E935E1202C), UINT64_C(0x3A7D73A3A48B4DE7),+ UINT64_C(0x718C75AE7CF7BBE2), UINT64_C(0x4E8794E4ED9DD629),+ UINT64_C(0x0F9BB73B5E236074), UINT64_C(0x30905671CF490DBF),+ UINT64_C(0x8DA3F084395E0CCE), UINT64_C(0xB2A811CEA8346105),+ UINT64_C(0xF3B432111B8AD758), UINT64_C(0xCCBFD35B8AE0BA93),+ UINT64_C(0x1B0BD0D158AACB3F), UINT64_C(0x2400319BC9C0A6F4),+ UINT64_C(0x651C12447A7E10A9), UINT64_C(0x5A17F30EEB147D62),+ UINT64_C(0xE72455FB1D037C13), UINT64_C(0xD82FB4B18C6911D8),+ UINT64_C(0x9933976E3FD7A785), UINT64_C(0xA6387624AEBDCA4E),+ UINT64_C(0xA4833F50344D5A58), UINT64_C(0x9B88DE1AA5273793),+ UINT64_C(0xDA94FDC5169981CE), UINT64_C(0xE59F1C8F87F3EC05),+ UINT64_C(0x58ACBA7A71E4ED74), UINT64_C(0x67A75B30E08E80BF),+ UINT64_C(0x26BB78EF533036E2), UINT64_C(0x19B099A5C25A5B29),+ UINT64_C(0xCE049A2F10102A85), UINT64_C(0xF10F7B65817A474E),+ UINT64_C(0xB01358BA32C4F113), UINT64_C(0x8F18B9F0A3AE9CD8),+ UINT64_C(0x322B1F0555B99DA9), UINT64_C(0x0D20FE4FC4D3F062),+ UINT64_C(0x4C3CDD90776D463F), UINT64_C(0x73373CDAE6072BF4),+ UINT64_C(0x494A4F79428C6613), UINT64_C(0x7641AE33D3E60BD8),+ UINT64_C(0x375D8DEC6058BD85), UINT64_C(0x08566CA6F132D04E),+ UINT64_C(0xB565CA530725D13F), UINT64_C(0x8A6E2B19964FBCF4),+ UINT64_C(0xCB7208C625F10AA9), UINT64_C(0xF479E98CB49B6762),+ UINT64_C(0x23CDEA0666D116CE), UINT64_C(0x1CC60B4CF7BB7B05),+ UINT64_C(0x5DDA28934405CD58), UINT64_C(0x62D1C9D9D56FA093),+ UINT64_C(0xDFE26F2C2378A1E2), UINT64_C(0xE0E98E66B212CC29),+ UINT64_C(0xA1F5ADB901AC7A74), UINT64_C(0x9EFE4CF390C617BF),+ UINT64_C(0x9C4505870A3687A9), UINT64_C(0xA34EE4CD9B5CEA62),+ UINT64_C(0xE252C71228E25C3F), UINT64_C(0xDD592658B98831F4),+ UINT64_C(0x606A80AD4F9F3085), UINT64_C(0x5F6161E7DEF55D4E),+ UINT64_C(0x1E7D42386D4BEB13), UINT64_C(0x2176A372FC2186D8),+ UINT64_C(0xF6C2A0F82E6BF774), UINT64_C(0xC9C941B2BF019ABF),+ UINT64_C(0x88D5626D0CBF2CE2), UINT64_C(0xB7DE83279DD54129),+ UINT64_C(0x0AED25D26BC24058), UINT64_C(0x35E6C498FAA82D93),+ UINT64_C(0x74FAE74749169BCE), UINT64_C(0x4BF1060DD87CF605),+ UINT64_C(0xE318EB5CF9EF77C4), UINT64_C(0xDC130A1668851A0F),+ UINT64_C(0x9D0F29C9DB3BAC52), UINT64_C(0xA204C8834A51C199),+ UINT64_C(0x1F376E76BC46C0E8), UINT64_C(0x203C8F3C2D2CAD23),+ UINT64_C(0x6120ACE39E921B7E), UINT64_C(0x5E2B4DA90FF876B5),+ UINT64_C(0x899F4E23DDB20719), UINT64_C(0xB694AF694CD86AD2),+ UINT64_C(0xF7888CB6FF66DC8F), UINT64_C(0xC8836DFC6E0CB144),+ UINT64_C(0x75B0CB09981BB035), UINT64_C(0x4ABB2A430971DDFE),+ UINT64_C(0x0BA7099CBACF6BA3), UINT64_C(0x34ACE8D62BA50668),+ UINT64_C(0x3617A1A2B155967E), UINT64_C(0x091C40E8203FFBB5),+ UINT64_C(0x4800633793814DE8), UINT64_C(0x770B827D02EB2023),+ UINT64_C(0xCA382488F4FC2152), UINT64_C(0xF533C5C265964C99),+ UINT64_C(0xB42FE61DD628FAC4), UINT64_C(0x8B2407574742970F),+ UINT64_C(0x5C9004DD9508E6A3), UINT64_C(0x639BE59704628B68),+ UINT64_C(0x2287C648B7DC3D35), UINT64_C(0x1D8C270226B650FE),+ UINT64_C(0xA0BF81F7D0A1518F), UINT64_C(0x9FB460BD41CB3C44),+ UINT64_C(0xDEA84362F2758A19), UINT64_C(0xE1A3A228631FE7D2),+ UINT64_C(0xDBDED18BC794AA35), UINT64_C(0xE4D530C156FEC7FE),+ UINT64_C(0xA5C9131EE54071A3), UINT64_C(0x9AC2F254742A1C68),+ UINT64_C(0x27F154A1823D1D19), UINT64_C(0x18FAB5EB135770D2),+ UINT64_C(0x59E69634A0E9C68F), UINT64_C(0x66ED777E3183AB44),+ UINT64_C(0xB15974F4E3C9DAE8), UINT64_C(0x8E5295BE72A3B723),+ UINT64_C(0xCF4EB661C11D017E), UINT64_C(0xF045572B50776CB5),+ UINT64_C(0x4D76F1DEA6606DC4), UINT64_C(0x727D1094370A000F),+ UINT64_C(0x3361334B84B4B652), UINT64_C(0x0C6AD20115DEDB99),+ UINT64_C(0x0ED19B758F2E4B8F), UINT64_C(0x31DA7A3F1E442644),+ UINT64_C(0x70C659E0ADFA9019), UINT64_C(0x4FCDB8AA3C90FDD2),+ UINT64_C(0xF2FE1E5FCA87FCA3), UINT64_C(0xCDF5FF155BED9168),+ UINT64_C(0x8CE9DCCAE8532735), UINT64_C(0xB3E23D8079394AFE),+ UINT64_C(0x64563E0AAB733B52), UINT64_C(0x5B5DDF403A195699),+ UINT64_C(0x1A41FC9F89A7E0C4), UINT64_C(0x254A1DD518CD8D0F),+ UINT64_C(0x9879BB20EEDA8C7E), UINT64_C(0xA7725A6A7FB0E1B5),+ UINT64_C(0xE66E79B5CC0E57E8), UINT64_C(0xD96598FF5D643A23),+ UINT64_C(0x92949EF28518CC26), UINT64_C(0xAD9F7FB81472A1ED),+ UINT64_C(0xEC835C67A7CC17B0), UINT64_C(0xD388BD2D36A67A7B),+ UINT64_C(0x6EBB1BD8C0B17B0A), UINT64_C(0x51B0FA9251DB16C1),+ UINT64_C(0x10ACD94DE265A09C), UINT64_C(0x2FA73807730FCD57),+ UINT64_C(0xF8133B8DA145BCFB), UINT64_C(0xC718DAC7302FD130),+ UINT64_C(0x8604F9188391676D), UINT64_C(0xB90F185212FB0AA6),+ UINT64_C(0x043CBEA7E4EC0BD7), UINT64_C(0x3B375FED7586661C),+ UINT64_C(0x7A2B7C32C638D041), UINT64_C(0x45209D785752BD8A),+ UINT64_C(0x479BD40CCDA22D9C), UINT64_C(0x789035465CC84057),+ UINT64_C(0x398C1699EF76F60A), UINT64_C(0x0687F7D37E1C9BC1),+ UINT64_C(0xBBB45126880B9AB0), UINT64_C(0x84BFB06C1961F77B),+ UINT64_C(0xC5A393B3AADF4126), UINT64_C(0xFAA872F93BB52CED),+ UINT64_C(0x2D1C7173E9FF5D41), UINT64_C(0x121790397895308A),+ UINT64_C(0x530BB3E6CB2B86D7), UINT64_C(0x6C0052AC5A41EB1C),+ UINT64_C(0xD133F459AC56EA6D), UINT64_C(0xEE3815133D3C87A6),+ UINT64_C(0xAF2436CC8E8231FB), UINT64_C(0x902FD7861FE85C30),+ UINT64_C(0xAA52A425BB6311D7), UINT64_C(0x9559456F2A097C1C),+ UINT64_C(0xD44566B099B7CA41), UINT64_C(0xEB4E87FA08DDA78A),+ UINT64_C(0x567D210FFECAA6FB), UINT64_C(0x6976C0456FA0CB30),+ UINT64_C(0x286AE39ADC1E7D6D), UINT64_C(0x176102D04D7410A6),+ UINT64_C(0xC0D5015A9F3E610A), UINT64_C(0xFFDEE0100E540CC1),+ UINT64_C(0xBEC2C3CFBDEABA9C), UINT64_C(0x81C922852C80D757),+ UINT64_C(0x3CFA8470DA97D626), UINT64_C(0x03F1653A4BFDBBED),+ UINT64_C(0x42ED46E5F8430DB0), UINT64_C(0x7DE6A7AF6929607B),+ UINT64_C(0x7F5DEEDBF3D9F06D), UINT64_C(0x40560F9162B39DA6),+ UINT64_C(0x014A2C4ED10D2BFB), UINT64_C(0x3E41CD0440674630),+ UINT64_C(0x83726BF1B6704741), UINT64_C(0xBC798ABB271A2A8A),+ UINT64_C(0xFD65A96494A49CD7), UINT64_C(0xC26E482E05CEF11C),+ UINT64_C(0x15DA4BA4D78480B0), UINT64_C(0x2AD1AAEE46EEED7B),+ UINT64_C(0x6BCD8931F5505B26), UINT64_C(0x54C6687B643A36ED),+ UINT64_C(0xE9F5CE8E922D379C), UINT64_C(0xD6FE2FC403475A57),+ UINT64_C(0x97E20C1BB0F9EC0A), UINT64_C(0xA8E9ED51219381C1)+ }, {+ UINT64_C(0x0000000000000000), UINT64_C(0x1DEE8A5E222CA1DC),+ UINT64_C(0x3BDD14BC445943B8), UINT64_C(0x26339EE26675E264),+ UINT64_C(0x77BA297888B28770), UINT64_C(0x6A54A326AA9E26AC),+ UINT64_C(0x4C673DC4CCEBC4C8), UINT64_C(0x5189B79AEEC76514),+ UINT64_C(0xEF7452F111650EE0), UINT64_C(0xF29AD8AF3349AF3C),+ UINT64_C(0xD4A9464D553C4D58), UINT64_C(0xC947CC137710EC84),+ UINT64_C(0x98CE7B8999D78990), UINT64_C(0x8520F1D7BBFB284C),+ UINT64_C(0xA3136F35DD8ECA28), UINT64_C(0xBEFDE56BFFA26BF4),+ UINT64_C(0x4C300AC98DC40345), UINT64_C(0x51DE8097AFE8A299),+ UINT64_C(0x77ED1E75C99D40FD), UINT64_C(0x6A03942BEBB1E121),+ UINT64_C(0x3B8A23B105768435), UINT64_C(0x2664A9EF275A25E9),+ UINT64_C(0x0057370D412FC78D), UINT64_C(0x1DB9BD5363036651),+ UINT64_C(0xA34458389CA10DA5), UINT64_C(0xBEAAD266BE8DAC79),+ UINT64_C(0x98994C84D8F84E1D), UINT64_C(0x8577C6DAFAD4EFC1),+ UINT64_C(0xD4FE714014138AD5), UINT64_C(0xC910FB1E363F2B09),+ UINT64_C(0xEF2365FC504AC96D), UINT64_C(0xF2CDEFA2726668B1),+ UINT64_C(0x986015931B88068A), UINT64_C(0x858E9FCD39A4A756),+ UINT64_C(0xA3BD012F5FD14532), UINT64_C(0xBE538B717DFDE4EE),+ UINT64_C(0xEFDA3CEB933A81FA), UINT64_C(0xF234B6B5B1162026),+ UINT64_C(0xD4072857D763C242), UINT64_C(0xC9E9A209F54F639E),+ UINT64_C(0x771447620AED086A), UINT64_C(0x6AFACD3C28C1A9B6),+ UINT64_C(0x4CC953DE4EB44BD2), UINT64_C(0x5127D9806C98EA0E),+ UINT64_C(0x00AE6E1A825F8F1A), UINT64_C(0x1D40E444A0732EC6),+ UINT64_C(0x3B737AA6C606CCA2), UINT64_C(0x269DF0F8E42A6D7E),+ UINT64_C(0xD4501F5A964C05CF), UINT64_C(0xC9BE9504B460A413),+ UINT64_C(0xEF8D0BE6D2154677), UINT64_C(0xF26381B8F039E7AB),+ UINT64_C(0xA3EA36221EFE82BF), UINT64_C(0xBE04BC7C3CD22363),+ UINT64_C(0x9837229E5AA7C107), UINT64_C(0x85D9A8C0788B60DB),+ UINT64_C(0x3B244DAB87290B2F), UINT64_C(0x26CAC7F5A505AAF3),+ UINT64_C(0x00F95917C3704897), UINT64_C(0x1D17D349E15CE94B),+ UINT64_C(0x4C9E64D30F9B8C5F), UINT64_C(0x5170EE8D2DB72D83),+ UINT64_C(0x7743706F4BC2CFE7), UINT64_C(0x6AADFA3169EE6E3B),+ UINT64_C(0xA218840D981E1391), UINT64_C(0xBFF60E53BA32B24D),+ UINT64_C(0x99C590B1DC475029), UINT64_C(0x842B1AEFFE6BF1F5),+ UINT64_C(0xD5A2AD7510AC94E1), UINT64_C(0xC84C272B3280353D),+ UINT64_C(0xEE7FB9C954F5D759), UINT64_C(0xF391339776D97685),+ UINT64_C(0x4D6CD6FC897B1D71), UINT64_C(0x50825CA2AB57BCAD),+ UINT64_C(0x76B1C240CD225EC9), UINT64_C(0x6B5F481EEF0EFF15),+ UINT64_C(0x3AD6FF8401C99A01), UINT64_C(0x273875DA23E53BDD),+ UINT64_C(0x010BEB384590D9B9), UINT64_C(0x1CE5616667BC7865),+ UINT64_C(0xEE288EC415DA10D4), UINT64_C(0xF3C6049A37F6B108),+ UINT64_C(0xD5F59A785183536C), UINT64_C(0xC81B102673AFF2B0),+ UINT64_C(0x9992A7BC9D6897A4), UINT64_C(0x847C2DE2BF443678),+ UINT64_C(0xA24FB300D931D41C), UINT64_C(0xBFA1395EFB1D75C0),+ UINT64_C(0x015CDC3504BF1E34), UINT64_C(0x1CB2566B2693BFE8),+ UINT64_C(0x3A81C88940E65D8C), UINT64_C(0x276F42D762CAFC50),+ UINT64_C(0x76E6F54D8C0D9944), UINT64_C(0x6B087F13AE213898),+ UINT64_C(0x4D3BE1F1C854DAFC), UINT64_C(0x50D56BAFEA787B20),+ UINT64_C(0x3A78919E8396151B), UINT64_C(0x27961BC0A1BAB4C7),+ UINT64_C(0x01A58522C7CF56A3), UINT64_C(0x1C4B0F7CE5E3F77F),+ UINT64_C(0x4DC2B8E60B24926B), UINT64_C(0x502C32B8290833B7),+ UINT64_C(0x761FAC5A4F7DD1D3), UINT64_C(0x6BF126046D51700F),+ UINT64_C(0xD50CC36F92F31BFB), UINT64_C(0xC8E24931B0DFBA27),+ UINT64_C(0xEED1D7D3D6AA5843), UINT64_C(0xF33F5D8DF486F99F),+ UINT64_C(0xA2B6EA171A419C8B), UINT64_C(0xBF586049386D3D57),+ UINT64_C(0x996BFEAB5E18DF33), UINT64_C(0x848574F57C347EEF),+ UINT64_C(0x76489B570E52165E), UINT64_C(0x6BA611092C7EB782),+ UINT64_C(0x4D958FEB4A0B55E6), UINT64_C(0x507B05B56827F43A),+ UINT64_C(0x01F2B22F86E0912E), UINT64_C(0x1C1C3871A4CC30F2),+ UINT64_C(0x3A2FA693C2B9D296), UINT64_C(0x27C12CCDE095734A),+ UINT64_C(0x993CC9A61F3718BE), UINT64_C(0x84D243F83D1BB962),+ UINT64_C(0xA2E1DD1A5B6E5B06), UINT64_C(0xBF0F57447942FADA),+ UINT64_C(0xEE86E0DE97859FCE), UINT64_C(0xF3686A80B5A93E12),+ UINT64_C(0xD55BF462D3DCDC76), UINT64_C(0xC8B57E3CF1F07DAA),+ UINT64_C(0xD6E9A7309F3239A7), UINT64_C(0xCB072D6EBD1E987B),+ UINT64_C(0xED34B38CDB6B7A1F), UINT64_C(0xF0DA39D2F947DBC3),+ UINT64_C(0xA1538E481780BED7), UINT64_C(0xBCBD041635AC1F0B),+ UINT64_C(0x9A8E9AF453D9FD6F), UINT64_C(0x876010AA71F55CB3),+ UINT64_C(0x399DF5C18E573747), UINT64_C(0x24737F9FAC7B969B),+ UINT64_C(0x0240E17DCA0E74FF), UINT64_C(0x1FAE6B23E822D523),+ UINT64_C(0x4E27DCB906E5B037), UINT64_C(0x53C956E724C911EB),+ UINT64_C(0x75FAC80542BCF38F), UINT64_C(0x6814425B60905253),+ UINT64_C(0x9AD9ADF912F63AE2), UINT64_C(0x873727A730DA9B3E),+ UINT64_C(0xA104B94556AF795A), UINT64_C(0xBCEA331B7483D886),+ UINT64_C(0xED6384819A44BD92), UINT64_C(0xF08D0EDFB8681C4E),+ UINT64_C(0xD6BE903DDE1DFE2A), UINT64_C(0xCB501A63FC315FF6),+ UINT64_C(0x75ADFF0803933402), UINT64_C(0x6843755621BF95DE),+ UINT64_C(0x4E70EBB447CA77BA), UINT64_C(0x539E61EA65E6D666),+ UINT64_C(0x0217D6708B21B372), UINT64_C(0x1FF95C2EA90D12AE),+ UINT64_C(0x39CAC2CCCF78F0CA), UINT64_C(0x24244892ED545116),+ UINT64_C(0x4E89B2A384BA3F2D), UINT64_C(0x536738FDA6969EF1),+ UINT64_C(0x7554A61FC0E37C95), UINT64_C(0x68BA2C41E2CFDD49),+ UINT64_C(0x39339BDB0C08B85D), UINT64_C(0x24DD11852E241981),+ UINT64_C(0x02EE8F674851FBE5), UINT64_C(0x1F0005396A7D5A39),+ UINT64_C(0xA1FDE05295DF31CD), UINT64_C(0xBC136A0CB7F39011),+ UINT64_C(0x9A20F4EED1867275), UINT64_C(0x87CE7EB0F3AAD3A9),+ UINT64_C(0xD647C92A1D6DB6BD), UINT64_C(0xCBA943743F411761),+ UINT64_C(0xED9ADD965934F505), UINT64_C(0xF07457C87B1854D9),+ UINT64_C(0x02B9B86A097E3C68), UINT64_C(0x1F5732342B529DB4),+ UINT64_C(0x3964ACD64D277FD0), UINT64_C(0x248A26886F0BDE0C),+ UINT64_C(0x7503911281CCBB18), UINT64_C(0x68ED1B4CA3E01AC4),+ UINT64_C(0x4EDE85AEC595F8A0), UINT64_C(0x53300FF0E7B9597C),+ UINT64_C(0xEDCDEA9B181B3288), UINT64_C(0xF02360C53A379354),+ UINT64_C(0xD610FE275C427130), UINT64_C(0xCBFE74797E6ED0EC),+ UINT64_C(0x9A77C3E390A9B5F8), UINT64_C(0x879949BDB2851424),+ UINT64_C(0xA1AAD75FD4F0F640), UINT64_C(0xBC445D01F6DC579C),+ UINT64_C(0x74F1233D072C2A36), UINT64_C(0x691FA96325008BEA),+ UINT64_C(0x4F2C37814375698E), UINT64_C(0x52C2BDDF6159C852),+ UINT64_C(0x034B0A458F9EAD46), UINT64_C(0x1EA5801BADB20C9A),+ UINT64_C(0x38961EF9CBC7EEFE), UINT64_C(0x257894A7E9EB4F22),+ UINT64_C(0x9B8571CC164924D6), UINT64_C(0x866BFB923465850A),+ UINT64_C(0xA05865705210676E), UINT64_C(0xBDB6EF2E703CC6B2),+ UINT64_C(0xEC3F58B49EFBA3A6), UINT64_C(0xF1D1D2EABCD7027A),+ UINT64_C(0xD7E24C08DAA2E01E), UINT64_C(0xCA0CC656F88E41C2),+ UINT64_C(0x38C129F48AE82973), UINT64_C(0x252FA3AAA8C488AF),+ UINT64_C(0x031C3D48CEB16ACB), UINT64_C(0x1EF2B716EC9DCB17),+ UINT64_C(0x4F7B008C025AAE03), UINT64_C(0x52958AD220760FDF),+ UINT64_C(0x74A614304603EDBB), UINT64_C(0x69489E6E642F4C67),+ UINT64_C(0xD7B57B059B8D2793), UINT64_C(0xCA5BF15BB9A1864F),+ UINT64_C(0xEC686FB9DFD4642B), UINT64_C(0xF186E5E7FDF8C5F7),+ UINT64_C(0xA00F527D133FA0E3), UINT64_C(0xBDE1D8233113013F),+ UINT64_C(0x9BD246C15766E35B), UINT64_C(0x863CCC9F754A4287),+ UINT64_C(0xEC9136AE1CA42CBC), UINT64_C(0xF17FBCF03E888D60),+ UINT64_C(0xD74C221258FD6F04), UINT64_C(0xCAA2A84C7AD1CED8),+ UINT64_C(0x9B2B1FD69416ABCC), UINT64_C(0x86C59588B63A0A10),+ UINT64_C(0xA0F60B6AD04FE874), UINT64_C(0xBD188134F26349A8),+ UINT64_C(0x03E5645F0DC1225C), UINT64_C(0x1E0BEE012FED8380),+ UINT64_C(0x383870E3499861E4), UINT64_C(0x25D6FABD6BB4C038),+ UINT64_C(0x745F4D278573A52C), UINT64_C(0x69B1C779A75F04F0),+ UINT64_C(0x4F82599BC12AE694), UINT64_C(0x526CD3C5E3064748),+ UINT64_C(0xA0A13C6791602FF9), UINT64_C(0xBD4FB639B34C8E25),+ UINT64_C(0x9B7C28DBD5396C41), UINT64_C(0x8692A285F715CD9D),+ UINT64_C(0xD71B151F19D2A889), UINT64_C(0xCAF59F413BFE0955),+ UINT64_C(0xECC601A35D8BEB31), UINT64_C(0xF1288BFD7FA74AED),+ UINT64_C(0x4FD56E9680052119), UINT64_C(0x523BE4C8A22980C5),+ UINT64_C(0x74087A2AC45C62A1), UINT64_C(0x69E6F074E670C37D),+ UINT64_C(0x386F47EE08B7A669), UINT64_C(0x2581CDB02A9B07B5),+ UINT64_C(0x03B253524CEEE5D1), UINT64_C(0x1E5CD90C6EC2440D)+ }+};
+ cbits/liblzma/check/crc64_tablegen.c view
@@ -0,0 +1,89 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file crc64_tablegen.c+/// \brief Generate crc64_table_le.h and crc64_table_be.h+///+/// Compiling: gcc -std=c99 -o crc64_tablegen crc64_tablegen.c+/// Add -DWORDS_BIGENDIAN to generate big endian table.+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include <stdio.h>+#include "../../common/tuklib_integer.h"+++static uint64_t crc64_table[4][256];+++extern void+init_crc64_table(void)+{+ static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42);++ for (size_t s = 0; s < 4; ++s) {+ for (size_t b = 0; b < 256; ++b) {+ uint64_t r = s == 0 ? b : crc64_table[s - 1][b];++ for (size_t i = 0; i < 8; ++i) {+ if (r & 1)+ r = (r >> 1) ^ poly64;+ else+ r >>= 1;+ }++ crc64_table[s][b] = r;+ }+ }++#ifdef WORDS_BIGENDIAN+ for (size_t s = 0; s < 4; ++s)+ for (size_t b = 0; b < 256; ++b)+ crc64_table[s][b] = byteswap64(crc64_table[s][b]);+#endif++ return;+}+++static void+print_crc64_table(void)+{+ // Split the SPDX string so that it won't accidentally match+ // when tools search for the string.+ printf("// SPDX" "-License-Identifier" ": 0BSD\n\n"+ "// This file has been generated by crc64_tablegen.c.\n\n"+ "const uint64_t lzma_crc64_table[4][256] = {\n\t{");++ for (size_t s = 0; s < 4; ++s) {+ for (size_t b = 0; b < 256; ++b) {+ if ((b % 2) == 0)+ printf("\n\t\t");++ printf("UINT64_C(0x%016" PRIX64 ")",+ crc64_table[s][b]);++ if (b != 255)+ printf(",%s", (b+1) % 2 == 0 ? "" : " ");+ }++ if (s == 3)+ printf("\n\t}\n};\n");+ else+ printf("\n\t}, {");+ }++ return;+}+++int+main(void)+{+ init_crc64_table();+ print_crc64_table();+ return 0;+}
+ cbits/liblzma/check/crc_common.h view
@@ -0,0 +1,137 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file crc_common.h+/// \brief Some functions and macros for CRC32 and CRC64+//+// Authors: Lasse Collin+// Ilya Kurdyukov+// Hans Jansen+// Jia Tan+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_CRC_COMMON_H+#define LZMA_CRC_COMMON_H++#include "common.h"+++#ifdef WORDS_BIGENDIAN+# define A(x) ((x) >> 24)+# define B(x) (((x) >> 16) & 0xFF)+# define C(x) (((x) >> 8) & 0xFF)+# define D(x) ((x) & 0xFF)++# define S8(x) ((x) << 8)+# define S32(x) ((x) << 32)++#else+# define A(x) ((x) & 0xFF)+# define B(x) (((x) >> 8) & 0xFF)+# define C(x) (((x) >> 16) & 0xFF)+# define D(x) ((x) >> 24)++# define S8(x) ((x) >> 8)+# define S32(x) ((x) >> 32)+#endif+++// CRC CLMUL code needs this because accessing input buffers that aren't+// aligned to the vector size will inherently trip the address sanitizer.+#if lzma_has_attribute(__no_sanitize_address__)+# define crc_attr_no_sanitize_address \+ __attribute__((__no_sanitize_address__))+#else+# define crc_attr_no_sanitize_address+#endif++// Keep this in sync with changes to crc32_arm64.h+#if defined(_WIN32) || defined(HAVE_GETAUXVAL) \+ || defined(HAVE_ELF_AUX_INFO) \+ || (defined(__APPLE__) && defined(HAVE_SYSCTLBYNAME))+# define ARM64_RUNTIME_DETECTION 1+#endif+++#undef CRC32_GENERIC+#undef CRC64_GENERIC++#undef CRC32_ARCH_OPTIMIZED+#undef CRC64_ARCH_OPTIMIZED++// The x86 CLMUL is used for both CRC32 and CRC64.+#undef CRC_X86_CLMUL++#undef CRC32_ARM64+#undef CRC64_ARM64_CLMUL++#undef CRC_USE_GENERIC_FOR_SMALL_INPUTS++// ARM64 CRC32 instruction is only useful for CRC32. Currently, only+// little endian is supported since we were unable to test on a big+// endian machine.+//+// NOTE: Keep this and the next check in sync with the macro+// NO_CRC32_TABLE in crc32_table.c+#if defined(HAVE_ARM64_CRC32) && !defined(WORDS_BIGENDIAN)+ // Allow ARM64 CRC32 instruction without a runtime check if+ // __ARM_FEATURE_CRC32 is defined. GCC and Clang only define+ // this if the proper compiler options are used.+# if defined(__ARM_FEATURE_CRC32)+# define CRC32_ARCH_OPTIMIZED 1+# define CRC32_ARM64 1+# elif defined(ARM64_RUNTIME_DETECTION)+# define CRC32_ARCH_OPTIMIZED 1+# define CRC32_ARM64 1+# define CRC32_GENERIC 1+# endif+#endif++#if defined(HAVE_USABLE_CLMUL)+// If CLMUL is allowed unconditionally in the compiler options then the+// generic version can be omitted. Note that this doesn't work with MSVC+// as I don't know how to detect the features here.+//+// NOTE: Keep this in sync with the NO_CRC32_TABLE macro in crc32_table.c+// and NO_CRC64_TABLE in crc64_table.c.+# if (defined(__SSSE3__) && defined(__SSE4_1__) && defined(__PCLMUL__)) \+ || (defined(__e2k__) && __iset__ >= 6)+# define CRC32_ARCH_OPTIMIZED 1+# define CRC64_ARCH_OPTIMIZED 1+# define CRC_X86_CLMUL 1+# else+# define CRC32_GENERIC 1+# define CRC64_GENERIC 1+# define CRC32_ARCH_OPTIMIZED 1+# define CRC64_ARCH_OPTIMIZED 1+# define CRC_X86_CLMUL 1++/*+ // The generic code is much faster with 1-8-byte inputs and+ // has similar performance up to 16 bytes at least in+ // microbenchmarks (it depends on input buffer alignment+ // too). If both versions are built, this #define will use+ // the generic version for inputs up to 16 bytes and CLMUL+ // for bigger inputs. It saves a little in code size since+ // the special cases for 0-16-byte inputs will be omitted+ // from the CLMUL code.+# define CRC_USE_GENERIC_FOR_SMALL_INPUTS 1+*/+# endif+#endif++// For CRC32 use the generic slice-by-eight implementation if no optimized+// version is available.+#if !defined(CRC32_ARCH_OPTIMIZED) && !defined(CRC32_GENERIC)+# define CRC32_GENERIC 1+#endif++// For CRC64 use the generic slice-by-four implementation if no optimized+// version is available.+#if !defined(CRC64_ARCH_OPTIMIZED) && !defined(CRC64_GENERIC)+# define CRC64_GENERIC 1+#endif++#endif
+ cbits/liblzma/check/crc_x86_clmul.h view
@@ -0,0 +1,432 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file crc_x86_clmul.h+/// \brief CRC32 and CRC64 implementations using CLMUL instructions.+///+/// The CRC32 and CRC64 implementations use 32/64-bit x86 SSSE3, SSE4.1, and+/// CLMUL instructions. This is compatible with Elbrus 2000 (E2K) too.+///+/// They were derived from+/// https://www.researchgate.net/publication/263424619_Fast_CRC_computation+/// and the public domain code from https://github.com/rawrunprotected/crc+/// (URLs were checked on 2023-10-14).+///+/// While this file has both CRC32 and CRC64 implementations, only one+/// should be built at a time to ensure that crc_simd_body() is inlined+/// even with compilers with which lzma_always_inline expands to plain inline.+/// The version to build is selected by defining BUILDING_CRC32_CLMUL or+/// BUILDING_CRC64_CLMUL before including this file.+///+/// FIXME: Builds for 32-bit x86 use the assembly .S files by default+/// unless configured with --disable-assembler. Even then the lookup table+/// isn't omitted in crc64_table.c since it doesn't know that assembly+/// code has been disabled.+//+// Authors: Ilya Kurdyukov+// Hans Jansen+// Lasse Collin+// Jia Tan+//+///////////////////////////////////////////////////////////////////////////////++// This file must not be included more than once.+#ifdef LZMA_CRC_X86_CLMUL_H+# error crc_x86_clmul.h was included twice.+#endif+#define LZMA_CRC_X86_CLMUL_H++#include <immintrin.h>++#if defined(_MSC_VER)+# include <intrin.h>+#elif defined(HAVE_CPUID_H)+# include <cpuid.h>+#endif+++// EDG-based compilers (Intel's classic compiler and compiler for E2K) can+// define __GNUC__ but the attribute must not be used with them.+// The new Clang-based ICX needs the attribute.+//+// NOTE: Build systems check for this too, keep them in sync with this.+#if (defined(__GNUC__) || defined(__clang__)) && !defined(__EDG__)+# define crc_attr_target \+ __attribute__((__target__("ssse3,sse4.1,pclmul")))+#else+# define crc_attr_target+#endif+++#define MASK_L(in, mask, r) r = _mm_shuffle_epi8(in, mask)++#define MASK_H(in, mask, r) \+ r = _mm_shuffle_epi8(in, _mm_xor_si128(mask, vsign))++#define MASK_LH(in, mask, low, high) \+ MASK_L(in, mask, low); \+ MASK_H(in, mask, high)+++crc_attr_target+crc_attr_no_sanitize_address+static lzma_always_inline void+crc_simd_body(const uint8_t *buf, const size_t size, __m128i *v0, __m128i *v1,+ const __m128i vfold16, const __m128i initial_crc)+{+ // Create a vector with 8-bit values 0 to 15. This is used to+ // construct control masks for _mm_blendv_epi8 and _mm_shuffle_epi8.+ const __m128i vramp = _mm_setr_epi32(+ 0x03020100, 0x07060504, 0x0b0a0908, 0x0f0e0d0c);++ // This is used to inverse the control mask of _mm_shuffle_epi8+ // so that bytes that wouldn't be picked with the original mask+ // will be picked and vice versa.+ const __m128i vsign = _mm_set1_epi8(-0x80);++ // Memory addresses A to D and the distances between them:+ //+ // A B C D+ // [skip_start][size][skip_end]+ // [ size2 ]+ //+ // A and D are 16-byte aligned. B and C are 1-byte aligned.+ // skip_start and skip_end are 0-15 bytes. size is at least 1 byte.+ //+ // A = aligned_buf will initially point to this address.+ // B = The address pointed by the caller-supplied buf.+ // C = buf + size == aligned_buf + size2+ // D = buf + size + skip_end == aligned_buf + size2 + skip_end+ const size_t skip_start = (size_t)((uintptr_t)buf & 15);+ const size_t skip_end = (size_t)((0U - (uintptr_t)(buf + size)) & 15);+ const __m128i *aligned_buf = (const __m128i *)(+ (uintptr_t)buf & ~(uintptr_t)15);++ // If size2 <= 16 then the whole input fits into a single 16-byte+ // vector. If size2 > 16 then at least two 16-byte vectors must+ // be processed. If size2 > 16 && size <= 16 then there is only+ // one 16-byte vector's worth of input but it is unaligned in memory.+ //+ // NOTE: There is no integer overflow here if the arguments+ // are valid. If this overflowed, buf + size would too.+ const size_t size2 = skip_start + size;++ // Masks to be used with _mm_blendv_epi8 and _mm_shuffle_epi8:+ // The first skip_start or skip_end bytes in the vectors will have+ // the high bit (0x80) set. _mm_blendv_epi8 and _mm_shuffle_epi8+ // will produce zeros for these positions. (Bitwise-xor of these+ // masks with vsign will produce the opposite behavior.)+ const __m128i mask_start+ = _mm_sub_epi8(vramp, _mm_set1_epi8((char)skip_start));+ const __m128i mask_end+ = _mm_sub_epi8(vramp, _mm_set1_epi8((char)skip_end));++ // Get the first 1-16 bytes into data0. If loading less than 16+ // bytes, the bytes are loaded to the high bits of the vector and+ // the least significant positions are filled with zeros.+ const __m128i data0 = _mm_blendv_epi8(_mm_load_si128(aligned_buf),+ _mm_setzero_si128(), mask_start);+ aligned_buf++;++ __m128i v2, v3;++#ifndef CRC_USE_GENERIC_FOR_SMALL_INPUTS+ if (size <= 16) {+ // Right-shift initial_crc by 1-16 bytes based on "size"+ // and store the result in v1 (high bytes) and v0 (low bytes).+ //+ // NOTE: The highest 8 bytes of initial_crc are zeros so+ // v1 will be filled with zeros if size >= 8. The highest+ // 8 bytes of v1 will always become zeros.+ //+ // [ v1 ][ v0 ]+ // [ initial_crc ] size == 1+ // [ initial_crc ] size == 2+ // [ initial_crc ] size == 15+ // [ initial_crc ] size == 16 (all in v0)+ const __m128i mask_low = _mm_add_epi8(+ vramp, _mm_set1_epi8((char)(size - 16)));+ MASK_LH(initial_crc, mask_low, *v0, *v1);++ if (size2 <= 16) {+ // There are 1-16 bytes of input and it is all+ // in data0. Copy the input bytes to v3. If there+ // are fewer than 16 bytes, the low bytes in v3+ // will be filled with zeros. That is, the input+ // bytes are stored to the same position as+ // (part of) initial_crc is in v0.+ MASK_L(data0, mask_end, v3);+ } else {+ // There are 2-16 bytes of input but not all bytes+ // are in data0.+ const __m128i data1 = _mm_load_si128(aligned_buf);++ // Collect the 2-16 input bytes from data0 and data1+ // to v2 and v3, and bitwise-xor them with the+ // low bits of initial_crc in v0. Note that the+ // the second xor is below this else-block as it+ // is shared with the other branch.+ MASK_H(data0, mask_end, v2);+ MASK_L(data1, mask_end, v3);+ *v0 = _mm_xor_si128(*v0, v2);+ }++ *v0 = _mm_xor_si128(*v0, v3);+ *v1 = _mm_alignr_epi8(*v1, *v0, 8);+ } else+#endif+ {+ // There is more than 16 bytes of input.+ const __m128i data1 = _mm_load_si128(aligned_buf);+ const __m128i *end = (const __m128i*)(+ (const char *)aligned_buf - 16 + size2);+ aligned_buf++;++ MASK_LH(initial_crc, mask_start, *v0, *v1);+ *v0 = _mm_xor_si128(*v0, data0);+ *v1 = _mm_xor_si128(*v1, data1);++ while (aligned_buf < end) {+ *v1 = _mm_xor_si128(*v1, _mm_clmulepi64_si128(+ *v0, vfold16, 0x00));+ *v0 = _mm_xor_si128(*v1, _mm_clmulepi64_si128(+ *v0, vfold16, 0x11));+ *v1 = _mm_load_si128(aligned_buf++);+ }++ if (aligned_buf != end) {+ MASK_H(*v0, mask_end, v2);+ MASK_L(*v0, mask_end, *v0);+ MASK_L(*v1, mask_end, v3);+ *v1 = _mm_or_si128(v2, v3);+ }++ *v1 = _mm_xor_si128(*v1, _mm_clmulepi64_si128(+ *v0, vfold16, 0x00));+ *v0 = _mm_xor_si128(*v1, _mm_clmulepi64_si128(+ *v0, vfold16, 0x11));+ *v1 = _mm_srli_si128(*v0, 8);+ }+}+++/////////////////////+// x86 CLMUL CRC32 //+/////////////////////++/*+// These functions were used to generate the constants+// at the top of crc32_arch_optimized().+static uint64_t+calc_lo(uint64_t p, uint64_t a, int n)+{+ uint64_t b = 0; int i;+ for (i = 0; i < n; i++) {+ b = b >> 1 | (a & 1) << (n - 1);+ a = (a >> 1) ^ ((0 - (a & 1)) & p);+ }+ return b;+}++// same as ~crc(&a, sizeof(a), ~0)+static uint64_t+calc_hi(uint64_t p, uint64_t a, int n)+{+ int i;+ for (i = 0; i < n; i++)+ a = (a >> 1) ^ ((0 - (a & 1)) & p);+ return a;+}+*/++#ifdef BUILDING_CRC32_CLMUL++crc_attr_target+crc_attr_no_sanitize_address+static uint32_t+crc32_arch_optimized(const uint8_t *buf, size_t size, uint32_t crc)+{+#ifndef CRC_USE_GENERIC_FOR_SMALL_INPUTS+ // The code assumes that there is at least one byte of input.+ if (size == 0)+ return crc;+#endif++ // uint32_t poly = 0xedb88320;+ const int64_t p = 0x1db710640; // p << 1+ const int64_t mu = 0x1f7011641; // calc_lo(p, p, 32) << 1 | 1+ const int64_t k5 = 0x163cd6124; // calc_hi(p, p, 32) << 1+ const int64_t k4 = 0x0ccaa009e; // calc_hi(p, p, 64) << 1+ const int64_t k3 = 0x1751997d0; // calc_hi(p, p, 128) << 1++ const __m128i vfold4 = _mm_set_epi64x(mu, p);+ const __m128i vfold8 = _mm_set_epi64x(0, k5);+ const __m128i vfold16 = _mm_set_epi64x(k4, k3);++ __m128i v0, v1, v2;++ crc_simd_body(buf, size, &v0, &v1, vfold16,+ _mm_cvtsi32_si128((int32_t)~crc));++ v1 = _mm_xor_si128(+ _mm_clmulepi64_si128(v0, vfold16, 0x10), v1); // xxx0+ v2 = _mm_shuffle_epi32(v1, 0xe7); // 0xx0+ v0 = _mm_slli_epi64(v1, 32); // [0]+ v0 = _mm_clmulepi64_si128(v0, vfold8, 0x00);+ v0 = _mm_xor_si128(v0, v2); // [1] [2]+ v2 = _mm_clmulepi64_si128(v0, vfold4, 0x10);+ v2 = _mm_clmulepi64_si128(v2, vfold4, 0x00);+ v0 = _mm_xor_si128(v0, v2); // [2]+ return ~(uint32_t)_mm_extract_epi32(v0, 2);+}+#endif // BUILDING_CRC32_CLMUL+++/////////////////////+// x86 CLMUL CRC64 //+/////////////////////++/*+// These functions were used to generate the constants+// at the top of crc64_arch_optimized().+static uint64_t+calc_lo(uint64_t poly)+{+ uint64_t a = poly;+ uint64_t b = 0;++ for (unsigned i = 0; i < 64; ++i) {+ b = (b >> 1) | (a << 63);+ a = (a >> 1) ^ (a & 1 ? poly : 0);+ }++ return b;+}++static uint64_t+calc_hi(uint64_t poly, uint64_t a)+{+ for (unsigned i = 0; i < 64; ++i)+ a = (a >> 1) ^ (a & 1 ? poly : 0);++ return a;+}+*/++#ifdef BUILDING_CRC64_CLMUL++// MSVC (VS2015 - VS2022) produces bad 32-bit x86 code from the CLMUL CRC+// code when optimizations are enabled (release build). According to the bug+// report, the ebx register is corrupted and the calculated result is wrong.+// Trying to workaround the problem with "__asm mov ebx, ebx" didn't help.+// The following pragma works and performance is still good. x86-64 builds+// and CRC32 CLMUL aren't affected by this problem. The problem does not+// happen in crc_simd_body() either (which is shared with CRC32 CLMUL anyway).+//+// NOTE: Another pragma after crc64_arch_optimized() restores+// the optimizations. If the #if condition here is updated,+// the other one must be updated too.+#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) \+ && defined(_M_IX86)+# pragma optimize("g", off)+#endif++crc_attr_target+crc_attr_no_sanitize_address+static uint64_t+crc64_arch_optimized(const uint8_t *buf, size_t size, uint64_t crc)+{+#ifndef CRC_USE_GENERIC_FOR_SMALL_INPUTS+ // The code assumes that there is at least one byte of input.+ if (size == 0)+ return crc;+#endif++ // const uint64_t poly = 0xc96c5795d7870f42; // CRC polynomial+ const uint64_t p = 0x92d8af2baf0e1e85; // (poly << 1) | 1+ const uint64_t mu = 0x9c3e466c172963d5; // (calc_lo(poly) << 1) | 1+ const uint64_t k2 = 0xdabe95afc7875f40; // calc_hi(poly, 1)+ const uint64_t k1 = 0xe05dd497ca393ae4; // calc_hi(poly, k2)++ const __m128i vfold8 = _mm_set_epi64x((int64_t)p, (int64_t)mu);+ const __m128i vfold16 = _mm_set_epi64x((int64_t)k2, (int64_t)k1);++ __m128i v0, v1, v2;++#if defined(__i386__) || defined(_M_IX86)+ crc_simd_body(buf, size, &v0, &v1, vfold16,+ _mm_set_epi64x(0, (int64_t)~crc));+#else+ // GCC and Clang would produce good code with _mm_set_epi64x+ // but MSVC needs _mm_cvtsi64_si128 on x86-64.+ crc_simd_body(buf, size, &v0, &v1, vfold16,+ _mm_cvtsi64_si128((int64_t)~crc));+#endif++ v1 = _mm_xor_si128(_mm_clmulepi64_si128(v0, vfold16, 0x10), v1);+ v0 = _mm_clmulepi64_si128(v1, vfold8, 0x00);+ v2 = _mm_clmulepi64_si128(v0, vfold8, 0x10);+ v0 = _mm_xor_si128(_mm_xor_si128(v1, _mm_slli_si128(v0, 8)), v2);++#if defined(__i386__) || defined(_M_IX86)+ return ~(((uint64_t)(uint32_t)_mm_extract_epi32(v0, 3) << 32) |+ (uint64_t)(uint32_t)_mm_extract_epi32(v0, 2));+#else+ return ~(uint64_t)_mm_extract_epi64(v0, 1);+#endif+}++#if defined(_MSC_VER) && !defined(__INTEL_COMPILER) && !defined(__clang__) \+ && defined(_M_IX86)+# pragma optimize("", on)+#endif++#endif // BUILDING_CRC64_CLMUL+++// Even though this is an inline function, compile it only when needed.+// This way it won't appear in E2K builds at all.+#if defined(CRC32_GENERIC) || defined(CRC64_GENERIC)+// Inlining this function duplicates the function body in crc32_resolve() and+// crc64_resolve(), but this is acceptable because this is a tiny function.+static inline bool+is_arch_extension_supported(void)+{+ int success = 1;+ uint32_t r[4]; // eax, ebx, ecx, edx++#if defined(_MSC_VER)+ // This needs <intrin.h> with MSVC. ICC has it as a built-in+ // on all platforms.+ __cpuid(r, 1);+#elif defined(HAVE_CPUID_H)+ // Compared to just using __asm__ to run CPUID, this also checks+ // that CPUID is supported and saves and restores ebx as that is+ // needed with GCC < 5 with position-independent code (PIC).+ success = __get_cpuid(1, &r[0], &r[1], &r[2], &r[3]);+#else+ // Just a fallback that shouldn't be needed.+ __asm__("cpuid\n\t"+ : "=a"(r[0]), "=b"(r[1]), "=c"(r[2]), "=d"(r[3])+ : "a"(1), "c"(0));+#endif++ // Returns true if these are supported:+ // CLMUL (bit 1 in ecx)+ // SSSE3 (bit 9 in ecx)+ // SSE4.1 (bit 19 in ecx)+ const uint32_t ecx_mask = (1 << 1) | (1 << 9) | (1 << 19);+ return success && (r[2] & ecx_mask) == ecx_mask;++ // Alternative methods that weren't used:+ // - ICC's _may_i_use_cpu_feature: the other methods should work too.+ // - GCC >= 6 / Clang / ICX __builtin_cpu_supports("pclmul")+ //+ // CPUID decoding is needed with MSVC anyway and older GCC. This keeps+ // the feature checks in the build system simpler too. The nice thing+ // about __builtin_cpu_supports would be that it generates very short+ // code as is it only reads a variable set at startup but a few bytes+ // doesn't matter here.+}+#endif
+ cbits/liblzma/check/sha256.c view
@@ -0,0 +1,189 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file sha256.c+/// \brief SHA-256+//+// The C code is based on the public domain SHA-256 code found from+// Crypto++ Library 5.5.1 released in 2007: https://www.cryptopp.com/+// A few minor tweaks have been made in liblzma.+//+// Authors: Wei Dai+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "check.h"++// Rotate a uint32_t. GCC can optimize this to a rotate instruction+// at least on x86.+static inline uint32_t+rotr_32(uint32_t num, unsigned amount)+{+ return (num >> amount) | (num << (32 - amount));+}++#define blk0(i) (W[i] = conv32be(data[i]))+#define blk2(i) (W[i & 15] += s1(W[(i - 2) & 15]) + W[(i - 7) & 15] \+ + s0(W[(i - 15) & 15]))++#define Ch(x, y, z) (z ^ (x & (y ^ z)))+#define Maj(x, y, z) ((x & (y ^ z)) + (y & z))++#define a(i) T[(0 - i) & 7]+#define b(i) T[(1 - i) & 7]+#define c(i) T[(2 - i) & 7]+#define d(i) T[(3 - i) & 7]+#define e(i) T[(4 - i) & 7]+#define f(i) T[(5 - i) & 7]+#define g(i) T[(6 - i) & 7]+#define h(i) T[(7 - i) & 7]++#define R(i, j, blk) \+ h(i) += S1(e(i)) + Ch(e(i), f(i), g(i)) + SHA256_K[i + j] + blk; \+ d(i) += h(i); \+ h(i) += S0(a(i)) + Maj(a(i), b(i), c(i))+#define R0(i) R(i, 0, blk0(i))+#define R2(i) R(i, j, blk2(i))++#define S0(x) rotr_32(x ^ rotr_32(x ^ rotr_32(x, 9), 11), 2)+#define S1(x) rotr_32(x ^ rotr_32(x ^ rotr_32(x, 14), 5), 6)+#define s0(x) (rotr_32(x ^ rotr_32(x, 11), 7) ^ (x >> 3))+#define s1(x) (rotr_32(x ^ rotr_32(x, 2), 17) ^ (x >> 10))+++static const uint32_t SHA256_K[64] = {+ 0x428A2F98, 0x71374491, 0xB5C0FBCF, 0xE9B5DBA5,+ 0x3956C25B, 0x59F111F1, 0x923F82A4, 0xAB1C5ED5,+ 0xD807AA98, 0x12835B01, 0x243185BE, 0x550C7DC3,+ 0x72BE5D74, 0x80DEB1FE, 0x9BDC06A7, 0xC19BF174,+ 0xE49B69C1, 0xEFBE4786, 0x0FC19DC6, 0x240CA1CC,+ 0x2DE92C6F, 0x4A7484AA, 0x5CB0A9DC, 0x76F988DA,+ 0x983E5152, 0xA831C66D, 0xB00327C8, 0xBF597FC7,+ 0xC6E00BF3, 0xD5A79147, 0x06CA6351, 0x14292967,+ 0x27B70A85, 0x2E1B2138, 0x4D2C6DFC, 0x53380D13,+ 0x650A7354, 0x766A0ABB, 0x81C2C92E, 0x92722C85,+ 0xA2BFE8A1, 0xA81A664B, 0xC24B8B70, 0xC76C51A3,+ 0xD192E819, 0xD6990624, 0xF40E3585, 0x106AA070,+ 0x19A4C116, 0x1E376C08, 0x2748774C, 0x34B0BCB5,+ 0x391C0CB3, 0x4ED8AA4A, 0x5B9CCA4F, 0x682E6FF3,+ 0x748F82EE, 0x78A5636F, 0x84C87814, 0x8CC70208,+ 0x90BEFFFA, 0xA4506CEB, 0xBEF9A3F7, 0xC67178F2,+};+++static void+transform(uint32_t state[8], const uint32_t data[16])+{+ uint32_t W[16];+ uint32_t T[8];++ // Copy state[] to working vars.+ memcpy(T, state, sizeof(T));++ // The first 16 operations unrolled+ R0( 0); R0( 1); R0( 2); R0( 3);+ R0( 4); R0( 5); R0( 6); R0( 7);+ R0( 8); R0( 9); R0(10); R0(11);+ R0(12); R0(13); R0(14); R0(15);++ // The remaining 48 operations partially unrolled+ for (unsigned int j = 16; j < 64; j += 16) {+ R2( 0); R2( 1); R2( 2); R2( 3);+ R2( 4); R2( 5); R2( 6); R2( 7);+ R2( 8); R2( 9); R2(10); R2(11);+ R2(12); R2(13); R2(14); R2(15);+ }++ // Add the working vars back into state[].+ state[0] += a(0);+ state[1] += b(0);+ state[2] += c(0);+ state[3] += d(0);+ state[4] += e(0);+ state[5] += f(0);+ state[6] += g(0);+ state[7] += h(0);+}+++static void+process(lzma_check_state *check)+{+ transform(check->state.sha256.state, check->buffer.u32);+ return;+}+++extern void+lzma_sha256_init(lzma_check_state *check)+{+ static const uint32_t s[8] = {+ 0x6A09E667, 0xBB67AE85, 0x3C6EF372, 0xA54FF53A,+ 0x510E527F, 0x9B05688C, 0x1F83D9AB, 0x5BE0CD19,+ };++ memcpy(check->state.sha256.state, s, sizeof(s));+ check->state.sha256.size = 0;++ return;+}+++extern void+lzma_sha256_update(const uint8_t *buf, size_t size, lzma_check_state *check)+{+ // Copy the input data into a properly aligned temporary buffer.+ // This way we can be called with arbitrarily sized buffers+ // (no need to be multiple of 64 bytes), and the code works also+ // on architectures that don't allow unaligned memory access.+ while (size > 0) {+ const size_t copy_start = check->state.sha256.size & 0x3F;+ size_t copy_size = 64 - copy_start;+ if (copy_size > size)+ copy_size = size;++ memcpy(check->buffer.u8 + copy_start, buf, copy_size);++ buf += copy_size;+ size -= copy_size;+ check->state.sha256.size += copy_size;++ if ((check->state.sha256.size & 0x3F) == 0)+ process(check);+ }++ return;+}+++extern void+lzma_sha256_finish(lzma_check_state *check)+{+ // Add padding as described in RFC 3174 (it describes SHA-1 but+ // the same padding style is used for SHA-256 too).+ size_t pos = check->state.sha256.size & 0x3F;+ check->buffer.u8[pos++] = 0x80;++ while (pos != 64 - 8) {+ if (pos == 64) {+ process(check);+ pos = 0;+ }++ check->buffer.u8[pos++] = 0x00;+ }++ // Convert the message size from bytes to bits.+ check->state.sha256.size *= 8;++ check->buffer.u64[(64 - 8) / 8] = conv64be(check->state.sha256.size);++ process(check);++ for (size_t i = 0; i < 8; ++i)+ check->buffer.u32[i] = conv32be(check->state.sha256.state[i]);++ return;+}
+ cbits/liblzma/common/alone_decoder.c view
@@ -0,0 +1,248 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file alone_decoder.c+/// \brief Decoder for LZMA_Alone files+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "alone_decoder.h"+#include "lzma_decoder.h"+#include "lz_decoder.h"+++typedef struct {+ lzma_next_coder next;++ enum {+ SEQ_PROPERTIES,+ SEQ_DICTIONARY_SIZE,+ SEQ_UNCOMPRESSED_SIZE,+ SEQ_CODER_INIT,+ SEQ_CODE,+ } sequence;++ /// If true, reject files that are unlikely to be .lzma files.+ /// If false, more non-.lzma files get accepted and will give+ /// LZMA_DATA_ERROR either immediately or after a few output bytes.+ bool picky;++ /// Position in the header fields+ size_t pos;++ /// Uncompressed size decoded from the header+ lzma_vli uncompressed_size;++ /// Memory usage limit+ uint64_t memlimit;++ /// Amount of memory actually needed (only an estimate)+ uint64_t memusage;++ /// Options decoded from the header needed to initialize+ /// the LZMA decoder+ lzma_options_lzma options;+} lzma_alone_coder;+++static lzma_ret+alone_decode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size,+ lzma_action action)+{+ lzma_alone_coder *coder = coder_ptr;++ while (*out_pos < out_size+ && (coder->sequence == SEQ_CODE || *in_pos < in_size))+ switch (coder->sequence) {+ case SEQ_PROPERTIES:+ if (lzma_lzma_lclppb_decode(&coder->options, in[*in_pos]))+ return LZMA_FORMAT_ERROR;++ coder->sequence = SEQ_DICTIONARY_SIZE;+ ++*in_pos;+ break;++ case SEQ_DICTIONARY_SIZE:+ coder->options.dict_size+ |= (size_t)(in[*in_pos]) << (coder->pos * 8);++ if (++coder->pos == 4) {+ if (coder->picky && coder->options.dict_size+ != UINT32_MAX) {+ // A hack to ditch tons of false positives:+ // We allow only dictionary sizes that are+ // 2^n or 2^n + 2^(n-1). LZMA_Alone created+ // only files with 2^n, but accepts any+ // dictionary size.+ uint32_t d = coder->options.dict_size - 1;+ d |= d >> 2;+ d |= d >> 3;+ d |= d >> 4;+ d |= d >> 8;+ d |= d >> 16;+ ++d;++ if (d != coder->options.dict_size)+ return LZMA_FORMAT_ERROR;+ }++ coder->pos = 0;+ coder->sequence = SEQ_UNCOMPRESSED_SIZE;+ }++ ++*in_pos;+ break;++ case SEQ_UNCOMPRESSED_SIZE:+ coder->uncompressed_size+ |= (lzma_vli)(in[*in_pos]) << (coder->pos * 8);+ ++*in_pos;+ if (++coder->pos < 8)+ break;++ // Another hack to ditch false positives: Assume that+ // if the uncompressed size is known, it must be less+ // than 256 GiB.+ //+ // FIXME? Without picky we allow > LZMA_VLI_MAX which doesn't+ // really matter in this specific situation (> LZMA_VLI_MAX is+ // safe in the LZMA decoder) but it's somewhat weird still.+ if (coder->picky+ && coder->uncompressed_size != LZMA_VLI_UNKNOWN+ && coder->uncompressed_size+ >= (LZMA_VLI_C(1) << 38))+ return LZMA_FORMAT_ERROR;++ // Use LZMA_FILTER_LZMA1EXT features to specify the+ // uncompressed size and that the end marker is allowed+ // even when the uncompressed size is known. Both .lzma+ // header and LZMA1EXT use UINT64_MAX indicate that size+ // is unknown.+ coder->options.ext_flags = LZMA_LZMA1EXT_ALLOW_EOPM;+ lzma_set_ext_size(coder->options, coder->uncompressed_size);++ // Calculate the memory usage so that it is ready+ // for SEQ_CODER_INIT.+ coder->memusage = lzma_lzma_decoder_memusage(&coder->options)+ + LZMA_MEMUSAGE_BASE;++ coder->pos = 0;+ coder->sequence = SEQ_CODER_INIT;++ // Fall through++ case SEQ_CODER_INIT: {+ if (coder->memusage > coder->memlimit)+ return LZMA_MEMLIMIT_ERROR;++ lzma_filter_info filters[2] = {+ {+ .id = LZMA_FILTER_LZMA1EXT,+ .init = &lzma_lzma_decoder_init,+ .options = &coder->options,+ }, {+ .init = NULL,+ }+ };++ return_if_error(lzma_next_filter_init(&coder->next,+ allocator, filters));++ coder->sequence = SEQ_CODE;+ break;+ }++ case SEQ_CODE: {+ return coder->next.code(coder->next.coder,+ allocator, in, in_pos, in_size,+ out, out_pos, out_size, action);+ }++ default:+ return LZMA_PROG_ERROR;+ }++ return LZMA_OK;+}+++static void+alone_decoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_alone_coder *coder = coder_ptr;+ lzma_next_end(&coder->next, allocator);+ lzma_free(coder, allocator);+ return;+}+++static lzma_ret+alone_decoder_memconfig(void *coder_ptr, uint64_t *memusage,+ uint64_t *old_memlimit, uint64_t new_memlimit)+{+ lzma_alone_coder *coder = coder_ptr;++ *memusage = coder->memusage;+ *old_memlimit = coder->memlimit;++ if (new_memlimit != 0) {+ if (new_memlimit < coder->memusage)+ return LZMA_MEMLIMIT_ERROR;++ coder->memlimit = new_memlimit;+ }++ return LZMA_OK;+}+++extern lzma_ret+lzma_alone_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ uint64_t memlimit, bool picky)+{+ lzma_next_coder_init(&lzma_alone_decoder_init, next, allocator);++ lzma_alone_coder *coder = next->coder;++ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_alone_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = &alone_decode;+ next->end = &alone_decoder_end;+ next->memconfig = &alone_decoder_memconfig;+ coder->next = LZMA_NEXT_CODER_INIT;+ }++ coder->sequence = SEQ_PROPERTIES;+ coder->picky = picky;+ coder->pos = 0;+ coder->options.dict_size = 0;+ coder->options.preset_dict = NULL;+ coder->options.preset_dict_size = 0;+ coder->uncompressed_size = 0;+ coder->memlimit = my_max(1, memlimit);+ coder->memusage = LZMA_MEMUSAGE_BASE;++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_alone_decoder(lzma_stream *strm, uint64_t memlimit)+{+ lzma_next_strm_init(lzma_alone_decoder_init, strm, memlimit, false);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}
+ cbits/liblzma/common/alone_decoder.h view
@@ -0,0 +1,22 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file alone_decoder.h+/// \brief Decoder for LZMA_Alone files+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_ALONE_DECODER_H+#define LZMA_ALONE_DECODER_H++#include "common.h"+++extern lzma_ret lzma_alone_decoder_init(+ lzma_next_coder *next, const lzma_allocator *allocator,+ uint64_t memlimit, bool picky);++#endif
+ cbits/liblzma/common/alone_encoder.c view
@@ -0,0 +1,151 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file alone_encoder.c+/// \brief Encoder for LZMA_Alone files+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+#include "lzma_encoder.h"+++#define ALONE_HEADER_SIZE (1 + 4 + 8)+++typedef struct {+ lzma_next_coder next;++ enum {+ SEQ_HEADER,+ SEQ_CODE,+ } sequence;++ size_t header_pos;+ uint8_t header[ALONE_HEADER_SIZE];+} lzma_alone_coder;+++static lzma_ret+alone_encode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size,+ lzma_action action)+{+ lzma_alone_coder *coder = coder_ptr;++ while (*out_pos < out_size)+ switch (coder->sequence) {+ case SEQ_HEADER:+ lzma_bufcpy(coder->header, &coder->header_pos,+ ALONE_HEADER_SIZE,+ out, out_pos, out_size);+ if (coder->header_pos < ALONE_HEADER_SIZE)+ return LZMA_OK;++ coder->sequence = SEQ_CODE;+ break;++ case SEQ_CODE:+ return coder->next.code(coder->next.coder,+ allocator, in, in_pos, in_size,+ out, out_pos, out_size, action);++ default:+ assert(0);+ return LZMA_PROG_ERROR;+ }++ return LZMA_OK;+}+++static void+alone_encoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_alone_coder *coder = coder_ptr;+ lzma_next_end(&coder->next, allocator);+ lzma_free(coder, allocator);+ return;+}+++static lzma_ret+alone_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_options_lzma *options)+{+ lzma_next_coder_init(&alone_encoder_init, next, allocator);++ lzma_alone_coder *coder = next->coder;++ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_alone_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = &alone_encode;+ next->end = &alone_encoder_end;+ coder->next = LZMA_NEXT_CODER_INIT;+ }++ // Basic initializations+ coder->sequence = SEQ_HEADER;+ coder->header_pos = 0;++ // Encode the header:+ // - Properties (1 byte)+ if (lzma_lzma_lclppb_encode(options, coder->header))+ return LZMA_OPTIONS_ERROR;++ // - Dictionary size (4 bytes)+ if (options->dict_size < LZMA_DICT_SIZE_MIN)+ return LZMA_OPTIONS_ERROR;++ // Round up to the next 2^n or 2^n + 2^(n - 1) depending on which+ // one is the next unless it is UINT32_MAX. While the header would+ // allow any 32-bit integer, we do this to keep the decoder of liblzma+ // accepting the resulting files.+ uint32_t d = options->dict_size - 1;+ d |= d >> 2;+ d |= d >> 3;+ d |= d >> 4;+ d |= d >> 8;+ d |= d >> 16;+ if (d != UINT32_MAX)+ ++d;++ write32le(coder->header + 1, d);++ // - Uncompressed size (always unknown and using EOPM)+ memset(coder->header + 1 + 4, 0xFF, 8);++ // Initialize the LZMA encoder.+ const lzma_filter_info filters[2] = {+ {+ .id = LZMA_FILTER_LZMA1,+ .init = &lzma_lzma_encoder_init,+ .options = (void *)(options),+ }, {+ .init = NULL,+ }+ };++ return lzma_next_filter_init(&coder->next, allocator, filters);+}+++extern LZMA_API(lzma_ret)+lzma_alone_encoder(lzma_stream *strm, const lzma_options_lzma *options)+{+ lzma_next_strm_init(alone_encoder_init, strm, options);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}
+ cbits/liblzma/common/auto_decoder.c view
@@ -0,0 +1,205 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file auto_decoder.c+/// \brief Autodetect between .xz, .lzma (LZMA_Alone), and .lz (lzip)+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "stream_decoder.h"+#include "alone_decoder.h"+#ifdef HAVE_LZIP_DECODER+# include "lzip_decoder.h"+#endif+++typedef struct {+ /// .xz Stream decoder, LZMA_Alone decoder, or lzip decoder+ lzma_next_coder next;++ uint64_t memlimit;+ uint32_t flags;++ enum {+ SEQ_INIT,+ SEQ_CODE,+ SEQ_FINISH,+ } sequence;+} lzma_auto_coder;+++static lzma_ret+auto_decode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size, lzma_action action)+{+ lzma_auto_coder *coder = coder_ptr;++ switch (coder->sequence) {+ case SEQ_INIT:+ if (*in_pos >= in_size)+ return LZMA_OK;++ // Update the sequence now, because we want to continue from+ // SEQ_CODE even if we return some LZMA_*_CHECK.+ coder->sequence = SEQ_CODE;++ // Detect the file format. .xz files start with 0xFD which+ // cannot be the first byte of .lzma (LZMA_Alone) format.+ // The .lz format starts with 0x4C which could be the+ // first byte of a .lzma file but luckily it would mean+ // lc/lp/pb being 4/3/1 which liblzma doesn't support because+ // lc + lp > 4. So using just 0x4C to detect .lz is OK here.+ if (in[*in_pos] == 0xFD) {+ return_if_error(lzma_stream_decoder_init(+ &coder->next, allocator,+ coder->memlimit, coder->flags));+#ifdef HAVE_LZIP_DECODER+ } else if (in[*in_pos] == 0x4C) {+ return_if_error(lzma_lzip_decoder_init(+ &coder->next, allocator,+ coder->memlimit, coder->flags));+#endif+ } else {+ return_if_error(lzma_alone_decoder_init(&coder->next,+ allocator, coder->memlimit, true));++ // If the application wants to know about missing+ // integrity check or about the check in general, we+ // need to handle it here, because LZMA_Alone decoder+ // doesn't accept any flags.+ if (coder->flags & LZMA_TELL_NO_CHECK)+ return LZMA_NO_CHECK;++ if (coder->flags & LZMA_TELL_ANY_CHECK)+ return LZMA_GET_CHECK;+ }++ // Fall through++ case SEQ_CODE: {+ const lzma_ret ret = coder->next.code(+ coder->next.coder, allocator,+ in, in_pos, in_size,+ out, out_pos, out_size, action);+ if (ret != LZMA_STREAM_END+ || (coder->flags & LZMA_CONCATENATED) == 0)+ return ret;++ coder->sequence = SEQ_FINISH;+ }++ // Fall through++ case SEQ_FINISH:+ // When LZMA_CONCATENATED was used and we were decoding+ // a LZMA_Alone file, we need to check that there is no+ // trailing garbage and wait for LZMA_FINISH.+ if (*in_pos < in_size)+ return LZMA_DATA_ERROR;++ return action == LZMA_FINISH ? LZMA_STREAM_END : LZMA_OK;++ default:+ assert(0);+ return LZMA_PROG_ERROR;+ }+}+++static void+auto_decoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_auto_coder *coder = coder_ptr;+ lzma_next_end(&coder->next, allocator);+ lzma_free(coder, allocator);+ return;+}+++static lzma_check+auto_decoder_get_check(const void *coder_ptr)+{+ const lzma_auto_coder *coder = coder_ptr;++ // It is LZMA_Alone if get_check is NULL.+ return coder->next.get_check == NULL ? LZMA_CHECK_NONE+ : coder->next.get_check(coder->next.coder);+}+++static lzma_ret+auto_decoder_memconfig(void *coder_ptr, uint64_t *memusage,+ uint64_t *old_memlimit, uint64_t new_memlimit)+{+ lzma_auto_coder *coder = coder_ptr;++ lzma_ret ret;++ if (coder->next.memconfig != NULL) {+ ret = coder->next.memconfig(coder->next.coder,+ memusage, old_memlimit, new_memlimit);+ assert(*old_memlimit == coder->memlimit);+ } else {+ // No coder is configured yet. Use the base value as+ // the current memory usage.+ *memusage = LZMA_MEMUSAGE_BASE;+ *old_memlimit = coder->memlimit;++ ret = LZMA_OK;+ if (new_memlimit != 0 && new_memlimit < *memusage)+ ret = LZMA_MEMLIMIT_ERROR;+ }++ if (ret == LZMA_OK && new_memlimit != 0)+ coder->memlimit = new_memlimit;++ return ret;+}+++static lzma_ret+auto_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ uint64_t memlimit, uint32_t flags)+{+ lzma_next_coder_init(&auto_decoder_init, next, allocator);++ if (flags & ~LZMA_SUPPORTED_FLAGS)+ return LZMA_OPTIONS_ERROR;++ lzma_auto_coder *coder = next->coder;+ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_auto_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = &auto_decode;+ next->end = &auto_decoder_end;+ next->get_check = &auto_decoder_get_check;+ next->memconfig = &auto_decoder_memconfig;+ coder->next = LZMA_NEXT_CODER_INIT;+ }++ coder->memlimit = my_max(1, memlimit);+ coder->flags = flags;+ coder->sequence = SEQ_INIT;++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_auto_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags)+{+ lzma_next_strm_init(auto_decoder_init, strm, memlimit, flags);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}
+ cbits/liblzma/common/block_buffer_decoder.c view
@@ -0,0 +1,79 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file block_buffer_decoder.c+/// \brief Single-call .xz Block decoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "block_decoder.h"+++extern LZMA_API(lzma_ret)+lzma_block_buffer_decode(lzma_block *block, const lzma_allocator *allocator,+ const uint8_t *in, size_t *in_pos, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+{+ if (in_pos == NULL || (in == NULL && *in_pos != in_size)+ || *in_pos > in_size || out_pos == NULL+ || (out == NULL && *out_pos != out_size)+ || *out_pos > out_size)+ return LZMA_PROG_ERROR;++ // Initialize the Block decoder.+ lzma_next_coder block_decoder = LZMA_NEXT_CODER_INIT;+ lzma_ret ret = lzma_block_decoder_init(+ &block_decoder, allocator, block);++ if (ret == LZMA_OK) {+ // Save the positions so that we can restore them in case+ // an error occurs.+ const size_t in_start = *in_pos;+ const size_t out_start = *out_pos;++ // Do the actual decoding.+ ret = block_decoder.code(block_decoder.coder, allocator,+ in, in_pos, in_size, out, out_pos, out_size,+ LZMA_FINISH);++ if (ret == LZMA_STREAM_END) {+ ret = LZMA_OK;+ } else {+ if (ret == LZMA_OK) {+ // Either the input was truncated or the+ // output buffer was too small.+ assert(*in_pos == in_size+ || *out_pos == out_size);++ // If all the input was consumed, then the+ // input is truncated, even if the output+ // buffer is also full. This is because+ // processing the last byte of the Block+ // never produces output.+ //+ // NOTE: This assumption may break when new+ // filters are added, if the end marker of+ // the filter doesn't consume at least one+ // complete byte.+ if (*in_pos == in_size)+ ret = LZMA_DATA_ERROR;+ else+ ret = LZMA_BUF_ERROR;+ }++ // Restore the positions.+ *in_pos = in_start;+ *out_pos = out_start;+ }+ }++ // Free the decoder memory. This needs to be done even if+ // initialization fails, because the internal API doesn't+ // require the initialization function to free its memory on error.+ lzma_next_end(&block_decoder, allocator);++ return ret;+}
+ cbits/liblzma/common/block_buffer_encoder.c view
@@ -0,0 +1,354 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file block_buffer_encoder.c+/// \brief Single-call .xz Block encoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "block_buffer_encoder.h"+#include "block_encoder.h"+#include "filter_encoder.h"+#include "lzma2_encoder.h"+#include "check.h"+++/// Estimate the maximum size of the Block Header and Check fields for+/// a Block that uses LZMA2 uncompressed chunks. We could use+/// lzma_block_header_size() but this is simpler.+///+/// Block Header Size + Block Flags + Compressed Size+/// + Uncompressed Size + Filter Flags for LZMA2 + CRC32 + Check+/// and round up to the next multiple of four to take Header Padding+/// into account.+#define HEADERS_BOUND ((1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 3 + 4 \+ + LZMA_CHECK_SIZE_MAX + 3) & ~3)+++static uint64_t+lzma2_bound(uint64_t uncompressed_size)+{+ // Prevent integer overflow in overhead calculation.+ if (uncompressed_size > COMPRESSED_SIZE_MAX)+ return 0;++ // Calculate the exact overhead of the LZMA2 headers: Round+ // uncompressed_size up to the next multiple of LZMA2_CHUNK_MAX,+ // multiply by the size of per-chunk header, and add one byte for+ // the end marker.+ const uint64_t overhead = ((uncompressed_size + LZMA2_CHUNK_MAX - 1)+ / LZMA2_CHUNK_MAX)+ * LZMA2_HEADER_UNCOMPRESSED + 1;++ // Catch the possible integer overflow.+ if (COMPRESSED_SIZE_MAX - overhead < uncompressed_size)+ return 0;++ return uncompressed_size + overhead;+}+++extern uint64_t+lzma_block_buffer_bound64(uint64_t uncompressed_size)+{+ // If the data doesn't compress, we always use uncompressed+ // LZMA2 chunks.+ uint64_t lzma2_size = lzma2_bound(uncompressed_size);+ if (lzma2_size == 0)+ return 0;++ // Take Block Padding into account.+ lzma2_size = (lzma2_size + 3) & ~UINT64_C(3);++ // No risk of integer overflow because lzma2_bound() already takes+ // into account the size of the headers in the Block.+ return HEADERS_BOUND + lzma2_size;+}+++extern LZMA_API(size_t)+lzma_block_buffer_bound(size_t uncompressed_size)+{+ uint64_t ret = lzma_block_buffer_bound64(uncompressed_size);++#if SIZE_MAX < UINT64_MAX+ // Catch the possible integer overflow on 32-bit systems.+ if (ret > SIZE_MAX)+ return 0;+#endif++ return ret;+}+++static lzma_ret+block_encode_uncompressed(lzma_block *block, const uint8_t *in, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+{+ // Use LZMA2 uncompressed chunks. We wouldn't need a dictionary at+ // all, but LZMA2 always requires a dictionary, so use the minimum+ // value to minimize memory usage of the decoder.+ lzma_options_lzma lzma2 = {+ .dict_size = LZMA_DICT_SIZE_MIN,+ };++ lzma_filter filters[2];+ filters[0].id = LZMA_FILTER_LZMA2;+ filters[0].options = &lzma2;+ filters[1].id = LZMA_VLI_UNKNOWN;++ // Set the above filter options to *block temporarily so that we can+ // encode the Block Header.+ lzma_filter *filters_orig = block->filters;+ block->filters = filters;++ if (lzma_block_header_size(block) != LZMA_OK) {+ block->filters = filters_orig;+ return LZMA_PROG_ERROR;+ }++ // Check that there's enough output space. The caller has already+ // set block->compressed_size to what lzma2_bound() has returned,+ // so we can reuse that value. We know that compressed_size is a+ // known valid VLI and header_size is a small value so their sum+ // will never overflow.+ assert(block->compressed_size == lzma2_bound(in_size));+ if (out_size - *out_pos+ < block->header_size + block->compressed_size) {+ block->filters = filters_orig;+ return LZMA_BUF_ERROR;+ }++ if (lzma_block_header_encode(block, out + *out_pos) != LZMA_OK) {+ block->filters = filters_orig;+ return LZMA_PROG_ERROR;+ }++ block->filters = filters_orig;+ *out_pos += block->header_size;++ // Encode the data using LZMA2 uncompressed chunks.+ size_t in_pos = 0;+ uint8_t control = 0x01; // Dictionary reset++ while (in_pos < in_size) {+ // Control byte: Indicate uncompressed chunk, of which+ // the first resets the dictionary.+ out[(*out_pos)++] = control;+ control = 0x02; // No dictionary reset++ // Size of the uncompressed chunk+ const size_t copy_size+ = my_min(in_size - in_pos, LZMA2_CHUNK_MAX);+ out[(*out_pos)++] = (copy_size - 1) >> 8;+ out[(*out_pos)++] = (copy_size - 1) & 0xFF;++ // The actual data+ assert(*out_pos + copy_size <= out_size);+ memcpy(out + *out_pos, in + in_pos, copy_size);++ in_pos += copy_size;+ *out_pos += copy_size;+ }++ // End marker+ out[(*out_pos)++] = 0x00;+ assert(*out_pos <= out_size);++ return LZMA_OK;+}+++static lzma_ret+block_encode_normal(lzma_block *block, const lzma_allocator *allocator,+ const uint8_t *in, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+{+ // Find out the size of the Block Header.+ return_if_error(lzma_block_header_size(block));++ // Reserve space for the Block Header and skip it for now.+ if (out_size - *out_pos <= block->header_size)+ return LZMA_BUF_ERROR;++ const size_t out_start = *out_pos;+ *out_pos += block->header_size;++ // Limit out_size so that we stop encoding if the output would grow+ // bigger than what uncompressed Block would be.+ if (out_size - *out_pos > block->compressed_size)+ out_size = *out_pos + block->compressed_size;++ // TODO: In many common cases this could be optimized to use+ // significantly less memory.+ lzma_next_coder raw_encoder = LZMA_NEXT_CODER_INIT;+ lzma_ret ret = lzma_raw_encoder_init(+ &raw_encoder, allocator, block->filters);++ if (ret == LZMA_OK) {+ size_t in_pos = 0;+ ret = raw_encoder.code(raw_encoder.coder, allocator,+ in, &in_pos, in_size, out, out_pos, out_size,+ LZMA_FINISH);+ }++ // NOTE: This needs to be run even if lzma_raw_encoder_init() failed.+ lzma_next_end(&raw_encoder, allocator);++ if (ret == LZMA_STREAM_END) {+ // Compression was successful. Write the Block Header.+ block->compressed_size+ = *out_pos - (out_start + block->header_size);+ ret = lzma_block_header_encode(block, out + out_start);+ if (ret != LZMA_OK)+ ret = LZMA_PROG_ERROR;++ } else if (ret == LZMA_OK) {+ // Output buffer became full.+ ret = LZMA_BUF_ERROR;+ }++ // Reset *out_pos if something went wrong.+ if (ret != LZMA_OK)+ *out_pos = out_start;++ return ret;+}+++static lzma_ret+block_buffer_encode(lzma_block *block, const lzma_allocator *allocator,+ const uint8_t *in, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size,+ bool try_to_compress)+{+ // Validate the arguments.+ if (block == NULL || (in == NULL && in_size != 0) || out == NULL+ || out_pos == NULL || *out_pos > out_size)+ return LZMA_PROG_ERROR;++ // The contents of the structure may depend on the version so+ // check the version before validating the contents of *block.+ if (block->version > 1)+ return LZMA_OPTIONS_ERROR;++ if ((unsigned int)(block->check) > LZMA_CHECK_ID_MAX+ || (try_to_compress && block->filters == NULL))+ return LZMA_PROG_ERROR;++ if (!lzma_check_is_supported(block->check))+ return LZMA_UNSUPPORTED_CHECK;++ // Size of a Block has to be a multiple of four, so limit the size+ // here already. This way we don't need to check it again when adding+ // Block Padding.+ out_size -= (out_size - *out_pos) & 3;++ // Get the size of the Check field.+ const size_t check_size = lzma_check_size(block->check);+ assert(check_size != UINT32_MAX);++ // Reserve space for the Check field.+ if (out_size - *out_pos <= check_size)+ return LZMA_BUF_ERROR;++ out_size -= check_size;++ // Initialize block->uncompressed_size and calculate the worst-case+ // value for block->compressed_size.+ block->uncompressed_size = in_size;+ block->compressed_size = lzma2_bound(in_size);+ if (block->compressed_size == 0)+ return LZMA_DATA_ERROR;++ // Do the actual compression.+ lzma_ret ret = LZMA_BUF_ERROR;+ if (try_to_compress)+ ret = block_encode_normal(block, allocator,+ in, in_size, out, out_pos, out_size);++ if (ret != LZMA_OK) {+ // If the error was something else than output buffer+ // becoming full, return the error now.+ if (ret != LZMA_BUF_ERROR)+ return ret;++ // The data was incompressible (at least with the options+ // given to us) or the output buffer was too small. Use the+ // uncompressed chunks of LZMA2 to wrap the data into a valid+ // Block. If we haven't been given enough output space, even+ // this may fail.+ return_if_error(block_encode_uncompressed(block, in, in_size,+ out, out_pos, out_size));+ }++ assert(*out_pos <= out_size);++ // Block Padding. No buffer overflow here, because we already adjusted+ // out_size so that (out_size - out_start) is a multiple of four.+ // Thus, if the buffer is full, the loop body can never run.+ for (size_t i = (size_t)(block->compressed_size); i & 3; ++i) {+ assert(*out_pos < out_size);+ out[(*out_pos)++] = 0x00;+ }++ // If there's no Check field, we are done now.+ if (check_size > 0) {+ // Calculate the integrity check. We reserved space for+ // the Check field earlier so we don't need to check for+ // available output space here.+ lzma_check_state check;+ lzma_check_init(&check, block->check);+ lzma_check_update(&check, block->check, in, in_size);+ lzma_check_finish(&check, block->check);++ memcpy(block->raw_check, check.buffer.u8, check_size);+ memcpy(out + *out_pos, check.buffer.u8, check_size);+ *out_pos += check_size;+ }++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_block_buffer_encode(lzma_block *block, const lzma_allocator *allocator,+ const uint8_t *in, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+{+ return block_buffer_encode(block, allocator,+ in, in_size, out, out_pos, out_size, true);+}+++#ifdef HAVE_SYMBOL_VERSIONS_LINUX+// This is for compatibility with binaries linked against liblzma that+// has been patched with xz-5.2.2-compat-libs.patch from RHEL/CentOS 7.+LZMA_SYMVER_API("lzma_block_uncomp_encode@XZ_5.2.2",+ lzma_ret, lzma_block_uncomp_encode_522)(lzma_block *block,+ const uint8_t *in, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+ lzma_nothrow lzma_attr_warn_unused_result+ __attribute__((__alias__("lzma_block_uncomp_encode_52")));++LZMA_SYMVER_API("lzma_block_uncomp_encode@@XZ_5.2",+ lzma_ret, lzma_block_uncomp_encode_52)(lzma_block *block,+ const uint8_t *in, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+ lzma_nothrow lzma_attr_warn_unused_result;++#define lzma_block_uncomp_encode lzma_block_uncomp_encode_52+#endif+extern LZMA_API(lzma_ret)+lzma_block_uncomp_encode(lzma_block *block,+ const uint8_t *in, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+{+ // It won't allocate any memory from heap so no need+ // for lzma_allocator.+ return block_buffer_encode(block, NULL,+ in, in_size, out, out_pos, out_size, false);+}
+ cbits/liblzma/common/block_buffer_encoder.h view
@@ -0,0 +1,23 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file block_buffer_encoder.h+/// \brief Single-call .xz Block encoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_BLOCK_BUFFER_ENCODER_H+#define LZMA_BLOCK_BUFFER_ENCODER_H++#include "common.h"+++/// uint64_t version of lzma_block_buffer_bound(). It is used by+/// stream_encoder_mt.c. Probably the original lzma_block_buffer_bound()+/// should have been 64-bit, but fixing it would break the ABI.+extern uint64_t lzma_block_buffer_bound64(uint64_t uncompressed_size);++#endif
+ cbits/liblzma/common/block_decoder.c view
@@ -0,0 +1,288 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file block_decoder.c+/// \brief Decodes .xz Blocks+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "block_decoder.h"+#include "filter_decoder.h"+#include "check.h"+++typedef struct {+ enum {+ SEQ_CODE,+ SEQ_PADDING,+ SEQ_CHECK,+ } sequence;++ /// The filters in the chain; initialized with lzma_raw_decoder_init().+ lzma_next_coder next;++ /// Decoding options; we also write Compressed Size and Uncompressed+ /// Size back to this structure when the decoding has been finished.+ lzma_block *block;++ /// Compressed Size calculated while decoding+ lzma_vli compressed_size;++ /// Uncompressed Size calculated while decoding+ lzma_vli uncompressed_size;++ /// Maximum allowed Compressed Size; this takes into account the+ /// size of the Block Header and Check fields when Compressed Size+ /// is unknown.+ lzma_vli compressed_limit;++ /// Maximum allowed Uncompressed Size.+ lzma_vli uncompressed_limit;++ /// Position when reading the Check field+ size_t check_pos;++ /// Check of the uncompressed data+ lzma_check_state check;++ /// True if the integrity check won't be calculated and verified.+ bool ignore_check;+} lzma_block_coder;+++static inline bool+is_size_valid(lzma_vli size, lzma_vli reference)+{+ return reference == LZMA_VLI_UNKNOWN || reference == size;+}+++static lzma_ret+block_decode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size, lzma_action action)+{+ lzma_block_coder *coder = coder_ptr;++ switch (coder->sequence) {+ case SEQ_CODE: {+ const size_t in_start = *in_pos;+ const size_t out_start = *out_pos;++ // Limit the amount of input and output space that we give+ // to the raw decoder based on the information we have+ // (or don't have) from Block Header.+ const size_t in_stop = *in_pos + (size_t)my_min(+ in_size - *in_pos,+ coder->compressed_limit - coder->compressed_size);+ const size_t out_stop = *out_pos + (size_t)my_min(+ out_size - *out_pos,+ coder->uncompressed_limit - coder->uncompressed_size);++ const lzma_ret ret = coder->next.code(coder->next.coder,+ allocator, in, in_pos, in_stop,+ out, out_pos, out_stop, action);++ const size_t in_used = *in_pos - in_start;+ const size_t out_used = *out_pos - out_start;++ // Because we have limited the input and output sizes,+ // we know that these cannot grow too big or overflow.+ coder->compressed_size += in_used;+ coder->uncompressed_size += out_used;++ if (ret == LZMA_OK) {+ const bool comp_done = coder->compressed_size+ == coder->block->compressed_size;+ const bool uncomp_done = coder->uncompressed_size+ == coder->block->uncompressed_size;++ // If both input and output amounts match the sizes+ // in Block Header but we still got LZMA_OK instead+ // of LZMA_STREAM_END, the file is broken.+ if (comp_done && uncomp_done)+ return LZMA_DATA_ERROR;++ // If the decoder has consumed all the input that it+ // needs but it still couldn't fill the output buffer+ // or return LZMA_STREAM_END, the file is broken.+ if (comp_done && *out_pos < out_size)+ return LZMA_DATA_ERROR;++ // If the decoder has produced all the output but+ // it still didn't return LZMA_STREAM_END or consume+ // more input (for example, detecting an end of+ // payload marker may need more input but produce+ // no output) the file is broken.+ if (uncomp_done && *in_pos < in_size)+ return LZMA_DATA_ERROR;+ }++ // Don't waste time updating the integrity check if it will be+ // ignored. Also skip it if no new output was produced. This+ // avoids null pointer + 0 (undefined behavior) when out == 0.+ if (!coder->ignore_check && out_used > 0)+ lzma_check_update(&coder->check, coder->block->check,+ out + out_start, out_used);++ if (ret != LZMA_STREAM_END)+ return ret;++ // Compressed and Uncompressed Sizes are now at their final+ // values. Verify that they match the values given to us.+ if (!is_size_valid(coder->compressed_size,+ coder->block->compressed_size)+ || !is_size_valid(coder->uncompressed_size,+ coder->block->uncompressed_size))+ return LZMA_DATA_ERROR;++ // Copy the values into coder->block. The caller+ // may use this information to construct Index.+ coder->block->compressed_size = coder->compressed_size;+ coder->block->uncompressed_size = coder->uncompressed_size;++ coder->sequence = SEQ_PADDING;+ }++ // Fall through++ case SEQ_PADDING:+ // Compressed Data is padded to a multiple of four bytes.+ while (coder->compressed_size & 3) {+ if (*in_pos >= in_size)+ return LZMA_OK;++ // We use compressed_size here just get the Padding+ // right. The actual Compressed Size was stored to+ // coder->block already, and won't be modified by+ // us anymore.+ ++coder->compressed_size;++ if (in[(*in_pos)++] != 0x00)+ return LZMA_DATA_ERROR;+ }++ if (coder->block->check == LZMA_CHECK_NONE)+ return LZMA_STREAM_END;++ if (!coder->ignore_check)+ lzma_check_finish(&coder->check, coder->block->check);++ coder->sequence = SEQ_CHECK;++ // Fall through++ case SEQ_CHECK: {+ const size_t check_size = lzma_check_size(coder->block->check);+ lzma_bufcpy(in, in_pos, in_size, coder->block->raw_check,+ &coder->check_pos, check_size);+ if (coder->check_pos < check_size)+ return LZMA_OK;++ // Validate the Check only if we support it.+ // coder->check.buffer may be uninitialized+ // when the Check ID is not supported.+ if (!coder->ignore_check+ && lzma_check_is_supported(coder->block->check)+ && memcmp(coder->block->raw_check,+ coder->check.buffer.u8,+ check_size) != 0)+ return LZMA_DATA_ERROR;++ return LZMA_STREAM_END;+ }+ }++ return LZMA_PROG_ERROR;+}+++static void+block_decoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_block_coder *coder = coder_ptr;+ lzma_next_end(&coder->next, allocator);+ lzma_free(coder, allocator);+ return;+}+++extern lzma_ret+lzma_block_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ lzma_block *block)+{+ lzma_next_coder_init(&lzma_block_decoder_init, next, allocator);++ // Validate the options. lzma_block_unpadded_size() does that for us+ // except for Uncompressed Size and filters. Filters are validated+ // by the raw decoder.+ if (lzma_block_unpadded_size(block) == 0+ || !lzma_vli_is_valid(block->uncompressed_size))+ return LZMA_PROG_ERROR;++ // Allocate *next->coder if needed.+ lzma_block_coder *coder = next->coder;+ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_block_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = &block_decode;+ next->end = &block_decoder_end;+ coder->next = LZMA_NEXT_CODER_INIT;+ }++ // Basic initializations+ coder->sequence = SEQ_CODE;+ coder->block = block;+ coder->compressed_size = 0;+ coder->uncompressed_size = 0;++ // If Compressed Size is not known, we calculate the maximum allowed+ // value so that encoded size of the Block (including Block Padding)+ // is still a valid VLI and a multiple of four.+ coder->compressed_limit+ = block->compressed_size == LZMA_VLI_UNKNOWN+ ? (LZMA_VLI_MAX & ~LZMA_VLI_C(3))+ - block->header_size+ - lzma_check_size(block->check)+ : block->compressed_size;++ // With Uncompressed Size this is simpler. If Block Header lacks+ // the size info, then LZMA_VLI_MAX is the maximum possible+ // Uncompressed Size.+ coder->uncompressed_limit+ = block->uncompressed_size == LZMA_VLI_UNKNOWN+ ? LZMA_VLI_MAX+ : block->uncompressed_size;++ // Initialize the check. It's caller's problem if the Check ID is not+ // supported, and the Block decoder cannot verify the Check field.+ // Caller can test lzma_check_is_supported(block->check).+ coder->check_pos = 0;+ lzma_check_init(&coder->check, block->check);++ coder->ignore_check = block->version >= 1+ ? block->ignore_check : false;++ // Initialize the filter chain.+ return lzma_raw_decoder_init(&coder->next, allocator,+ block->filters);+}+++extern LZMA_API(lzma_ret)+lzma_block_decoder(lzma_stream *strm, lzma_block *block)+{+ lzma_next_strm_init(lzma_block_decoder_init, strm, block);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}
+ cbits/liblzma/common/block_decoder.h view
@@ -0,0 +1,21 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file block_decoder.h+/// \brief Decodes .xz Blocks+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_BLOCK_DECODER_H+#define LZMA_BLOCK_DECODER_H++#include "common.h"+++extern lzma_ret lzma_block_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator, lzma_block *block);++#endif
+ cbits/liblzma/common/block_encoder.c view
@@ -0,0 +1,226 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file block_encoder.c+/// \brief Encodes .xz Blocks+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "block_encoder.h"+#include "filter_encoder.h"+#include "check.h"+++typedef struct {+ /// The filters in the chain; initialized with lzma_raw_decoder_init().+ lzma_next_coder next;++ /// Encoding options; we also write Unpadded Size, Compressed Size,+ /// and Uncompressed Size back to this structure when the encoding+ /// has been finished.+ lzma_block *block;++ enum {+ SEQ_CODE,+ SEQ_PADDING,+ SEQ_CHECK,+ } sequence;++ /// Compressed Size calculated while encoding+ lzma_vli compressed_size;++ /// Uncompressed Size calculated while encoding+ lzma_vli uncompressed_size;++ /// Position in the Check field+ size_t pos;++ /// Check of the uncompressed data+ lzma_check_state check;+} lzma_block_coder;+++static lzma_ret+block_encode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size, lzma_action action)+{+ lzma_block_coder *coder = coder_ptr;++ // Check that our amount of input stays in proper limits.+ if (LZMA_VLI_MAX - coder->uncompressed_size < in_size - *in_pos)+ return LZMA_DATA_ERROR;++ switch (coder->sequence) {+ case SEQ_CODE: {+ const size_t in_start = *in_pos;+ const size_t out_start = *out_pos;++ const lzma_ret ret = coder->next.code(coder->next.coder,+ allocator, in, in_pos, in_size,+ out, out_pos, out_size, action);++ const size_t in_used = *in_pos - in_start;+ const size_t out_used = *out_pos - out_start;++ if (COMPRESSED_SIZE_MAX - coder->compressed_size < out_used)+ return LZMA_DATA_ERROR;++ coder->compressed_size += out_used;++ // No need to check for overflow because we have already+ // checked it at the beginning of this function.+ coder->uncompressed_size += in_used;++ // Call lzma_check_update() only if input was consumed. This+ // avoids null pointer + 0 (undefined behavior) when in == 0.+ if (in_used > 0)+ lzma_check_update(&coder->check, coder->block->check,+ in + in_start, in_used);++ if (ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH)+ return ret;++ assert(*in_pos == in_size);+ assert(action == LZMA_FINISH);++ // Copy the values into coder->block. The caller+ // may use this information to construct Index.+ coder->block->compressed_size = coder->compressed_size;+ coder->block->uncompressed_size = coder->uncompressed_size;++ coder->sequence = SEQ_PADDING;+ }++ // Fall through++ case SEQ_PADDING:+ // Pad Compressed Data to a multiple of four bytes. We can+ // use coder->compressed_size for this since we don't need+ // it for anything else anymore.+ while (coder->compressed_size & 3) {+ if (*out_pos >= out_size)+ return LZMA_OK;++ out[*out_pos] = 0x00;+ ++*out_pos;+ ++coder->compressed_size;+ }++ if (coder->block->check == LZMA_CHECK_NONE)+ return LZMA_STREAM_END;++ lzma_check_finish(&coder->check, coder->block->check);++ coder->sequence = SEQ_CHECK;++ // Fall through++ case SEQ_CHECK: {+ const size_t check_size = lzma_check_size(coder->block->check);+ lzma_bufcpy(coder->check.buffer.u8, &coder->pos, check_size,+ out, out_pos, out_size);+ if (coder->pos < check_size)+ return LZMA_OK;++ memcpy(coder->block->raw_check, coder->check.buffer.u8,+ check_size);+ return LZMA_STREAM_END;+ }+ }++ return LZMA_PROG_ERROR;+}+++static void+block_encoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_block_coder *coder = coder_ptr;+ lzma_next_end(&coder->next, allocator);+ lzma_free(coder, allocator);+ return;+}+++static lzma_ret+block_encoder_update(void *coder_ptr, const lzma_allocator *allocator,+ const lzma_filter *filters lzma_attribute((__unused__)),+ const lzma_filter *reversed_filters)+{+ lzma_block_coder *coder = coder_ptr;++ if (coder->sequence != SEQ_CODE)+ return LZMA_PROG_ERROR;++ return lzma_next_filter_update(+ &coder->next, allocator, reversed_filters);+}+++extern lzma_ret+lzma_block_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ lzma_block *block)+{+ lzma_next_coder_init(&lzma_block_encoder_init, next, allocator);++ if (block == NULL)+ return LZMA_PROG_ERROR;++ // The contents of the structure may depend on the version so+ // check the version first.+ if (block->version > 1)+ return LZMA_OPTIONS_ERROR;++ // If the Check ID is not supported, we cannot calculate the check and+ // thus not create a proper Block.+ if ((unsigned int)(block->check) > LZMA_CHECK_ID_MAX)+ return LZMA_PROG_ERROR;++ if (!lzma_check_is_supported(block->check))+ return LZMA_UNSUPPORTED_CHECK;++ // Allocate and initialize *next->coder if needed.+ lzma_block_coder *coder = next->coder;+ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_block_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = &block_encode;+ next->end = &block_encoder_end;+ next->update = &block_encoder_update;+ coder->next = LZMA_NEXT_CODER_INIT;+ }++ // Basic initializations+ coder->sequence = SEQ_CODE;+ coder->block = block;+ coder->compressed_size = 0;+ coder->uncompressed_size = 0;+ coder->pos = 0;++ // Initialize the check+ lzma_check_init(&coder->check, block->check);++ // Initialize the requested filters.+ return lzma_raw_encoder_init(&coder->next, allocator, block->filters);+}+++extern LZMA_API(lzma_ret)+lzma_block_encoder(lzma_stream *strm, lzma_block *block)+{+ lzma_next_strm_init(lzma_block_encoder_init, strm, block);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}
+ cbits/liblzma/common/block_encoder.h view
@@ -0,0 +1,46 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file block_encoder.h+/// \brief Encodes .xz Blocks+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_BLOCK_ENCODER_H+#define LZMA_BLOCK_ENCODER_H++#include "common.h"+++/// \brief Biggest Compressed Size value that the Block encoder supports+///+/// The maximum size of a single Block is limited by the maximum size of+/// a Stream, which in theory is 2^63 - 3 bytes (i.e. LZMA_VLI_MAX - 3).+/// While the size is really big and no one should hit it in practice, we+/// take it into account in some places anyway to catch some errors e.g. if+/// application passes insanely big value to some function.+///+/// We could take into account the headers etc. to determine the exact+/// maximum size of the Compressed Data field, but the complexity would give+/// us nothing useful. Instead, limit the size of Compressed Data so that+/// even with biggest possible Block Header and Check fields the total+/// encoded size of the Block stays as a valid VLI. This doesn't guarantee+/// that the size of the Stream doesn't grow too big, but that problem is+/// taken care outside the Block handling code.+///+/// ~LZMA_VLI_C(3) is to guarantee that if we need padding at the end of+/// the Compressed Data field, it will still stay in the proper limit.+///+/// This constant is in this file because it is needed in both+/// block_encoder.c and block_buffer_encoder.c.+#define COMPRESSED_SIZE_MAX ((LZMA_VLI_MAX - LZMA_BLOCK_HEADER_SIZE_MAX \+ - LZMA_CHECK_SIZE_MAX) & ~LZMA_VLI_C(3))+++extern lzma_ret lzma_block_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator, lzma_block *block);++#endif
+ cbits/liblzma/common/block_header_decoder.c view
@@ -0,0 +1,114 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file block_header_decoder.c+/// \brief Decodes Block Header from .xz files+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+#include "check.h"+++extern LZMA_API(lzma_ret)+lzma_block_header_decode(lzma_block *block,+ const lzma_allocator *allocator, const uint8_t *in)+{+ // NOTE: We consider the header to be corrupt not only when the+ // CRC32 doesn't match, but also when variable-length integers+ // are invalid or over 63 bits, or if the header is too small+ // to contain the claimed information.++ // Catch unexpected NULL pointers.+ if (block == NULL || block->filters == NULL || in == NULL)+ return LZMA_PROG_ERROR;++ // Initialize the filter options array. This way the caller can+ // safely free() the options even if an error occurs in this function.+ for (size_t i = 0; i <= LZMA_FILTERS_MAX; ++i) {+ block->filters[i].id = LZMA_VLI_UNKNOWN;+ block->filters[i].options = NULL;+ }++ // Versions 0 and 1 are supported. If a newer version was specified,+ // we need to downgrade it.+ if (block->version > 1)+ block->version = 1;++ // This isn't a Block Header option, but since the decompressor will+ // read it if version >= 1, it's better to initialize it here than+ // to expect the caller to do it since in almost all cases this+ // should be false.+ block->ignore_check = false;++ // Validate Block Header Size and Check type. The caller must have+ // already set these, so it is a programming error if this test fails.+ if (lzma_block_header_size_decode(in[0]) != block->header_size+ || (unsigned int)(block->check) > LZMA_CHECK_ID_MAX)+ return LZMA_PROG_ERROR;++ // Exclude the CRC32 field.+ const size_t in_size = block->header_size - 4;++ // Verify CRC32+ if (lzma_crc32(in, in_size, 0) != read32le(in + in_size)) {+#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION+ return LZMA_DATA_ERROR;+#endif+ }++ // Check for unsupported flags.+ if (in[1] & 0x3C)+ return LZMA_OPTIONS_ERROR;++ // Start after the Block Header Size and Block Flags fields.+ size_t in_pos = 2;++ // Compressed Size+ if (in[1] & 0x40) {+ return_if_error(lzma_vli_decode(&block->compressed_size,+ NULL, in, &in_pos, in_size));++ // Validate Compressed Size. This checks that it isn't zero+ // and that the total size of the Block is a valid VLI.+ if (lzma_block_unpadded_size(block) == 0)+ return LZMA_DATA_ERROR;+ } else {+ block->compressed_size = LZMA_VLI_UNKNOWN;+ }++ // Uncompressed Size+ if (in[1] & 0x80)+ return_if_error(lzma_vli_decode(&block->uncompressed_size,+ NULL, in, &in_pos, in_size));+ else+ block->uncompressed_size = LZMA_VLI_UNKNOWN;++ // Filter Flags+ const size_t filter_count = (in[1] & 3U) + 1;+ for (size_t i = 0; i < filter_count; ++i) {+ const lzma_ret ret = lzma_filter_flags_decode(+ &block->filters[i], allocator,+ in, &in_pos, in_size);+ if (ret != LZMA_OK) {+ lzma_filters_free(block->filters, allocator);+ return ret;+ }+ }++ // Padding+ while (in_pos < in_size) {+ if (in[in_pos++] != 0x00) {+ lzma_filters_free(block->filters, allocator);++ // Possibly some new field present so use+ // LZMA_OPTIONS_ERROR instead of LZMA_DATA_ERROR.+ return LZMA_OPTIONS_ERROR;+ }+ }++ return LZMA_OK;+}
+ cbits/liblzma/common/block_header_encoder.c view
@@ -0,0 +1,131 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file block_header_encoder.c+/// \brief Encodes Block Header for .xz files+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+#include "check.h"+++extern LZMA_API(lzma_ret)+lzma_block_header_size(lzma_block *block)+{+ if (block->version > 1)+ return LZMA_OPTIONS_ERROR;++ // Block Header Size + Block Flags + CRC32.+ uint32_t size = 1 + 1 + 4;++ // Compressed Size+ if (block->compressed_size != LZMA_VLI_UNKNOWN) {+ const uint32_t add = lzma_vli_size(block->compressed_size);+ if (add == 0 || block->compressed_size == 0)+ return LZMA_PROG_ERROR;++ size += add;+ }++ // Uncompressed Size+ if (block->uncompressed_size != LZMA_VLI_UNKNOWN) {+ const uint32_t add = lzma_vli_size(block->uncompressed_size);+ if (add == 0)+ return LZMA_PROG_ERROR;++ size += add;+ }++ // List of Filter Flags+ if (block->filters == NULL || block->filters[0].id == LZMA_VLI_UNKNOWN)+ return LZMA_PROG_ERROR;++ for (size_t i = 0; block->filters[i].id != LZMA_VLI_UNKNOWN; ++i) {+ // Don't allow too many filters.+ if (i == LZMA_FILTERS_MAX)+ return LZMA_PROG_ERROR;++ uint32_t add;+ return_if_error(lzma_filter_flags_size(&add,+ block->filters + i));++ size += add;+ }++ // Pad to a multiple of four bytes.+ block->header_size = (size + 3) & ~UINT32_C(3);++ // NOTE: We don't verify that the encoded size of the Block stays+ // within limits. This is because it is possible that we are called+ // with exaggerated Compressed Size (e.g. LZMA_VLI_MAX) to reserve+ // space for Block Header, and later called again with lower,+ // real values.++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_block_header_encode(const lzma_block *block, uint8_t *out)+{+ // Validate everything but filters.+ if (lzma_block_unpadded_size(block) == 0+ || !lzma_vli_is_valid(block->uncompressed_size))+ return LZMA_PROG_ERROR;++ // Indicate the size of the buffer _excluding_ the CRC32 field.+ const size_t out_size = block->header_size - 4;++ // Store the Block Header Size.+ out[0] = out_size / 4;++ // We write Block Flags in pieces.+ out[1] = 0x00;+ size_t out_pos = 2;++ // Compressed Size+ if (block->compressed_size != LZMA_VLI_UNKNOWN) {+ return_if_error(lzma_vli_encode(block->compressed_size, NULL,+ out, &out_pos, out_size));++ out[1] |= 0x40;+ }++ // Uncompressed Size+ if (block->uncompressed_size != LZMA_VLI_UNKNOWN) {+ return_if_error(lzma_vli_encode(block->uncompressed_size, NULL,+ out, &out_pos, out_size));++ out[1] |= 0x80;+ }++ // Filter Flags+ if (block->filters == NULL || block->filters[0].id == LZMA_VLI_UNKNOWN)+ return LZMA_PROG_ERROR;++ size_t filter_count = 0;+ do {+ // There can be a maximum of four filters.+ if (filter_count == LZMA_FILTERS_MAX)+ return LZMA_PROG_ERROR;++ return_if_error(lzma_filter_flags_encode(+ block->filters + filter_count,+ out, &out_pos, out_size));++ } while (block->filters[++filter_count].id != LZMA_VLI_UNKNOWN);++ out[1] |= filter_count - 1;++ // Padding+ memzero(out + out_pos, out_size - out_pos);++ // CRC32+ write32le(out + out_size, lzma_crc32(out, out_size, 0));++ return LZMA_OK;+}
+ cbits/liblzma/common/block_util.c view
@@ -0,0 +1,89 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file block_util.c+/// \brief Utility functions to handle lzma_block+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+#include "index.h"+++extern LZMA_API(lzma_ret)+lzma_block_compressed_size(lzma_block *block, lzma_vli unpadded_size)+{+ // Validate everything but Uncompressed Size and filters.+ if (lzma_block_unpadded_size(block) == 0)+ return LZMA_PROG_ERROR;++ const uint32_t container_size = block->header_size+ + lzma_check_size(block->check);++ // Validate that Compressed Size will be greater than zero.+ if (unpadded_size <= container_size)+ return LZMA_DATA_ERROR;++ // Calculate what Compressed Size is supposed to be.+ // If Compressed Size was present in Block Header,+ // compare that the new value matches it.+ const lzma_vli compressed_size = unpadded_size - container_size;+ if (block->compressed_size != LZMA_VLI_UNKNOWN+ && block->compressed_size != compressed_size)+ return LZMA_DATA_ERROR;++ block->compressed_size = compressed_size;++ return LZMA_OK;+}+++extern LZMA_API(lzma_vli)+lzma_block_unpadded_size(const lzma_block *block)+{+ // Validate the values that we are interested in i.e. all but+ // Uncompressed Size and the filters.+ //+ // NOTE: This function is used for validation too, so it is+ // essential that these checks are always done even if+ // Compressed Size is unknown.+ if (block == NULL || block->version > 1+ || block->header_size < LZMA_BLOCK_HEADER_SIZE_MIN+ || block->header_size > LZMA_BLOCK_HEADER_SIZE_MAX+ || (block->header_size & 3)+ || !lzma_vli_is_valid(block->compressed_size)+ || block->compressed_size == 0+ || (unsigned int)(block->check) > LZMA_CHECK_ID_MAX)+ return 0;++ // If Compressed Size is unknown, return that we cannot know+ // size of the Block either.+ if (block->compressed_size == LZMA_VLI_UNKNOWN)+ return LZMA_VLI_UNKNOWN;++ // Calculate Unpadded Size and validate it.+ const lzma_vli unpadded_size = block->compressed_size+ + block->header_size+ + lzma_check_size(block->check);++ assert(unpadded_size >= UNPADDED_SIZE_MIN);+ if (unpadded_size > UNPADDED_SIZE_MAX)+ return 0;++ return unpadded_size;+}+++extern LZMA_API(lzma_vli)+lzma_block_total_size(const lzma_block *block)+{+ lzma_vli unpadded_size = lzma_block_unpadded_size(block);++ if (unpadded_size != LZMA_VLI_UNKNOWN)+ unpadded_size = vli_ceil4(unpadded_size);++ return unpadded_size;+}
+ cbits/liblzma/common/common.c view
@@ -0,0 +1,480 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file common.c+/// \brief Common functions needed in many places in liblzma+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+++/////////////+// Version //+/////////////++extern LZMA_API(uint32_t)+lzma_version_number(void)+{+ return LZMA_VERSION;+}+++extern LZMA_API(const char *)+lzma_version_string(void)+{+ return LZMA_VERSION_STRING;+}+++///////////////////////+// Memory allocation //+///////////////////////++lzma_attr_alloc_size(1)+extern void *+lzma_alloc(size_t size, const lzma_allocator *allocator)+{+ // Some malloc() variants return NULL if called with size == 0.+ if (size == 0)+ size = 1;++ void *ptr;++ if (allocator != NULL && allocator->alloc != NULL)+ ptr = allocator->alloc(allocator->opaque, 1, size);+ else+ ptr = malloc(size);++ return ptr;+}+++lzma_attr_alloc_size(1)+extern void *+lzma_alloc_zero(size_t size, const lzma_allocator *allocator)+{+ // Some calloc() variants return NULL if called with size == 0.+ if (size == 0)+ size = 1;++ void *ptr;++ if (allocator != NULL && allocator->alloc != NULL) {+ ptr = allocator->alloc(allocator->opaque, 1, size);+ if (ptr != NULL)+ memzero(ptr, size);+ } else {+ ptr = calloc(1, size);+ }++ return ptr;+}+++extern void+lzma_free(void *ptr, const lzma_allocator *allocator)+{+ if (allocator != NULL && allocator->free != NULL)+ allocator->free(allocator->opaque, ptr);+ else+ free(ptr);++ return;+}+++//////////+// Misc //+//////////++extern size_t+lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size)+{+ const size_t in_avail = in_size - *in_pos;+ const size_t out_avail = out_size - *out_pos;+ const size_t copy_size = my_min(in_avail, out_avail);++ // Call memcpy() only if there is something to copy. If there is+ // nothing to copy, in or out might be NULL and then the memcpy()+ // call would trigger undefined behavior.+ if (copy_size > 0)+ memcpy(out + *out_pos, in + *in_pos, copy_size);++ *in_pos += copy_size;+ *out_pos += copy_size;++ return copy_size;+}+++extern lzma_ret+lzma_next_filter_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ lzma_next_coder_init(filters[0].init, next, allocator);+ next->id = filters[0].id;+ return filters[0].init == NULL+ ? LZMA_OK : filters[0].init(next, allocator, filters);+}+++extern lzma_ret+lzma_next_filter_update(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter *reversed_filters)+{+ // Check that the application isn't trying to change the Filter ID.+ // End of filters is indicated with LZMA_VLI_UNKNOWN in both+ // reversed_filters[0].id and next->id.+ if (reversed_filters[0].id != next->id)+ return LZMA_PROG_ERROR;++ if (reversed_filters[0].id == LZMA_VLI_UNKNOWN)+ return LZMA_OK;++ assert(next->update != NULL);+ return next->update(next->coder, allocator, NULL, reversed_filters);+}+++extern void+lzma_next_end(lzma_next_coder *next, const lzma_allocator *allocator)+{+ if (next->init != (uintptr_t)(NULL)) {+ // To avoid tiny end functions that simply call+ // lzma_free(coder, allocator), we allow leaving next->end+ // NULL and call lzma_free() here.+ if (next->end != NULL)+ next->end(next->coder, allocator);+ else+ lzma_free(next->coder, allocator);++ // Reset the variables so the we don't accidentally think+ // that it is an already initialized coder.+ *next = LZMA_NEXT_CODER_INIT;+ }++ return;+}+++//////////////////////////////////////+// External to internal API wrapper //+//////////////////////////////////////++extern lzma_ret+lzma_strm_init(lzma_stream *strm)+{+ if (strm == NULL)+ return LZMA_PROG_ERROR;++ if (strm->internal == NULL) {+ strm->internal = lzma_alloc(sizeof(lzma_internal),+ strm->allocator);+ if (strm->internal == NULL)+ return LZMA_MEM_ERROR;++ strm->internal->next = LZMA_NEXT_CODER_INIT;+ }++ memzero(strm->internal->supported_actions,+ sizeof(strm->internal->supported_actions));+ strm->internal->sequence = ISEQ_RUN;+ strm->internal->allow_buf_error = false;++ strm->total_in = 0;+ strm->total_out = 0;++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_code(lzma_stream *strm, lzma_action action)+{+ // Sanity checks+ if ((strm->next_in == NULL && strm->avail_in != 0)+ || (strm->next_out == NULL && strm->avail_out != 0)+ || strm->internal == NULL+ || strm->internal->next.code == NULL+ || (unsigned int)(action) > LZMA_ACTION_MAX+ || !strm->internal->supported_actions[action])+ return LZMA_PROG_ERROR;++ // Check if unsupported members have been set to non-zero or non-NULL,+ // which would indicate that some new feature is wanted.+ if (strm->reserved_ptr1 != NULL+ || strm->reserved_ptr2 != NULL+ || strm->reserved_ptr3 != NULL+ || strm->reserved_ptr4 != NULL+ || strm->reserved_int2 != 0+ || strm->reserved_int3 != 0+ || strm->reserved_int4 != 0+ || strm->reserved_enum1 != LZMA_RESERVED_ENUM+ || strm->reserved_enum2 != LZMA_RESERVED_ENUM)+ return LZMA_OPTIONS_ERROR;++ switch (strm->internal->sequence) {+ case ISEQ_RUN:+ switch (action) {+ case LZMA_RUN:+ break;++ case LZMA_SYNC_FLUSH:+ strm->internal->sequence = ISEQ_SYNC_FLUSH;+ break;++ case LZMA_FULL_FLUSH:+ strm->internal->sequence = ISEQ_FULL_FLUSH;+ break;++ case LZMA_FINISH:+ strm->internal->sequence = ISEQ_FINISH;+ break;++ case LZMA_FULL_BARRIER:+ strm->internal->sequence = ISEQ_FULL_BARRIER;+ break;+ }++ break;++ case ISEQ_SYNC_FLUSH:+ // The same action must be used until we return+ // LZMA_STREAM_END, and the amount of input must not change.+ if (action != LZMA_SYNC_FLUSH+ || strm->internal->avail_in != strm->avail_in)+ return LZMA_PROG_ERROR;++ break;++ case ISEQ_FULL_FLUSH:+ if (action != LZMA_FULL_FLUSH+ || strm->internal->avail_in != strm->avail_in)+ return LZMA_PROG_ERROR;++ break;++ case ISEQ_FINISH:+ if (action != LZMA_FINISH+ || strm->internal->avail_in != strm->avail_in)+ return LZMA_PROG_ERROR;++ break;++ case ISEQ_FULL_BARRIER:+ if (action != LZMA_FULL_BARRIER+ || strm->internal->avail_in != strm->avail_in)+ return LZMA_PROG_ERROR;++ break;++ case ISEQ_END:+ return LZMA_STREAM_END;++ case ISEQ_ERROR:+ default:+ return LZMA_PROG_ERROR;+ }++ size_t in_pos = 0;+ size_t out_pos = 0;+ lzma_ret ret = strm->internal->next.code(+ strm->internal->next.coder, strm->allocator,+ strm->next_in, &in_pos, strm->avail_in,+ strm->next_out, &out_pos, strm->avail_out, action);++ // Updating next_in and next_out has to be skipped when they are NULL+ // to avoid null pointer + 0 (undefined behavior). Do this by checking+ // in_pos > 0 and out_pos > 0 because this way NULL + non-zero (a bug)+ // will get caught one way or other.+ if (in_pos > 0) {+ strm->next_in += in_pos;+ strm->avail_in -= in_pos;+ strm->total_in += in_pos;+ }++ if (out_pos > 0) {+ strm->next_out += out_pos;+ strm->avail_out -= out_pos;+ strm->total_out += out_pos;+ }++ strm->internal->avail_in = strm->avail_in;++ switch (ret) {+ case LZMA_OK:+ // Don't return LZMA_BUF_ERROR when it happens the first time.+ // This is to avoid returning LZMA_BUF_ERROR when avail_out+ // was zero but still there was no more data left to written+ // to next_out.+ if (out_pos == 0 && in_pos == 0) {+ if (strm->internal->allow_buf_error)+ ret = LZMA_BUF_ERROR;+ else+ strm->internal->allow_buf_error = true;+ } else {+ strm->internal->allow_buf_error = false;+ }+ break;++ case LZMA_TIMED_OUT:+ strm->internal->allow_buf_error = false;+ ret = LZMA_OK;+ break;++ case LZMA_SEEK_NEEDED:+ strm->internal->allow_buf_error = false;++ // If LZMA_FINISH was used, reset it back to the+ // LZMA_RUN-based state so that new input can be supplied+ // by the application.+ if (strm->internal->sequence == ISEQ_FINISH)+ strm->internal->sequence = ISEQ_RUN;++ break;++ case LZMA_STREAM_END:+ if (strm->internal->sequence == ISEQ_SYNC_FLUSH+ || strm->internal->sequence == ISEQ_FULL_FLUSH+ || strm->internal->sequence+ == ISEQ_FULL_BARRIER)+ strm->internal->sequence = ISEQ_RUN;+ else+ strm->internal->sequence = ISEQ_END;++ // Fall through++ case LZMA_NO_CHECK:+ case LZMA_UNSUPPORTED_CHECK:+ case LZMA_GET_CHECK:+ case LZMA_MEMLIMIT_ERROR:+ // Something else than LZMA_OK, but not a fatal error,+ // that is, coding may be continued (except if ISEQ_END).+ strm->internal->allow_buf_error = false;+ break;++ default:+ // All the other errors are fatal; coding cannot be continued.+ assert(ret != LZMA_BUF_ERROR);+ strm->internal->sequence = ISEQ_ERROR;+ break;+ }++ return ret;+}+++extern LZMA_API(void)+lzma_end(lzma_stream *strm)+{+ if (strm != NULL && strm->internal != NULL) {+ lzma_next_end(&strm->internal->next, strm->allocator);+ lzma_free(strm->internal, strm->allocator);+ strm->internal = NULL;+ }++ return;+}+++#ifdef HAVE_SYMBOL_VERSIONS_LINUX+// This is for compatibility with binaries linked against liblzma that+// has been patched with xz-5.2.2-compat-libs.patch from RHEL/CentOS 7.+LZMA_SYMVER_API("lzma_get_progress@XZ_5.2.2",+ void, lzma_get_progress_522)(lzma_stream *strm,+ uint64_t *progress_in, uint64_t *progress_out) lzma_nothrow+ __attribute__((__alias__("lzma_get_progress_52")));++LZMA_SYMVER_API("lzma_get_progress@@XZ_5.2",+ void, lzma_get_progress_52)(lzma_stream *strm,+ uint64_t *progress_in, uint64_t *progress_out) lzma_nothrow;++#define lzma_get_progress lzma_get_progress_52+#endif+extern LZMA_API(void)+lzma_get_progress(lzma_stream *strm,+ uint64_t *progress_in, uint64_t *progress_out)+{+ if (strm->internal->next.get_progress != NULL) {+ strm->internal->next.get_progress(strm->internal->next.coder,+ progress_in, progress_out);+ } else {+ *progress_in = strm->total_in;+ *progress_out = strm->total_out;+ }++ return;+}+++extern LZMA_API(lzma_check)+lzma_get_check(const lzma_stream *strm)+{+ // Return LZMA_CHECK_NONE if we cannot know the check type.+ // It's a bug in the application if this happens.+ if (strm->internal->next.get_check == NULL)+ return LZMA_CHECK_NONE;++ return strm->internal->next.get_check(strm->internal->next.coder);+}+++extern LZMA_API(uint64_t)+lzma_memusage(const lzma_stream *strm)+{+ uint64_t memusage;+ uint64_t old_memlimit;++ if (strm == NULL || strm->internal == NULL+ || strm->internal->next.memconfig == NULL+ || strm->internal->next.memconfig(+ strm->internal->next.coder,+ &memusage, &old_memlimit, 0) != LZMA_OK)+ return 0;++ return memusage;+}+++extern LZMA_API(uint64_t)+lzma_memlimit_get(const lzma_stream *strm)+{+ uint64_t old_memlimit;+ uint64_t memusage;++ if (strm == NULL || strm->internal == NULL+ || strm->internal->next.memconfig == NULL+ || strm->internal->next.memconfig(+ strm->internal->next.coder,+ &memusage, &old_memlimit, 0) != LZMA_OK)+ return 0;++ return old_memlimit;+}+++extern LZMA_API(lzma_ret)+lzma_memlimit_set(lzma_stream *strm, uint64_t new_memlimit)+{+ // Dummy variables to simplify memconfig functions+ uint64_t old_memlimit;+ uint64_t memusage;++ if (strm == NULL || strm->internal == NULL+ || strm->internal->next.memconfig == NULL)+ return LZMA_PROG_ERROR;++ // Zero is a special value that cannot be used as an actual limit.+ // If 0 was specified, use 1 instead.+ if (new_memlimit == 0)+ new_memlimit = 1;++ return strm->internal->next.memconfig(strm->internal->next.coder,+ &memusage, &old_memlimit, new_memlimit);+}
+ cbits/liblzma/common/common.h view
@@ -0,0 +1,412 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file common.h+/// \brief Definitions common to the whole liblzma library+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_COMMON_H+#define LZMA_COMMON_H++#include "sysdefs.h"+#include "mythread.h"+#include "tuklib_integer.h"++// LZMA_API_EXPORT is used to mark the exported API functions.+// It's used to define the LZMA_API macro.+//+// lzma_attr_visibility_hidden is used for marking *declarations* of extern+// variables that are internal to liblzma (-fvisibility=hidden alone is+// enough to hide the *definitions*). Such markings allow slightly more+// efficient code to accesses those variables in ELF shared libraries.+#if defined(_WIN32) || defined(__CYGWIN__)+# ifdef DLL_EXPORT+# define LZMA_API_EXPORT __declspec(dllexport)+# else+# define LZMA_API_EXPORT+# endif+# define lzma_attr_visibility_hidden+// Don't use ifdef or defined() below.+#elif HAVE_VISIBILITY+# define LZMA_API_EXPORT __attribute__((__visibility__("default")))+# define lzma_attr_visibility_hidden \+ __attribute__((__visibility__("hidden")))+#else+# define LZMA_API_EXPORT+# define lzma_attr_visibility_hidden+#endif++#define LZMA_API(type) LZMA_API_EXPORT type LZMA_API_CALL++#include "lzma.h"++// This is for detecting modern GCC and Clang attributes+// like __symver__ in GCC >= 10.+#ifdef __has_attribute+# define lzma_has_attribute(attr) __has_attribute(attr)+#else+# define lzma_has_attribute(attr) 0+#endif++// The extra symbol versioning in the C files may only be used when+// building a shared library. If HAVE_SYMBOL_VERSIONS_LINUX is defined+// to 2 then symbol versioning is done only if also PIC is defined.+// By default Libtool defines PIC when building a shared library and+// doesn't define it when building a static library but it can be+// overridden with --with-pic and --without-pic. configure let's rely+// on PIC if neither --with-pic or --without-pic was used.+#if defined(HAVE_SYMBOL_VERSIONS_LINUX) \+ && (HAVE_SYMBOL_VERSIONS_LINUX == 2 && !defined(PIC))+# undef HAVE_SYMBOL_VERSIONS_LINUX+#endif++#ifdef HAVE_SYMBOL_VERSIONS_LINUX+// To keep link-time optimization (LTO, -flto) working with GCC,+// the __symver__ attribute must be used instead of __asm__(".symver ...").+// Otherwise the symbol versions may be lost, resulting in broken liblzma+// that has wrong default versions in the exported symbol list!+// The attribute was added in GCC 10; LTO with older GCC is not supported.+//+// To keep -Wmissing-prototypes happy, use LZMA_SYMVER_API only with function+// declarations (including those with __alias__ attribute) and LZMA_API with+// the function definitions. This means a little bit of silly copy-and-paste+// between declarations and definitions though.+//+// As of GCC 12.2, the __symver__ attribute supports only @ and @@ but the+// very convenient @@@ isn't supported (it's supported by GNU assembler+// since 2000). When using @@ instead of @@@, the internal name must not be+// the same as the external name to avoid problems in some situations. This+// is why "#define foo_52 foo" is needed for the default symbol versions.+//+// __has_attribute is supported before GCC 10 and it is supported in Clang 14+// too (which doesn't support __symver__) so use it to detect if __symver__+// is available. This should be far more reliable than looking at compiler+// version macros as nowadays especially __GNUC__ is defined by many compilers.+# if lzma_has_attribute(__symver__)+# define LZMA_SYMVER_API(extnamever, type, intname) \+ extern __attribute__((__symver__(extnamever))) \+ LZMA_API(type) intname+# else+# define LZMA_SYMVER_API(extnamever, type, intname) \+ __asm__(".symver " #intname "," extnamever); \+ extern LZMA_API(type) intname+# endif+#endif++// MSVC has __forceinline which shouldn't be combined with the inline keyword+// (results in a warning).+//+// GCC 3.1 added always_inline attribute so we don't need to check+// for __GNUC__ version. Similarly, all relevant Clang versions+// support it (at least Clang 3.0.0 does already).+// Other compilers might support too which also support __has_attribute+// (Solaris Studio) so do that check too.+#if defined(_MSC_VER)+# define lzma_always_inline __forceinline+#elif defined(__GNUC__) || defined(__clang__) || defined(__INTEL_COMPILER) \+ || lzma_has_attribute(__always_inline__)+# define lzma_always_inline inline __attribute__((__always_inline__))+#else+# define lzma_always_inline inline+#endif++// These allow helping the compiler in some often-executed branches, whose+// result is almost always the same.+#ifdef __GNUC__+# define likely(expr) __builtin_expect(expr, true)+# define unlikely(expr) __builtin_expect(expr, false)+#else+# define likely(expr) (expr)+# define unlikely(expr) (expr)+#endif+++/// Size of temporary buffers needed in some filters+#define LZMA_BUFFER_SIZE 4096+++/// Maximum number of worker threads within one multithreaded component.+/// The limit exists solely to make it simpler to prevent integer overflows+/// when allocating structures etc. This should be big enough for now...+/// the code won't scale anywhere close to this number anyway.+#define LZMA_THREADS_MAX 16384+++/// Starting value for memory usage estimates. Instead of calculating size+/// of _every_ structure and taking into account malloc() overhead etc., we+/// add a base size to all memory usage estimates. It's not very accurate+/// but should be easily good enough.+#define LZMA_MEMUSAGE_BASE (UINT64_C(1) << 15)++/// Start of internal Filter ID space. These IDs must never be used+/// in Streams.+#define LZMA_FILTER_RESERVED_START (LZMA_VLI_C(1) << 62)+++/// Supported flags that can be passed to lzma_stream_decoder(),+/// lzma_auto_decoder(), or lzma_stream_decoder_mt().+#define LZMA_SUPPORTED_FLAGS \+ ( LZMA_TELL_NO_CHECK \+ | LZMA_TELL_UNSUPPORTED_CHECK \+ | LZMA_TELL_ANY_CHECK \+ | LZMA_IGNORE_CHECK \+ | LZMA_CONCATENATED \+ | LZMA_FAIL_FAST )+++/// Largest valid lzma_action value as unsigned integer.+#define LZMA_ACTION_MAX ((unsigned int)(LZMA_FULL_BARRIER))+++/// Special return value (lzma_ret) to indicate that a timeout was reached+/// and lzma_code() must not return LZMA_BUF_ERROR. This is converted to+/// LZMA_OK in lzma_code().+#define LZMA_TIMED_OUT LZMA_RET_INTERNAL1++/// Special return value (lzma_ret) for use in stream_decoder_mt.c to+/// indicate Index was detected instead of a Block Header.+#define LZMA_INDEX_DETECTED LZMA_RET_INTERNAL2+++typedef struct lzma_next_coder_s lzma_next_coder;++typedef struct lzma_filter_info_s lzma_filter_info;+++/// Type of a function used to initialize a filter encoder or decoder+typedef lzma_ret (*lzma_init_function)(+ lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters);++/// Type of a function to do some kind of coding work (filters, Stream,+/// Block encoders/decoders etc.). Some special coders use don't use both+/// input and output buffers, but for simplicity they still use this same+/// function prototype.+typedef lzma_ret (*lzma_code_function)(+ void *coder, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size,+ lzma_action action);++/// Type of a function to free the memory allocated for the coder+typedef void (*lzma_end_function)(+ void *coder, const lzma_allocator *allocator);+++/// Raw coder validates and converts an array of lzma_filter structures to+/// an array of lzma_filter_info structures. This array is used with+/// lzma_next_filter_init to initialize the filter chain.+struct lzma_filter_info_s {+ /// Filter ID. This can be used to share the same initiazation+ /// function *and* data structures with different Filter IDs+ /// (LZMA_FILTER_LZMA1EXT does it), and also by the encoder+ /// with lzma_filters_update() if filter chain is updated+ /// in the middle of a raw stream or Block (LZMA_SYNC_FLUSH).+ lzma_vli id;++ /// Pointer to function used to initialize the filter.+ /// This is NULL to indicate end of array.+ lzma_init_function init;++ /// Pointer to filter's options structure+ void *options;+};+++/// Hold data and function pointers of the next filter in the chain.+struct lzma_next_coder_s {+ /// Pointer to coder-specific data+ void *coder;++ /// Filter ID. This is LZMA_VLI_UNKNOWN when this structure doesn't+ /// point to a filter coder.+ lzma_vli id;++ /// "Pointer" to init function. This is never called here.+ /// We need only to detect if we are initializing a coder+ /// that was allocated earlier. See lzma_next_coder_init and+ /// lzma_next_strm_init macros in this file.+ uintptr_t init;++ /// Pointer to function to do the actual coding+ lzma_code_function code;++ /// Pointer to function to free lzma_next_coder.coder. This can+ /// be NULL; in that case, lzma_free is called to free+ /// lzma_next_coder.coder.+ lzma_end_function end;++ /// Pointer to a function to get progress information. If this is NULL,+ /// lzma_stream.total_in and .total_out are used instead.+ void (*get_progress)(void *coder,+ uint64_t *progress_in, uint64_t *progress_out);++ /// Pointer to function to return the type of the integrity check.+ /// Most coders won't support this.+ lzma_check (*get_check)(const void *coder);++ /// Pointer to function to get and/or change the memory usage limit.+ /// If new_memlimit == 0, the limit is not changed.+ lzma_ret (*memconfig)(void *coder, uint64_t *memusage,+ uint64_t *old_memlimit, uint64_t new_memlimit);++ /// Update the filter-specific options or the whole filter chain+ /// in the encoder.+ lzma_ret (*update)(void *coder, const lzma_allocator *allocator,+ const lzma_filter *filters,+ const lzma_filter *reversed_filters);++ /// Set how many bytes of output this coder may produce at maximum.+ /// On success LZMA_OK must be returned.+ /// If the filter chain as a whole cannot support this feature,+ /// this must return LZMA_OPTIONS_ERROR.+ /// If no input has been given to the coder and the requested limit+ /// is too small, this must return LZMA_BUF_ERROR. If input has been+ /// seen, LZMA_OK is allowed too.+ lzma_ret (*set_out_limit)(void *coder, uint64_t *uncomp_size,+ uint64_t out_limit);+};+++/// Macro to initialize lzma_next_coder structure+#define LZMA_NEXT_CODER_INIT \+ (lzma_next_coder){ \+ .coder = NULL, \+ .init = (uintptr_t)(NULL), \+ .id = LZMA_VLI_UNKNOWN, \+ .code = NULL, \+ .end = NULL, \+ .get_progress = NULL, \+ .get_check = NULL, \+ .memconfig = NULL, \+ .update = NULL, \+ .set_out_limit = NULL, \+ }+++/// Internal data for lzma_strm_init, lzma_code, and lzma_end. A pointer to+/// this is stored in lzma_stream.+struct lzma_internal_s {+ /// The actual coder that should do something useful+ lzma_next_coder next;++ /// Track the state of the coder. This is used to validate arguments+ /// so that the actual coders can rely on e.g. that LZMA_SYNC_FLUSH+ /// is used on every call to lzma_code until next.code has returned+ /// LZMA_STREAM_END.+ enum {+ ISEQ_RUN,+ ISEQ_SYNC_FLUSH,+ ISEQ_FULL_FLUSH,+ ISEQ_FINISH,+ ISEQ_FULL_BARRIER,+ ISEQ_END,+ ISEQ_ERROR,+ } sequence;++ /// A copy of lzma_stream avail_in. This is used to verify that the+ /// amount of input doesn't change once e.g. LZMA_FINISH has been+ /// used.+ size_t avail_in;++ /// Indicates which lzma_action values are allowed by next.code.+ bool supported_actions[LZMA_ACTION_MAX + 1];++ /// If true, lzma_code will return LZMA_BUF_ERROR if no progress was+ /// made (no input consumed and no output produced by next.code).+ bool allow_buf_error;+};+++/// Allocates memory+lzma_attr_alloc_size(1)+extern void *lzma_alloc(size_t size, const lzma_allocator *allocator);++/// Allocates memory and zeroes it (like calloc()). This can be faster+/// than lzma_alloc() + memzero() while being backward compatible with+/// custom allocators.+lzma_attr_alloc_size(1)+extern void *lzma_alloc_zero(size_t size, const lzma_allocator *allocator);++/// Frees memory+extern void lzma_free(void *ptr, const lzma_allocator *allocator);+++/// Allocates strm->internal if it is NULL, and initializes *strm and+/// strm->internal. This function is only called via lzma_next_strm_init macro.+extern lzma_ret lzma_strm_init(lzma_stream *strm);++/// Initializes the next filter in the chain, if any. This takes care of+/// freeing the memory of previously initialized filter if it is different+/// than the filter being initialized now. This way the actual filter+/// initialization functions don't need to use lzma_next_coder_init macro.+extern lzma_ret lzma_next_filter_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++/// Update the next filter in the chain, if any. This checks that+/// the application is not trying to change the Filter IDs.+extern lzma_ret lzma_next_filter_update(+ lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter *reversed_filters);++/// Frees the memory allocated for next->coder either using next->end or,+/// if next->end is NULL, using lzma_free.+extern void lzma_next_end(lzma_next_coder *next,+ const lzma_allocator *allocator);+++/// Copy as much data as possible from in[] to out[] and update *in_pos+/// and *out_pos accordingly. Returns the number of bytes copied.+extern size_t lzma_bufcpy(const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size);+++/// \brief Return if expression doesn't evaluate to LZMA_OK+///+/// There are several situations where we want to return immediately+/// with the value of expr if it isn't LZMA_OK. This macro shortens+/// the code a little.+#define return_if_error(expr) \+do { \+ const lzma_ret ret_ = (expr); \+ if (ret_ != LZMA_OK) \+ return ret_; \+} while (0)+++/// If next isn't already initialized, free the previous coder. Then mark+/// that next is _possibly_ initialized for the coder using this macro.+/// "Possibly" means that if e.g. allocation of next->coder fails, the+/// structure isn't actually initialized for this coder, but leaving+/// next->init to func is still OK.+#define lzma_next_coder_init(func, next, allocator) \+do { \+ if ((uintptr_t)(func) != (next)->init) \+ lzma_next_end(next, allocator); \+ (next)->init = (uintptr_t)(func); \+} while (0)+++/// Initializes lzma_strm and calls func() to initialize strm->internal->next.+/// (The function being called will use lzma_next_coder_init()). If+/// initialization fails, memory that wasn't freed by func() is freed+/// along strm->internal.+#define lzma_next_strm_init(func, strm, ...) \+do { \+ return_if_error(lzma_strm_init(strm)); \+ const lzma_ret ret_ = func(&(strm)->internal->next, \+ (strm)->allocator, __VA_ARGS__); \+ if (ret_ != LZMA_OK) { \+ lzma_end(strm); \+ return ret_; \+ } \+} while (0)++#endif
+ cbits/liblzma/common/easy_buffer_encoder.c view
@@ -0,0 +1,26 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file easy_buffer_encoder.c+/// \brief Easy single-call .xz Stream encoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "easy_preset.h"+++extern LZMA_API(lzma_ret)+lzma_easy_buffer_encode(uint32_t preset, lzma_check check,+ const lzma_allocator *allocator, const uint8_t *in,+ size_t in_size, uint8_t *out, size_t *out_pos, size_t out_size)+{+ lzma_options_easy opt_easy;+ if (lzma_easy_preset(&opt_easy, preset))+ return LZMA_OPTIONS_ERROR;++ return lzma_stream_buffer_encode(opt_easy.filters, check,+ allocator, in, in_size, out, out_pos, out_size);+}
+ cbits/liblzma/common/easy_decoder_memusage.c view
@@ -0,0 +1,23 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file easy_decoder_memusage.c+/// \brief Decoder memory usage calculation to match easy encoder presets+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "easy_preset.h"+++extern LZMA_API(uint64_t)+lzma_easy_decoder_memusage(uint32_t preset)+{+ lzma_options_easy opt_easy;+ if (lzma_easy_preset(&opt_easy, preset))+ return UINT32_MAX;++ return lzma_raw_decoder_memusage(opt_easy.filters);+}
+ cbits/liblzma/common/easy_encoder.c view
@@ -0,0 +1,23 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file easy_encoder.c+/// \brief Easy .xz Stream encoder initialization+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "easy_preset.h"+++extern LZMA_API(lzma_ret)+lzma_easy_encoder(lzma_stream *strm, uint32_t preset, lzma_check check)+{+ lzma_options_easy opt_easy;+ if (lzma_easy_preset(&opt_easy, preset))+ return LZMA_OPTIONS_ERROR;++ return lzma_stream_encoder(strm, opt_easy.filters, check);+}
+ cbits/liblzma/common/easy_encoder_memusage.c view
@@ -0,0 +1,23 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file easy_encoder_memusage.c+/// \brief Easy .xz Stream encoder memory usage calculation+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "easy_preset.h"+++extern LZMA_API(uint64_t)+lzma_easy_encoder_memusage(uint32_t preset)+{+ lzma_options_easy opt_easy;+ if (lzma_easy_preset(&opt_easy, preset))+ return UINT32_MAX;++ return lzma_raw_encoder_memusage(opt_easy.filters);+}
+ cbits/liblzma/common/easy_preset.c view
@@ -0,0 +1,26 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file easy_preset.c+/// \brief Preset handling for easy encoder and decoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "easy_preset.h"+++extern bool+lzma_easy_preset(lzma_options_easy *opt_easy, uint32_t preset)+{+ if (lzma_lzma_preset(&opt_easy->opt_lzma, preset))+ return true;++ opt_easy->filters[0].id = LZMA_FILTER_LZMA2;+ opt_easy->filters[0].options = &opt_easy->opt_lzma;+ opt_easy->filters[1].id = LZMA_VLI_UNKNOWN;++ return false;+}
+ cbits/liblzma/common/easy_preset.h view
@@ -0,0 +1,36 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file easy_preset.h+/// \brief Preset handling for easy encoder and decoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_EASY_PRESET_H+#define LZMA_EASY_PRESET_H++#include "common.h"+++typedef struct {+ /// We need to keep the filters array available in case+ /// LZMA_FULL_FLUSH is used.+ lzma_filter filters[LZMA_FILTERS_MAX + 1];++ /// Options for LZMA2+ lzma_options_lzma opt_lzma;++ // Options for more filters can be added later, so this struct+ // is not ready to be put into the public API.++} lzma_options_easy;+++/// Set *easy to the settings given by the preset. Returns true on error,+/// false on success.+extern bool lzma_easy_preset(lzma_options_easy *easy, uint32_t preset);++#endif
+ cbits/liblzma/common/file_info.c view
@@ -0,0 +1,854 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file file_info.c+/// \brief Decode .xz file information into a lzma_index structure+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "index_decoder.h"+++typedef struct {+ enum {+ SEQ_MAGIC_BYTES,+ SEQ_PADDING_SEEK,+ SEQ_PADDING_DECODE,+ SEQ_FOOTER,+ SEQ_INDEX_INIT,+ SEQ_INDEX_DECODE,+ SEQ_HEADER_DECODE,+ SEQ_HEADER_COMPARE,+ } sequence;++ /// Absolute position of in[*in_pos] in the file. All code that+ /// modifies *in_pos also updates this. seek_to_pos() needs this+ /// to determine if we need to request the application to seek for+ /// us or if we can do the seeking internally by adjusting *in_pos.+ uint64_t file_cur_pos;++ /// This refers to absolute positions of interesting parts of the+ /// input file. Sometimes it points to the *beginning* of a specific+ /// field and sometimes to the *end* of a field. The current target+ /// position at each moment is explained in the comments.+ uint64_t file_target_pos;++ /// Size of the .xz file (from the application).+ uint64_t file_size;++ /// Index decoder+ lzma_next_coder index_decoder;++ /// Number of bytes remaining in the Index field that is currently+ /// being decoded.+ lzma_vli index_remaining;++ /// The Index decoder will store the decoded Index in this pointer.+ lzma_index *this_index;++ /// Amount of Stream Padding in the current Stream.+ lzma_vli stream_padding;++ /// The final combined index is collected here.+ lzma_index *combined_index;++ /// Pointer from the application where to store the index information+ /// after successful decoding.+ lzma_index **dest_index;++ /// Pointer to lzma_stream.seek_pos to be used when returning+ /// LZMA_SEEK_NEEDED. This is set by seek_to_pos() when needed.+ uint64_t *external_seek_pos;++ /// Memory usage limit+ uint64_t memlimit;++ /// Stream Flags from the very beginning of the file.+ lzma_stream_flags first_header_flags;++ /// Stream Flags from Stream Header of the current Stream.+ lzma_stream_flags header_flags;++ /// Stream Flags from Stream Footer of the current Stream.+ lzma_stream_flags footer_flags;++ size_t temp_pos;+ size_t temp_size;+ uint8_t temp[8192];++} lzma_file_info_coder;+++/// Copies data from in[*in_pos] into coder->temp until+/// coder->temp_pos == coder->temp_size. This also keeps coder->file_cur_pos+/// in sync with *in_pos. Returns true if more input is needed.+static bool+fill_temp(lzma_file_info_coder *coder, const uint8_t *restrict in,+ size_t *restrict in_pos, size_t in_size)+{+ coder->file_cur_pos += lzma_bufcpy(in, in_pos, in_size,+ coder->temp, &coder->temp_pos, coder->temp_size);+ return coder->temp_pos < coder->temp_size;+}+++/// Seeks to the absolute file position specified by target_pos.+/// This tries to do the seeking by only modifying *in_pos, if possible.+/// The main benefit of this is that if one passes the whole file at once+/// to lzma_code(), the decoder will never need to return LZMA_SEEK_NEEDED+/// as all the seeking can be done by adjusting *in_pos in this function.+///+/// Returns true if an external seek is needed and the caller must return+/// LZMA_SEEK_NEEDED.+static bool+seek_to_pos(lzma_file_info_coder *coder, uint64_t target_pos,+ size_t in_start, size_t *in_pos, size_t in_size)+{+ // The input buffer doesn't extend beyond the end of the file.+ // This has been checked by file_info_decode() already.+ assert(coder->file_size - coder->file_cur_pos >= in_size - *in_pos);++ const uint64_t pos_min = coder->file_cur_pos - (*in_pos - in_start);+ const uint64_t pos_max = coder->file_cur_pos + (in_size - *in_pos);++ bool external_seek_needed;++ if (target_pos >= pos_min && target_pos <= pos_max) {+ // The requested position is available in the current input+ // buffer or right after it. That is, in a corner case we+ // end up setting *in_pos == in_size and thus will immediately+ // need new input bytes from the application.+ *in_pos += (size_t)(target_pos - coder->file_cur_pos);+ external_seek_needed = false;+ } else {+ // Ask the application to seek the input file.+ *coder->external_seek_pos = target_pos;+ external_seek_needed = true;++ // Mark the whole input buffer as used. This way+ // lzma_stream.total_in will have a better estimate+ // of the amount of data read. It still won't be perfect+ // as the value will depend on the input buffer size that+ // the application uses, but it should be good enough for+ // those few who want an estimate.+ *in_pos = in_size;+ }++ // After seeking (internal or external) the current position+ // will match the requested target position.+ coder->file_cur_pos = target_pos;++ return external_seek_needed;+}+++/// The caller sets coder->file_target_pos so that it points to the *end*+/// of the desired file position. This function then determines how far+/// backwards from that position we can seek. After seeking fill_temp()+/// can be used to read data into coder->temp. When fill_temp() has finished,+/// coder->temp[coder->temp_size] will match coder->file_target_pos.+///+/// This also validates that coder->target_file_pos is sane in sense that+/// we aren't trying to seek too far backwards (too close or beyond the+/// beginning of the file).+static lzma_ret+reverse_seek(lzma_file_info_coder *coder,+ size_t in_start, size_t *in_pos, size_t in_size)+{+ // Check that there is enough data before the target position+ // to contain at least Stream Header and Stream Footer. If there+ // isn't, the file cannot be valid.+ if (coder->file_target_pos < 2 * LZMA_STREAM_HEADER_SIZE)+ return LZMA_DATA_ERROR;++ coder->temp_pos = 0;++ // The Stream Header at the very beginning of the file gets handled+ // specially in SEQ_MAGIC_BYTES and thus we will never need to seek+ // there. By not seeking to the first LZMA_STREAM_HEADER_SIZE bytes+ // we avoid a useless external seek after SEQ_MAGIC_BYTES if the+ // application uses an extremely small input buffer and the input+ // file is very small.+ if (coder->file_target_pos - LZMA_STREAM_HEADER_SIZE+ < sizeof(coder->temp))+ coder->temp_size = (size_t)(coder->file_target_pos+ - LZMA_STREAM_HEADER_SIZE);+ else+ coder->temp_size = sizeof(coder->temp);++ // The above if-statements guarantee this. This is important because+ // the Stream Header/Footer decoders assume that there's at least+ // LZMA_STREAM_HEADER_SIZE bytes in coder->temp.+ assert(coder->temp_size >= LZMA_STREAM_HEADER_SIZE);++ if (seek_to_pos(coder, coder->file_target_pos - coder->temp_size,+ in_start, in_pos, in_size))+ return LZMA_SEEK_NEEDED;++ return LZMA_OK;+}+++/// Gets the number of zero-bytes at the end of the buffer.+static size_t+get_padding_size(const uint8_t *buf, size_t buf_size)+{+ size_t padding = 0;+ while (buf_size > 0 && buf[--buf_size] == 0x00)+ ++padding;++ return padding;+}+++/// With the Stream Header at the very beginning of the file, LZMA_FORMAT_ERROR+/// is used to tell the application that Magic Bytes didn't match. In other+/// Stream Header/Footer fields (in the middle/end of the file) it could be+/// a bit confusing to return LZMA_FORMAT_ERROR as we already know that there+/// is a valid Stream Header at the beginning of the file. For those cases+/// this function is used to convert LZMA_FORMAT_ERROR to LZMA_DATA_ERROR.+static lzma_ret+hide_format_error(lzma_ret ret)+{+ if (ret == LZMA_FORMAT_ERROR)+ ret = LZMA_DATA_ERROR;++ return ret;+}+++/// Calls the Index decoder and updates coder->index_remaining.+/// This is a separate function because the input can be either directly+/// from the application or from coder->temp.+static lzma_ret+decode_index(lzma_file_info_coder *coder, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, bool update_file_cur_pos)+{+ const size_t in_start = *in_pos;++ const lzma_ret ret = coder->index_decoder.code(+ coder->index_decoder.coder,+ allocator, in, in_pos, in_size,+ NULL, NULL, 0, LZMA_RUN);++ coder->index_remaining -= *in_pos - in_start;++ if (update_file_cur_pos)+ coder->file_cur_pos += *in_pos - in_start;++ return ret;+}+++static lzma_ret+file_info_decode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size,+ uint8_t *restrict out lzma_attribute((__unused__)),+ size_t *restrict out_pos lzma_attribute((__unused__)),+ size_t out_size lzma_attribute((__unused__)),+ lzma_action action lzma_attribute((__unused__)))+{+ lzma_file_info_coder *coder = coder_ptr;+ const size_t in_start = *in_pos;++ // If the caller provides input past the end of the file, trim+ // the extra bytes from the buffer so that we won't read too far.+ assert(coder->file_size >= coder->file_cur_pos);+ if (coder->file_size - coder->file_cur_pos < in_size - in_start)+ in_size = in_start+ + (size_t)(coder->file_size - coder->file_cur_pos);++ while (true)+ switch (coder->sequence) {+ case SEQ_MAGIC_BYTES:+ // Decode the Stream Header at the beginning of the file+ // first to check if the Magic Bytes match. The flags+ // are stored in coder->first_header_flags so that we+ // don't need to seek to it again.+ //+ // Check that the file is big enough to contain at least+ // Stream Header.+ if (coder->file_size < LZMA_STREAM_HEADER_SIZE)+ return LZMA_FORMAT_ERROR;++ // Read the Stream Header field into coder->temp.+ if (fill_temp(coder, in, in_pos, in_size))+ return LZMA_OK;++ // This is the only Stream Header/Footer decoding where we+ // want to return LZMA_FORMAT_ERROR if the Magic Bytes don't+ // match. Elsewhere it will be converted to LZMA_DATA_ERROR.+ return_if_error(lzma_stream_header_decode(+ &coder->first_header_flags, coder->temp));++ // Now that we know that the Magic Bytes match, check the+ // file size. It's better to do this here after checking the+ // Magic Bytes since this way we can give LZMA_FORMAT_ERROR+ // instead of LZMA_DATA_ERROR when the Magic Bytes don't+ // match in a file that is too big or isn't a multiple of+ // four bytes.+ if (coder->file_size > LZMA_VLI_MAX || (coder->file_size & 3))+ return LZMA_DATA_ERROR;++ // Start looking for Stream Padding and Stream Footer+ // at the end of the file.+ coder->file_target_pos = coder->file_size;++ // Fall through++ case SEQ_PADDING_SEEK:+ coder->sequence = SEQ_PADDING_DECODE;+ return_if_error(reverse_seek(+ coder, in_start, in_pos, in_size));++ // Fall through++ case SEQ_PADDING_DECODE: {+ // Copy to coder->temp first. This keeps the code simpler if+ // the application only provides input a few bytes at a time.+ if (fill_temp(coder, in, in_pos, in_size))+ return LZMA_OK;++ // Scan the buffer backwards to get the size of the+ // Stream Padding field (if any).+ const size_t new_padding = get_padding_size(+ coder->temp, coder->temp_size);+ coder->stream_padding += new_padding;++ // Set the target position to the beginning of Stream Padding+ // that has been observed so far. If all Stream Padding has+ // been seen, then the target position will be at the end+ // of the Stream Footer field.+ coder->file_target_pos -= new_padding;++ if (new_padding == coder->temp_size) {+ // The whole buffer was padding. Seek backwards in+ // the file to get more input.+ coder->sequence = SEQ_PADDING_SEEK;+ break;+ }++ // Size of Stream Padding must be a multiple of 4 bytes.+ if (coder->stream_padding & 3)+ return LZMA_DATA_ERROR;++ coder->sequence = SEQ_FOOTER;++ // Calculate the amount of non-padding data in coder->temp.+ coder->temp_size -= new_padding;+ coder->temp_pos = coder->temp_size;++ // We can avoid an external seek if the whole Stream Footer+ // is already in coder->temp. In that case SEQ_FOOTER won't+ // read more input and will find the Stream Footer from+ // coder->temp[coder->temp_size - LZMA_STREAM_HEADER_SIZE].+ //+ // Otherwise we will need to seek. The seeking is done so+ // that Stream Footer will be at the end of coder->temp.+ // This way it's likely that we also get a complete Index+ // field into coder->temp without needing a separate seek+ // for that (unless the Index field is big).+ if (coder->temp_size < LZMA_STREAM_HEADER_SIZE)+ return_if_error(reverse_seek(+ coder, in_start, in_pos, in_size));+ }++ // Fall through++ case SEQ_FOOTER:+ // Copy the Stream Footer field into coder->temp.+ // If Stream Footer was already available in coder->temp+ // in SEQ_PADDING_DECODE, then this does nothing.+ if (fill_temp(coder, in, in_pos, in_size))+ return LZMA_OK;++ // Make coder->file_target_pos and coder->temp_size point+ // to the beginning of Stream Footer and thus to the end+ // of the Index field. coder->temp_pos will be updated+ // a bit later.+ coder->file_target_pos -= LZMA_STREAM_HEADER_SIZE;+ coder->temp_size -= LZMA_STREAM_HEADER_SIZE;++ // Decode Stream Footer.+ return_if_error(hide_format_error(lzma_stream_footer_decode(+ &coder->footer_flags,+ coder->temp + coder->temp_size)));++ // Check that we won't seek past the beginning of the file.+ //+ // LZMA_STREAM_HEADER_SIZE is added because there must be+ // space for Stream Header too even though we won't seek+ // there before decoding the Index field.+ //+ // There's no risk of integer overflow here because+ // Backward Size cannot be greater than 2^34.+ if (coder->file_target_pos < coder->footer_flags.backward_size+ + LZMA_STREAM_HEADER_SIZE)+ return LZMA_DATA_ERROR;++ // Set the target position to the beginning of the Index field.+ coder->file_target_pos -= coder->footer_flags.backward_size;+ coder->sequence = SEQ_INDEX_INIT;++ // We can avoid an external seek if the whole Index field is+ // already available in coder->temp.+ if (coder->temp_size >= coder->footer_flags.backward_size) {+ // Set coder->temp_pos to point to the beginning+ // of the Index.+ coder->temp_pos = coder->temp_size+ - coder->footer_flags.backward_size;+ } else {+ // These are set to zero to indicate that there's no+ // useful data (Index or anything else) in coder->temp.+ coder->temp_pos = 0;+ coder->temp_size = 0;++ // Seek to the beginning of the Index field.+ if (seek_to_pos(coder, coder->file_target_pos,+ in_start, in_pos, in_size))+ return LZMA_SEEK_NEEDED;+ }++ // Fall through++ case SEQ_INDEX_INIT: {+ // Calculate the amount of memory already used by the earlier+ // Indexes so that we know how big memory limit to pass to+ // the Index decoder.+ //+ // NOTE: When there are multiple Streams, the separate+ // lzma_index structures can use more RAM (as measured by+ // lzma_index_memused()) than the final combined lzma_index.+ // Thus memlimit may need to be slightly higher than the final+ // calculated memory usage will be. This is perhaps a bit+ // confusing to the application, but I think it shouldn't+ // cause problems in practice.+ uint64_t memused = 0;+ if (coder->combined_index != NULL) {+ memused = lzma_index_memused(coder->combined_index);+ assert(memused <= coder->memlimit);+ if (memused > coder->memlimit) // Extra sanity check+ return LZMA_PROG_ERROR;+ }++ // Initialize the Index decoder.+ return_if_error(lzma_index_decoder_init(+ &coder->index_decoder, allocator,+ &coder->this_index,+ coder->memlimit - memused));++ coder->index_remaining = coder->footer_flags.backward_size;+ coder->sequence = SEQ_INDEX_DECODE;+ }++ // Fall through++ case SEQ_INDEX_DECODE: {+ // Decode (a part of) the Index. If the whole Index is already+ // in coder->temp, read it from there. Otherwise read from+ // in[*in_pos] onwards. Note that index_decode() updates+ // coder->index_remaining and optionally coder->file_cur_pos.+ lzma_ret ret;+ if (coder->temp_size != 0) {+ assert(coder->temp_size - coder->temp_pos+ == coder->index_remaining);+ ret = decode_index(coder, allocator, coder->temp,+ &coder->temp_pos, coder->temp_size,+ false);+ } else {+ // Don't give the decoder more input than the known+ // remaining size of the Index field.+ size_t in_stop = in_size;+ if (in_size - *in_pos > coder->index_remaining)+ in_stop = *in_pos+ + (size_t)(coder->index_remaining);++ ret = decode_index(coder, allocator,+ in, in_pos, in_stop, true);+ }++ switch (ret) {+ case LZMA_OK:+ // If the Index docoder asks for more input when we+ // have already given it as much input as Backward Size+ // indicated, the file is invalid.+ if (coder->index_remaining == 0)+ return LZMA_DATA_ERROR;++ // We cannot get here if we were reading Index from+ // coder->temp because when reading from coder->temp+ // we give the Index decoder exactly+ // coder->index_remaining bytes of input.+ assert(coder->temp_size == 0);++ return LZMA_OK;++ case LZMA_STREAM_END:+ // If the decoding seems to be successful, check also+ // that the Index decoder consumed as much input as+ // indicated by the Backward Size field.+ if (coder->index_remaining != 0)+ return LZMA_DATA_ERROR;++ break;++ default:+ return ret;+ }++ // Calculate how much the Index tells us to seek backwards+ // (relative to the beginning of the Index): Total size of+ // all Blocks plus the size of the Stream Header field.+ // No integer overflow here because lzma_index_total_size()+ // cannot return a value greater than LZMA_VLI_MAX.+ const uint64_t seek_amount+ = lzma_index_total_size(coder->this_index)+ + LZMA_STREAM_HEADER_SIZE;++ // Check that Index is sane in sense that seek_amount won't+ // make us seek past the beginning of the file when locating+ // the Stream Header.+ //+ // coder->file_target_pos still points to the beginning of+ // the Index field.+ if (coder->file_target_pos < seek_amount)+ return LZMA_DATA_ERROR;++ // Set the target to the beginning of Stream Header.+ coder->file_target_pos -= seek_amount;++ if (coder->file_target_pos == 0) {+ // We would seek to the beginning of the file, but+ // since we already decoded that Stream Header in+ // SEQ_MAGIC_BYTES, we can use the cached value from+ // coder->first_header_flags to avoid the seek.+ coder->header_flags = coder->first_header_flags;+ coder->sequence = SEQ_HEADER_COMPARE;+ break;+ }++ coder->sequence = SEQ_HEADER_DECODE;++ // Make coder->file_target_pos point to the end of+ // the Stream Header field.+ coder->file_target_pos += LZMA_STREAM_HEADER_SIZE;++ // If coder->temp_size is non-zero, it points to the end+ // of the Index field. Then the beginning of the Index+ // field is at coder->temp[coder->temp_size+ // - coder->footer_flags.backward_size].+ assert(coder->temp_size == 0 || coder->temp_size+ >= coder->footer_flags.backward_size);++ // If coder->temp contained the whole Index, see if it has+ // enough data to contain also the Stream Header. If so,+ // we avoid an external seek.+ //+ // NOTE: This can happen only with small .xz files and only+ // for the non-first Stream as the Stream Flags of the first+ // Stream are cached and already handled a few lines above.+ // So this isn't as useful as the other seek-avoidance cases.+ if (coder->temp_size != 0 && coder->temp_size+ - coder->footer_flags.backward_size+ >= seek_amount) {+ // Make temp_pos and temp_size point to the *end* of+ // Stream Header so that SEQ_HEADER_DECODE will find+ // the start of Stream Header from coder->temp[+ // coder->temp_size - LZMA_STREAM_HEADER_SIZE].+ coder->temp_pos = coder->temp_size+ - coder->footer_flags.backward_size+ - seek_amount+ + LZMA_STREAM_HEADER_SIZE;+ coder->temp_size = coder->temp_pos;+ } else {+ // Seek so that Stream Header will be at the end of+ // coder->temp. With typical multi-Stream files we+ // will usually also get the Stream Footer and Index+ // of the *previous* Stream in coder->temp and thus+ // won't need a separate seek for them.+ return_if_error(reverse_seek(coder,+ in_start, in_pos, in_size));+ }+ }++ // Fall through++ case SEQ_HEADER_DECODE:+ // Copy the Stream Header field into coder->temp.+ // If Stream Header was already available in coder->temp+ // in SEQ_INDEX_DECODE, then this does nothing.+ if (fill_temp(coder, in, in_pos, in_size))+ return LZMA_OK;++ // Make all these point to the beginning of Stream Header.+ coder->file_target_pos -= LZMA_STREAM_HEADER_SIZE;+ coder->temp_size -= LZMA_STREAM_HEADER_SIZE;+ coder->temp_pos = coder->temp_size;++ // Decode the Stream Header.+ return_if_error(hide_format_error(lzma_stream_header_decode(+ &coder->header_flags,+ coder->temp + coder->temp_size)));++ coder->sequence = SEQ_HEADER_COMPARE;++ // Fall through++ case SEQ_HEADER_COMPARE:+ // Compare Stream Header against Stream Footer. They must+ // match.+ return_if_error(lzma_stream_flags_compare(+ &coder->header_flags, &coder->footer_flags));++ // Store the decoded Stream Flags into the Index. Use the+ // Footer Flags because it contains Backward Size, although+ // it shouldn't matter in practice.+ if (lzma_index_stream_flags(coder->this_index,+ &coder->footer_flags) != LZMA_OK)+ return LZMA_PROG_ERROR;++ // Store also the size of the Stream Padding field. It is+ // needed to calculate the offsets of the Streams correctly.+ if (lzma_index_stream_padding(coder->this_index,+ coder->stream_padding) != LZMA_OK)+ return LZMA_PROG_ERROR;++ // Reset it so that it's ready for the next Stream.+ coder->stream_padding = 0;++ // Append the earlier decoded Indexes after this_index.+ if (coder->combined_index != NULL)+ return_if_error(lzma_index_cat(coder->this_index,+ coder->combined_index, allocator));++ coder->combined_index = coder->this_index;+ coder->this_index = NULL;++ // If the whole file was decoded, tell the caller that we+ // are finished.+ if (coder->file_target_pos == 0) {+ // The combined index must indicate the same file+ // size as was told to us at initialization.+ assert(lzma_index_file_size(coder->combined_index)+ == coder->file_size);++ // Make the combined index available to+ // the application.+ *coder->dest_index = coder->combined_index;+ coder->combined_index = NULL;++ // Mark the input buffer as used since we may have+ // done internal seeking and thus don't know how+ // many input bytes were actually used. This way+ // lzma_stream.total_in gets a slightly better+ // estimate of the amount of input used.+ *in_pos = in_size;+ return LZMA_STREAM_END;+ }++ // We didn't hit the beginning of the file yet, so continue+ // reading backwards in the file. If we have unprocessed+ // data in coder->temp, use it before requesting more data+ // from the application.+ //+ // coder->file_target_pos, coder->temp_size, and+ // coder->temp_pos all point to the beginning of Stream Header+ // and thus the end of the previous Stream in the file.+ coder->sequence = coder->temp_size > 0+ ? SEQ_PADDING_DECODE : SEQ_PADDING_SEEK;+ break;++ default:+ assert(0);+ return LZMA_PROG_ERROR;+ }+}+++static lzma_ret+file_info_decoder_memconfig(void *coder_ptr, uint64_t *memusage,+ uint64_t *old_memlimit, uint64_t new_memlimit)+{+ lzma_file_info_coder *coder = coder_ptr;++ // The memory usage calculation comes from three things:+ //+ // (1) The Indexes that have already been decoded and processed into+ // coder->combined_index.+ //+ // (2) The latest Index in coder->this_index that has been decoded but+ // not yet put into coder->combined_index.+ //+ // (3) The latest Index that we have started decoding but haven't+ // finished and thus isn't available in coder->this_index yet.+ // Memory usage and limit information needs to be communicated+ // from/to coder->index_decoder.+ //+ // Care has to be taken to not do both (2) and (3) when calculating+ // the memory usage.+ uint64_t combined_index_memusage = 0;+ uint64_t this_index_memusage = 0;++ // (1) If we have already successfully decoded one or more Indexes,+ // get their memory usage.+ if (coder->combined_index != NULL)+ combined_index_memusage = lzma_index_memused(+ coder->combined_index);++ // Choose between (2), (3), or neither.+ if (coder->this_index != NULL) {+ // (2) The latest Index is available. Use its memory usage.+ this_index_memusage = lzma_index_memused(coder->this_index);++ } else if (coder->sequence == SEQ_INDEX_DECODE) {+ // (3) The Index decoder is activate and hasn't yet stored+ // the new index in coder->this_index. Get the memory usage+ // information from the Index decoder.+ //+ // NOTE: If the Index decoder doesn't yet know how much memory+ // it will eventually need, it will return a tiny value here.+ uint64_t dummy;+ if (coder->index_decoder.memconfig(coder->index_decoder.coder,+ &this_index_memusage, &dummy, 0)+ != LZMA_OK) {+ assert(0);+ return LZMA_PROG_ERROR;+ }+ }++ // Now we know the total memory usage/requirement. If we had neither+ // old Indexes nor a new Index, this will be zero which isn't+ // acceptable as lzma_memusage() has to return non-zero on success+ // and even with an empty .xz file we will end up with a lzma_index+ // that takes some memory.+ *memusage = combined_index_memusage + this_index_memusage;+ if (*memusage == 0)+ *memusage = lzma_index_memusage(1, 0);++ *old_memlimit = coder->memlimit;++ // If requested, set a new memory usage limit.+ if (new_memlimit != 0) {+ if (new_memlimit < *memusage)+ return LZMA_MEMLIMIT_ERROR;++ // In the condition (3) we need to tell the Index decoder+ // its new memory usage limit.+ if (coder->this_index == NULL+ && coder->sequence == SEQ_INDEX_DECODE) {+ const uint64_t idec_new_memlimit = new_memlimit+ - combined_index_memusage;++ assert(this_index_memusage > 0);+ assert(idec_new_memlimit > 0);++ uint64_t dummy1;+ uint64_t dummy2;++ if (coder->index_decoder.memconfig(+ coder->index_decoder.coder,+ &dummy1, &dummy2, idec_new_memlimit)+ != LZMA_OK) {+ assert(0);+ return LZMA_PROG_ERROR;+ }+ }++ coder->memlimit = new_memlimit;+ }++ return LZMA_OK;+}+++static void+file_info_decoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_file_info_coder *coder = coder_ptr;++ lzma_next_end(&coder->index_decoder, allocator);+ lzma_index_end(coder->this_index, allocator);+ lzma_index_end(coder->combined_index, allocator);++ lzma_free(coder, allocator);+ return;+}+++static lzma_ret+lzma_file_info_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator, uint64_t *seek_pos,+ lzma_index **dest_index,+ uint64_t memlimit, uint64_t file_size)+{+ lzma_next_coder_init(&lzma_file_info_decoder_init, next, allocator);++ if (dest_index == NULL)+ return LZMA_PROG_ERROR;++ lzma_file_info_coder *coder = next->coder;+ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_file_info_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = &file_info_decode;+ next->end = &file_info_decoder_end;+ next->memconfig = &file_info_decoder_memconfig;++ coder->index_decoder = LZMA_NEXT_CODER_INIT;+ coder->this_index = NULL;+ coder->combined_index = NULL;+ }++ coder->sequence = SEQ_MAGIC_BYTES;+ coder->file_cur_pos = 0;+ coder->file_target_pos = 0;+ coder->file_size = file_size;++ lzma_index_end(coder->this_index, allocator);+ coder->this_index = NULL;++ lzma_index_end(coder->combined_index, allocator);+ coder->combined_index = NULL;++ coder->stream_padding = 0;++ coder->dest_index = dest_index;+ coder->external_seek_pos = seek_pos;++ // If memlimit is 0, make it 1 to ensure that lzma_memlimit_get()+ // won't return 0 (which would indicate an error).+ coder->memlimit = my_max(1, memlimit);++ // Prepare these for reading the first Stream Header into coder->temp.+ coder->temp_pos = 0;+ coder->temp_size = LZMA_STREAM_HEADER_SIZE;++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_file_info_decoder(lzma_stream *strm, lzma_index **dest_index,+ uint64_t memlimit, uint64_t file_size)+{+ lzma_next_strm_init(lzma_file_info_decoder_init, strm, &strm->seek_pos,+ dest_index, memlimit, file_size);++ // We allow LZMA_FINISH in addition to LZMA_RUN for convenience.+ // lzma_code() is able to handle the LZMA_FINISH + LZMA_SEEK_NEEDED+ // combination in a sane way. Applications still need to be careful+ // if they use LZMA_FINISH so that they remember to reset it back+ // to LZMA_RUN after seeking if needed.+ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}
+ cbits/liblzma/common/filter_buffer_decoder.c view
@@ -0,0 +1,87 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file filter_buffer_decoder.c+/// \brief Single-call raw decoding+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "filter_decoder.h"+++extern LZMA_API(lzma_ret)+lzma_raw_buffer_decode(+ const lzma_filter *filters, const lzma_allocator *allocator,+ const uint8_t *in, size_t *in_pos, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+{+ // Validate what isn't validated later in filter_common.c.+ if (in == NULL || in_pos == NULL || *in_pos > in_size || out == NULL+ || out_pos == NULL || *out_pos > out_size)+ return LZMA_PROG_ERROR;++ // Initialize the decoder.+ lzma_next_coder next = LZMA_NEXT_CODER_INIT;+ return_if_error(lzma_raw_decoder_init(&next, allocator, filters));++ // Store the positions so that we can restore them if something+ // goes wrong.+ const size_t in_start = *in_pos;+ const size_t out_start = *out_pos;++ // Do the actual decoding and free decoder's memory.+ lzma_ret ret = next.code(next.coder, allocator, in, in_pos, in_size,+ out, out_pos, out_size, LZMA_FINISH);++ if (ret == LZMA_STREAM_END) {+ ret = LZMA_OK;+ } else {+ if (ret == LZMA_OK) {+ // Either the input was truncated or the+ // output buffer was too small.+ assert(*in_pos == in_size || *out_pos == out_size);++ if (*in_pos != in_size) {+ // Since input wasn't consumed completely,+ // the output buffer became full and is+ // too small.+ ret = LZMA_BUF_ERROR;++ } else if (*out_pos != out_size) {+ // Since output didn't became full, the input+ // has to be truncated.+ ret = LZMA_DATA_ERROR;++ } else {+ // All the input was consumed and output+ // buffer is full. Now we don't immediately+ // know the reason for the error. Try+ // decoding one more byte. If it succeeds,+ // then the output buffer was too small. If+ // we cannot get a new output byte, the input+ // is truncated.+ uint8_t tmp[1];+ size_t tmp_pos = 0;+ (void)next.code(next.coder, allocator,+ in, in_pos, in_size,+ tmp, &tmp_pos, 1, LZMA_FINISH);++ if (tmp_pos == 1)+ ret = LZMA_BUF_ERROR;+ else+ ret = LZMA_DATA_ERROR;+ }+ }++ // Restore the positions.+ *in_pos = in_start;+ *out_pos = out_start;+ }++ lzma_next_end(&next, allocator);++ return ret;+}
+ cbits/liblzma/common/filter_buffer_encoder.c view
@@ -0,0 +1,54 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file filter_buffer_encoder.c+/// \brief Single-call raw encoding+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "filter_encoder.h"+++extern LZMA_API(lzma_ret)+lzma_raw_buffer_encode(+ const lzma_filter *filters, const lzma_allocator *allocator,+ const uint8_t *in, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+{+ // Validate what isn't validated later in filter_common.c.+ if ((in == NULL && in_size != 0) || out == NULL+ || out_pos == NULL || *out_pos > out_size)+ return LZMA_PROG_ERROR;++ // Initialize the encoder+ lzma_next_coder next = LZMA_NEXT_CODER_INIT;+ return_if_error(lzma_raw_encoder_init(&next, allocator, filters));++ // Store the output position so that we can restore it if+ // something goes wrong.+ const size_t out_start = *out_pos;++ // Do the actual encoding and free coder's memory.+ size_t in_pos = 0;+ lzma_ret ret = next.code(next.coder, allocator, in, &in_pos, in_size,+ out, out_pos, out_size, LZMA_FINISH);+ lzma_next_end(&next, allocator);++ if (ret == LZMA_STREAM_END) {+ ret = LZMA_OK;+ } else {+ if (ret == LZMA_OK) {+ // Output buffer was too small.+ assert(*out_pos == out_size);+ ret = LZMA_BUF_ERROR;+ }++ // Restore the output position.+ *out_pos = out_start;+ }++ return ret;+}
+ cbits/liblzma/common/filter_common.c view
@@ -0,0 +1,393 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file filter_common.c+/// \brief Filter-specific stuff common for both encoder and decoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "filter_common.h"+++static const struct {+ /// Filter ID+ lzma_vli id;++ /// Size of the filter-specific options structure+ size_t options_size;++ /// True if it is OK to use this filter as non-last filter in+ /// the chain.+ bool non_last_ok;++ /// True if it is OK to use this filter as the last filter in+ /// the chain.+ bool last_ok;++ /// True if the filter may change the size of the data (that is, the+ /// amount of encoded output can be different than the amount of+ /// uncompressed input).+ bool changes_size;++} features[] = {+#if defined (HAVE_ENCODER_LZMA1) || defined(HAVE_DECODER_LZMA1)+ {+ .id = LZMA_FILTER_LZMA1,+ .options_size = sizeof(lzma_options_lzma),+ .non_last_ok = false,+ .last_ok = true,+ .changes_size = true,+ },+ {+ .id = LZMA_FILTER_LZMA1EXT,+ .options_size = sizeof(lzma_options_lzma),+ .non_last_ok = false,+ .last_ok = true,+ .changes_size = true,+ },+#endif+#if defined(HAVE_ENCODER_LZMA2) || defined(HAVE_DECODER_LZMA2)+ {+ .id = LZMA_FILTER_LZMA2,+ .options_size = sizeof(lzma_options_lzma),+ .non_last_ok = false,+ .last_ok = true,+ .changes_size = true,+ },+#endif+#if defined(HAVE_ENCODER_X86) || defined(HAVE_DECODER_X86)+ {+ .id = LZMA_FILTER_X86,+ .options_size = sizeof(lzma_options_bcj),+ .non_last_ok = true,+ .last_ok = false,+ .changes_size = false,+ },+#endif+#if defined(HAVE_ENCODER_POWERPC) || defined(HAVE_DECODER_POWERPC)+ {+ .id = LZMA_FILTER_POWERPC,+ .options_size = sizeof(lzma_options_bcj),+ .non_last_ok = true,+ .last_ok = false,+ .changes_size = false,+ },+#endif+#if defined(HAVE_ENCODER_IA64) || defined(HAVE_DECODER_IA64)+ {+ .id = LZMA_FILTER_IA64,+ .options_size = sizeof(lzma_options_bcj),+ .non_last_ok = true,+ .last_ok = false,+ .changes_size = false,+ },+#endif+#if defined(HAVE_ENCODER_ARM) || defined(HAVE_DECODER_ARM)+ {+ .id = LZMA_FILTER_ARM,+ .options_size = sizeof(lzma_options_bcj),+ .non_last_ok = true,+ .last_ok = false,+ .changes_size = false,+ },+#endif+#if defined(HAVE_ENCODER_ARMTHUMB) || defined(HAVE_DECODER_ARMTHUMB)+ {+ .id = LZMA_FILTER_ARMTHUMB,+ .options_size = sizeof(lzma_options_bcj),+ .non_last_ok = true,+ .last_ok = false,+ .changes_size = false,+ },+#endif+#if defined(HAVE_ENCODER_ARM64) || defined(HAVE_DECODER_ARM64)+ {+ .id = LZMA_FILTER_ARM64,+ .options_size = sizeof(lzma_options_bcj),+ .non_last_ok = true,+ .last_ok = false,+ .changes_size = false,+ },+#endif+#if defined(HAVE_ENCODER_SPARC) || defined(HAVE_DECODER_SPARC)+ {+ .id = LZMA_FILTER_SPARC,+ .options_size = sizeof(lzma_options_bcj),+ .non_last_ok = true,+ .last_ok = false,+ .changes_size = false,+ },+#endif+#if defined(HAVE_ENCODER_RISCV) || defined(HAVE_DECODER_RISCV)+ {+ .id = LZMA_FILTER_RISCV,+ .options_size = sizeof(lzma_options_bcj),+ .non_last_ok = true,+ .last_ok = false,+ .changes_size = false,+ },+#endif+#if defined(HAVE_ENCODER_DELTA) || defined(HAVE_DECODER_DELTA)+ {+ .id = LZMA_FILTER_DELTA,+ .options_size = sizeof(lzma_options_delta),+ .non_last_ok = true,+ .last_ok = false,+ .changes_size = false,+ },+#endif+ {+ .id = LZMA_VLI_UNKNOWN+ }+};+++extern LZMA_API(lzma_ret)+lzma_filters_copy(const lzma_filter *src, lzma_filter *real_dest,+ const lzma_allocator *allocator)+{+ if (src == NULL || real_dest == NULL)+ return LZMA_PROG_ERROR;++ // Use a temporary destination so that the real destination+ // will never be modified if an error occurs.+ lzma_filter dest[LZMA_FILTERS_MAX + 1];++ lzma_ret ret;+ size_t i;+ for (i = 0; src[i].id != LZMA_VLI_UNKNOWN; ++i) {+ // There must be a maximum of four filters plus+ // the array terminator.+ if (i == LZMA_FILTERS_MAX) {+ ret = LZMA_OPTIONS_ERROR;+ goto error;+ }++ dest[i].id = src[i].id;++ if (src[i].options == NULL) {+ dest[i].options = NULL;+ } else {+ // See if the filter is supported only when the+ // options is not NULL. This might be convenient+ // sometimes if the app is actually copying only+ // a partial filter chain with a place holder ID.+ //+ // When options is not NULL, the Filter ID must be+ // supported by us, because otherwise we don't know+ // how big the options are.+ size_t j;+ for (j = 0; src[i].id != features[j].id; ++j) {+ if (features[j].id == LZMA_VLI_UNKNOWN) {+ ret = LZMA_OPTIONS_ERROR;+ goto error;+ }+ }++ // Allocate and copy the options.+ dest[i].options = lzma_alloc(features[j].options_size,+ allocator);+ if (dest[i].options == NULL) {+ ret = LZMA_MEM_ERROR;+ goto error;+ }++ memcpy(dest[i].options, src[i].options,+ features[j].options_size);+ }+ }++ // Terminate the filter array.+ assert(i < LZMA_FILTERS_MAX + 1);+ dest[i].id = LZMA_VLI_UNKNOWN;+ dest[i].options = NULL;++ // Copy it to the caller-supplied array now that we know that+ // no errors occurred.+ memcpy(real_dest, dest, (i + 1) * sizeof(lzma_filter));++ return LZMA_OK;++error:+ // Free the options which we have already allocated.+ while (i-- > 0)+ lzma_free(dest[i].options, allocator);++ return ret;+}+++extern LZMA_API(void)+lzma_filters_free(lzma_filter *filters, const lzma_allocator *allocator)+{+ if (filters == NULL)+ return;++ for (size_t i = 0; filters[i].id != LZMA_VLI_UNKNOWN; ++i) {+ if (i == LZMA_FILTERS_MAX) {+ // The API says that LZMA_FILTERS_MAX + 1 is the+ // maximum allowed size including the terminating+ // element. Thus, we should never get here but in+ // case there is a bug and we do anyway, don't go+ // past the (probable) end of the array.+ assert(0);+ break;+ }++ lzma_free(filters[i].options, allocator);+ filters[i].options = NULL;+ filters[i].id = LZMA_VLI_UNKNOWN;+ }++ return;+}+++extern lzma_ret+lzma_validate_chain(const lzma_filter *filters, size_t *count)+{+ // There must be at least one filter.+ if (filters == NULL || filters[0].id == LZMA_VLI_UNKNOWN)+ return LZMA_PROG_ERROR;++ // Number of non-last filters that may change the size of the data+ // significantly (that is, more than 1-2 % or so).+ size_t changes_size_count = 0;++ // True if it is OK to add a new filter after the current filter.+ bool non_last_ok = true;++ // True if the last filter in the given chain is actually usable as+ // the last filter. Only filters that support embedding End of Payload+ // Marker can be used as the last filter in the chain.+ bool last_ok = false;++ size_t i = 0;+ do {+ size_t j;+ for (j = 0; filters[i].id != features[j].id; ++j)+ if (features[j].id == LZMA_VLI_UNKNOWN)+ return LZMA_OPTIONS_ERROR;++ // If the previous filter in the chain cannot be a non-last+ // filter, the chain is invalid.+ if (!non_last_ok)+ return LZMA_OPTIONS_ERROR;++ non_last_ok = features[j].non_last_ok;+ last_ok = features[j].last_ok;+ changes_size_count += features[j].changes_size;++ } while (filters[++i].id != LZMA_VLI_UNKNOWN);++ // There must be 1-4 filters. The last filter must be usable as+ // the last filter in the chain. A maximum of three filters are+ // allowed to change the size of the data.+ if (i > LZMA_FILTERS_MAX || !last_ok || changes_size_count > 3)+ return LZMA_OPTIONS_ERROR;++ *count = i;+ return LZMA_OK;+}+++extern lzma_ret+lzma_raw_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter *options,+ lzma_filter_find coder_find, bool is_encoder)+{+ // Do some basic validation and get the number of filters.+ size_t count;+ return_if_error(lzma_validate_chain(options, &count));++ // Set the filter functions and copy the options pointer.+ lzma_filter_info filters[LZMA_FILTERS_MAX + 1];+ if (is_encoder) {+ for (size_t i = 0; i < count; ++i) {+ // The order of the filters is reversed in the+ // encoder. It allows more efficient handling+ // of the uncompressed data.+ const size_t j = count - i - 1;++ const lzma_filter_coder *const fc+ = coder_find(options[i].id);+ if (fc == NULL || fc->init == NULL)+ return LZMA_OPTIONS_ERROR;++ filters[j].id = options[i].id;+ filters[j].init = fc->init;+ filters[j].options = options[i].options;+ }+ } else {+ for (size_t i = 0; i < count; ++i) {+ const lzma_filter_coder *const fc+ = coder_find(options[i].id);+ if (fc == NULL || fc->init == NULL)+ return LZMA_OPTIONS_ERROR;++ filters[i].id = options[i].id;+ filters[i].init = fc->init;+ filters[i].options = options[i].options;+ }+ }++ // Terminate the array.+ filters[count].id = LZMA_VLI_UNKNOWN;+ filters[count].init = NULL;++ // Initialize the filters.+ const lzma_ret ret = lzma_next_filter_init(next, allocator, filters);+ if (ret != LZMA_OK)+ lzma_next_end(next, allocator);++ return ret;+}+++extern uint64_t+lzma_raw_coder_memusage(lzma_filter_find coder_find,+ const lzma_filter *filters)+{+ // The chain has to have at least one filter.+ {+ size_t tmp;+ if (lzma_validate_chain(filters, &tmp) != LZMA_OK)+ return UINT64_MAX;+ }++ uint64_t total = 0;+ size_t i = 0;++ do {+ const lzma_filter_coder *const fc+ = coder_find(filters[i].id);+ if (fc == NULL)+ return UINT64_MAX; // Unsupported Filter ID++ if (fc->memusage == NULL) {+ // This filter doesn't have a function to calculate+ // the memory usage and validate the options. Such+ // filters need only little memory, so we use 1 KiB+ // as a good estimate. They also accept all possible+ // options, so there's no need to worry about lack+ // of validation.+ total += 1024;+ } else {+ // Call the filter-specific memory usage calculation+ // function.+ const uint64_t usage+ = fc->memusage(filters[i].options);+ if (usage == UINT64_MAX)+ return UINT64_MAX; // Invalid options++ total += usage;+ }+ } while (filters[++i].id != LZMA_VLI_UNKNOWN);++ // Add some fixed amount of extra. It's to compensate memory usage+ // of Stream, Block etc. coders, malloc() overhead, stack etc.+ return total + LZMA_MEMUSAGE_BASE;+}
+ cbits/liblzma/common/filter_common.h view
@@ -0,0 +1,50 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file filter_common.h+/// \brief Filter-specific stuff common for both encoder and decoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_FILTER_COMMON_H+#define LZMA_FILTER_COMMON_H++#include "common.h"+++/// Both lzma_filter_encoder and lzma_filter_decoder begin with these members.+typedef struct {+ /// Filter ID+ lzma_vli id;++ /// Initializes the filter encoder and calls lzma_next_filter_init()+ /// for filters + 1.+ lzma_init_function init;++ /// Calculates memory usage of the encoder. If the options are+ /// invalid, UINT64_MAX is returned.+ uint64_t (*memusage)(const void *options);++} lzma_filter_coder;+++typedef const lzma_filter_coder *(*lzma_filter_find)(lzma_vli id);+++extern lzma_ret lzma_validate_chain(const lzma_filter *filters, size_t *count);+++extern lzma_ret lzma_raw_coder_init(+ lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter *filters,+ lzma_filter_find coder_find, bool is_encoder);+++extern uint64_t lzma_raw_coder_memusage(lzma_filter_find coder_find,+ const lzma_filter *filters);+++#endif
+ cbits/liblzma/common/filter_decoder.c view
@@ -0,0 +1,214 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file filter_decoder.c+/// \brief Filter ID mapping to filter-specific functions+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "filter_decoder.h"+#include "filter_common.h"+#include "lzma_decoder.h"+#include "lzma2_decoder.h"+#include "simple_decoder.h"+#include "delta_decoder.h"+++typedef struct {+ /// Filter ID+ lzma_vli id;++ /// Initializes the filter encoder and calls lzma_next_filter_init()+ /// for filters + 1.+ lzma_init_function init;++ /// Calculates memory usage of the encoder. If the options are+ /// invalid, UINT64_MAX is returned.+ uint64_t (*memusage)(const void *options);++ /// Decodes Filter Properties.+ ///+ /// \return - LZMA_OK: Properties decoded successfully.+ /// - LZMA_OPTIONS_ERROR: Unsupported properties+ /// - LZMA_MEM_ERROR: Memory allocation failed.+ lzma_ret (*props_decode)(+ void **options, const lzma_allocator *allocator,+ const uint8_t *props, size_t props_size);++} lzma_filter_decoder;+++static const lzma_filter_decoder decoders[] = {+#ifdef HAVE_DECODER_LZMA1+ {+ .id = LZMA_FILTER_LZMA1,+ .init = &lzma_lzma_decoder_init,+ .memusage = &lzma_lzma_decoder_memusage,+ .props_decode = &lzma_lzma_props_decode,+ },+ {+ .id = LZMA_FILTER_LZMA1EXT,+ .init = &lzma_lzma_decoder_init,+ .memusage = &lzma_lzma_decoder_memusage,+ .props_decode = &lzma_lzma_props_decode,+ },+#endif+#ifdef HAVE_DECODER_LZMA2+ {+ .id = LZMA_FILTER_LZMA2,+ .init = &lzma_lzma2_decoder_init,+ .memusage = &lzma_lzma2_decoder_memusage,+ .props_decode = &lzma_lzma2_props_decode,+ },+#endif+#ifdef HAVE_DECODER_X86+ {+ .id = LZMA_FILTER_X86,+ .init = &lzma_simple_x86_decoder_init,+ .memusage = NULL,+ .props_decode = &lzma_simple_props_decode,+ },+#endif+#ifdef HAVE_DECODER_POWERPC+ {+ .id = LZMA_FILTER_POWERPC,+ .init = &lzma_simple_powerpc_decoder_init,+ .memusage = NULL,+ .props_decode = &lzma_simple_props_decode,+ },+#endif+#ifdef HAVE_DECODER_IA64+ {+ .id = LZMA_FILTER_IA64,+ .init = &lzma_simple_ia64_decoder_init,+ .memusage = NULL,+ .props_decode = &lzma_simple_props_decode,+ },+#endif+#ifdef HAVE_DECODER_ARM+ {+ .id = LZMA_FILTER_ARM,+ .init = &lzma_simple_arm_decoder_init,+ .memusage = NULL,+ .props_decode = &lzma_simple_props_decode,+ },+#endif+#ifdef HAVE_DECODER_ARMTHUMB+ {+ .id = LZMA_FILTER_ARMTHUMB,+ .init = &lzma_simple_armthumb_decoder_init,+ .memusage = NULL,+ .props_decode = &lzma_simple_props_decode,+ },+#endif+#ifdef HAVE_DECODER_ARM64+ {+ .id = LZMA_FILTER_ARM64,+ .init = &lzma_simple_arm64_decoder_init,+ .memusage = NULL,+ .props_decode = &lzma_simple_props_decode,+ },+#endif+#ifdef HAVE_DECODER_SPARC+ {+ .id = LZMA_FILTER_SPARC,+ .init = &lzma_simple_sparc_decoder_init,+ .memusage = NULL,+ .props_decode = &lzma_simple_props_decode,+ },+#endif+#ifdef HAVE_DECODER_RISCV+ {+ .id = LZMA_FILTER_RISCV,+ .init = &lzma_simple_riscv_decoder_init,+ .memusage = NULL,+ .props_decode = &lzma_simple_props_decode,+ },+#endif+#ifdef HAVE_DECODER_DELTA+ {+ .id = LZMA_FILTER_DELTA,+ .init = &lzma_delta_decoder_init,+ .memusage = &lzma_delta_coder_memusage,+ .props_decode = &lzma_delta_props_decode,+ },+#endif+};+++static const lzma_filter_decoder *+decoder_find(lzma_vli id)+{+ for (size_t i = 0; i < ARRAY_SIZE(decoders); ++i)+ if (decoders[i].id == id)+ return decoders + i;++ return NULL;+}+++// lzma_filter_coder begins with the same members as lzma_filter_decoder.+// This function is a wrapper with a type that is compatible with the+// typedef of lzma_filter_find in filter_common.h.+static const lzma_filter_coder *+coder_find(lzma_vli id)+{+ return (const lzma_filter_coder *)decoder_find(id);+}+++extern LZMA_API(lzma_bool)+lzma_filter_decoder_is_supported(lzma_vli id)+{+ return decoder_find(id) != NULL;+}+++extern lzma_ret+lzma_raw_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter *options)+{+ return lzma_raw_coder_init(next, allocator,+ options, &coder_find, false);+}+++extern LZMA_API(lzma_ret)+lzma_raw_decoder(lzma_stream *strm, const lzma_filter *options)+{+ lzma_next_strm_init(lzma_raw_decoder_init, strm, options);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}+++extern LZMA_API(uint64_t)+lzma_raw_decoder_memusage(const lzma_filter *filters)+{+ return lzma_raw_coder_memusage(&coder_find, filters);+}+++extern LZMA_API(lzma_ret)+lzma_properties_decode(lzma_filter *filter, const lzma_allocator *allocator,+ const uint8_t *props, size_t props_size)+{+ // Make it always NULL so that the caller can always safely free() it.+ filter->options = NULL;++ const lzma_filter_decoder *const fd = decoder_find(filter->id);+ if (fd == NULL)+ return LZMA_OPTIONS_ERROR;++ if (fd->props_decode == NULL)+ return props_size == 0 ? LZMA_OK : LZMA_OPTIONS_ERROR;++ return fd->props_decode(+ &filter->options, allocator, props, props_size);+}
+ cbits/liblzma/common/filter_decoder.h view
@@ -0,0 +1,22 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file filter_decoder.h+/// \brief Filter ID mapping to filter-specific functions+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_FILTER_DECODER_H+#define LZMA_FILTER_DECODER_H++#include "common.h"+++extern lzma_ret lzma_raw_decoder_init(+ lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter *options);++#endif
+ cbits/liblzma/common/filter_encoder.c view
@@ -0,0 +1,330 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file filter_decoder.c+/// \brief Filter ID mapping to filter-specific functions+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "filter_encoder.h"+#include "filter_common.h"+#include "lzma_encoder.h"+#include "lzma2_encoder.h"+#include "simple_encoder.h"+#include "delta_encoder.h"+++typedef struct {+ /// Filter ID+ lzma_vli id;++ /// Initializes the filter encoder and calls lzma_next_filter_init()+ /// for filters + 1.+ lzma_init_function init;++ /// Calculates memory usage of the encoder. If the options are+ /// invalid, UINT64_MAX is returned.+ uint64_t (*memusage)(const void *options);++ /// Calculates the recommended Uncompressed Size for .xz Blocks to+ /// which the input data can be split to make multithreaded+ /// encoding possible. If this is NULL, it is assumed that+ /// the encoder is fast enough with single thread. If the options+ /// are invalid, UINT64_MAX is returned.+ uint64_t (*block_size)(const void *options);++ /// Tells the size of the Filter Properties field. If options are+ /// invalid, LZMA_OPTIONS_ERROR is returned and size is set to+ /// UINT32_MAX.+ lzma_ret (*props_size_get)(uint32_t *size, const void *options);++ /// Some filters will always have the same size Filter Properties+ /// field. If props_size_get is NULL, this value is used.+ uint32_t props_size_fixed;++ /// Encodes Filter Properties.+ ///+ /// \return - LZMA_OK: Properties encoded successfully.+ /// - LZMA_OPTIONS_ERROR: Unsupported options+ /// - LZMA_PROG_ERROR: Invalid options or not enough+ /// output space+ lzma_ret (*props_encode)(const void *options, uint8_t *out);++} lzma_filter_encoder;+++static const lzma_filter_encoder encoders[] = {+#ifdef HAVE_ENCODER_LZMA1+ {+ .id = LZMA_FILTER_LZMA1,+ .init = &lzma_lzma_encoder_init,+ .memusage = &lzma_lzma_encoder_memusage,+ .block_size = NULL, // Not needed for LZMA1+ .props_size_get = NULL,+ .props_size_fixed = 5,+ .props_encode = &lzma_lzma_props_encode,+ },+ {+ .id = LZMA_FILTER_LZMA1EXT,+ .init = &lzma_lzma_encoder_init,+ .memusage = &lzma_lzma_encoder_memusage,+ .block_size = NULL, // Not needed for LZMA1+ .props_size_get = NULL,+ .props_size_fixed = 5,+ .props_encode = &lzma_lzma_props_encode,+ },+#endif+#ifdef HAVE_ENCODER_LZMA2+ {+ .id = LZMA_FILTER_LZMA2,+ .init = &lzma_lzma2_encoder_init,+ .memusage = &lzma_lzma2_encoder_memusage,+ .block_size = &lzma_lzma2_block_size,+ .props_size_get = NULL,+ .props_size_fixed = 1,+ .props_encode = &lzma_lzma2_props_encode,+ },+#endif+#ifdef HAVE_ENCODER_X86+ {+ .id = LZMA_FILTER_X86,+ .init = &lzma_simple_x86_encoder_init,+ .memusage = NULL,+ .block_size = NULL,+ .props_size_get = &lzma_simple_props_size,+ .props_encode = &lzma_simple_props_encode,+ },+#endif+#ifdef HAVE_ENCODER_POWERPC+ {+ .id = LZMA_FILTER_POWERPC,+ .init = &lzma_simple_powerpc_encoder_init,+ .memusage = NULL,+ .block_size = NULL,+ .props_size_get = &lzma_simple_props_size,+ .props_encode = &lzma_simple_props_encode,+ },+#endif+#ifdef HAVE_ENCODER_IA64+ {+ .id = LZMA_FILTER_IA64,+ .init = &lzma_simple_ia64_encoder_init,+ .memusage = NULL,+ .block_size = NULL,+ .props_size_get = &lzma_simple_props_size,+ .props_encode = &lzma_simple_props_encode,+ },+#endif+#ifdef HAVE_ENCODER_ARM+ {+ .id = LZMA_FILTER_ARM,+ .init = &lzma_simple_arm_encoder_init,+ .memusage = NULL,+ .block_size = NULL,+ .props_size_get = &lzma_simple_props_size,+ .props_encode = &lzma_simple_props_encode,+ },+#endif+#ifdef HAVE_ENCODER_ARMTHUMB+ {+ .id = LZMA_FILTER_ARMTHUMB,+ .init = &lzma_simple_armthumb_encoder_init,+ .memusage = NULL,+ .block_size = NULL,+ .props_size_get = &lzma_simple_props_size,+ .props_encode = &lzma_simple_props_encode,+ },+#endif+#ifdef HAVE_ENCODER_ARM64+ {+ .id = LZMA_FILTER_ARM64,+ .init = &lzma_simple_arm64_encoder_init,+ .memusage = NULL,+ .block_size = NULL,+ .props_size_get = &lzma_simple_props_size,+ .props_encode = &lzma_simple_props_encode,+ },+#endif+#ifdef HAVE_ENCODER_SPARC+ {+ .id = LZMA_FILTER_SPARC,+ .init = &lzma_simple_sparc_encoder_init,+ .memusage = NULL,+ .block_size = NULL,+ .props_size_get = &lzma_simple_props_size,+ .props_encode = &lzma_simple_props_encode,+ },+#endif+#ifdef HAVE_ENCODER_RISCV+ {+ .id = LZMA_FILTER_RISCV,+ .init = &lzma_simple_riscv_encoder_init,+ .memusage = NULL,+ .block_size = NULL,+ .props_size_get = &lzma_simple_props_size,+ .props_encode = &lzma_simple_props_encode,+ },+#endif+#ifdef HAVE_ENCODER_DELTA+ {+ .id = LZMA_FILTER_DELTA,+ .init = &lzma_delta_encoder_init,+ .memusage = &lzma_delta_coder_memusage,+ .block_size = NULL,+ .props_size_get = NULL,+ .props_size_fixed = 1,+ .props_encode = &lzma_delta_props_encode,+ },+#endif+};+++static const lzma_filter_encoder *+encoder_find(lzma_vli id)+{+ for (size_t i = 0; i < ARRAY_SIZE(encoders); ++i)+ if (encoders[i].id == id)+ return encoders + i;++ return NULL;+}+++// lzma_filter_coder begins with the same members as lzma_filter_encoder.+// This function is a wrapper with a type that is compatible with the+// typedef of lzma_filter_find in filter_common.h.+static const lzma_filter_coder *+coder_find(lzma_vli id)+{+ return (const lzma_filter_coder *)encoder_find(id);+}+++extern LZMA_API(lzma_bool)+lzma_filter_encoder_is_supported(lzma_vli id)+{+ return encoder_find(id) != NULL;+}+++extern LZMA_API(lzma_ret)+lzma_filters_update(lzma_stream *strm, const lzma_filter *filters)+{+ if (strm->internal->next.update == NULL)+ return LZMA_PROG_ERROR;++ // Validate the filter chain.+ if (lzma_raw_encoder_memusage(filters) == UINT64_MAX)+ return LZMA_OPTIONS_ERROR;++ // The actual filter chain in the encoder is reversed. Some things+ // still want the normal order chain, so we provide both.+ size_t count = 1;+ while (filters[count].id != LZMA_VLI_UNKNOWN)+ ++count;++ lzma_filter reversed_filters[LZMA_FILTERS_MAX + 1];+ for (size_t i = 0; i < count; ++i)+ reversed_filters[count - i - 1] = filters[i];++ reversed_filters[count].id = LZMA_VLI_UNKNOWN;++ return strm->internal->next.update(strm->internal->next.coder,+ strm->allocator, filters, reversed_filters);+}+++extern lzma_ret+lzma_raw_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter *filters)+{+ return lzma_raw_coder_init(next, allocator,+ filters, &coder_find, true);+}+++extern LZMA_API(lzma_ret)+lzma_raw_encoder(lzma_stream *strm, const lzma_filter *filters)+{+ lzma_next_strm_init(lzma_raw_coder_init, strm, filters,+ &coder_find, true);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}+++extern LZMA_API(uint64_t)+lzma_raw_encoder_memusage(const lzma_filter *filters)+{+ return lzma_raw_coder_memusage(&coder_find, filters);+}+++extern LZMA_API(uint64_t)+lzma_mt_block_size(const lzma_filter *filters)+{+ if (filters == NULL)+ return UINT64_MAX;++ uint64_t max = 0;++ for (size_t i = 0; filters[i].id != LZMA_VLI_UNKNOWN; ++i) {+ const lzma_filter_encoder *const fe+ = encoder_find(filters[i].id);+ if (fe == NULL)+ return UINT64_MAX;++ if (fe->block_size != NULL) {+ const uint64_t size+ = fe->block_size(filters[i].options);+ if (size > max)+ max = size;+ }+ }++ return max == 0 ? UINT64_MAX : max;+}+++extern LZMA_API(lzma_ret)+lzma_properties_size(uint32_t *size, const lzma_filter *filter)+{+ const lzma_filter_encoder *const fe = encoder_find(filter->id);+ if (fe == NULL) {+ // Unknown filter - if the Filter ID is a proper VLI,+ // return LZMA_OPTIONS_ERROR instead of LZMA_PROG_ERROR,+ // because it's possible that we just don't have support+ // compiled in for the requested filter.+ return filter->id <= LZMA_VLI_MAX+ ? LZMA_OPTIONS_ERROR : LZMA_PROG_ERROR;+ }++ if (fe->props_size_get == NULL) {+ // No props_size_get() function, use props_size_fixed.+ *size = fe->props_size_fixed;+ return LZMA_OK;+ }++ return fe->props_size_get(size, filter->options);+}+++extern LZMA_API(lzma_ret)+lzma_properties_encode(const lzma_filter *filter, uint8_t *props)+{+ const lzma_filter_encoder *const fe = encoder_find(filter->id);+ if (fe == NULL)+ return LZMA_PROG_ERROR;++ if (fe->props_encode == NULL)+ return LZMA_OK;++ return fe->props_encode(filter->options, props);+}
+ cbits/liblzma/common/filter_encoder.h view
@@ -0,0 +1,22 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file filter_encoder.h+/// \brief Filter ID mapping to filter-specific functions+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_FILTER_ENCODER_H+#define LZMA_FILTER_ENCODER_H++#include "common.h"+++extern lzma_ret lzma_raw_encoder_init(+ lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter *filters);++#endif
+ cbits/liblzma/common/filter_flags_decoder.c view
@@ -0,0 +1,45 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file filter_flags_decoder.c+/// \brief Decodes a Filter Flags field+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "filter_decoder.h"+++extern LZMA_API(lzma_ret)+lzma_filter_flags_decode(+ lzma_filter *filter, const lzma_allocator *allocator,+ const uint8_t *in, size_t *in_pos, size_t in_size)+{+ // Set the pointer to NULL so the caller can always safely free it.+ filter->options = NULL;++ // Filter ID+ return_if_error(lzma_vli_decode(&filter->id, NULL,+ in, in_pos, in_size));++ if (filter->id >= LZMA_FILTER_RESERVED_START)+ return LZMA_DATA_ERROR;++ // Size of Properties+ lzma_vli props_size;+ return_if_error(lzma_vli_decode(&props_size, NULL,+ in, in_pos, in_size));++ // Filter Properties+ if (in_size - *in_pos < props_size)+ return LZMA_DATA_ERROR;++ const lzma_ret ret = lzma_properties_decode(+ filter, allocator, in + *in_pos, props_size);++ *in_pos += props_size;++ return ret;+}
+ cbits/liblzma/common/filter_flags_encoder.c view
@@ -0,0 +1,55 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file filter_flags_encoder.c+/// \brief Encodes a Filter Flags field+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "filter_encoder.h"+++extern LZMA_API(lzma_ret)+lzma_filter_flags_size(uint32_t *size, const lzma_filter *filter)+{+ if (filter->id >= LZMA_FILTER_RESERVED_START)+ return LZMA_PROG_ERROR;++ return_if_error(lzma_properties_size(size, filter));++ *size += lzma_vli_size(filter->id) + lzma_vli_size(*size);++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_filter_flags_encode(const lzma_filter *filter,+ uint8_t *out, size_t *out_pos, size_t out_size)+{+ // Filter ID+ if (filter->id >= LZMA_FILTER_RESERVED_START)+ return LZMA_PROG_ERROR;++ return_if_error(lzma_vli_encode(filter->id, NULL,+ out, out_pos, out_size));++ // Size of Properties+ uint32_t props_size;+ return_if_error(lzma_properties_size(&props_size, filter));+ return_if_error(lzma_vli_encode(props_size, NULL,+ out, out_pos, out_size));++ // Filter Properties+ if (out_size - *out_pos < props_size)+ return LZMA_PROG_ERROR;++ return_if_error(lzma_properties_encode(filter, out + *out_pos));++ *out_pos += props_size;++ return LZMA_OK;+}
+ cbits/liblzma/common/hardware_cputhreads.c view
@@ -0,0 +1,33 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file hardware_cputhreads.c+/// \brief Get the number of CPU threads or cores+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"++#include "tuklib_cpucores.h"+++#ifdef HAVE_SYMBOL_VERSIONS_LINUX+// This is for compatibility with binaries linked against liblzma that+// has been patched with xz-5.2.2-compat-libs.patch from RHEL/CentOS 7.+LZMA_SYMVER_API("lzma_cputhreads@XZ_5.2.2",+ uint32_t, lzma_cputhreads_522)(void) lzma_nothrow+ __attribute__((__alias__("lzma_cputhreads_52")));++LZMA_SYMVER_API("lzma_cputhreads@@XZ_5.2",+ uint32_t, lzma_cputhreads_52)(void) lzma_nothrow;++#define lzma_cputhreads lzma_cputhreads_52+#endif+extern LZMA_API(uint32_t)+lzma_cputhreads(void)+{+ return tuklib_cpucores();+}
+ cbits/liblzma/common/hardware_physmem.c view
@@ -0,0 +1,24 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file hardware_physmem.c+/// \brief Get the total amount of physical memory (RAM)+//+// Author: Jonathan Nieder+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"++#include "tuklib_physmem.h"+++extern LZMA_API(uint64_t)+lzma_physmem(void)+{+ // It is simpler to make lzma_physmem() a wrapper for+ // tuklib_physmem() than to hack appropriate symbol visibility+ // support for the tuklib modules.+ return tuklib_physmem();+}
+ cbits/liblzma/common/index.c view
@@ -0,0 +1,1268 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file index.c+/// \brief Handling of .xz Indexes and some other Stream information+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+#include "index.h"+#include "stream_flags_common.h"+++/// \brief How many Records to allocate at once+///+/// This should be big enough to avoid making lots of tiny allocations+/// but small enough to avoid too much unused memory at once.+#define INDEX_GROUP_SIZE 512+++/// \brief How many Records can be allocated at once at maximum+#define PREALLOC_MAX ((SIZE_MAX - sizeof(index_group)) / sizeof(index_record))+++/// \brief Base structure for index_stream and index_group structures+typedef struct index_tree_node_s index_tree_node;+struct index_tree_node_s {+ /// Uncompressed start offset of this Stream (relative to the+ /// beginning of the file) or Block (relative to the beginning+ /// of the Stream)+ lzma_vli uncompressed_base;++ /// Compressed start offset of this Stream or Block+ lzma_vli compressed_base;++ index_tree_node *parent;+ index_tree_node *left;+ index_tree_node *right;+};+++/// \brief AVL tree to hold index_stream or index_group structures+typedef struct {+ /// Root node+ index_tree_node *root;++ /// Leftmost node. Since the tree will be filled sequentially,+ /// this won't change after the first node has been added to+ /// the tree.+ index_tree_node *leftmost;++ /// The rightmost node in the tree. Since the tree is filled+ /// sequentially, this is always the node where to add the new data.+ index_tree_node *rightmost;++ /// Number of nodes in the tree+ uint32_t count;++} index_tree;+++typedef struct {+ lzma_vli uncompressed_sum;+ lzma_vli unpadded_sum;+} index_record;+++typedef struct {+ /// Every Record group is part of index_stream.groups tree.+ index_tree_node node;++ /// Number of Blocks in this Stream before this group.+ lzma_vli number_base;++ /// Number of Records that can be put in records[].+ size_t allocated;++ /// Index of the last Record in use.+ size_t last;++ /// The sizes in this array are stored as cumulative sums relative+ /// to the beginning of the Stream. This makes it possible to+ /// use binary search in lzma_index_locate().+ ///+ /// Note that the cumulative summing is done specially for+ /// unpadded_sum: The previous value is rounded up to the next+ /// multiple of four before adding the Unpadded Size of the new+ /// Block. The total encoded size of the Blocks in the Stream+ /// is records[last].unpadded_sum in the last Record group of+ /// the Stream.+ ///+ /// For example, if the Unpadded Sizes are 39, 57, and 81, the+ /// stored values are 39, 97 (40 + 57), and 181 (100 + 181).+ /// The total encoded size of these Blocks is 184.+ ///+ /// This is a flexible array, because it makes easy to optimize+ /// memory usage in case someone concatenates many Streams that+ /// have only one or few Blocks.+ index_record records[];++} index_group;+++typedef struct {+ /// Every index_stream is a node in the tree of Streams.+ index_tree_node node;++ /// Number of this Stream (first one is 1)+ uint32_t number;++ /// Total number of Blocks before this Stream+ lzma_vli block_number_base;++ /// Record groups of this Stream are stored in a tree.+ /// It's a T-tree with AVL-tree balancing. There are+ /// INDEX_GROUP_SIZE Records per node by default.+ /// This keeps the number of memory allocations reasonable+ /// and finding a Record is fast.+ index_tree groups;++ /// Number of Records in this Stream+ lzma_vli record_count;++ /// Size of the List of Records field in this Stream. This is used+ /// together with record_count to calculate the size of the Index+ /// field and thus the total size of the Stream.+ lzma_vli index_list_size;++ /// Stream Flags of this Stream. This is meaningful only if+ /// the Stream Flags have been told us with lzma_index_stream_flags().+ /// Initially stream_flags.version is set to UINT32_MAX to indicate+ /// that the Stream Flags are unknown.+ lzma_stream_flags stream_flags;++ /// Amount of Stream Padding after this Stream. This defaults to+ /// zero and can be set with lzma_index_stream_padding().+ lzma_vli stream_padding;++} index_stream;+++struct lzma_index_s {+ /// AVL-tree containing the Stream(s). Often there is just one+ /// Stream, but using a tree keeps lookups fast even when there+ /// are many concatenated Streams.+ index_tree streams;++ /// Uncompressed size of all the Blocks in the Stream(s)+ lzma_vli uncompressed_size;++ /// Total size of all the Blocks in the Stream(s)+ lzma_vli total_size;++ /// Total number of Records in all Streams in this lzma_index+ lzma_vli record_count;++ /// Size of the List of Records field if all the Streams in this+ /// lzma_index were packed into a single Stream (makes it simpler to+ /// take many .xz files and combine them into a single Stream).+ ///+ /// This value together with record_count is needed to calculate+ /// Backward Size that is stored into Stream Footer.+ lzma_vli index_list_size;++ /// How many Records to allocate at once in lzma_index_append().+ /// This defaults to INDEX_GROUP_SIZE but can be overridden with+ /// lzma_index_prealloc().+ size_t prealloc;++ /// Bitmask indicating what integrity check types have been used+ /// as set by lzma_index_stream_flags(). The bit of the last Stream+ /// is not included here, since it is possible to change it by+ /// calling lzma_index_stream_flags() again.+ uint32_t checks;+};+++static void+index_tree_init(index_tree *tree)+{+ tree->root = NULL;+ tree->leftmost = NULL;+ tree->rightmost = NULL;+ tree->count = 0;+ return;+}+++/// Helper for index_tree_end()+static void+index_tree_node_end(index_tree_node *node, const lzma_allocator *allocator,+ void (*free_func)(void *node, const lzma_allocator *allocator))+{+ // The tree won't ever be very huge, so recursion should be fine.+ // 20 levels in the tree is likely quite a lot already in practice.+ if (node->left != NULL)+ index_tree_node_end(node->left, allocator, free_func);++ if (node->right != NULL)+ index_tree_node_end(node->right, allocator, free_func);++ free_func(node, allocator);+ return;+}+++/// Free the memory allocated for a tree. Each node is freed using the+/// given free_func which is either &lzma_free or &index_stream_end.+/// The latter is used to free the Record groups from each index_stream+/// before freeing the index_stream itself.+static void+index_tree_end(index_tree *tree, const lzma_allocator *allocator,+ void (*free_func)(void *node, const lzma_allocator *allocator))+{+ assert(free_func != NULL);++ if (tree->root != NULL)+ index_tree_node_end(tree->root, allocator, free_func);++ return;+}+++/// Add a new node to the tree. node->uncompressed_base and+/// node->compressed_base must have been set by the caller already.+static void+index_tree_append(index_tree *tree, index_tree_node *node)+{+ node->parent = tree->rightmost;+ node->left = NULL;+ node->right = NULL;++ ++tree->count;++ // Handle the special case of adding the first node.+ if (tree->root == NULL) {+ tree->root = node;+ tree->leftmost = node;+ tree->rightmost = node;+ return;+ }++ // The tree is always filled sequentially.+ assert(tree->rightmost->uncompressed_base <= node->uncompressed_base);+ assert(tree->rightmost->compressed_base < node->compressed_base);++ // Add the new node after the rightmost node. It's the correct+ // place due to the reason above.+ tree->rightmost->right = node;+ tree->rightmost = node;++ // Balance the AVL-tree if needed. We don't need to keep the balance+ // factors in nodes, because we always fill the tree sequentially,+ // and thus know the state of the tree just by looking at the node+ // count. From the node count we can calculate how many steps to go+ // up in the tree to find the rotation root.+ uint32_t up = tree->count ^ (UINT32_C(1) << bsr32(tree->count));+ if (up != 0) {+ // Locate the root node for the rotation.+ up = ctz32(tree->count) + 2;+ do {+ node = node->parent;+ } while (--up > 0);++ // Rotate left using node as the rotation root.+ index_tree_node *pivot = node->right;++ if (node->parent == NULL) {+ tree->root = pivot;+ } else {+ assert(node->parent->right == node);+ node->parent->right = pivot;+ }++ pivot->parent = node->parent;++ node->right = pivot->left;+ if (node->right != NULL)+ node->right->parent = node;++ pivot->left = node;+ node->parent = pivot;+ }++ return;+}+++/// Get the next node in the tree. Return NULL if there are no more nodes.+static void *+index_tree_next(const index_tree_node *node)+{+ if (node->right != NULL) {+ node = node->right;+ while (node->left != NULL)+ node = node->left;++ return (void *)(node);+ }++ while (node->parent != NULL && node->parent->right == node)+ node = node->parent;++ return (void *)(node->parent);+}+++/// Locate a node that contains the given uncompressed offset. It is+/// caller's job to check that target is not bigger than the uncompressed+/// size of the tree (the last node would be returned in that case still).+static void *+index_tree_locate(const index_tree *tree, lzma_vli target)+{+ const index_tree_node *result = NULL;+ const index_tree_node *node = tree->root;++ assert(tree->leftmost == NULL+ || tree->leftmost->uncompressed_base == 0);++ // Consecutive nodes may have the same uncompressed_base.+ // We must pick the rightmost one.+ while (node != NULL) {+ if (node->uncompressed_base > target) {+ node = node->left;+ } else {+ result = node;+ node = node->right;+ }+ }++ return (void *)(result);+}+++/// Allocate and initialize a new Stream using the given base offsets.+static index_stream *+index_stream_init(lzma_vli compressed_base, lzma_vli uncompressed_base,+ uint32_t stream_number, lzma_vli block_number_base,+ const lzma_allocator *allocator)+{+ index_stream *s = lzma_alloc(sizeof(index_stream), allocator);+ if (s == NULL)+ return NULL;++ s->node.uncompressed_base = uncompressed_base;+ s->node.compressed_base = compressed_base;+ s->node.parent = NULL;+ s->node.left = NULL;+ s->node.right = NULL;++ s->number = stream_number;+ s->block_number_base = block_number_base;++ index_tree_init(&s->groups);++ s->record_count = 0;+ s->index_list_size = 0;+ s->stream_flags.version = UINT32_MAX;+ s->stream_padding = 0;++ return s;+}+++/// Free the memory allocated for a Stream and its Record groups.+static void+index_stream_end(void *node, const lzma_allocator *allocator)+{+ index_stream *s = node;+ index_tree_end(&s->groups, allocator, &lzma_free);+ lzma_free(s, allocator);+ return;+}+++static lzma_index *+index_init_plain(const lzma_allocator *allocator)+{+ lzma_index *i = lzma_alloc(sizeof(lzma_index), allocator);+ if (i != NULL) {+ index_tree_init(&i->streams);+ i->uncompressed_size = 0;+ i->total_size = 0;+ i->record_count = 0;+ i->index_list_size = 0;+ i->prealloc = INDEX_GROUP_SIZE;+ i->checks = 0;+ }++ return i;+}+++extern LZMA_API(lzma_index *)+lzma_index_init(const lzma_allocator *allocator)+{+ lzma_index *i = index_init_plain(allocator);+ if (i == NULL)+ return NULL;++ index_stream *s = index_stream_init(0, 0, 1, 0, allocator);+ if (s == NULL) {+ lzma_free(i, allocator);+ return NULL;+ }++ index_tree_append(&i->streams, &s->node);++ return i;+}+++extern LZMA_API(void)+lzma_index_end(lzma_index *i, const lzma_allocator *allocator)+{+ // NOTE: If you modify this function, check also the bottom+ // of lzma_index_cat().+ if (i != NULL) {+ index_tree_end(&i->streams, allocator, &index_stream_end);+ lzma_free(i, allocator);+ }++ return;+}+++extern void+lzma_index_prealloc(lzma_index *i, lzma_vli records)+{+ if (records > PREALLOC_MAX)+ records = PREALLOC_MAX;++ i->prealloc = (size_t)(records);+ return;+}+++extern LZMA_API(uint64_t)+lzma_index_memusage(lzma_vli streams, lzma_vli blocks)+{+ // This calculates an upper bound that is only a little bit+ // bigger than the exact maximum memory usage with the given+ // parameters.++ // Typical malloc() overhead is 2 * sizeof(void *) but we take+ // a little bit extra just in case. Using LZMA_MEMUSAGE_BASE+ // instead would give too inaccurate estimate.+ const size_t alloc_overhead = 4 * sizeof(void *);++ // Amount of memory needed for each Stream base structures.+ // We assume that every Stream has at least one Block and+ // thus at least one group.+ const size_t stream_base = sizeof(index_stream)+ + sizeof(index_group) + 2 * alloc_overhead;++ // Amount of memory needed per group.+ const size_t group_base = sizeof(index_group)+ + INDEX_GROUP_SIZE * sizeof(index_record)+ + alloc_overhead;++ // Number of groups. There may actually be more, but that overhead+ // has been taken into account in stream_base already.+ const lzma_vli groups+ = (blocks + INDEX_GROUP_SIZE - 1) / INDEX_GROUP_SIZE;++ // Memory used by index_stream and index_group structures.+ const uint64_t streams_mem = streams * stream_base;+ const uint64_t groups_mem = groups * group_base;++ // Memory used by the base structure.+ const uint64_t index_base = sizeof(lzma_index) + alloc_overhead;++ // Validate the arguments and catch integer overflows.+ // Maximum number of Streams is "only" UINT32_MAX, because+ // that limit is used by the tree containing the Streams.+ const uint64_t limit = UINT64_MAX - index_base;+ if (streams == 0 || streams > UINT32_MAX || blocks > LZMA_VLI_MAX+ || streams > limit / stream_base+ || groups > limit / group_base+ || limit - streams_mem < groups_mem)+ return UINT64_MAX;++ return index_base + streams_mem + groups_mem;+}+++extern LZMA_API(uint64_t)+lzma_index_memused(const lzma_index *i)+{+ return lzma_index_memusage(i->streams.count, i->record_count);+}+++extern LZMA_API(lzma_vli)+lzma_index_block_count(const lzma_index *i)+{+ return i->record_count;+}+++extern LZMA_API(lzma_vli)+lzma_index_stream_count(const lzma_index *i)+{+ return i->streams.count;+}+++extern LZMA_API(lzma_vli)+lzma_index_size(const lzma_index *i)+{+ return index_size(i->record_count, i->index_list_size);+}+++extern LZMA_API(lzma_vli)+lzma_index_total_size(const lzma_index *i)+{+ return i->total_size;+}+++extern LZMA_API(lzma_vli)+lzma_index_stream_size(const lzma_index *i)+{+ // Stream Header + Blocks + Index + Stream Footer+ return LZMA_STREAM_HEADER_SIZE + i->total_size+ + index_size(i->record_count, i->index_list_size)+ + LZMA_STREAM_HEADER_SIZE;+}+++static lzma_vli+index_file_size(lzma_vli compressed_base, lzma_vli unpadded_sum,+ lzma_vli record_count, lzma_vli index_list_size,+ lzma_vli stream_padding)+{+ // Earlier Streams and Stream Paddings + Stream Header+ // + Blocks + Index + Stream Footer + Stream Padding+ //+ // This might go over LZMA_VLI_MAX due to too big unpadded_sum+ // when this function is used in lzma_index_append().+ lzma_vli file_size = compressed_base + 2 * LZMA_STREAM_HEADER_SIZE+ + stream_padding + vli_ceil4(unpadded_sum);+ if (file_size > LZMA_VLI_MAX)+ return LZMA_VLI_UNKNOWN;++ // The same applies here.+ file_size += index_size(record_count, index_list_size);+ if (file_size > LZMA_VLI_MAX)+ return LZMA_VLI_UNKNOWN;++ return file_size;+}+++extern LZMA_API(lzma_vli)+lzma_index_file_size(const lzma_index *i)+{+ const index_stream *s = (const index_stream *)(i->streams.rightmost);+ const index_group *g = (const index_group *)(s->groups.rightmost);+ return index_file_size(s->node.compressed_base,+ g == NULL ? 0 : g->records[g->last].unpadded_sum,+ s->record_count, s->index_list_size,+ s->stream_padding);+}+++extern LZMA_API(lzma_vli)+lzma_index_uncompressed_size(const lzma_index *i)+{+ return i->uncompressed_size;+}+++extern LZMA_API(uint32_t)+lzma_index_checks(const lzma_index *i)+{+ uint32_t checks = i->checks;++ // Get the type of the Check of the last Stream too.+ const index_stream *s = (const index_stream *)(i->streams.rightmost);+ if (s->stream_flags.version != UINT32_MAX)+ checks |= UINT32_C(1) << s->stream_flags.check;++ return checks;+}+++extern uint32_t+lzma_index_padding_size(const lzma_index *i)+{+ return (LZMA_VLI_C(4) - index_size_unpadded(+ i->record_count, i->index_list_size)) & 3;+}+++extern LZMA_API(lzma_ret)+lzma_index_stream_flags(lzma_index *i, const lzma_stream_flags *stream_flags)+{+ if (i == NULL || stream_flags == NULL)+ return LZMA_PROG_ERROR;++ // Validate the Stream Flags.+ return_if_error(lzma_stream_flags_compare(+ stream_flags, stream_flags));++ index_stream *s = (index_stream *)(i->streams.rightmost);+ s->stream_flags = *stream_flags;++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_index_stream_padding(lzma_index *i, lzma_vli stream_padding)+{+ if (i == NULL || stream_padding > LZMA_VLI_MAX+ || (stream_padding & 3) != 0)+ return LZMA_PROG_ERROR;++ index_stream *s = (index_stream *)(i->streams.rightmost);++ // Check that the new value won't make the file grow too big.+ const lzma_vli old_stream_padding = s->stream_padding;+ s->stream_padding = 0;+ if (lzma_index_file_size(i) + stream_padding > LZMA_VLI_MAX) {+ s->stream_padding = old_stream_padding;+ return LZMA_DATA_ERROR;+ }++ s->stream_padding = stream_padding;+ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_index_append(lzma_index *i, const lzma_allocator *allocator,+ lzma_vli unpadded_size, lzma_vli uncompressed_size)+{+ // Validate.+ if (i == NULL || unpadded_size < UNPADDED_SIZE_MIN+ || unpadded_size > UNPADDED_SIZE_MAX+ || uncompressed_size > LZMA_VLI_MAX)+ return LZMA_PROG_ERROR;++ index_stream *s = (index_stream *)(i->streams.rightmost);+ index_group *g = (index_group *)(s->groups.rightmost);++ const lzma_vli compressed_base = g == NULL ? 0+ : vli_ceil4(g->records[g->last].unpadded_sum);+ const lzma_vli uncompressed_base = g == NULL ? 0+ : g->records[g->last].uncompressed_sum;+ const uint32_t index_list_size_add = lzma_vli_size(unpadded_size)+ + lzma_vli_size(uncompressed_size);++ // Check that uncompressed size will not overflow.+ if (uncompressed_base + uncompressed_size > LZMA_VLI_MAX)+ return LZMA_DATA_ERROR;++ // Check that the new unpadded sum will not overflow. This is+ // checked again in index_file_size(), but the unpadded sum is+ // passed to vli_ceil4() which expects a valid lzma_vli value.+ if (compressed_base + unpadded_size > UNPADDED_SIZE_MAX)+ return LZMA_DATA_ERROR;++ // Check that the file size will stay within limits.+ if (index_file_size(s->node.compressed_base,+ compressed_base + unpadded_size, s->record_count + 1,+ s->index_list_size + index_list_size_add,+ s->stream_padding) == LZMA_VLI_UNKNOWN)+ return LZMA_DATA_ERROR;++ // The size of the Index field must not exceed the maximum value+ // that can be stored in the Backward Size field.+ if (index_size(i->record_count + 1,+ i->index_list_size + index_list_size_add)+ > LZMA_BACKWARD_SIZE_MAX)+ return LZMA_DATA_ERROR;++ if (g != NULL && g->last + 1 < g->allocated) {+ // There is space in the last group at least for one Record.+ ++g->last;+ } else {+ // We need to allocate a new group.+ g = lzma_alloc(sizeof(index_group)+ + i->prealloc * sizeof(index_record),+ allocator);+ if (g == NULL)+ return LZMA_MEM_ERROR;++ g->last = 0;+ g->allocated = i->prealloc;++ // Reset prealloc so that if the application happens to+ // add new Records, the allocation size will be sane.+ i->prealloc = INDEX_GROUP_SIZE;++ // Set the start offsets of this group.+ g->node.uncompressed_base = uncompressed_base;+ g->node.compressed_base = compressed_base;+ g->number_base = s->record_count + 1;++ // Add the new group to the Stream.+ index_tree_append(&s->groups, &g->node);+ }++ // Add the new Record to the group.+ g->records[g->last].uncompressed_sum+ = uncompressed_base + uncompressed_size;+ g->records[g->last].unpadded_sum+ = compressed_base + unpadded_size;++ // Update the totals.+ ++s->record_count;+ s->index_list_size += index_list_size_add;++ i->total_size += vli_ceil4(unpadded_size);+ i->uncompressed_size += uncompressed_size;+ ++i->record_count;+ i->index_list_size += index_list_size_add;++ return LZMA_OK;+}+++/// Structure to pass info to index_cat_helper()+typedef struct {+ /// Uncompressed size of the destination+ lzma_vli uncompressed_size;++ /// Compressed file size of the destination+ lzma_vli file_size;++ /// Same as above but for Block numbers+ lzma_vli block_number_add;++ /// Number of Streams that were in the destination index before we+ /// started appending new Streams from the source index. This is+ /// used to fix the Stream numbering.+ uint32_t stream_number_add;++ /// Destination index' Stream tree+ index_tree *streams;++} index_cat_info;+++/// Add the Stream nodes from the source index to dest using recursion.+/// Simplest iterative traversal of the source tree wouldn't work, because+/// we update the pointers in nodes when moving them to the destination tree.+static void+index_cat_helper(const index_cat_info *info, index_stream *this)+{+ index_stream *left = (index_stream *)(this->node.left);+ index_stream *right = (index_stream *)(this->node.right);++ if (left != NULL)+ index_cat_helper(info, left);++ this->node.uncompressed_base += info->uncompressed_size;+ this->node.compressed_base += info->file_size;+ this->number += info->stream_number_add;+ this->block_number_base += info->block_number_add;+ index_tree_append(info->streams, &this->node);++ if (right != NULL)+ index_cat_helper(info, right);++ return;+}+++extern LZMA_API(lzma_ret)+lzma_index_cat(lzma_index *restrict dest, lzma_index *restrict src,+ const lzma_allocator *allocator)+{+ if (dest == NULL || src == NULL)+ return LZMA_PROG_ERROR;++ const lzma_vli dest_file_size = lzma_index_file_size(dest);++ // Check that we don't exceed the file size limits.+ if (dest_file_size + lzma_index_file_size(src) > LZMA_VLI_MAX+ || dest->uncompressed_size + src->uncompressed_size+ > LZMA_VLI_MAX)+ return LZMA_DATA_ERROR;++ // Check that the encoded size of the combined lzma_indexes stays+ // within limits. In theory, this should be done only if we know+ // that the user plans to actually combine the Streams and thus+ // construct a single Index (probably rare). However, exceeding+ // this limit is quite theoretical, so we do this check always+ // to simplify things elsewhere.+ {+ const lzma_vli dest_size = index_size_unpadded(+ dest->record_count, dest->index_list_size);+ const lzma_vli src_size = index_size_unpadded(+ src->record_count, src->index_list_size);+ if (vli_ceil4(dest_size + src_size) > LZMA_BACKWARD_SIZE_MAX)+ return LZMA_DATA_ERROR;+ }++ // Optimize the last group to minimize memory usage. Allocation has+ // to be done before modifying dest or src.+ {+ index_stream *s = (index_stream *)(dest->streams.rightmost);+ index_group *g = (index_group *)(s->groups.rightmost);+ if (g != NULL && g->last + 1 < g->allocated) {+ assert(g->node.left == NULL);+ assert(g->node.right == NULL);++ index_group *newg = lzma_alloc(sizeof(index_group)+ + (g->last + 1)+ * sizeof(index_record),+ allocator);+ if (newg == NULL)+ return LZMA_MEM_ERROR;++ newg->node = g->node;+ newg->allocated = g->last + 1;+ newg->last = g->last;+ newg->number_base = g->number_base;++ memcpy(newg->records, g->records, newg->allocated+ * sizeof(index_record));++ if (g->node.parent != NULL) {+ assert(g->node.parent->right == &g->node);+ g->node.parent->right = &newg->node;+ }++ if (s->groups.leftmost == &g->node) {+ assert(s->groups.root == &g->node);+ s->groups.leftmost = &newg->node;+ s->groups.root = &newg->node;+ }++ assert(s->groups.rightmost == &g->node);+ s->groups.rightmost = &newg->node;++ lzma_free(g, allocator);++ // NOTE: newg isn't leaked here because+ // newg == (void *)&newg->node.+ }+ }++ // dest->checks includes the check types of all except the last Stream+ // in dest. Set the bit for the check type of the last Stream now so+ // that it won't get lost when Stream(s) from src are appended to dest.+ dest->checks = lzma_index_checks(dest);++ // Add all the Streams from src to dest. Update the base offsets+ // of each Stream from src.+ const index_cat_info info = {+ .uncompressed_size = dest->uncompressed_size,+ .file_size = dest_file_size,+ .stream_number_add = dest->streams.count,+ .block_number_add = dest->record_count,+ .streams = &dest->streams,+ };+ index_cat_helper(&info, (index_stream *)(src->streams.root));++ // Update info about all the combined Streams.+ dest->uncompressed_size += src->uncompressed_size;+ dest->total_size += src->total_size;+ dest->record_count += src->record_count;+ dest->index_list_size += src->index_list_size;+ dest->checks |= src->checks;++ // There's nothing else left in src than the base structure.+ lzma_free(src, allocator);++ return LZMA_OK;+}+++/// Duplicate an index_stream.+static index_stream *+index_dup_stream(const index_stream *src, const lzma_allocator *allocator)+{+ // Catch a somewhat theoretical integer overflow.+ if (src->record_count > PREALLOC_MAX)+ return NULL;++ // Allocate and initialize a new Stream.+ index_stream *dest = index_stream_init(src->node.compressed_base,+ src->node.uncompressed_base, src->number,+ src->block_number_base, allocator);+ if (dest == NULL)+ return NULL;++ // Copy the overall information.+ dest->record_count = src->record_count;+ dest->index_list_size = src->index_list_size;+ dest->stream_flags = src->stream_flags;+ dest->stream_padding = src->stream_padding;++ // Return if there are no groups to duplicate.+ if (src->groups.leftmost == NULL)+ return dest;++ // Allocate memory for the Records. We put all the Records into+ // a single group. It's simplest and also tends to make+ // lzma_index_locate() a little bit faster with very big Indexes.+ index_group *destg = lzma_alloc(sizeof(index_group)+ + src->record_count * sizeof(index_record),+ allocator);+ if (destg == NULL) {+ index_stream_end(dest, allocator);+ return NULL;+ }++ // Initialize destg.+ destg->node.uncompressed_base = 0;+ destg->node.compressed_base = 0;+ destg->number_base = 1;+ destg->allocated = src->record_count;+ destg->last = src->record_count - 1;++ // Go through all the groups in src and copy the Records into destg.+ const index_group *srcg = (const index_group *)(src->groups.leftmost);+ size_t i = 0;+ do {+ memcpy(destg->records + i, srcg->records,+ (srcg->last + 1) * sizeof(index_record));+ i += srcg->last + 1;+ srcg = index_tree_next(&srcg->node);+ } while (srcg != NULL);++ assert(i == destg->allocated);++ // Add the group to the new Stream.+ index_tree_append(&dest->groups, &destg->node);++ return dest;+}+++extern LZMA_API(lzma_index *)+lzma_index_dup(const lzma_index *src, const lzma_allocator *allocator)+{+ // Allocate the base structure (no initial Stream).+ lzma_index *dest = index_init_plain(allocator);+ if (dest == NULL)+ return NULL;++ // Copy the totals.+ dest->uncompressed_size = src->uncompressed_size;+ dest->total_size = src->total_size;+ dest->record_count = src->record_count;+ dest->index_list_size = src->index_list_size;++ // Copy the Streams and the groups in them.+ const index_stream *srcstream+ = (const index_stream *)(src->streams.leftmost);+ do {+ index_stream *deststream = index_dup_stream(+ srcstream, allocator);+ if (deststream == NULL) {+ lzma_index_end(dest, allocator);+ return NULL;+ }++ index_tree_append(&dest->streams, &deststream->node);++ srcstream = index_tree_next(&srcstream->node);+ } while (srcstream != NULL);++ return dest;+}+++/// Indexing for lzma_index_iter.internal[]+enum {+ ITER_INDEX,+ ITER_STREAM,+ ITER_GROUP,+ ITER_RECORD,+ ITER_METHOD,+};+++/// Values for lzma_index_iter.internal[ITER_METHOD].s+enum {+ ITER_METHOD_NORMAL,+ ITER_METHOD_NEXT,+ ITER_METHOD_LEFTMOST,+};+++static void+iter_set_info(lzma_index_iter *iter)+{+ const lzma_index *i = iter->internal[ITER_INDEX].p;+ const index_stream *stream = iter->internal[ITER_STREAM].p;+ const index_group *group = iter->internal[ITER_GROUP].p;+ const size_t record = iter->internal[ITER_RECORD].s;++ // lzma_index_iter.internal must not contain a pointer to the last+ // group in the index, because that may be reallocated by+ // lzma_index_cat().+ if (group == NULL) {+ // There are no groups.+ assert(stream->groups.root == NULL);+ iter->internal[ITER_METHOD].s = ITER_METHOD_LEFTMOST;++ } else if (i->streams.rightmost != &stream->node+ || stream->groups.rightmost != &group->node) {+ // The group is not not the last group in the index.+ iter->internal[ITER_METHOD].s = ITER_METHOD_NORMAL;++ } else if (stream->groups.leftmost != &group->node) {+ // The group isn't the only group in the Stream, thus we+ // know that it must have a parent group i.e. it's not+ // the root node.+ assert(stream->groups.root != &group->node);+ assert(group->node.parent->right == &group->node);+ iter->internal[ITER_METHOD].s = ITER_METHOD_NEXT;+ iter->internal[ITER_GROUP].p = group->node.parent;++ } else {+ // The Stream has only one group.+ assert(stream->groups.root == &group->node);+ assert(group->node.parent == NULL);+ iter->internal[ITER_METHOD].s = ITER_METHOD_LEFTMOST;+ iter->internal[ITER_GROUP].p = NULL;+ }++ // NOTE: lzma_index_iter.stream.number is lzma_vli but we use uint32_t+ // internally.+ iter->stream.number = stream->number;+ iter->stream.block_count = stream->record_count;+ iter->stream.compressed_offset = stream->node.compressed_base;+ iter->stream.uncompressed_offset = stream->node.uncompressed_base;++ // iter->stream.flags will be NULL if the Stream Flags haven't been+ // set with lzma_index_stream_flags().+ iter->stream.flags = stream->stream_flags.version == UINT32_MAX+ ? NULL : &stream->stream_flags;+ iter->stream.padding = stream->stream_padding;++ if (stream->groups.rightmost == NULL) {+ // Stream has no Blocks.+ iter->stream.compressed_size = index_size(0, 0)+ + 2 * LZMA_STREAM_HEADER_SIZE;+ iter->stream.uncompressed_size = 0;+ } else {+ const index_group *g = (const index_group *)(+ stream->groups.rightmost);++ // Stream Header + Stream Footer + Index + Blocks+ iter->stream.compressed_size = 2 * LZMA_STREAM_HEADER_SIZE+ + index_size(stream->record_count,+ stream->index_list_size)+ + vli_ceil4(g->records[g->last].unpadded_sum);+ iter->stream.uncompressed_size+ = g->records[g->last].uncompressed_sum;+ }++ if (group != NULL) {+ iter->block.number_in_stream = group->number_base + record;+ iter->block.number_in_file = iter->block.number_in_stream+ + stream->block_number_base;++ iter->block.compressed_stream_offset+ = record == 0 ? group->node.compressed_base+ : vli_ceil4(group->records[+ record - 1].unpadded_sum);+ iter->block.uncompressed_stream_offset+ = record == 0 ? group->node.uncompressed_base+ : group->records[record - 1].uncompressed_sum;++ iter->block.uncompressed_size+ = group->records[record].uncompressed_sum+ - iter->block.uncompressed_stream_offset;+ iter->block.unpadded_size+ = group->records[record].unpadded_sum+ - iter->block.compressed_stream_offset;+ iter->block.total_size = vli_ceil4(iter->block.unpadded_size);++ iter->block.compressed_stream_offset+ += LZMA_STREAM_HEADER_SIZE;++ iter->block.compressed_file_offset+ = iter->block.compressed_stream_offset+ + iter->stream.compressed_offset;+ iter->block.uncompressed_file_offset+ = iter->block.uncompressed_stream_offset+ + iter->stream.uncompressed_offset;+ }++ return;+}+++extern LZMA_API(void)+lzma_index_iter_init(lzma_index_iter *iter, const lzma_index *i)+{+ iter->internal[ITER_INDEX].p = i;+ lzma_index_iter_rewind(iter);+ return;+}+++extern LZMA_API(void)+lzma_index_iter_rewind(lzma_index_iter *iter)+{+ iter->internal[ITER_STREAM].p = NULL;+ iter->internal[ITER_GROUP].p = NULL;+ iter->internal[ITER_RECORD].s = 0;+ iter->internal[ITER_METHOD].s = ITER_METHOD_NORMAL;+ return;+}+++extern LZMA_API(lzma_bool)+lzma_index_iter_next(lzma_index_iter *iter, lzma_index_iter_mode mode)+{+ // Catch unsupported mode values.+ if ((unsigned int)(mode) > LZMA_INDEX_ITER_NONEMPTY_BLOCK)+ return true;++ const lzma_index *i = iter->internal[ITER_INDEX].p;+ const index_stream *stream = iter->internal[ITER_STREAM].p;+ const index_group *group = NULL;+ size_t record = iter->internal[ITER_RECORD].s;++ // If we are being asked for the next Stream, leave group to NULL+ // so that the rest of the this function thinks that this Stream+ // has no groups and will thus go to the next Stream.+ if (mode != LZMA_INDEX_ITER_STREAM) {+ // Get the pointer to the current group. See iter_set_inf()+ // for explanation.+ switch (iter->internal[ITER_METHOD].s) {+ case ITER_METHOD_NORMAL:+ group = iter->internal[ITER_GROUP].p;+ break;++ case ITER_METHOD_NEXT:+ group = index_tree_next(iter->internal[ITER_GROUP].p);+ break;++ case ITER_METHOD_LEFTMOST:+ group = (const index_group *)(+ stream->groups.leftmost);+ break;+ }+ }++again:+ if (stream == NULL) {+ // We at the beginning of the lzma_index.+ // Locate the first Stream.+ stream = (const index_stream *)(i->streams.leftmost);+ if (mode >= LZMA_INDEX_ITER_BLOCK) {+ // Since we are being asked to return information+ // about the first a Block, skip Streams that have+ // no Blocks.+ while (stream->groups.leftmost == NULL) {+ stream = index_tree_next(&stream->node);+ if (stream == NULL)+ return true;+ }+ }++ // Start from the first Record in the Stream.+ group = (const index_group *)(stream->groups.leftmost);+ record = 0;++ } else if (group != NULL && record < group->last) {+ // The next Record is in the same group.+ ++record;++ } else {+ // This group has no more Records or this Stream has+ // no Blocks at all.+ record = 0;++ // If group is not NULL, this Stream has at least one Block+ // and thus at least one group. Find the next group.+ if (group != NULL)+ group = index_tree_next(&group->node);++ if (group == NULL) {+ // This Stream has no more Records. Find the next+ // Stream. If we are being asked to return information+ // about a Block, we skip empty Streams.+ do {+ stream = index_tree_next(&stream->node);+ if (stream == NULL)+ return true;+ } while (mode >= LZMA_INDEX_ITER_BLOCK+ && stream->groups.leftmost == NULL);++ group = (const index_group *)(+ stream->groups.leftmost);+ }+ }++ if (mode == LZMA_INDEX_ITER_NONEMPTY_BLOCK) {+ // We need to look for the next Block again if this Block+ // is empty.+ if (record == 0) {+ if (group->node.uncompressed_base+ == group->records[0].uncompressed_sum)+ goto again;+ } else if (group->records[record - 1].uncompressed_sum+ == group->records[record].uncompressed_sum) {+ goto again;+ }+ }++ iter->internal[ITER_STREAM].p = stream;+ iter->internal[ITER_GROUP].p = group;+ iter->internal[ITER_RECORD].s = record;++ iter_set_info(iter);++ return false;+}+++extern LZMA_API(lzma_bool)+lzma_index_iter_locate(lzma_index_iter *iter, lzma_vli target)+{+ const lzma_index *i = iter->internal[ITER_INDEX].p;++ // If the target is past the end of the file, return immediately.+ if (i->uncompressed_size <= target)+ return true;++ // Locate the Stream containing the target offset.+ const index_stream *stream = index_tree_locate(&i->streams, target);+ assert(stream != NULL);+ target -= stream->node.uncompressed_base;++ // Locate the group containing the target offset.+ const index_group *group = index_tree_locate(&stream->groups, target);+ assert(group != NULL);++ // Use binary search to locate the exact Record. It is the first+ // Record whose uncompressed_sum is greater than target.+ // This is because we want the rightmost Record that fulfills the+ // search criterion. It is possible that there are empty Blocks;+ // we don't want to return them.+ size_t left = 0;+ size_t right = group->last;++ while (left < right) {+ const size_t pos = left + (right - left) / 2;+ if (group->records[pos].uncompressed_sum <= target)+ left = pos + 1;+ else+ right = pos;+ }++ iter->internal[ITER_STREAM].p = stream;+ iter->internal[ITER_GROUP].p = group;+ iter->internal[ITER_RECORD].s = left;++ iter_set_info(iter);++ return false;+}
+ cbits/liblzma/common/index.h view
@@ -0,0 +1,80 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file index.h+/// \brief Handling of Index+/// \note This header file does not include common.h or lzma.h because+/// this file is needed by both liblzma internally and by the+/// tests. Including common.h will include and define many things+/// the tests do not need and prevents issues with header file+/// include order. This way, if lzma.h or common.h are not+/// included before this file it will break on every OS instead+/// of causing more subtle errors.+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_INDEX_H+#define LZMA_INDEX_H+++/// Minimum Unpadded Size+#define UNPADDED_SIZE_MIN LZMA_VLI_C(5)++/// Maximum Unpadded Size+#define UNPADDED_SIZE_MAX (LZMA_VLI_MAX & ~LZMA_VLI_C(3))++/// Index Indicator based on xz specification+#define INDEX_INDICATOR 0+++/// Get the size of the Index Padding field. This is needed by Index encoder+/// and decoder, but applications should have no use for this.+extern uint32_t lzma_index_padding_size(const lzma_index *i);+++/// Set for how many Records to allocate memory the next time+/// lzma_index_append() needs to allocate space for a new Record.+/// This is used only by the Index decoder.+extern void lzma_index_prealloc(lzma_index *i, lzma_vli records);+++/// Round the variable-length integer to the next multiple of four.+static inline lzma_vli+vli_ceil4(lzma_vli vli)+{+ assert(vli <= UNPADDED_SIZE_MAX);+ return (vli + 3) & ~LZMA_VLI_C(3);+}+++/// Calculate the size of the Index field excluding Index Padding+static inline lzma_vli+index_size_unpadded(lzma_vli count, lzma_vli index_list_size)+{+ // Index Indicator + Number of Records + List of Records + CRC32+ return 1 + lzma_vli_size(count) + index_list_size + 4;+}+++/// Calculate the size of the Index field including Index Padding+static inline lzma_vli+index_size(lzma_vli count, lzma_vli index_list_size)+{+ return vli_ceil4(index_size_unpadded(count, index_list_size));+}+++/// Calculate the total size of the Stream+static inline lzma_vli+index_stream_size(lzma_vli blocks_size,+ lzma_vli count, lzma_vli index_list_size)+{+ return LZMA_STREAM_HEADER_SIZE + blocks_size+ + index_size(count, index_list_size)+ + LZMA_STREAM_HEADER_SIZE;+}++#endif
+ cbits/liblzma/common/index_decoder.c view
@@ -0,0 +1,372 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file index_decoder.c+/// \brief Decodes the Index field+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "index_decoder.h"+#include "check.h"+++typedef struct {+ enum {+ SEQ_INDICATOR,+ SEQ_COUNT,+ SEQ_MEMUSAGE,+ SEQ_UNPADDED,+ SEQ_UNCOMPRESSED,+ SEQ_PADDING_INIT,+ SEQ_PADDING,+ SEQ_CRC32,+ } sequence;++ /// Memory usage limit+ uint64_t memlimit;++ /// Target Index+ lzma_index *index;++ /// Pointer give by the application, which is set after+ /// successful decoding.+ lzma_index **index_ptr;++ /// Number of Records left to decode.+ lzma_vli count;++ /// The most recent Unpadded Size field+ lzma_vli unpadded_size;++ /// The most recent Uncompressed Size field+ lzma_vli uncompressed_size;++ /// Position in integers+ size_t pos;++ /// CRC32 of the List of Records field+ uint32_t crc32;+} lzma_index_coder;+++static lzma_ret+index_decode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size,+ uint8_t *restrict out lzma_attribute((__unused__)),+ size_t *restrict out_pos lzma_attribute((__unused__)),+ size_t out_size lzma_attribute((__unused__)),+ lzma_action action lzma_attribute((__unused__)))+{+ lzma_index_coder *coder = coder_ptr;++ // Similar optimization as in index_encoder.c+ const size_t in_start = *in_pos;+ lzma_ret ret = LZMA_OK;++ while (*in_pos < in_size)+ switch (coder->sequence) {+ case SEQ_INDICATOR:+ // Return LZMA_DATA_ERROR instead of e.g. LZMA_PROG_ERROR or+ // LZMA_FORMAT_ERROR, because a typical usage case for Index+ // decoder is when parsing the Stream backwards. If seeking+ // backward from the Stream Footer gives us something that+ // doesn't begin with Index Indicator, the file is considered+ // corrupt, not "programming error" or "unrecognized file+ // format". One could argue that the application should+ // verify the Index Indicator before trying to decode the+ // Index, but well, I suppose it is simpler this way.+ if (in[(*in_pos)++] != INDEX_INDICATOR)+ return LZMA_DATA_ERROR;++ coder->sequence = SEQ_COUNT;+ break;++ case SEQ_COUNT:+ ret = lzma_vli_decode(&coder->count, &coder->pos,+ in, in_pos, in_size);+ if (ret != LZMA_STREAM_END)+ goto out;++ coder->pos = 0;+ coder->sequence = SEQ_MEMUSAGE;++ // Fall through++ case SEQ_MEMUSAGE:+ if (lzma_index_memusage(1, coder->count) > coder->memlimit) {+ ret = LZMA_MEMLIMIT_ERROR;+ goto out;+ }++ // Tell the Index handling code how many Records this+ // Index has to allow it to allocate memory more efficiently.+ lzma_index_prealloc(coder->index, coder->count);++ ret = LZMA_OK;+ coder->sequence = coder->count == 0+ ? SEQ_PADDING_INIT : SEQ_UNPADDED;+ break;++ case SEQ_UNPADDED:+ case SEQ_UNCOMPRESSED: {+ lzma_vli *size = coder->sequence == SEQ_UNPADDED+ ? &coder->unpadded_size+ : &coder->uncompressed_size;++ ret = lzma_vli_decode(size, &coder->pos,+ in, in_pos, in_size);+ if (ret != LZMA_STREAM_END)+ goto out;++ ret = LZMA_OK;+ coder->pos = 0;++ if (coder->sequence == SEQ_UNPADDED) {+ // Validate that encoded Unpadded Size isn't too small+ // or too big.+ if (coder->unpadded_size < UNPADDED_SIZE_MIN+ || coder->unpadded_size+ > UNPADDED_SIZE_MAX)+ return LZMA_DATA_ERROR;++ coder->sequence = SEQ_UNCOMPRESSED;+ } else {+ // Add the decoded Record to the Index.+ return_if_error(lzma_index_append(+ coder->index, allocator,+ coder->unpadded_size,+ coder->uncompressed_size));++ // Check if this was the last Record.+ coder->sequence = --coder->count == 0+ ? SEQ_PADDING_INIT+ : SEQ_UNPADDED;+ }++ break;+ }++ case SEQ_PADDING_INIT:+ coder->pos = lzma_index_padding_size(coder->index);+ coder->sequence = SEQ_PADDING;++ // Fall through++ case SEQ_PADDING:+ if (coder->pos > 0) {+ --coder->pos;+ if (in[(*in_pos)++] != 0x00)+ return LZMA_DATA_ERROR;++ break;+ }++ // Finish the CRC32 calculation.+ coder->crc32 = lzma_crc32(in + in_start,+ *in_pos - in_start, coder->crc32);++ coder->sequence = SEQ_CRC32;++ // Fall through++ case SEQ_CRC32:+ do {+ if (*in_pos == in_size)+ return LZMA_OK;++ if (((coder->crc32 >> (coder->pos * 8)) & 0xFF)+ != in[(*in_pos)++]) {+#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION+ return LZMA_DATA_ERROR;+#endif+ }++ } while (++coder->pos < 4);++ // Decoding was successful, now we can let the application+ // see the decoded Index.+ *coder->index_ptr = coder->index;++ // Make index NULL so we don't free it unintentionally.+ coder->index = NULL;++ return LZMA_STREAM_END;++ default:+ assert(0);+ return LZMA_PROG_ERROR;+ }++out:+ // Update the CRC32.+ //+ // Avoid null pointer + 0 (undefined behavior) in "in + in_start".+ // In such a case we had no input and thus in_used == 0.+ {+ const size_t in_used = *in_pos - in_start;+ if (in_used > 0)+ coder->crc32 = lzma_crc32(in + in_start,+ in_used, coder->crc32);+ }++ return ret;+}+++static void+index_decoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_index_coder *coder = coder_ptr;+ lzma_index_end(coder->index, allocator);+ lzma_free(coder, allocator);+ return;+}+++static lzma_ret+index_decoder_memconfig(void *coder_ptr, uint64_t *memusage,+ uint64_t *old_memlimit, uint64_t new_memlimit)+{+ lzma_index_coder *coder = coder_ptr;++ *memusage = lzma_index_memusage(1, coder->count);+ *old_memlimit = coder->memlimit;++ if (new_memlimit != 0) {+ if (new_memlimit < *memusage)+ return LZMA_MEMLIMIT_ERROR;++ coder->memlimit = new_memlimit;+ }++ return LZMA_OK;+}+++static lzma_ret+index_decoder_reset(lzma_index_coder *coder, const lzma_allocator *allocator,+ lzma_index **i, uint64_t memlimit)+{+ // Remember the pointer given by the application. We will set it+ // to point to the decoded Index only if decoding is successful.+ // Before that, keep it NULL so that applications can always safely+ // pass it to lzma_index_end() no matter did decoding succeed or not.+ coder->index_ptr = i;+ *i = NULL;++ // We always allocate a new lzma_index.+ coder->index = lzma_index_init(allocator);+ if (coder->index == NULL)+ return LZMA_MEM_ERROR;++ // Initialize the rest.+ coder->sequence = SEQ_INDICATOR;+ coder->memlimit = my_max(1, memlimit);+ coder->count = 0; // Needs to be initialized due to _memconfig().+ coder->pos = 0;+ coder->crc32 = 0;++ return LZMA_OK;+}+++extern lzma_ret+lzma_index_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ lzma_index **i, uint64_t memlimit)+{+ lzma_next_coder_init(&lzma_index_decoder_init, next, allocator);++ if (i == NULL)+ return LZMA_PROG_ERROR;++ lzma_index_coder *coder = next->coder;+ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_index_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = &index_decode;+ next->end = &index_decoder_end;+ next->memconfig = &index_decoder_memconfig;+ coder->index = NULL;+ } else {+ lzma_index_end(coder->index, allocator);+ }++ return index_decoder_reset(coder, allocator, i, memlimit);+}+++extern LZMA_API(lzma_ret)+lzma_index_decoder(lzma_stream *strm, lzma_index **i, uint64_t memlimit)+{+ // If i isn't NULL, *i must always be initialized due to+ // the wording in the API docs. This way it is initialized+ // if we return LZMA_PROG_ERROR due to strm == NULL.+ if (i != NULL)+ *i = NULL;++ lzma_next_strm_init(lzma_index_decoder_init, strm, i, memlimit);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_index_buffer_decode(lzma_index **i, uint64_t *memlimit,+ const lzma_allocator *allocator,+ const uint8_t *in, size_t *in_pos, size_t in_size)+{+ // If i isn't NULL, *i must always be initialized due to+ // the wording in the API docs.+ if (i != NULL)+ *i = NULL;++ // Sanity checks+ if (i == NULL || memlimit == NULL+ || in == NULL || in_pos == NULL || *in_pos > in_size)+ return LZMA_PROG_ERROR;++ // Initialize the decoder.+ lzma_index_coder coder;+ return_if_error(index_decoder_reset(&coder, allocator, i, *memlimit));++ // Store the input start position so that we can restore it in case+ // of an error.+ const size_t in_start = *in_pos;++ // Do the actual decoding.+ lzma_ret ret = index_decode(&coder, allocator, in, in_pos, in_size,+ NULL, NULL, 0, LZMA_RUN);++ if (ret == LZMA_STREAM_END) {+ ret = LZMA_OK;+ } else {+ // Something went wrong, free the Index structure and restore+ // the input position.+ lzma_index_end(coder.index, allocator);+ *in_pos = in_start;++ if (ret == LZMA_OK) {+ // The input is truncated or otherwise corrupt.+ // Use LZMA_DATA_ERROR instead of LZMA_BUF_ERROR+ // like lzma_vli_decode() does in single-call mode.+ ret = LZMA_DATA_ERROR;++ } else if (ret == LZMA_MEMLIMIT_ERROR) {+ // Tell the caller how much memory would have+ // been needed.+ *memlimit = lzma_index_memusage(1, coder.count);+ }+ }++ return ret;+}
+ cbits/liblzma/common/index_decoder.h view
@@ -0,0 +1,24 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file index_decoder.h+/// \brief Decodes the Index field+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_INDEX_DECODER_H+#define LZMA_INDEX_DECODER_H++#include "common.h"+#include "index.h"+++extern lzma_ret lzma_index_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ lzma_index **i, uint64_t memlimit);+++#endif
+ cbits/liblzma/common/index_encoder.c view
@@ -0,0 +1,262 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file index_encoder.c+/// \brief Encodes the Index field+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "index_encoder.h"+#include "index.h"+#include "check.h"+++typedef struct {+ enum {+ SEQ_INDICATOR,+ SEQ_COUNT,+ SEQ_UNPADDED,+ SEQ_UNCOMPRESSED,+ SEQ_NEXT,+ SEQ_PADDING,+ SEQ_CRC32,+ } sequence;++ /// Index being encoded+ const lzma_index *index;++ /// Iterator for the Index being encoded+ lzma_index_iter iter;++ /// Position in integers+ size_t pos;++ /// CRC32 of the List of Records field+ uint32_t crc32;+} lzma_index_coder;+++static lzma_ret+index_encode(void *coder_ptr,+ const lzma_allocator *allocator lzma_attribute((__unused__)),+ const uint8_t *restrict in lzma_attribute((__unused__)),+ size_t *restrict in_pos lzma_attribute((__unused__)),+ size_t in_size lzma_attribute((__unused__)),+ uint8_t *restrict out, size_t *restrict out_pos,+ size_t out_size,+ lzma_action action lzma_attribute((__unused__)))+{+ lzma_index_coder *coder = coder_ptr;++ // Position where to start calculating CRC32. The idea is that we+ // need to call lzma_crc32() only once per call to index_encode().+ const size_t out_start = *out_pos;++ // Return value to use if we return at the end of this function.+ // We use "goto out" to jump out of the while-switch construct+ // instead of returning directly, because that way we don't need+ // to copypaste the lzma_crc32() call to many places.+ lzma_ret ret = LZMA_OK;++ while (*out_pos < out_size)+ switch (coder->sequence) {+ case SEQ_INDICATOR:+ out[*out_pos] = INDEX_INDICATOR;+ ++*out_pos;+ coder->sequence = SEQ_COUNT;+ break;++ case SEQ_COUNT: {+ const lzma_vli count = lzma_index_block_count(coder->index);+ ret = lzma_vli_encode(count, &coder->pos,+ out, out_pos, out_size);+ if (ret != LZMA_STREAM_END)+ goto out;++ ret = LZMA_OK;+ coder->pos = 0;+ coder->sequence = SEQ_NEXT;+ break;+ }++ case SEQ_NEXT:+ if (lzma_index_iter_next(+ &coder->iter, LZMA_INDEX_ITER_BLOCK)) {+ // Get the size of the Index Padding field.+ coder->pos = lzma_index_padding_size(coder->index);+ assert(coder->pos <= 3);+ coder->sequence = SEQ_PADDING;+ break;+ }++ coder->sequence = SEQ_UNPADDED;++ // Fall through++ case SEQ_UNPADDED:+ case SEQ_UNCOMPRESSED: {+ const lzma_vli size = coder->sequence == SEQ_UNPADDED+ ? coder->iter.block.unpadded_size+ : coder->iter.block.uncompressed_size;++ ret = lzma_vli_encode(size, &coder->pos,+ out, out_pos, out_size);+ if (ret != LZMA_STREAM_END)+ goto out;++ ret = LZMA_OK;+ coder->pos = 0;++ // Advance to SEQ_UNCOMPRESSED or SEQ_NEXT.+ ++coder->sequence;+ break;+ }++ case SEQ_PADDING:+ if (coder->pos > 0) {+ --coder->pos;+ out[(*out_pos)++] = 0x00;+ break;+ }++ // Finish the CRC32 calculation.+ coder->crc32 = lzma_crc32(out + out_start,+ *out_pos - out_start, coder->crc32);++ coder->sequence = SEQ_CRC32;++ // Fall through++ case SEQ_CRC32:+ // We don't use the main loop, because we don't want+ // coder->crc32 to be touched anymore.+ do {+ if (*out_pos == out_size)+ return LZMA_OK;++ out[*out_pos] = (coder->crc32 >> (coder->pos * 8))+ & 0xFF;+ ++*out_pos;++ } while (++coder->pos < 4);++ return LZMA_STREAM_END;++ default:+ assert(0);+ return LZMA_PROG_ERROR;+ }++out:+ // Update the CRC32.+ //+ // Avoid null pointer + 0 (undefined behavior) in "out + out_start".+ // In such a case we had no input and thus out_used == 0.+ {+ const size_t out_used = *out_pos - out_start;+ if (out_used > 0)+ coder->crc32 = lzma_crc32(out + out_start,+ out_used, coder->crc32);+ }++ return ret;+}+++static void+index_encoder_end(void *coder, const lzma_allocator *allocator)+{+ lzma_free(coder, allocator);+ return;+}+++static void+index_encoder_reset(lzma_index_coder *coder, const lzma_index *i)+{+ lzma_index_iter_init(&coder->iter, i);++ coder->sequence = SEQ_INDICATOR;+ coder->index = i;+ coder->pos = 0;+ coder->crc32 = 0;++ return;+}+++extern lzma_ret+lzma_index_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_index *i)+{+ lzma_next_coder_init(&lzma_index_encoder_init, next, allocator);++ if (i == NULL)+ return LZMA_PROG_ERROR;++ if (next->coder == NULL) {+ next->coder = lzma_alloc(sizeof(lzma_index_coder), allocator);+ if (next->coder == NULL)+ return LZMA_MEM_ERROR;++ next->code = &index_encode;+ next->end = &index_encoder_end;+ }++ index_encoder_reset(next->coder, i);++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_index_encoder(lzma_stream *strm, const lzma_index *i)+{+ lzma_next_strm_init(lzma_index_encoder_init, strm, i);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_index_buffer_encode(const lzma_index *i,+ uint8_t *out, size_t *out_pos, size_t out_size)+{+ // Validate the arguments.+ if (i == NULL || out == NULL || out_pos == NULL || *out_pos > out_size)+ return LZMA_PROG_ERROR;++ // Don't try to encode if there's not enough output space.+ if (out_size - *out_pos < lzma_index_size(i))+ return LZMA_BUF_ERROR;++ // The Index encoder needs just one small data structure so we can+ // allocate it on stack.+ lzma_index_coder coder;+ index_encoder_reset(&coder, i);++ // Do the actual encoding. This should never fail, but store+ // the original *out_pos just in case.+ const size_t out_start = *out_pos;+ lzma_ret ret = index_encode(&coder, NULL, NULL, NULL, 0,+ out, out_pos, out_size, LZMA_RUN);++ if (ret == LZMA_STREAM_END) {+ ret = LZMA_OK;+ } else {+ // We should never get here, but just in case, restore the+ // output position and set the error accordingly if something+ // goes wrong and debugging isn't enabled.+ assert(0);+ *out_pos = out_start;+ ret = LZMA_PROG_ERROR;+ }++ return ret;+}
+ cbits/liblzma/common/index_encoder.h view
@@ -0,0 +1,22 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file index_encoder.h+/// \brief Encodes the Index field+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_INDEX_ENCODER_H+#define LZMA_INDEX_ENCODER_H++#include "common.h"+++extern lzma_ret lzma_index_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator, const lzma_index *i);+++#endif
+ cbits/liblzma/common/index_hash.c view
@@ -0,0 +1,342 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file index_hash.c+/// \brief Validates Index by using a hash function+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+#include "index.h"+#include "check.h"+++typedef struct {+ /// Sum of the Block sizes (including Block Padding)+ lzma_vli blocks_size;++ /// Sum of the Uncompressed Size fields+ lzma_vli uncompressed_size;++ /// Number of Records+ lzma_vli count;++ /// Size of the List of Index Records as bytes+ lzma_vli index_list_size;++ /// Check calculated from Unpadded Sizes and Uncompressed Sizes.+ lzma_check_state check;++} lzma_index_hash_info;+++struct lzma_index_hash_s {+ enum {+ SEQ_BLOCK,+ SEQ_COUNT,+ SEQ_UNPADDED,+ SEQ_UNCOMPRESSED,+ SEQ_PADDING_INIT,+ SEQ_PADDING,+ SEQ_CRC32,+ } sequence;++ /// Information collected while decoding the actual Blocks.+ lzma_index_hash_info blocks;++ /// Information collected from the Index field.+ lzma_index_hash_info records;++ /// Number of Records not fully decoded+ lzma_vli remaining;++ /// Unpadded Size currently being read from an Index Record.+ lzma_vli unpadded_size;++ /// Uncompressed Size currently being read from an Index Record.+ lzma_vli uncompressed_size;++ /// Position in variable-length integers when decoding them from+ /// the List of Records.+ size_t pos;++ /// CRC32 of the Index+ uint32_t crc32;+};+++extern LZMA_API(lzma_index_hash *)+lzma_index_hash_init(lzma_index_hash *index_hash,+ const lzma_allocator *allocator)+{+ if (index_hash == NULL) {+ index_hash = lzma_alloc(sizeof(lzma_index_hash), allocator);+ if (index_hash == NULL)+ return NULL;+ }++ index_hash->sequence = SEQ_BLOCK;+ index_hash->blocks.blocks_size = 0;+ index_hash->blocks.uncompressed_size = 0;+ index_hash->blocks.count = 0;+ index_hash->blocks.index_list_size = 0;+ index_hash->records.blocks_size = 0;+ index_hash->records.uncompressed_size = 0;+ index_hash->records.count = 0;+ index_hash->records.index_list_size = 0;+ index_hash->unpadded_size = 0;+ index_hash->uncompressed_size = 0;+ index_hash->pos = 0;+ index_hash->crc32 = 0;++ // These cannot fail because LZMA_CHECK_BEST is known to be supported.+ (void)lzma_check_init(&index_hash->blocks.check, LZMA_CHECK_BEST);+ (void)lzma_check_init(&index_hash->records.check, LZMA_CHECK_BEST);++ return index_hash;+}+++extern LZMA_API(void)+lzma_index_hash_end(lzma_index_hash *index_hash,+ const lzma_allocator *allocator)+{+ lzma_free(index_hash, allocator);+ return;+}+++extern LZMA_API(lzma_vli)+lzma_index_hash_size(const lzma_index_hash *index_hash)+{+ // Get the size of the Index from ->blocks instead of ->records for+ // cases where application wants to know the Index Size before+ // decoding the Index.+ return index_size(index_hash->blocks.count,+ index_hash->blocks.index_list_size);+}+++/// Updates the sizes and the hash without any validation.+static void+hash_append(lzma_index_hash_info *info, lzma_vli unpadded_size,+ lzma_vli uncompressed_size)+{+ info->blocks_size += vli_ceil4(unpadded_size);+ info->uncompressed_size += uncompressed_size;+ info->index_list_size += lzma_vli_size(unpadded_size)+ + lzma_vli_size(uncompressed_size);+ ++info->count;++ const lzma_vli sizes[2] = { unpadded_size, uncompressed_size };+ lzma_check_update(&info->check, LZMA_CHECK_BEST,+ (const uint8_t *)(sizes), sizeof(sizes));++ return;+}+++extern LZMA_API(lzma_ret)+lzma_index_hash_append(lzma_index_hash *index_hash, lzma_vli unpadded_size,+ lzma_vli uncompressed_size)+{+ // Validate the arguments.+ if (index_hash == NULL || index_hash->sequence != SEQ_BLOCK+ || unpadded_size < UNPADDED_SIZE_MIN+ || unpadded_size > UNPADDED_SIZE_MAX+ || uncompressed_size > LZMA_VLI_MAX)+ return LZMA_PROG_ERROR;++ // Update the hash.+ hash_append(&index_hash->blocks, unpadded_size, uncompressed_size);++ // Validate the properties of *info are still in allowed limits.+ if (index_hash->blocks.blocks_size > LZMA_VLI_MAX+ || index_hash->blocks.uncompressed_size > LZMA_VLI_MAX+ || index_size(index_hash->blocks.count,+ index_hash->blocks.index_list_size)+ > LZMA_BACKWARD_SIZE_MAX+ || index_stream_size(index_hash->blocks.blocks_size,+ index_hash->blocks.count,+ index_hash->blocks.index_list_size)+ > LZMA_VLI_MAX)+ return LZMA_DATA_ERROR;++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_index_hash_decode(lzma_index_hash *index_hash, const uint8_t *in,+ size_t *in_pos, size_t in_size)+{+ // Catch zero input buffer here, because in contrast to Index encoder+ // and decoder functions, applications call this function directly+ // instead of via lzma_code(), which does the buffer checking.+ if (*in_pos >= in_size)+ return LZMA_BUF_ERROR;++ // NOTE: This function has many similarities to index_encode() and+ // index_decode() functions found from index_encoder.c and+ // index_decoder.c. See the comments especially in index_encoder.c.+ const size_t in_start = *in_pos;+ lzma_ret ret = LZMA_OK;++ while (*in_pos < in_size)+ switch (index_hash->sequence) {+ case SEQ_BLOCK:+ // Check the Index Indicator is present.+ if (in[(*in_pos)++] != INDEX_INDICATOR)+ return LZMA_DATA_ERROR;++ index_hash->sequence = SEQ_COUNT;+ break;++ case SEQ_COUNT: {+ ret = lzma_vli_decode(&index_hash->remaining,+ &index_hash->pos, in, in_pos, in_size);+ if (ret != LZMA_STREAM_END)+ goto out;++ // The count must match the count of the Blocks decoded.+ if (index_hash->remaining != index_hash->blocks.count)+ return LZMA_DATA_ERROR;++ ret = LZMA_OK;+ index_hash->pos = 0;++ // Handle the special case when there are no Blocks.+ index_hash->sequence = index_hash->remaining == 0+ ? SEQ_PADDING_INIT : SEQ_UNPADDED;+ break;+ }++ case SEQ_UNPADDED:+ case SEQ_UNCOMPRESSED: {+ lzma_vli *size = index_hash->sequence == SEQ_UNPADDED+ ? &index_hash->unpadded_size+ : &index_hash->uncompressed_size;++ ret = lzma_vli_decode(size, &index_hash->pos,+ in, in_pos, in_size);+ if (ret != LZMA_STREAM_END)+ goto out;++ ret = LZMA_OK;+ index_hash->pos = 0;++ if (index_hash->sequence == SEQ_UNPADDED) {+ if (index_hash->unpadded_size < UNPADDED_SIZE_MIN+ || index_hash->unpadded_size+ > UNPADDED_SIZE_MAX)+ return LZMA_DATA_ERROR;++ index_hash->sequence = SEQ_UNCOMPRESSED;+ } else {+ // Update the hash.+ hash_append(&index_hash->records,+ index_hash->unpadded_size,+ index_hash->uncompressed_size);++ // Verify that we don't go over the known sizes. Note+ // that this validation is simpler than the one used+ // in lzma_index_hash_append(), because here we know+ // that values in index_hash->blocks are already+ // validated and we are fine as long as we don't+ // exceed them in index_hash->records.+ if (index_hash->blocks.blocks_size+ < index_hash->records.blocks_size+ || index_hash->blocks.uncompressed_size+ < index_hash->records.uncompressed_size+ || index_hash->blocks.index_list_size+ < index_hash->records.index_list_size)+ return LZMA_DATA_ERROR;++ // Check if this was the last Record.+ index_hash->sequence = --index_hash->remaining == 0+ ? SEQ_PADDING_INIT : SEQ_UNPADDED;+ }++ break;+ }++ case SEQ_PADDING_INIT:+ index_hash->pos = (LZMA_VLI_C(4) - index_size_unpadded(+ index_hash->records.count,+ index_hash->records.index_list_size)) & 3;+ index_hash->sequence = SEQ_PADDING;++ // Fall through++ case SEQ_PADDING:+ if (index_hash->pos > 0) {+ --index_hash->pos;+ if (in[(*in_pos)++] != 0x00)+ return LZMA_DATA_ERROR;++ break;+ }++ // Compare the sizes.+ if (index_hash->blocks.blocks_size+ != index_hash->records.blocks_size+ || index_hash->blocks.uncompressed_size+ != index_hash->records.uncompressed_size+ || index_hash->blocks.index_list_size+ != index_hash->records.index_list_size)+ return LZMA_DATA_ERROR;++ // Finish the hashes and compare them.+ lzma_check_finish(&index_hash->blocks.check, LZMA_CHECK_BEST);+ lzma_check_finish(&index_hash->records.check, LZMA_CHECK_BEST);+ if (memcmp(index_hash->blocks.check.buffer.u8,+ index_hash->records.check.buffer.u8,+ lzma_check_size(LZMA_CHECK_BEST)) != 0)+ return LZMA_DATA_ERROR;++ // Finish the CRC32 calculation.+ index_hash->crc32 = lzma_crc32(in + in_start,+ *in_pos - in_start, index_hash->crc32);++ index_hash->sequence = SEQ_CRC32;++ // Fall through++ case SEQ_CRC32:+ do {+ if (*in_pos == in_size)+ return LZMA_OK;++ if (((index_hash->crc32 >> (index_hash->pos * 8))+ & 0xFF) != in[(*in_pos)++]) {+#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION+ return LZMA_DATA_ERROR;+#endif+ }++ } while (++index_hash->pos < 4);++ return LZMA_STREAM_END;++ default:+ assert(0);+ return LZMA_PROG_ERROR;+ }++out:+ // Update the CRC32.+ //+ // Avoid null pointer + 0 (undefined behavior) in "in + in_start".+ // In such a case we had no input and thus in_used == 0.+ {+ const size_t in_used = *in_pos - in_start;+ if (in_used > 0)+ index_hash->crc32 = lzma_crc32(in + in_start,+ in_used, index_hash->crc32);+ }++ return ret;+}
+ cbits/liblzma/common/lzip_decoder.c view
@@ -0,0 +1,417 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzip_decoder.c+/// \brief Decodes .lz (lzip) files+//+// Author: Michał Górny+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "lzip_decoder.h"+#include "lzma_decoder.h"+#include "check.h"+++// .lz format version 0 lacks the 64-bit Member size field in the footer.+#define LZIP_V0_FOOTER_SIZE 12+#define LZIP_V1_FOOTER_SIZE 20+#define LZIP_FOOTER_SIZE_MAX LZIP_V1_FOOTER_SIZE++// lc/lp/pb are hardcoded in the .lz format.+#define LZIP_LC 3+#define LZIP_LP 0+#define LZIP_PB 2+++typedef struct {+ enum {+ SEQ_ID_STRING,+ SEQ_VERSION,+ SEQ_DICT_SIZE,+ SEQ_CODER_INIT,+ SEQ_LZMA_STREAM,+ SEQ_MEMBER_FOOTER,+ } sequence;++ /// .lz member format version+ uint32_t version;++ /// CRC32 of the uncompressed data in the .lz member+ uint32_t crc32;++ /// Uncompressed size of the .lz member+ uint64_t uncompressed_size;++ /// Compressed size of the .lz member+ uint64_t member_size;++ /// Memory usage limit+ uint64_t memlimit;++ /// Amount of memory actually needed+ uint64_t memusage;++ /// If true, LZMA_GET_CHECK is returned after decoding the header+ /// fields. As all files use CRC32 this is redundant but it's+ /// implemented anyway since the initialization functions supports+ /// all other flags in addition to LZMA_TELL_ANY_CHECK.+ bool tell_any_check;++ /// If true, we won't calculate or verify the CRC32 of+ /// the uncompressed data.+ bool ignore_check;++ /// If true, we will decode concatenated .lz members and stop if+ /// non-.lz data is seen after at least one member has been+ /// successfully decoded.+ bool concatenated;++ /// When decoding concatenated .lz members, this is true as long as+ /// we are decoding the first .lz member. This is needed to avoid+ /// incorrect LZMA_FORMAT_ERROR in case there is non-.lz data at+ /// the end of the file.+ bool first_member;++ /// Reading position in the header and footer fields+ size_t pos;++ /// Buffer to hold the .lz footer fields+ uint8_t buffer[LZIP_FOOTER_SIZE_MAX];++ /// Options decoded from the .lz header that needed to initialize+ /// the LZMA1 decoder.+ lzma_options_lzma options;++ /// LZMA1 decoder+ lzma_next_coder lzma_decoder;++} lzma_lzip_coder;+++static lzma_ret+lzip_decode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size, lzma_action action)+{+ lzma_lzip_coder *coder = coder_ptr;++ while (true)+ switch (coder->sequence) {+ case SEQ_ID_STRING: {+ // The "ID string" or magic bytes are "LZIP" in US-ASCII.+ const uint8_t lzip_id_string[4] = { 0x4C, 0x5A, 0x49, 0x50 };++ while (coder->pos < sizeof(lzip_id_string)) {+ if (*in_pos >= in_size) {+ // If we are on the 2nd+ concatenated member+ // and the input ends before we can read+ // the magic bytes, we discard the bytes that+ // were already read (up to 3) and finish.+ // See the reasoning below.+ return !coder->first_member+ && action == LZMA_FINISH+ ? LZMA_STREAM_END : LZMA_OK;+ }++ if (in[*in_pos] != lzip_id_string[coder->pos]) {+ // The .lz format allows putting non-.lz data+ // at the end of the file. If we have seen+ // at least one valid .lz member already,+ // then we won't consume the byte at *in_pos+ // and will return LZMA_STREAM_END. This way+ // apps can easily locate and read the non-.lz+ // data after the .lz member(s).+ //+ // NOTE: If the first 1-3 bytes of the non-.lz+ // data match the .lz ID string then the first+ // 1-3 bytes of the junk will get ignored by+ // us. If apps want to properly locate the+ // trailing data they must ensure that the+ // first byte of their custom data isn't the+ // same as the first byte of .lz ID string.+ // With the liblzma API we cannot rewind the+ // input position across calls to lzma_code().+ return !coder->first_member+ ? LZMA_STREAM_END : LZMA_FORMAT_ERROR;+ }++ ++*in_pos;+ ++coder->pos;+ }++ coder->pos = 0;++ coder->crc32 = 0;+ coder->uncompressed_size = 0;+ coder->member_size = sizeof(lzip_id_string);++ coder->sequence = SEQ_VERSION;+ }++ // Fall through++ case SEQ_VERSION:+ if (*in_pos >= in_size)+ return LZMA_OK;++ coder->version = in[(*in_pos)++];++ // We support version 0 and unextended version 1.+ if (coder->version > 1)+ return LZMA_OPTIONS_ERROR;++ ++coder->member_size;+ coder->sequence = SEQ_DICT_SIZE;++ // .lz versions 0 and 1 use CRC32 as the integrity check+ // so if the application wanted to know that+ // (LZMA_TELL_ANY_CHECK) we can tell it now.+ if (coder->tell_any_check)+ return LZMA_GET_CHECK;++ // Fall through++ case SEQ_DICT_SIZE: {+ if (*in_pos >= in_size)+ return LZMA_OK;++ const uint32_t ds = in[(*in_pos)++];+ ++coder->member_size;++ // The five lowest bits are for the base-2 logarithm of+ // the dictionary size and the highest three bits are+ // the fractional part (0/16 to 7/16) that will be+ // subtracted to get the final value.+ //+ // For example, with 0xB5:+ // b2log = 21+ // fracnum = 5+ // dict_size = 2^21 - 2^21 * 5 / 16 = 1408 KiB+ const uint32_t b2log = ds & 0x1F;+ const uint32_t fracnum = ds >> 5;++ // The format versions 0 and 1 allow dictionary size in the+ // range [4 KiB, 512 MiB].+ if (b2log < 12 || b2log > 29 || (b2log == 12 && fracnum > 0))+ return LZMA_DATA_ERROR;++ // 2^[b2log] - 2^[b2log] * [fracnum] / 16+ // = 2^[b2log] - [fracnum] * 2^([b2log] - 4)+ coder->options.dict_size = (UINT32_C(1) << b2log)+ - (fracnum << (b2log - 4));++ assert(coder->options.dict_size >= 4096);+ assert(coder->options.dict_size <= (UINT32_C(512) << 20));++ coder->options.preset_dict = NULL;+ coder->options.lc = LZIP_LC;+ coder->options.lp = LZIP_LP;+ coder->options.pb = LZIP_PB;++ // Calculate the memory usage.+ coder->memusage = lzma_lzma_decoder_memusage(&coder->options)+ + LZMA_MEMUSAGE_BASE;++ // Initialization is a separate step because if we return+ // LZMA_MEMLIMIT_ERROR we need to be able to restart after+ // the memlimit has been increased.+ coder->sequence = SEQ_CODER_INIT;+ }++ // Fall through++ case SEQ_CODER_INIT: {+ if (coder->memusage > coder->memlimit)+ return LZMA_MEMLIMIT_ERROR;++ const lzma_filter_info filters[2] = {+ {+ .id = LZMA_FILTER_LZMA1,+ .init = &lzma_lzma_decoder_init,+ .options = &coder->options,+ }, {+ .init = NULL,+ }+ };++ return_if_error(lzma_next_filter_init(&coder->lzma_decoder,+ allocator, filters));++ coder->crc32 = 0;+ coder->sequence = SEQ_LZMA_STREAM;+ }++ // Fall through++ case SEQ_LZMA_STREAM: {+ const size_t in_start = *in_pos;+ const size_t out_start = *out_pos;++ const lzma_ret ret = coder->lzma_decoder.code(+ coder->lzma_decoder.coder, allocator,+ in, in_pos, in_size, out, out_pos, out_size,+ action);++ const size_t out_used = *out_pos - out_start;++ coder->member_size += *in_pos - in_start;+ coder->uncompressed_size += out_used;++ // Don't update the CRC32 if the integrity check will be+ // ignored or if there was no new output. The latter is+ // important in case out == NULL to avoid null pointer + 0+ // which is undefined behavior.+ if (!coder->ignore_check && out_used > 0)+ coder->crc32 = lzma_crc32(out + out_start, out_used,+ coder->crc32);++ if (ret != LZMA_STREAM_END)+ return ret;++ coder->sequence = SEQ_MEMBER_FOOTER;+ }++ // Fall through++ case SEQ_MEMBER_FOOTER: {+ // The footer of .lz version 0 lacks the Member size field.+ // This is the only difference between version 0 and+ // unextended version 1 formats.+ const size_t footer_size = coder->version == 0+ ? LZIP_V0_FOOTER_SIZE+ : LZIP_V1_FOOTER_SIZE;++ // Copy the CRC32, Data size, and Member size fields to+ // the internal buffer.+ lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,+ footer_size);++ // Return if we didn't get the whole footer yet.+ if (coder->pos < footer_size)+ return LZMA_OK;++ coder->pos = 0;+ coder->member_size += footer_size;++ // Check that the footer fields match the observed data.+ if (!coder->ignore_check+ && coder->crc32 != read32le(&coder->buffer[0]))+ return LZMA_DATA_ERROR;++ if (coder->uncompressed_size != read64le(&coder->buffer[4]))+ return LZMA_DATA_ERROR;++ if (coder->version > 0) {+ // .lz version 0 has no Member size field.+ if (coder->member_size != read64le(&coder->buffer[12]))+ return LZMA_DATA_ERROR;+ }++ // Decoding is finished if we weren't requested to decode+ // more than one .lz member.+ if (!coder->concatenated)+ return LZMA_STREAM_END;++ coder->first_member = false;+ coder->sequence = SEQ_ID_STRING;+ break;+ }++ default:+ assert(0);+ return LZMA_PROG_ERROR;+ }++ // Never reached+}+++static void+lzip_decoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_lzip_coder *coder = coder_ptr;+ lzma_next_end(&coder->lzma_decoder, allocator);+ lzma_free(coder, allocator);+ return;+}+++static lzma_check+lzip_decoder_get_check(const void *coder_ptr lzma_attribute((__unused__)))+{+ return LZMA_CHECK_CRC32;+}+++static lzma_ret+lzip_decoder_memconfig(void *coder_ptr, uint64_t *memusage,+ uint64_t *old_memlimit, uint64_t new_memlimit)+{+ lzma_lzip_coder *coder = coder_ptr;++ *memusage = coder->memusage;+ *old_memlimit = coder->memlimit;++ if (new_memlimit != 0) {+ if (new_memlimit < coder->memusage)+ return LZMA_MEMLIMIT_ERROR;++ coder->memlimit = new_memlimit;+ }++ return LZMA_OK;+}+++extern lzma_ret+lzma_lzip_decoder_init(+ lzma_next_coder *next, const lzma_allocator *allocator,+ uint64_t memlimit, uint32_t flags)+{+ lzma_next_coder_init(&lzma_lzip_decoder_init, next, allocator);++ if (flags & ~LZMA_SUPPORTED_FLAGS)+ return LZMA_OPTIONS_ERROR;++ lzma_lzip_coder *coder = next->coder;+ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_lzip_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = &lzip_decode;+ next->end = &lzip_decoder_end;+ next->get_check = &lzip_decoder_get_check;+ next->memconfig = &lzip_decoder_memconfig;++ coder->lzma_decoder = LZMA_NEXT_CODER_INIT;+ }++ coder->sequence = SEQ_ID_STRING;+ coder->memlimit = my_max(1, memlimit);+ coder->memusage = LZMA_MEMUSAGE_BASE;+ coder->tell_any_check = (flags & LZMA_TELL_ANY_CHECK) != 0;+ coder->ignore_check = (flags & LZMA_IGNORE_CHECK) != 0;+ coder->concatenated = (flags & LZMA_CONCATENATED) != 0;+ coder->first_member = true;+ coder->pos = 0;++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_lzip_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags)+{+ lzma_next_strm_init(lzma_lzip_decoder_init, strm, memlimit, flags);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}
+ cbits/liblzma/common/lzip_decoder.h view
@@ -0,0 +1,21 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzip_decoder.h+/// \brief Decodes .lz (lzip) files+//+// Author: Michał Górny+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_LZIP_DECODER_H+#define LZMA_LZIP_DECODER_H++#include "common.h"++extern lzma_ret lzma_lzip_decoder_init(+ lzma_next_coder *next, const lzma_allocator *allocator,+ uint64_t memlimit, uint32_t flags);++#endif
+ cbits/liblzma/common/memcmplen.h view
@@ -0,0 +1,188 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file memcmplen.h+/// \brief Optimized comparison of two buffers+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_MEMCMPLEN_H+#define LZMA_MEMCMPLEN_H++#include "common.h"++#ifdef HAVE_IMMINTRIN_H+# include <immintrin.h>+#endif++// Only include <intrin.h> if it is needed. The header is only needed+// on Windows when using an MSVC compatible compiler. The Intel compiler+// can use the intrinsics without the header file.+#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \+ && defined(_MSC_VER) \+ && (defined(_M_X64) \+ || defined(_M_ARM64) || defined(_M_ARM64EC)) \+ && !defined(__INTEL_COMPILER)+# include <intrin.h>+#endif+++/// Find out how many equal bytes the two buffers have.+///+/// \param buf1 First buffer+/// \param buf2 Second buffer+/// \param len How many bytes have already been compared and will+/// be assumed to match+/// \param limit How many bytes to compare at most, including the+/// already-compared bytes. This must be significantly+/// smaller than UINT32_MAX to avoid integer overflows.+/// Up to LZMA_MEMCMPLEN_EXTRA bytes may be read past+/// the specified limit from both buf1 and buf2.+///+/// \return Number of equal bytes in the buffers is returned.+/// This is always at least len and at most limit.+///+/// \note LZMA_MEMCMPLEN_EXTRA defines how many extra bytes may be read.+/// It's rounded up to 2^n. This extra amount needs to be+/// allocated in the buffers being used. It needs to be+/// initialized too to keep Valgrind quiet.+static lzma_always_inline uint32_t+lzma_memcmplen(const uint8_t *buf1, const uint8_t *buf2,+ uint32_t len, uint32_t limit)+{+ assert(len <= limit);+ assert(limit <= UINT32_MAX / 2);++#if defined(TUKLIB_FAST_UNALIGNED_ACCESS) \+ && (((TUKLIB_GNUC_REQ(3, 4) || defined(__clang__)) \+ && (defined(__x86_64__) \+ || defined(__aarch64__))) \+ || (defined(__INTEL_COMPILER) && defined(__x86_64__)) \+ || (defined(__INTEL_COMPILER) && defined(_M_X64)) \+ || (defined(_MSC_VER) && (defined(_M_X64) \+ || defined(_M_ARM64) || defined(_M_ARM64EC))))+ // This is only for x86-64 and ARM64 for now. This might be fine on+ // other 64-bit processors too. On big endian one should use xor+ // instead of subtraction and switch to __builtin_clzll().+ //+ // Reasons to use subtraction instead of xor:+ //+ // - On some x86-64 processors (Intel Sandy Bridge to Tiger Lake),+ // sub+jz and sub+jnz can be fused but xor+jz or xor+jnz cannot.+ // Thus using subtraction has potential to be a tiny amount faster+ // since the code checks if the quotient is non-zero.+ //+ // - Some processors (Intel Pentium 4) used to have more ALU+ // resources for add/sub instructions than and/or/xor.+ //+ // The processor info is based on Agner Fog's microarchitecture.pdf+ // version 2023-05-26. https://www.agner.org/optimize/+#define LZMA_MEMCMPLEN_EXTRA 8+ while (len < limit) {+ const uint64_t x = read64ne(buf1 + len) - read64ne(buf2 + len);+ if (x != 0) {+ // MSVC or Intel C compiler on Windows+# if defined(_MSC_VER) || defined(__INTEL_COMPILER)+ unsigned long tmp;+ _BitScanForward64(&tmp, x);+ len += (uint32_t)tmp >> 3;+ // GCC, Clang, or Intel C compiler+# else+ len += (uint32_t)__builtin_ctzll(x) >> 3;+# endif+ return my_min(len, limit);+ }++ len += 8;+ }++ return limit;++#elif defined(TUKLIB_FAST_UNALIGNED_ACCESS) \+ && defined(HAVE__MM_MOVEMASK_EPI8) \+ && (defined(__SSE2__) \+ || (defined(_MSC_VER) && defined(_M_IX86_FP) \+ && _M_IX86_FP >= 2))+ // NOTE: This will use 128-bit unaligned access which+ // TUKLIB_FAST_UNALIGNED_ACCESS wasn't meant to permit,+ // but it's convenient here since this is x86-only.+ //+ // SSE2 version for 32-bit and 64-bit x86. On x86-64 the above+ // version is sometimes significantly faster and sometimes+ // slightly slower than this SSE2 version, so this SSE2+ // version isn't used on x86-64.+# define LZMA_MEMCMPLEN_EXTRA 16+ while (len < limit) {+ const uint32_t x = 0xFFFF ^ (uint32_t)_mm_movemask_epi8(+ _mm_cmpeq_epi8(+ _mm_loadu_si128((const __m128i *)(buf1 + len)),+ _mm_loadu_si128((const __m128i *)(buf2 + len))));++ if (x != 0) {+ len += ctz32(x);+ return my_min(len, limit);+ }++ len += 16;+ }++ return limit;++#elif defined(TUKLIB_FAST_UNALIGNED_ACCESS) && !defined(WORDS_BIGENDIAN)+ // Generic 32-bit little endian method+# define LZMA_MEMCMPLEN_EXTRA 4+ while (len < limit) {+ uint32_t x = read32ne(buf1 + len) - read32ne(buf2 + len);+ if (x != 0) {+ if ((x & 0xFFFF) == 0) {+ len += 2;+ x >>= 16;+ }++ if ((x & 0xFF) == 0)+ ++len;++ return my_min(len, limit);+ }++ len += 4;+ }++ return limit;++#elif defined(TUKLIB_FAST_UNALIGNED_ACCESS) && defined(WORDS_BIGENDIAN)+ // Generic 32-bit big endian method+# define LZMA_MEMCMPLEN_EXTRA 4+ while (len < limit) {+ uint32_t x = read32ne(buf1 + len) ^ read32ne(buf2 + len);+ if (x != 0) {+ if ((x & 0xFFFF0000) == 0) {+ len += 2;+ x <<= 16;+ }++ if ((x & 0xFF000000) == 0)+ ++len;++ return my_min(len, limit);+ }++ len += 4;+ }++ return limit;++#else+ // Simple portable version that doesn't use unaligned access.+# define LZMA_MEMCMPLEN_EXTRA 0+ while (len < limit && buf1[len] == buf2[len])+ ++len;++ return len;+#endif+}++#endif
+ cbits/liblzma/common/microlzma_decoder.c view
@@ -0,0 +1,220 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file microlzma_decoder.c+/// \brief Decode MicroLZMA format+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "lzma_decoder.h"+#include "lz_decoder.h"+++typedef struct {+ /// LZMA1 decoder+ lzma_next_coder lzma;++ /// Compressed size of the stream as given by the application.+ /// This must be exactly correct.+ ///+ /// This will be decremented when input is read.+ uint64_t comp_size;++ /// Uncompressed size of the stream as given by the application.+ /// This may be less than the actual uncompressed size if+ /// uncomp_size_is_exact is false.+ ///+ /// This will be decremented when output is produced.+ lzma_vli uncomp_size;++ /// LZMA dictionary size as given by the application+ uint32_t dict_size;++ /// If true, the exact uncompressed size is known. If false,+ /// uncomp_size may be smaller than the real uncompressed size;+ /// uncomp_size may never be bigger than the real uncompressed size.+ bool uncomp_size_is_exact;++ /// True once the first byte of the MicroLZMA stream+ /// has been processed.+ bool props_decoded;+} lzma_microlzma_coder;+++static lzma_ret+microlzma_decode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size, lzma_action action)+{+ lzma_microlzma_coder *coder = coder_ptr;++ // Remember the in start position so that we can update comp_size.+ const size_t in_start = *in_pos;++ // Remember the out start position so that we can update uncomp_size.+ const size_t out_start = *out_pos;++ // Limit the amount of input so that the decoder won't read more than+ // comp_size. This is required when uncomp_size isn't exact because+ // in that case the LZMA decoder will try to decode more input even+ // when it has no output space (it can be looking for EOPM).+ if (in_size - *in_pos > coder->comp_size)+ in_size = *in_pos + (size_t)(coder->comp_size);++ // When the exact uncompressed size isn't known, we must limit+ // the available output space to prevent the LZMA decoder from+ // trying to decode too much.+ if (!coder->uncomp_size_is_exact+ && out_size - *out_pos > coder->uncomp_size)+ out_size = *out_pos + (size_t)(coder->uncomp_size);++ if (!coder->props_decoded) {+ // There must be at least one byte of input to decode+ // the properties byte.+ if (*in_pos >= in_size)+ return LZMA_OK;++ lzma_options_lzma options = {+ .dict_size = coder->dict_size,+ .preset_dict = NULL,+ .preset_dict_size = 0,+ .ext_flags = 0, // EOPM not allowed when size is known+ .ext_size_low = UINT32_MAX, // Unknown size by default+ .ext_size_high = UINT32_MAX,+ };++ if (coder->uncomp_size_is_exact)+ lzma_set_ext_size(options, coder->uncomp_size);++ // The properties are stored as bitwise-negation+ // of the typical encoding.+ if (lzma_lzma_lclppb_decode(&options, ~in[*in_pos]))+ return LZMA_OPTIONS_ERROR;++ ++*in_pos;++ // Initialize the decoder.+ lzma_filter_info filters[2] = {+ {+ .id = LZMA_FILTER_LZMA1EXT,+ .init = &lzma_lzma_decoder_init,+ .options = &options,+ }, {+ .init = NULL,+ }+ };++ return_if_error(lzma_next_filter_init(&coder->lzma,+ allocator, filters));++ // Pass one dummy 0x00 byte to the LZMA decoder since that+ // is what it expects the first byte to be.+ const uint8_t dummy_in = 0;+ size_t dummy_in_pos = 0;+ if (coder->lzma.code(coder->lzma.coder, allocator,+ &dummy_in, &dummy_in_pos, 1,+ out, out_pos, out_size, LZMA_RUN) != LZMA_OK)+ return LZMA_PROG_ERROR;++ assert(dummy_in_pos == 1);+ coder->props_decoded = true;+ }++ // The rest is normal LZMA decoding.+ lzma_ret ret = coder->lzma.code(coder->lzma.coder, allocator,+ in, in_pos, in_size,+ out, out_pos, out_size, action);++ // Update the remaining compressed size.+ assert(coder->comp_size >= *in_pos - in_start);+ coder->comp_size -= *in_pos - in_start;++ if (coder->uncomp_size_is_exact) {+ // After successful decompression of the complete stream+ // the compressed size must match.+ if (ret == LZMA_STREAM_END && coder->comp_size != 0)+ ret = LZMA_DATA_ERROR;+ } else {+ // Update the amount of output remaining.+ assert(coder->uncomp_size >= *out_pos - out_start);+ coder->uncomp_size -= *out_pos - out_start;++ // - We must not get LZMA_STREAM_END because the stream+ // shouldn't have EOPM.+ // - We must use uncomp_size to determine when to+ // return LZMA_STREAM_END.+ if (ret == LZMA_STREAM_END)+ ret = LZMA_DATA_ERROR;+ else if (coder->uncomp_size == 0)+ ret = LZMA_STREAM_END;+ }++ return ret;+}+++static void+microlzma_decoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_microlzma_coder *coder = coder_ptr;+ lzma_next_end(&coder->lzma, allocator);+ lzma_free(coder, allocator);+ return;+}+++static lzma_ret+microlzma_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ uint64_t comp_size,+ uint64_t uncomp_size, bool uncomp_size_is_exact,+ uint32_t dict_size)+{+ lzma_next_coder_init(µlzma_decoder_init, next, allocator);++ lzma_microlzma_coder *coder = next->coder;++ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_microlzma_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = µlzma_decode;+ next->end = µlzma_decoder_end;++ coder->lzma = LZMA_NEXT_CODER_INIT;+ }++ // The public API is uint64_t but the internal LZ decoder API uses+ // lzma_vli.+ if (uncomp_size > LZMA_VLI_MAX)+ return LZMA_OPTIONS_ERROR;++ coder->comp_size = comp_size;+ coder->uncomp_size = uncomp_size;+ coder->uncomp_size_is_exact = uncomp_size_is_exact;+ coder->dict_size = dict_size;++ coder->props_decoded = false;++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_microlzma_decoder(lzma_stream *strm, uint64_t comp_size,+ uint64_t uncomp_size, lzma_bool uncomp_size_is_exact,+ uint32_t dict_size)+{+ lzma_next_strm_init(microlzma_decoder_init, strm, comp_size,+ uncomp_size, uncomp_size_is_exact, dict_size);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}
+ cbits/liblzma/common/microlzma_encoder.c view
@@ -0,0 +1,140 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file microlzma_encoder.c+/// \brief Encode into MicroLZMA format+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "lzma_encoder.h"+++typedef struct {+ /// LZMA1 encoder+ lzma_next_coder lzma;++ /// LZMA properties byte (lc/lp/pb)+ uint8_t props;+} lzma_microlzma_coder;+++static lzma_ret+microlzma_encode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size, lzma_action action)+{+ lzma_microlzma_coder *coder = coder_ptr;++ // Remember *out_pos so that we can overwrite the first byte with+ // the LZMA properties byte.+ const size_t out_start = *out_pos;++ // Remember *in_pos so that we can set it based on how many+ // uncompressed bytes were actually encoded.+ const size_t in_start = *in_pos;++ // Set the output size limit based on the available output space.+ // We know that the encoder supports set_out_limit() so+ // LZMA_OPTIONS_ERROR isn't possible. LZMA_BUF_ERROR is possible+ // but lzma_code() has an assertion to not allow it to be returned+ // from here and I don't want to change that for now, so+ // LZMA_BUF_ERROR becomes LZMA_PROG_ERROR.+ uint64_t uncomp_size;+ if (coder->lzma.set_out_limit(coder->lzma.coder,+ &uncomp_size, out_size - *out_pos) != LZMA_OK)+ return LZMA_PROG_ERROR;++ // set_out_limit fails if this isn't true.+ assert(out_size - *out_pos >= 6);++ // Encode as much as possible.+ const lzma_ret ret = coder->lzma.code(coder->lzma.coder, allocator,+ in, in_pos, in_size, out, out_pos, out_size, action);++ if (ret != LZMA_STREAM_END) {+ if (ret == LZMA_OK) {+ assert(0);+ return LZMA_PROG_ERROR;+ }++ return ret;+ }++ // The first output byte is bitwise-negation of the properties byte.+ // We know that there is space for this byte because set_out_limit+ // and the actual encoding succeeded.+ out[out_start] = (uint8_t)(~coder->props);++ // The LZMA encoder likely read more input than it was able to encode.+ // Set *in_pos based on uncomp_size.+ assert(uncomp_size <= in_size - in_start);+ *in_pos = in_start + (size_t)(uncomp_size);++ return ret;+}+++static void+microlzma_encoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_microlzma_coder *coder = coder_ptr;+ lzma_next_end(&coder->lzma, allocator);+ lzma_free(coder, allocator);+ return;+}+++static lzma_ret+microlzma_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_options_lzma *options)+{+ lzma_next_coder_init(µlzma_encoder_init, next, allocator);++ lzma_microlzma_coder *coder = next->coder;++ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_microlzma_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = µlzma_encode;+ next->end = µlzma_encoder_end;++ coder->lzma = LZMA_NEXT_CODER_INIT;+ }++ // Encode the properties byte. Bitwise-negation of it will be the+ // first output byte.+ if (lzma_lzma_lclppb_encode(options, &coder->props))+ return LZMA_OPTIONS_ERROR;++ // Initialize the LZMA encoder.+ const lzma_filter_info filters[2] = {+ {+ .id = LZMA_FILTER_LZMA1,+ .init = &lzma_lzma_encoder_init,+ .options = (void *)(options),+ }, {+ .init = NULL,+ }+ };++ return lzma_next_filter_init(&coder->lzma, allocator, filters);+}+++extern LZMA_API(lzma_ret)+lzma_microlzma_encoder(lzma_stream *strm, const lzma_options_lzma *options)+{+ lzma_next_strm_init(microlzma_encoder_init, strm, options);++ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;++}
+ cbits/liblzma/common/outqueue.c view
@@ -0,0 +1,286 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file outqueue.c+/// \brief Output queue handling in multithreaded coding+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "outqueue.h"+++/// Get the maximum number of buffers that may be allocated based+/// on the number of threads. For now this is twice the number of threads.+/// It's a compromise between RAM usage and keeping the worker threads busy+/// when buffers finish out of order.+#define GET_BUFS_LIMIT(threads) (2 * (threads))+++extern uint64_t+lzma_outq_memusage(uint64_t buf_size_max, uint32_t threads)+{+ // This is to ease integer overflow checking: We may allocate up to+ // GET_BUFS_LIMIT(LZMA_THREADS_MAX) buffers and we need some extra+ // memory for other data structures too (that's the /2).+ //+ // lzma_outq_prealloc_buf() will still accept bigger buffers than this.+ const uint64_t limit+ = UINT64_MAX / GET_BUFS_LIMIT(LZMA_THREADS_MAX) / 2;++ if (threads > LZMA_THREADS_MAX || buf_size_max > limit)+ return UINT64_MAX;++ return GET_BUFS_LIMIT(threads)+ * lzma_outq_outbuf_memusage(buf_size_max);+}+++static void+move_head_to_cache(lzma_outq *outq, const lzma_allocator *allocator)+{+ assert(outq->head != NULL);+ assert(outq->tail != NULL);+ assert(outq->bufs_in_use > 0);++ lzma_outbuf *buf = outq->head;+ outq->head = buf->next;+ if (outq->head == NULL)+ outq->tail = NULL;++ if (outq->cache != NULL && outq->cache->allocated != buf->allocated)+ lzma_outq_clear_cache(outq, allocator);++ buf->next = outq->cache;+ outq->cache = buf;++ --outq->bufs_in_use;+ outq->mem_in_use -= lzma_outq_outbuf_memusage(buf->allocated);++ return;+}+++static void+free_one_cached_buffer(lzma_outq *outq, const lzma_allocator *allocator)+{+ assert(outq->cache != NULL);++ lzma_outbuf *buf = outq->cache;+ outq->cache = buf->next;++ --outq->bufs_allocated;+ outq->mem_allocated -= lzma_outq_outbuf_memusage(buf->allocated);++ lzma_free(buf, allocator);+ return;+}+++extern void+lzma_outq_clear_cache(lzma_outq *outq, const lzma_allocator *allocator)+{+ while (outq->cache != NULL)+ free_one_cached_buffer(outq, allocator);++ return;+}+++extern void+lzma_outq_clear_cache2(lzma_outq *outq, const lzma_allocator *allocator,+ size_t keep_size)+{+ if (outq->cache == NULL)+ return;++ // Free all but one.+ while (outq->cache->next != NULL)+ free_one_cached_buffer(outq, allocator);++ // Free the last one only if its size doesn't equal to keep_size.+ if (outq->cache->allocated != keep_size)+ free_one_cached_buffer(outq, allocator);++ return;+}+++extern lzma_ret+lzma_outq_init(lzma_outq *outq, const lzma_allocator *allocator,+ uint32_t threads)+{+ if (threads > LZMA_THREADS_MAX)+ return LZMA_OPTIONS_ERROR;++ const uint32_t bufs_limit = GET_BUFS_LIMIT(threads);++ // Clear head/tail.+ while (outq->head != NULL)+ move_head_to_cache(outq, allocator);++ // If new buf_limit is lower than the old one, we may need to free+ // a few cached buffers.+ while (bufs_limit < outq->bufs_allocated)+ free_one_cached_buffer(outq, allocator);++ outq->bufs_limit = bufs_limit;+ outq->read_pos = 0;++ return LZMA_OK;+}+++extern void+lzma_outq_end(lzma_outq *outq, const lzma_allocator *allocator)+{+ while (outq->head != NULL)+ move_head_to_cache(outq, allocator);++ lzma_outq_clear_cache(outq, allocator);+ return;+}+++extern lzma_ret+lzma_outq_prealloc_buf(lzma_outq *outq, const lzma_allocator *allocator,+ size_t size)+{+ // Caller must have checked it with lzma_outq_has_buf().+ assert(outq->bufs_in_use < outq->bufs_limit);++ // If there already is appropriately-sized buffer in the cache,+ // we need to do nothing.+ if (outq->cache != NULL && outq->cache->allocated == size)+ return LZMA_OK;++ if (size > SIZE_MAX - sizeof(lzma_outbuf))+ return LZMA_MEM_ERROR;++ const size_t alloc_size = lzma_outq_outbuf_memusage(size);++ // The cache may have buffers but their size is wrong.+ lzma_outq_clear_cache(outq, allocator);++ outq->cache = lzma_alloc(alloc_size, allocator);+ if (outq->cache == NULL)+ return LZMA_MEM_ERROR;++ outq->cache->next = NULL;+ outq->cache->allocated = size;++ ++outq->bufs_allocated;+ outq->mem_allocated += alloc_size;++ return LZMA_OK;+}+++extern lzma_outbuf *+lzma_outq_get_buf(lzma_outq *outq, void *worker)+{+ // Caller must have used lzma_outq_prealloc_buf() to ensure these.+ assert(outq->bufs_in_use < outq->bufs_limit);+ assert(outq->bufs_in_use < outq->bufs_allocated);+ assert(outq->cache != NULL);++ lzma_outbuf *buf = outq->cache;+ outq->cache = buf->next;+ buf->next = NULL;++ if (outq->tail != NULL) {+ assert(outq->head != NULL);+ outq->tail->next = buf;+ } else {+ assert(outq->head == NULL);+ outq->head = buf;+ }++ outq->tail = buf;++ buf->worker = worker;+ buf->finished = false;+ buf->finish_ret = LZMA_STREAM_END;+ buf->pos = 0;+ buf->decoder_in_pos = 0;++ buf->unpadded_size = 0;+ buf->uncompressed_size = 0;++ ++outq->bufs_in_use;+ outq->mem_in_use += lzma_outq_outbuf_memusage(buf->allocated);++ return buf;+}+++extern bool+lzma_outq_is_readable(const lzma_outq *outq)+{+ if (outq->head == NULL)+ return false;++ return outq->read_pos < outq->head->pos || outq->head->finished;+}+++extern lzma_ret+lzma_outq_read(lzma_outq *restrict outq,+ const lzma_allocator *restrict allocator,+ uint8_t *restrict out, size_t *restrict out_pos,+ size_t out_size,+ lzma_vli *restrict unpadded_size,+ lzma_vli *restrict uncompressed_size)+{+ // There must be at least one buffer from which to read.+ if (outq->bufs_in_use == 0)+ return LZMA_OK;++ // Get the buffer.+ lzma_outbuf *buf = outq->head;++ // Copy from the buffer to output.+ //+ // FIXME? In threaded decoder it may be bad to do this copy while+ // the mutex is being held.+ lzma_bufcpy(buf->buf, &outq->read_pos, buf->pos,+ out, out_pos, out_size);++ // Return if we didn't get all the data from the buffer.+ if (!buf->finished || outq->read_pos < buf->pos)+ return LZMA_OK;++ // The buffer was finished. Tell the caller its size information.+ if (unpadded_size != NULL)+ *unpadded_size = buf->unpadded_size;++ if (uncompressed_size != NULL)+ *uncompressed_size = buf->uncompressed_size;++ // Remember the return value.+ const lzma_ret finish_ret = buf->finish_ret;++ // Free this buffer for further use.+ move_head_to_cache(outq, allocator);+ outq->read_pos = 0;++ return finish_ret;+}+++extern void+lzma_outq_enable_partial_output(lzma_outq *outq,+ void (*enable_partial_output)(void *worker))+{+ if (outq->head != NULL && !outq->head->finished+ && outq->head->worker != NULL) {+ enable_partial_output(outq->head->worker);++ // Set it to NULL since calling it twice is pointless.+ outq->head->worker = NULL;+ }++ return;+}
+ cbits/liblzma/common/outqueue.h view
@@ -0,0 +1,258 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file outqueue.h+/// \brief Output queue handling in multithreaded coding+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_OUTQUEUE_H+#define LZMA_OUTQUEUE_H++#include "common.h"+++/// Output buffer for a single thread+typedef struct lzma_outbuf_s lzma_outbuf;+struct lzma_outbuf_s {+ /// Pointer to the next buffer. This is used for the cached buffers.+ /// The worker thread must not modify this.+ lzma_outbuf *next;++ /// This initialized by lzma_outq_get_buf() and+ /// is used by lzma_outq_enable_partial_output().+ /// The worker thread must not modify this.+ void *worker;++ /// Amount of memory allocated for buf[].+ /// The worker thread must not modify this.+ size_t allocated;++ /// Writing position in the worker thread or, in other words, the+ /// amount of finished data written to buf[] which can be copied out+ ///+ /// \note This is read by another thread and thus access+ /// to this variable needs a mutex.+ size_t pos;++ /// Decompression: Position in the input buffer in the worker thread+ /// that matches the output "pos" above. This is used to detect if+ /// more output might be possible from the worker thread: if it has+ /// consumed all its input, then more output isn't possible.+ ///+ /// \note This is read by another thread and thus access+ /// to this variable needs a mutex.+ size_t decoder_in_pos;++ /// True when no more data will be written into this buffer.+ ///+ /// \note This is read by another thread and thus access+ /// to this variable needs a mutex.+ bool finished;++ /// Return value for lzma_outq_read() when the last byte from+ /// a finished buffer has been read. Defaults to LZMA_STREAM_END.+ /// This must *not* be LZMA_OK. The idea is to allow a decoder to+ /// pass an error code to the main thread, setting the code here+ /// together with finished = true.+ lzma_ret finish_ret;++ /// Additional size information. lzma_outq_read() may read these+ /// when "finished" is true.+ lzma_vli unpadded_size;+ lzma_vli uncompressed_size;++ /// Buffer of "allocated" bytes+ uint8_t buf[];+};+++typedef struct {+ /// Linked list of buffers in use. The next output byte will be+ /// read from the head and buffers for the next thread will be+ /// appended to the tail. tail->next is always NULL.+ lzma_outbuf *head;+ lzma_outbuf *tail;++ /// Number of bytes read from head->buf[] in lzma_outq_read()+ size_t read_pos;++ /// Linked list of allocated buffers that aren't currently used.+ /// This way buffers of similar size can be reused and don't+ /// need to be reallocated every time. For simplicity, all+ /// cached buffers in the list have the same allocated size.+ lzma_outbuf *cache;++ /// Total amount of memory allocated for buffers+ uint64_t mem_allocated;++ /// Amount of memory used by the buffers that are in use in+ /// the head...tail linked list.+ uint64_t mem_in_use;++ /// Number of buffers in use in the head...tail list. If and only if+ /// this is zero, the pointers head and tail above are NULL.+ uint32_t bufs_in_use;++ /// Number of buffers allocated (in use + cached)+ uint32_t bufs_allocated;++ /// Maximum allowed number of allocated buffers+ uint32_t bufs_limit;+} lzma_outq;+++/**+ * \brief Calculate the memory usage of an output queue+ *+ * \return Approximate memory usage in bytes or UINT64_MAX on error.+ */+extern uint64_t lzma_outq_memusage(uint64_t buf_size_max, uint32_t threads);+++/// \brief Initialize an output queue+///+/// \param outq Pointer to an output queue. Before calling+/// this function the first time, *outq should+/// have been zeroed with memzero() so that this+/// function knows that there are no previous+/// allocations to free.+/// \param allocator Pointer to allocator or NULL+/// \param threads Number of buffers that may be in use+/// concurrently. Note that more than this number+/// of buffers may actually get allocated to+/// improve performance when buffers finish+/// out of order. The actual maximum number of+/// allocated buffers is derived from the number+/// of threads.+///+/// \return - LZMA_OK+/// - LZMA_MEM_ERROR+///+extern lzma_ret lzma_outq_init(lzma_outq *outq,+ const lzma_allocator *allocator, uint32_t threads);+++/// \brief Free the memory associated with the output queue+extern void lzma_outq_end(lzma_outq *outq, const lzma_allocator *allocator);+++/// \brief Free all cached buffers that consume memory but aren't in use+extern void lzma_outq_clear_cache(+ lzma_outq *outq, const lzma_allocator *allocator);+++/// \brief Like lzma_outq_clear_cache() but might keep one buffer+///+/// One buffer is not freed if its size is equal to keep_size.+/// This is useful if the caller knows that it will soon need a buffer of+/// keep_size bytes. This way it won't be freed and immediately reallocated.+extern void lzma_outq_clear_cache2(+ lzma_outq *outq, const lzma_allocator *allocator,+ size_t keep_size);+++/// \brief Preallocate a new buffer into cache+///+/// Splitting the buffer allocation into a separate function makes it+/// possible to ensure that way lzma_outq_get_buf() cannot fail.+/// If the preallocated buffer isn't actually used (for example, some+/// other error occurs), the caller has to do nothing as the buffer will+/// be used later or cleared from the cache when not needed.+///+/// \return LZMA_OK on success, LZMA_MEM_ERROR if allocation fails+///+extern lzma_ret lzma_outq_prealloc_buf(+ lzma_outq *outq, const lzma_allocator *allocator, size_t size);+++/// \brief Get a new buffer+///+/// lzma_outq_prealloc_buf() must be used to ensure that there is a buffer+/// available before calling lzma_outq_get_buf().+///+extern lzma_outbuf *lzma_outq_get_buf(lzma_outq *outq, void *worker);+++/// \brief Test if there is data ready to be read+///+/// Call to this function must be protected with the same mutex that+/// is used to protect lzma_outbuf.finished.+///+extern bool lzma_outq_is_readable(const lzma_outq *outq);+++/// \brief Read finished data+///+/// \param outq Pointer to an output queue+/// \param out Beginning of the output buffer+/// \param out_pos The next byte will be written to+/// out[*out_pos].+/// \param out_size Size of the out buffer; the first byte into+/// which no data is written to is out[out_size].+/// \param unpadded_size Unpadded Size from the Block encoder+/// \param uncompressed_size Uncompressed Size from the Block encoder+///+/// \return - LZMA: All OK. Either no data was available or the buffer+/// being read didn't become empty yet.+/// - LZMA_STREAM_END: The buffer being read was finished.+/// *unpadded_size and *uncompressed_size were set if they+/// were not NULL.+///+/// \note This reads lzma_outbuf.finished and .pos variables and thus+/// calls to this function need to be protected with a mutex.+///+extern lzma_ret lzma_outq_read(lzma_outq *restrict outq,+ const lzma_allocator *restrict allocator,+ uint8_t *restrict out, size_t *restrict out_pos,+ size_t out_size, lzma_vli *restrict unpadded_size,+ lzma_vli *restrict uncompressed_size);+++/// \brief Enable partial output from a worker thread+///+/// If the buffer at the head of the output queue isn't finished,+/// this will call enable_partial_output on the worker associated with+/// that output buffer.+///+/// \note This reads a lzma_outbuf.finished variable and thus+/// calls to this function need to be protected with a mutex.+///+extern void lzma_outq_enable_partial_output(lzma_outq *outq,+ void (*enable_partial_output)(void *worker));+++/// \brief Test if there is at least one buffer free+///+/// This must be used before getting a new buffer with lzma_outq_get_buf().+///+static inline bool+lzma_outq_has_buf(const lzma_outq *outq)+{+ return outq->bufs_in_use < outq->bufs_limit;+}+++/// \brief Test if the queue is completely empty+static inline bool+lzma_outq_is_empty(const lzma_outq *outq)+{+ return outq->bufs_in_use == 0;+}+++/// \brief Get the amount of memory needed for a single lzma_outbuf+///+/// \note Caller must check that the argument is significantly less+/// than SIZE_MAX to avoid an integer overflow!+static inline uint64_t+lzma_outq_outbuf_memusage(size_t buf_size)+{+ assert(buf_size <= SIZE_MAX - sizeof(lzma_outbuf));+ return sizeof(lzma_outbuf) + buf_size;+}++#endif
+ cbits/liblzma/common/stream_buffer_decoder.c view
@@ -0,0 +1,90 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file stream_buffer_decoder.c+/// \brief Single-call .xz Stream decoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "stream_decoder.h"+++extern LZMA_API(lzma_ret)+lzma_stream_buffer_decode(uint64_t *memlimit, uint32_t flags,+ const lzma_allocator *allocator,+ const uint8_t *in, size_t *in_pos, size_t in_size,+ uint8_t *out, size_t *out_pos, size_t out_size)+{+ // Sanity checks+ if (in_pos == NULL || (in == NULL && *in_pos != in_size)+ || *in_pos > in_size || out_pos == NULL+ || (out == NULL && *out_pos != out_size)+ || *out_pos > out_size)+ return LZMA_PROG_ERROR;++ // Catch flags that are not allowed in buffer-to-buffer decoding.+ if (flags & LZMA_TELL_ANY_CHECK)+ return LZMA_PROG_ERROR;++ // Initialize the Stream decoder.+ // TODO: We need something to tell the decoder that it can use the+ // output buffer as workspace, and thus save significant amount of RAM.+ lzma_next_coder stream_decoder = LZMA_NEXT_CODER_INIT;+ lzma_ret ret = lzma_stream_decoder_init(+ &stream_decoder, allocator, *memlimit, flags);++ if (ret == LZMA_OK) {+ // Save the positions so that we can restore them in case+ // an error occurs.+ const size_t in_start = *in_pos;+ const size_t out_start = *out_pos;++ // Do the actual decoding.+ ret = stream_decoder.code(stream_decoder.coder, allocator,+ in, in_pos, in_size, out, out_pos, out_size,+ LZMA_FINISH);++ if (ret == LZMA_STREAM_END) {+ ret = LZMA_OK;+ } else {+ // Something went wrong, restore the positions.+ *in_pos = in_start;+ *out_pos = out_start;++ if (ret == LZMA_OK) {+ // Either the input was truncated or the+ // output buffer was too small.+ assert(*in_pos == in_size+ || *out_pos == out_size);++ // If all the input was consumed, then the+ // input is truncated, even if the output+ // buffer is also full. This is because+ // processing the last byte of the Stream+ // never produces output.+ if (*in_pos == in_size)+ ret = LZMA_DATA_ERROR;+ else+ ret = LZMA_BUF_ERROR;++ } else if (ret == LZMA_MEMLIMIT_ERROR) {+ // Let the caller know how much memory would+ // have been needed.+ uint64_t memusage;+ (void)stream_decoder.memconfig(+ stream_decoder.coder,+ memlimit, &memusage, 0);+ }+ }+ }++ // Free the decoder memory. This needs to be done even if+ // initialization fails, because the internal API doesn't+ // require the initialization function to free its memory on error.+ lzma_next_end(&stream_decoder, allocator);++ return ret;+}
+ cbits/liblzma/common/stream_buffer_encoder.c view
@@ -0,0 +1,141 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file stream_buffer_encoder.c+/// \brief Single-call .xz Stream encoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+#include "index.h"+++/// Maximum size of Index that has exactly one Record.+/// Index Indicator + Number of Records + Record + CRC32 rounded up to+/// the next multiple of four.+#define INDEX_BOUND ((1 + 1 + 2 * LZMA_VLI_BYTES_MAX + 4 + 3) & ~3)++/// Stream Header, Stream Footer, and Index+#define HEADERS_BOUND (2 * LZMA_STREAM_HEADER_SIZE + INDEX_BOUND)+++extern LZMA_API(size_t)+lzma_stream_buffer_bound(size_t uncompressed_size)+{+ // Get the maximum possible size of a Block.+ const size_t block_bound = lzma_block_buffer_bound(uncompressed_size);+ if (block_bound == 0)+ return 0;++ // Catch the possible integer overflow and also prevent the size of+ // the Stream exceeding LZMA_VLI_MAX (theoretically possible on+ // 64-bit systems).+ if (my_min(SIZE_MAX, LZMA_VLI_MAX) - block_bound < HEADERS_BOUND)+ return 0;++ return block_bound + HEADERS_BOUND;+}+++extern LZMA_API(lzma_ret)+lzma_stream_buffer_encode(lzma_filter *filters, lzma_check check,+ const lzma_allocator *allocator,+ const uint8_t *in, size_t in_size,+ uint8_t *out, size_t *out_pos_ptr, size_t out_size)+{+ // Sanity checks+ if (filters == NULL || (unsigned int)(check) > LZMA_CHECK_ID_MAX+ || (in == NULL && in_size != 0) || out == NULL+ || out_pos_ptr == NULL || *out_pos_ptr > out_size)+ return LZMA_PROG_ERROR;++ if (!lzma_check_is_supported(check))+ return LZMA_UNSUPPORTED_CHECK;++ // Note for the paranoids: Index encoder prevents the Stream from+ // getting too big and still being accepted with LZMA_OK, and Block+ // encoder catches if the input is too big. So we don't need to+ // separately check if the buffers are too big.++ // Use a local copy. We update *out_pos_ptr only if everything+ // succeeds.+ size_t out_pos = *out_pos_ptr;++ // Check that there's enough space for both Stream Header and+ // Stream Footer.+ if (out_size - out_pos <= 2 * LZMA_STREAM_HEADER_SIZE)+ return LZMA_BUF_ERROR;++ // Reserve space for Stream Footer so we don't need to check for+ // available space again before encoding Stream Footer.+ out_size -= LZMA_STREAM_HEADER_SIZE;++ // Encode the Stream Header.+ lzma_stream_flags stream_flags = {+ .version = 0,+ .check = check,+ };++ if (lzma_stream_header_encode(&stream_flags, out + out_pos)+ != LZMA_OK)+ return LZMA_PROG_ERROR;++ out_pos += LZMA_STREAM_HEADER_SIZE;++ // Encode a Block but only if there is at least one byte of input.+ lzma_block block = {+ .version = 0,+ .check = check,+ .filters = filters,+ };++ if (in_size > 0)+ return_if_error(lzma_block_buffer_encode(&block, allocator,+ in, in_size, out, &out_pos, out_size));++ // Index+ {+ // Create an Index. It will have one Record if there was+ // at least one byte of input to encode. Otherwise the+ // Index will be empty.+ lzma_index *i = lzma_index_init(allocator);+ if (i == NULL)+ return LZMA_MEM_ERROR;++ lzma_ret ret = LZMA_OK;++ if (in_size > 0)+ ret = lzma_index_append(i, allocator,+ lzma_block_unpadded_size(&block),+ block.uncompressed_size);++ // If adding the Record was successful, encode the Index+ // and get its size which will be stored into Stream Footer.+ if (ret == LZMA_OK) {+ ret = lzma_index_buffer_encode(+ i, out, &out_pos, out_size);++ stream_flags.backward_size = lzma_index_size(i);+ }++ lzma_index_end(i, allocator);++ if (ret != LZMA_OK)+ return ret;+ }++ // Stream Footer. We have already reserved space for this.+ if (lzma_stream_footer_encode(&stream_flags, out + out_pos)+ != LZMA_OK)+ return LZMA_PROG_ERROR;++ out_pos += LZMA_STREAM_HEADER_SIZE;++ // Everything went fine, make the new output position available+ // to the application.+ *out_pos_ptr = out_pos;+ return LZMA_OK;+}
+ cbits/liblzma/common/stream_decoder.c view
@@ -0,0 +1,473 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file stream_decoder.c+/// \brief Decodes .xz Streams+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "stream_decoder.h"+#include "block_decoder.h"+#include "index.h"+++typedef struct {+ enum {+ SEQ_STREAM_HEADER,+ SEQ_BLOCK_HEADER,+ SEQ_BLOCK_INIT,+ SEQ_BLOCK_RUN,+ SEQ_INDEX,+ SEQ_STREAM_FOOTER,+ SEQ_STREAM_PADDING,+ } sequence;++ /// Block decoder+ lzma_next_coder block_decoder;++ /// Block options decoded by the Block Header decoder and used by+ /// the Block decoder.+ lzma_block block_options;++ /// Stream Flags from Stream Header+ lzma_stream_flags stream_flags;++ /// Index is hashed so that it can be compared to the sizes of Blocks+ /// with O(1) memory usage.+ lzma_index_hash *index_hash;++ /// Memory usage limit+ uint64_t memlimit;++ /// Amount of memory actually needed (only an estimate)+ uint64_t memusage;++ /// If true, LZMA_NO_CHECK is returned if the Stream has+ /// no integrity check.+ bool tell_no_check;++ /// If true, LZMA_UNSUPPORTED_CHECK is returned if the Stream has+ /// an integrity check that isn't supported by this liblzma build.+ bool tell_unsupported_check;++ /// If true, LZMA_GET_CHECK is returned after decoding Stream Header.+ bool tell_any_check;++ /// If true, we will tell the Block decoder to skip calculating+ /// and verifying the integrity check.+ bool ignore_check;++ /// If true, we will decode concatenated Streams that possibly have+ /// Stream Padding between or after them. LZMA_STREAM_END is returned+ /// once the application isn't giving us any new input (LZMA_FINISH),+ /// and we aren't in the middle of a Stream, and possible+ /// Stream Padding is a multiple of four bytes.+ bool concatenated;++ /// When decoding concatenated Streams, this is true as long as we+ /// are decoding the first Stream. This is needed to avoid misleading+ /// LZMA_FORMAT_ERROR in case the later Streams don't have valid magic+ /// bytes.+ bool first_stream;++ /// Write position in buffer[] and position in Stream Padding+ size_t pos;++ /// Buffer to hold Stream Header, Block Header, and Stream Footer.+ /// Block Header has biggest maximum size.+ uint8_t buffer[LZMA_BLOCK_HEADER_SIZE_MAX];+} lzma_stream_coder;+++static lzma_ret+stream_decoder_reset(lzma_stream_coder *coder, const lzma_allocator *allocator)+{+ // Initialize the Index hash used to verify the Index.+ coder->index_hash = lzma_index_hash_init(coder->index_hash, allocator);+ if (coder->index_hash == NULL)+ return LZMA_MEM_ERROR;++ // Reset the rest of the variables.+ coder->sequence = SEQ_STREAM_HEADER;+ coder->pos = 0;++ return LZMA_OK;+}+++static lzma_ret+stream_decode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size, lzma_action action)+{+ lzma_stream_coder *coder = coder_ptr;++ // When decoding the actual Block, it may be able to produce more+ // output even if we don't give it any new input.+ while (true)+ switch (coder->sequence) {+ case SEQ_STREAM_HEADER: {+ // Copy the Stream Header to the internal buffer.+ lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,+ LZMA_STREAM_HEADER_SIZE);++ // Return if we didn't get the whole Stream Header yet.+ if (coder->pos < LZMA_STREAM_HEADER_SIZE)+ return LZMA_OK;++ coder->pos = 0;++ // Decode the Stream Header.+ const lzma_ret ret = lzma_stream_header_decode(+ &coder->stream_flags, coder->buffer);+ if (ret != LZMA_OK)+ return ret == LZMA_FORMAT_ERROR && !coder->first_stream+ ? LZMA_DATA_ERROR : ret;++ // If we are decoding concatenated Streams, and the later+ // Streams have invalid Header Magic Bytes, we give+ // LZMA_DATA_ERROR instead of LZMA_FORMAT_ERROR.+ coder->first_stream = false;++ // Copy the type of the Check so that Block Header and Block+ // decoders see it.+ coder->block_options.check = coder->stream_flags.check;++ // Even if we return LZMA_*_CHECK below, we want+ // to continue from Block Header decoding.+ coder->sequence = SEQ_BLOCK_HEADER;++ // Detect if there's no integrity check or if it is+ // unsupported if those were requested by the application.+ if (coder->tell_no_check && coder->stream_flags.check+ == LZMA_CHECK_NONE)+ return LZMA_NO_CHECK;++ if (coder->tell_unsupported_check+ && !lzma_check_is_supported(+ coder->stream_flags.check))+ return LZMA_UNSUPPORTED_CHECK;++ if (coder->tell_any_check)+ return LZMA_GET_CHECK;+ }++ // Fall through++ case SEQ_BLOCK_HEADER: {+ if (*in_pos >= in_size)+ return LZMA_OK;++ if (coder->pos == 0) {+ // Detect if it's Index.+ if (in[*in_pos] == INDEX_INDICATOR) {+ coder->sequence = SEQ_INDEX;+ break;+ }++ // Calculate the size of the Block Header. Note that+ // Block Header decoder wants to see this byte too+ // so don't advance *in_pos.+ coder->block_options.header_size+ = lzma_block_header_size_decode(+ in[*in_pos]);+ }++ // Copy the Block Header to the internal buffer.+ lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,+ coder->block_options.header_size);++ // Return if we didn't get the whole Block Header yet.+ if (coder->pos < coder->block_options.header_size)+ return LZMA_OK;++ coder->pos = 0;+ coder->sequence = SEQ_BLOCK_INIT;+ }++ // Fall through++ case SEQ_BLOCK_INIT: {+ // Checking memusage and doing the initialization needs+ // its own sequence point because we need to be able to+ // retry if we return LZMA_MEMLIMIT_ERROR.++ // Version 1 is needed to support the .ignore_check option.+ coder->block_options.version = 1;++ // Set up a buffer to hold the filter chain. Block Header+ // decoder will initialize all members of this array so+ // we don't need to do it here.+ lzma_filter filters[LZMA_FILTERS_MAX + 1];+ coder->block_options.filters = filters;++ // Decode the Block Header.+ return_if_error(lzma_block_header_decode(&coder->block_options,+ allocator, coder->buffer));++ // If LZMA_IGNORE_CHECK was used, this flag needs to be set.+ // It has to be set after lzma_block_header_decode() because+ // it always resets this to false.+ coder->block_options.ignore_check = coder->ignore_check;++ // Check the memory usage limit.+ const uint64_t memusage = lzma_raw_decoder_memusage(filters);+ lzma_ret ret;++ if (memusage == UINT64_MAX) {+ // One or more unknown Filter IDs.+ ret = LZMA_OPTIONS_ERROR;+ } else {+ // Now we can set coder->memusage since we know that+ // the filter chain is valid. We don't want+ // lzma_memusage() to return UINT64_MAX in case of+ // invalid filter chain.+ coder->memusage = memusage;++ if (memusage > coder->memlimit) {+ // The chain would need too much memory.+ ret = LZMA_MEMLIMIT_ERROR;+ } else {+ // Memory usage is OK.+ // Initialize the Block decoder.+ ret = lzma_block_decoder_init(+ &coder->block_decoder,+ allocator,+ &coder->block_options);+ }+ }++ // Free the allocated filter options since they are needed+ // only to initialize the Block decoder.+ lzma_filters_free(filters, allocator);+ coder->block_options.filters = NULL;++ // Check if memory usage calculation and Block decoder+ // initialization succeeded.+ if (ret != LZMA_OK)+ return ret;++ coder->sequence = SEQ_BLOCK_RUN;+ }++ // Fall through++ case SEQ_BLOCK_RUN: {+ const lzma_ret ret = coder->block_decoder.code(+ coder->block_decoder.coder, allocator,+ in, in_pos, in_size, out, out_pos, out_size,+ action);++ if (ret != LZMA_STREAM_END)+ return ret;++ // Block decoded successfully. Add the new size pair to+ // the Index hash.+ return_if_error(lzma_index_hash_append(coder->index_hash,+ lzma_block_unpadded_size(+ &coder->block_options),+ coder->block_options.uncompressed_size));++ coder->sequence = SEQ_BLOCK_HEADER;+ break;+ }++ case SEQ_INDEX: {+ // If we don't have any input, don't call+ // lzma_index_hash_decode() since it would return+ // LZMA_BUF_ERROR, which we must not do here.+ if (*in_pos >= in_size)+ return LZMA_OK;++ // Decode the Index and compare it to the hash calculated+ // from the sizes of the Blocks (if any).+ const lzma_ret ret = lzma_index_hash_decode(coder->index_hash,+ in, in_pos, in_size);+ if (ret != LZMA_STREAM_END)+ return ret;++ coder->sequence = SEQ_STREAM_FOOTER;+ }++ // Fall through++ case SEQ_STREAM_FOOTER: {+ // Copy the Stream Footer to the internal buffer.+ lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,+ LZMA_STREAM_HEADER_SIZE);++ // Return if we didn't get the whole Stream Footer yet.+ if (coder->pos < LZMA_STREAM_HEADER_SIZE)+ return LZMA_OK;++ coder->pos = 0;++ // Decode the Stream Footer. The decoder gives+ // LZMA_FORMAT_ERROR if the magic bytes don't match,+ // so convert that return code to LZMA_DATA_ERROR.+ lzma_stream_flags footer_flags;+ const lzma_ret ret = lzma_stream_footer_decode(+ &footer_flags, coder->buffer);+ if (ret != LZMA_OK)+ return ret == LZMA_FORMAT_ERROR+ ? LZMA_DATA_ERROR : ret;++ // Check that Index Size stored in the Stream Footer matches+ // the real size of the Index field.+ if (lzma_index_hash_size(coder->index_hash)+ != footer_flags.backward_size)+ return LZMA_DATA_ERROR;++ // Compare that the Stream Flags fields are identical in+ // both Stream Header and Stream Footer.+ return_if_error(lzma_stream_flags_compare(+ &coder->stream_flags, &footer_flags));++ if (!coder->concatenated)+ return LZMA_STREAM_END;++ coder->sequence = SEQ_STREAM_PADDING;+ }++ // Fall through++ case SEQ_STREAM_PADDING:+ assert(coder->concatenated);++ // Skip over possible Stream Padding.+ while (true) {+ if (*in_pos >= in_size) {+ // Unless LZMA_FINISH was used, we cannot+ // know if there's more input coming later.+ if (action != LZMA_FINISH)+ return LZMA_OK;++ // Stream Padding must be a multiple of+ // four bytes.+ return coder->pos == 0+ ? LZMA_STREAM_END+ : LZMA_DATA_ERROR;+ }++ // If the byte is not zero, it probably indicates+ // beginning of a new Stream (or the file is corrupt).+ if (in[*in_pos] != 0x00)+ break;++ ++*in_pos;+ coder->pos = (coder->pos + 1) & 3;+ }++ // Stream Padding must be a multiple of four bytes (empty+ // Stream Padding is OK).+ if (coder->pos != 0) {+ ++*in_pos;+ return LZMA_DATA_ERROR;+ }++ // Prepare to decode the next Stream.+ return_if_error(stream_decoder_reset(coder, allocator));+ break;++ default:+ assert(0);+ return LZMA_PROG_ERROR;+ }++ // Never reached+}+++static void+stream_decoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_stream_coder *coder = coder_ptr;+ lzma_next_end(&coder->block_decoder, allocator);+ lzma_index_hash_end(coder->index_hash, allocator);+ lzma_free(coder, allocator);+ return;+}+++static lzma_check+stream_decoder_get_check(const void *coder_ptr)+{+ const lzma_stream_coder *coder = coder_ptr;+ return coder->stream_flags.check;+}+++static lzma_ret+stream_decoder_memconfig(void *coder_ptr, uint64_t *memusage,+ uint64_t *old_memlimit, uint64_t new_memlimit)+{+ lzma_stream_coder *coder = coder_ptr;++ *memusage = coder->memusage;+ *old_memlimit = coder->memlimit;++ if (new_memlimit != 0) {+ if (new_memlimit < coder->memusage)+ return LZMA_MEMLIMIT_ERROR;++ coder->memlimit = new_memlimit;+ }++ return LZMA_OK;+}+++extern lzma_ret+lzma_stream_decoder_init(+ lzma_next_coder *next, const lzma_allocator *allocator,+ uint64_t memlimit, uint32_t flags)+{+ lzma_next_coder_init(&lzma_stream_decoder_init, next, allocator);++ if (flags & ~LZMA_SUPPORTED_FLAGS)+ return LZMA_OPTIONS_ERROR;++ lzma_stream_coder *coder = next->coder;+ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_stream_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = &stream_decode;+ next->end = &stream_decoder_end;+ next->get_check = &stream_decoder_get_check;+ next->memconfig = &stream_decoder_memconfig;++ coder->block_decoder = LZMA_NEXT_CODER_INIT;+ coder->index_hash = NULL;+ }++ coder->memlimit = my_max(1, memlimit);+ coder->memusage = LZMA_MEMUSAGE_BASE;+ coder->tell_no_check = (flags & LZMA_TELL_NO_CHECK) != 0;+ coder->tell_unsupported_check+ = (flags & LZMA_TELL_UNSUPPORTED_CHECK) != 0;+ coder->tell_any_check = (flags & LZMA_TELL_ANY_CHECK) != 0;+ coder->ignore_check = (flags & LZMA_IGNORE_CHECK) != 0;+ coder->concatenated = (flags & LZMA_CONCATENATED) != 0;+ coder->first_stream = true;++ return stream_decoder_reset(coder, allocator);+}+++extern LZMA_API(lzma_ret)+lzma_stream_decoder(lzma_stream *strm, uint64_t memlimit, uint32_t flags)+{+ lzma_next_strm_init(lzma_stream_decoder_init, strm, memlimit, flags);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}
+ cbits/liblzma/common/stream_decoder.h view
@@ -0,0 +1,21 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file stream_decoder.h+/// \brief Decodes .xz Streams+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_STREAM_DECODER_H+#define LZMA_STREAM_DECODER_H++#include "common.h"++extern lzma_ret lzma_stream_decoder_init(+ lzma_next_coder *next, const lzma_allocator *allocator,+ uint64_t memlimit, uint32_t flags);++#endif
+ cbits/liblzma/common/stream_decoder_mt.c view
@@ -0,0 +1,2017 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file stream_decoder_mt.c+/// \brief Multithreaded .xz Stream decoder+//+// Authors: Sebastian Andrzej Siewior+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+#include "block_decoder.h"+#include "stream_decoder.h"+#include "index.h"+#include "outqueue.h"+++typedef enum {+ /// Waiting for work.+ /// Main thread may change this to THR_RUN or THR_EXIT.+ THR_IDLE,++ /// Decoding is in progress.+ /// Main thread may change this to THR_STOP or THR_EXIT.+ /// The worker thread may change this to THR_IDLE.+ THR_RUN,++ /// The main thread wants the thread to stop whatever it was doing+ /// but not exit. Main thread may change this to THR_EXIT.+ /// The worker thread may change this to THR_IDLE.+ THR_STOP,++ /// The main thread wants the thread to exit.+ THR_EXIT,++} worker_state;+++typedef enum {+ /// Partial updates (storing of worker thread progress+ /// to lzma_outbuf) are disabled.+ PARTIAL_DISABLED,++ /// Main thread requests partial updates to be enabled but+ /// no partial update has been done by the worker thread yet.+ ///+ /// Changing from PARTIAL_DISABLED to PARTIAL_START requires+ /// use of the worker-thread mutex. Other transitions don't+ /// need a mutex.+ PARTIAL_START,++ /// Partial updates are enabled and the worker thread has done+ /// at least one partial update.+ PARTIAL_ENABLED,++} partial_update_mode;+++struct worker_thread {+ /// Worker state is protected with our mutex.+ worker_state state;++ /// Input buffer that will contain the whole Block except Block Header.+ uint8_t *in;++ /// Amount of memory allocated for "in"+ size_t in_size;++ /// Number of bytes written to "in" by the main thread+ size_t in_filled;++ /// Number of bytes consumed from "in" by the worker thread.+ size_t in_pos;++ /// Amount of uncompressed data that has been decoded. This local+ /// copy is needed because updating outbuf->pos requires locking+ /// the main mutex (coder->mutex).+ size_t out_pos;++ /// Pointer to the main structure is needed to (1) lock the main+ /// mutex (coder->mutex) when updating outbuf->pos and (2) when+ /// putting this thread back to the stack of free threads.+ struct lzma_stream_coder *coder;++ /// The allocator is set by the main thread. Since a copy of the+ /// pointer is kept here, the application must not change the+ /// allocator before calling lzma_end().+ const lzma_allocator *allocator;++ /// Output queue buffer to which the uncompressed data is written.+ lzma_outbuf *outbuf;++ /// Amount of compressed data that has already been decompressed.+ /// This is updated from in_pos when our mutex is locked.+ /// This is size_t, not uint64_t, because per-thread progress+ /// is limited to sizes of allocated buffers.+ size_t progress_in;++ /// Like progress_in but for uncompressed data.+ size_t progress_out;++ /// Updating outbuf->pos requires locking the main mutex+ /// (coder->mutex). Since the main thread will only read output+ /// from the oldest outbuf in the queue, only the worker thread+ /// that is associated with the oldest outbuf needs to update its+ /// outbuf->pos. This avoids useless mutex contention that would+ /// happen if all worker threads were frequently locking the main+ /// mutex to update their outbuf->pos.+ ///+ /// Only when partial_update is something else than PARTIAL_DISABLED,+ /// this worker thread will update outbuf->pos after each call to+ /// the Block decoder.+ partial_update_mode partial_update;++ /// Block decoder+ lzma_next_coder block_decoder;++ /// Thread-specific Block options are needed because the Block+ /// decoder modifies the struct given to it at initialization.+ lzma_block block_options;++ /// Filter chain memory usage+ uint64_t mem_filters;++ /// Next structure in the stack of free worker threads.+ struct worker_thread *next;++ mythread_mutex mutex;+ mythread_cond cond;++ /// The ID of this thread is used to join the thread+ /// when it's not needed anymore.+ mythread thread_id;+};+++struct lzma_stream_coder {+ enum {+ SEQ_STREAM_HEADER,+ SEQ_BLOCK_HEADER,+ SEQ_BLOCK_INIT,+ SEQ_BLOCK_THR_INIT,+ SEQ_BLOCK_THR_RUN,+ SEQ_BLOCK_DIRECT_INIT,+ SEQ_BLOCK_DIRECT_RUN,+ SEQ_INDEX_WAIT_OUTPUT,+ SEQ_INDEX_DECODE,+ SEQ_STREAM_FOOTER,+ SEQ_STREAM_PADDING,+ SEQ_ERROR,+ } sequence;++ /// Block decoder+ lzma_next_coder block_decoder;++ /// Every Block Header will be decoded into this structure.+ /// This is also used to initialize a Block decoder when in+ /// direct mode. In threaded mode, a thread-specific copy will+ /// be made for decoder initialization because the Block decoder+ /// will modify the structure given to it.+ lzma_block block_options;++ /// Buffer to hold a filter chain for Block Header decoding and+ /// initialization. These are freed after successful Block decoder+ /// initialization or at stream_decoder_mt_end(). The thread-specific+ /// copy of block_options won't hold a pointer to filters[] after+ /// initialization.+ lzma_filter filters[LZMA_FILTERS_MAX + 1];++ /// Stream Flags from Stream Header+ lzma_stream_flags stream_flags;++ /// Index is hashed so that it can be compared to the sizes of Blocks+ /// with O(1) memory usage.+ lzma_index_hash *index_hash;+++ /// Maximum wait time if cannot use all the input and cannot+ /// fill the output buffer. This is in milliseconds.+ uint32_t timeout;+++ /// Error code from a worker thread.+ ///+ /// \note Use mutex.+ lzma_ret thread_error;++ /// Error code to return after pending output has been copied out. If+ /// set in read_output_and_wait(), this is a mirror of thread_error.+ /// If set in stream_decode_mt() then it's, for example, error that+ /// occurred when decoding Block Header.+ lzma_ret pending_error;++ /// Number of threads that will be created at maximum.+ uint32_t threads_max;++ /// Number of thread structures that have been initialized from+ /// "threads", and thus the number of worker threads actually+ /// created so far.+ uint32_t threads_initialized;++ /// Array of allocated thread-specific structures. When no threads+ /// are in use (direct mode) this is NULL. In threaded mode this+ /// points to an array of threads_max number of worker_thread structs.+ struct worker_thread *threads;++ /// Stack of free threads. When a thread finishes, it puts itself+ /// back into this stack. This starts as empty because threads+ /// are created only when actually needed.+ ///+ /// \note Use mutex.+ struct worker_thread *threads_free;++ /// The most recent worker thread to which the main thread writes+ /// the new input from the application.+ struct worker_thread *thr;++ /// Output buffer queue for decompressed data from the worker threads+ ///+ /// \note Use mutex with operations that need it.+ lzma_outq outq;++ mythread_mutex mutex;+ mythread_cond cond;+++ /// Memory usage that will not be exceeded in multi-threaded mode.+ /// Single-threaded mode can exceed this even by a large amount.+ uint64_t memlimit_threading;++ /// Memory usage limit that should never be exceeded.+ /// LZMA_MEMLIMIT_ERROR will be returned if decoding isn't possible+ /// even in single-threaded mode without exceeding this limit.+ uint64_t memlimit_stop;++ /// Amount of memory in use by the direct mode decoder+ /// (coder->block_decoder). In threaded mode this is 0.+ uint64_t mem_direct_mode;++ /// Amount of memory needed by the running worker threads.+ /// This doesn't include the memory needed by the output buffer.+ ///+ /// \note Use mutex.+ uint64_t mem_in_use;++ /// Amount of memory used by the idle (cached) threads.+ ///+ /// \note Use mutex.+ uint64_t mem_cached;+++ /// Amount of memory needed for the filter chain of the next Block.+ uint64_t mem_next_filters;++ /// Amount of memory needed for the thread-specific input buffer+ /// for the next Block.+ uint64_t mem_next_in;++ /// Amount of memory actually needed to decode the next Block+ /// in threaded mode. This is+ /// mem_next_filters + mem_next_in + memory needed for lzma_outbuf.+ uint64_t mem_next_block;+++ /// Amount of compressed data in Stream Header + Blocks that have+ /// already been finished.+ ///+ /// \note Use mutex.+ uint64_t progress_in;++ /// Amount of uncompressed data in Blocks that have already+ /// been finished.+ ///+ /// \note Use mutex.+ uint64_t progress_out;+++ /// If true, LZMA_NO_CHECK is returned if the Stream has+ /// no integrity check.+ bool tell_no_check;++ /// If true, LZMA_UNSUPPORTED_CHECK is returned if the Stream has+ /// an integrity check that isn't supported by this liblzma build.+ bool tell_unsupported_check;++ /// If true, LZMA_GET_CHECK is returned after decoding Stream Header.+ bool tell_any_check;++ /// If true, we will tell the Block decoder to skip calculating+ /// and verifying the integrity check.+ bool ignore_check;++ /// If true, we will decode concatenated Streams that possibly have+ /// Stream Padding between or after them. LZMA_STREAM_END is returned+ /// once the application isn't giving us any new input (LZMA_FINISH),+ /// and we aren't in the middle of a Stream, and possible+ /// Stream Padding is a multiple of four bytes.+ bool concatenated;++ /// If true, we will return any errors immediately instead of first+ /// producing all output before the location of the error.+ bool fail_fast;+++ /// When decoding concatenated Streams, this is true as long as we+ /// are decoding the first Stream. This is needed to avoid misleading+ /// LZMA_FORMAT_ERROR in case the later Streams don't have valid magic+ /// bytes.+ bool first_stream;++ /// This is used to track if the previous call to stream_decode_mt()+ /// had output space (*out_pos < out_size) and managed to fill the+ /// output buffer (*out_pos == out_size). This may be set to true+ /// in read_output_and_wait(). This is read and then reset to false+ /// at the beginning of stream_decode_mt().+ ///+ /// This is needed to support applications that call lzma_code() in+ /// such a way that more input is provided only when lzma_code()+ /// didn't fill the output buffer completely. Basically, this makes+ /// it easier to convert such applications from single-threaded+ /// decoder to multi-threaded decoder.+ bool out_was_filled;++ /// Write position in buffer[] and position in Stream Padding+ size_t pos;++ /// Buffer to hold Stream Header, Block Header, and Stream Footer.+ /// Block Header has biggest maximum size.+ uint8_t buffer[LZMA_BLOCK_HEADER_SIZE_MAX];+};+++/// Enables updating of outbuf->pos. This is a callback function that is+/// used with lzma_outq_enable_partial_output().+static void+worker_enable_partial_update(void *thr_ptr)+{+ struct worker_thread *thr = thr_ptr;++ mythread_sync(thr->mutex) {+ thr->partial_update = PARTIAL_START;+ mythread_cond_signal(&thr->cond);+ }+}+++/// Things do to at THR_STOP or when finishing a Block.+/// This is called with thr->mutex locked.+static void+worker_stop(struct worker_thread *thr)+{+ // Update memory usage counters.+ thr->coder->mem_in_use -= thr->in_size;+ thr->in_size = 0; // thr->in was freed above.++ thr->coder->mem_in_use -= thr->mem_filters;+ thr->coder->mem_cached += thr->mem_filters;++ // Put this thread to the stack of free threads.+ thr->next = thr->coder->threads_free;+ thr->coder->threads_free = thr;++ mythread_cond_signal(&thr->coder->cond);+ return;+}+++static MYTHREAD_RET_TYPE+worker_decoder(void *thr_ptr)+{+ struct worker_thread *thr = thr_ptr;+ size_t in_filled;+ partial_update_mode partial_update;+ lzma_ret ret;++next_loop_lock:++ mythread_mutex_lock(&thr->mutex);+next_loop_unlocked:++ if (thr->state == THR_IDLE) {+ mythread_cond_wait(&thr->cond, &thr->mutex);+ goto next_loop_unlocked;+ }++ if (thr->state == THR_EXIT) {+ mythread_mutex_unlock(&thr->mutex);++ lzma_free(thr->in, thr->allocator);+ lzma_next_end(&thr->block_decoder, thr->allocator);++ mythread_mutex_destroy(&thr->mutex);+ mythread_cond_destroy(&thr->cond);++ return MYTHREAD_RET_VALUE;+ }++ if (thr->state == THR_STOP) {+ thr->state = THR_IDLE;+ mythread_mutex_unlock(&thr->mutex);++ mythread_sync(thr->coder->mutex) {+ worker_stop(thr);+ }++ goto next_loop_lock;+ }++ assert(thr->state == THR_RUN);++ // Update progress info for get_progress().+ thr->progress_in = thr->in_pos;+ thr->progress_out = thr->out_pos;++ // If we don't have any new input, wait for a signal from the main+ // thread except if partial output has just been enabled. In that+ // case we will do one normal run so that the partial output info+ // gets passed to the main thread. The call to block_decoder.code()+ // is useless but harmless as it can occur only once per Block.+ in_filled = thr->in_filled;+ partial_update = thr->partial_update;++ if (in_filled == thr->in_pos && partial_update != PARTIAL_START) {+ mythread_cond_wait(&thr->cond, &thr->mutex);+ goto next_loop_unlocked;+ }++ mythread_mutex_unlock(&thr->mutex);++ // Pass the input in small chunks to the Block decoder.+ // This way we react reasonably fast if we are told to stop/exit,+ // and (when partial update is enabled) we tell about our progress+ // to the main thread frequently enough.+ const size_t chunk_size = 16384;+ if ((in_filled - thr->in_pos) > chunk_size)+ in_filled = thr->in_pos + chunk_size;++ ret = thr->block_decoder.code(+ thr->block_decoder.coder, thr->allocator,+ thr->in, &thr->in_pos, in_filled,+ thr->outbuf->buf, &thr->out_pos,+ thr->outbuf->allocated, LZMA_RUN);++ if (ret == LZMA_OK) {+ if (partial_update != PARTIAL_DISABLED) {+ // The main thread uses thr->mutex to change from+ // PARTIAL_DISABLED to PARTIAL_START. The main thread+ // doesn't care about this variable after that so we+ // can safely change it here to PARTIAL_ENABLED+ // without a mutex.+ thr->partial_update = PARTIAL_ENABLED;++ // The main thread is reading decompressed data+ // from thr->outbuf. Tell the main thread about+ // our progress.+ //+ // NOTE: It's possible that we consumed input without+ // producing any new output so it's possible that+ // only in_pos has changed. In case of PARTIAL_START+ // it is possible that neither in_pos nor out_pos has+ // changed.+ mythread_sync(thr->coder->mutex) {+ thr->outbuf->pos = thr->out_pos;+ thr->outbuf->decoder_in_pos = thr->in_pos;+ mythread_cond_signal(&thr->coder->cond);+ }+ }++ goto next_loop_lock;+ }++ // Either we finished successfully (LZMA_STREAM_END) or an error+ // occurred. Both cases are handled almost identically. The error+ // case requires updating thr->coder->thread_error.+ //+ // The sizes are in the Block Header and the Block decoder+ // checks that they match, thus we know these:+ assert(ret != LZMA_STREAM_END || thr->in_pos == thr->in_size);+ assert(ret != LZMA_STREAM_END+ || thr->out_pos == thr->block_options.uncompressed_size);++ // Free the input buffer. Don't update in_size as we need+ // it later to update thr->coder->mem_in_use.+ lzma_free(thr->in, thr->allocator);+ thr->in = NULL;++ mythread_sync(thr->mutex) {+ if (thr->state != THR_EXIT)+ thr->state = THR_IDLE;+ }++ mythread_sync(thr->coder->mutex) {+ // Move our progress info to the main thread.+ thr->coder->progress_in += thr->in_pos;+ thr->coder->progress_out += thr->out_pos;+ thr->progress_in = 0;+ thr->progress_out = 0;++ // Mark the outbuf as finished.+ thr->outbuf->pos = thr->out_pos;+ thr->outbuf->decoder_in_pos = thr->in_pos;+ thr->outbuf->finished = true;+ thr->outbuf->finish_ret = ret;+ thr->outbuf = NULL;++ // If an error occurred, tell it to the main thread.+ if (ret != LZMA_STREAM_END+ && thr->coder->thread_error == LZMA_OK)+ thr->coder->thread_error = ret;++ worker_stop(thr);+ }++ goto next_loop_lock;+}+++/// Tells the worker threads to exit and waits for them to terminate.+static void+threads_end(struct lzma_stream_coder *coder, const lzma_allocator *allocator)+{+ for (uint32_t i = 0; i < coder->threads_initialized; ++i) {+ mythread_sync(coder->threads[i].mutex) {+ coder->threads[i].state = THR_EXIT;+ mythread_cond_signal(&coder->threads[i].cond);+ }+ }++ for (uint32_t i = 0; i < coder->threads_initialized; ++i)+ mythread_join(coder->threads[i].thread_id);++ lzma_free(coder->threads, allocator);+ coder->threads_initialized = 0;+ coder->threads = NULL;+ coder->threads_free = NULL;++ // The threads don't update these when they exit. Do it here.+ coder->mem_in_use = 0;+ coder->mem_cached = 0;++ return;+}+++static void+threads_stop(struct lzma_stream_coder *coder)+{+ for (uint32_t i = 0; i < coder->threads_initialized; ++i) {+ mythread_sync(coder->threads[i].mutex) {+ // The state must be changed conditionally because+ // THR_IDLE -> THR_STOP is not a valid state change.+ if (coder->threads[i].state != THR_IDLE) {+ coder->threads[i].state = THR_STOP;+ mythread_cond_signal(&coder->threads[i].cond);+ }+ }+ }++ return;+}+++/// Initialize a new worker_thread structure and create a new thread.+static lzma_ret+initialize_new_thread(struct lzma_stream_coder *coder,+ const lzma_allocator *allocator)+{+ // Allocate the coder->threads array if needed. It's done here instead+ // of when initializing the decoder because we don't need this if we+ // use the direct mode (we may even free coder->threads in the middle+ // of the file if we switch from threaded to direct mode).+ if (coder->threads == NULL) {+ coder->threads = lzma_alloc(+ coder->threads_max * sizeof(struct worker_thread),+ allocator);++ if (coder->threads == NULL)+ return LZMA_MEM_ERROR;+ }++ // Pick a free structure.+ assert(coder->threads_initialized < coder->threads_max);+ struct worker_thread *thr+ = &coder->threads[coder->threads_initialized];++ if (mythread_mutex_init(&thr->mutex))+ goto error_mutex;++ if (mythread_cond_init(&thr->cond))+ goto error_cond;++ thr->state = THR_IDLE;+ thr->in = NULL;+ thr->in_size = 0;+ thr->allocator = allocator;+ thr->coder = coder;+ thr->outbuf = NULL;+ thr->block_decoder = LZMA_NEXT_CODER_INIT;+ thr->mem_filters = 0;++ if (mythread_create(&thr->thread_id, worker_decoder, thr))+ goto error_thread;++ ++coder->threads_initialized;+ coder->thr = thr;++ return LZMA_OK;++error_thread:+ mythread_cond_destroy(&thr->cond);++error_cond:+ mythread_mutex_destroy(&thr->mutex);++error_mutex:+ return LZMA_MEM_ERROR;+}+++static lzma_ret+get_thread(struct lzma_stream_coder *coder, const lzma_allocator *allocator)+{+ // If there is a free structure on the stack, use it.+ mythread_sync(coder->mutex) {+ if (coder->threads_free != NULL) {+ coder->thr = coder->threads_free;+ coder->threads_free = coder->threads_free->next;++ // The thread is no longer in the cache so subtract+ // it from the cached memory usage. Don't add it+ // to mem_in_use though; the caller will handle it+ // since it knows how much memory it will actually+ // use (the filter chain might change).+ coder->mem_cached -= coder->thr->mem_filters;+ }+ }++ if (coder->thr == NULL) {+ assert(coder->threads_initialized < coder->threads_max);++ // Initialize a new thread.+ return_if_error(initialize_new_thread(coder, allocator));+ }++ coder->thr->in_filled = 0;+ coder->thr->in_pos = 0;+ coder->thr->out_pos = 0;++ coder->thr->progress_in = 0;+ coder->thr->progress_out = 0;++ coder->thr->partial_update = PARTIAL_DISABLED;++ return LZMA_OK;+}+++static lzma_ret+read_output_and_wait(struct lzma_stream_coder *coder,+ const lzma_allocator *allocator,+ uint8_t *restrict out, size_t *restrict out_pos,+ size_t out_size,+ bool *input_is_possible,+ bool waiting_allowed,+ mythread_condtime *wait_abs, bool *has_blocked)+{+ lzma_ret ret = LZMA_OK;++ mythread_sync(coder->mutex) {+ do {+ // Get as much output from the queue as is possible+ // without blocking.+ const size_t out_start = *out_pos;+ do {+ ret = lzma_outq_read(&coder->outq, allocator,+ out, out_pos, out_size,+ NULL, NULL);++ // If a Block was finished, tell the worker+ // thread of the next Block (if it is still+ // running) to start telling the main thread+ // when new output is available.+ if (ret == LZMA_STREAM_END)+ lzma_outq_enable_partial_output(+ &coder->outq,+ &worker_enable_partial_update);++ // Loop until a Block wasn't finished.+ // It's important to loop around even if+ // *out_pos == out_size because there could+ // be an empty Block that will return+ // LZMA_STREAM_END without needing any+ // output space.+ } while (ret == LZMA_STREAM_END);++ // Check if lzma_outq_read reported an error from+ // the Block decoder.+ if (ret != LZMA_OK)+ break;++ // If the output buffer is now full but it wasn't full+ // when this function was called, set out_was_filled.+ // This way the next call to stream_decode_mt() knows+ // that some output was produced and no output space+ // remained in the previous call to stream_decode_mt().+ if (*out_pos == out_size && *out_pos != out_start)+ coder->out_was_filled = true;++ // Check if any thread has indicated an error.+ if (coder->thread_error != LZMA_OK) {+ // If LZMA_FAIL_FAST was used, report errors+ // from worker threads immediately.+ if (coder->fail_fast) {+ ret = coder->thread_error;+ break;+ }++ // Otherwise set pending_error. The value we+ // set here will not actually get used other+ // than working as a flag that an error has+ // occurred. This is because in SEQ_ERROR+ // all output before the error will be read+ // first by calling this function, and once we+ // reach the location of the (first) error the+ // error code from the above lzma_outq_read()+ // will be returned to the application.+ //+ // Use LZMA_PROG_ERROR since the value should+ // never leak to the application. It's+ // possible that pending_error has already+ // been set but that doesn't matter: if we get+ // here, pending_error only works as a flag.+ coder->pending_error = LZMA_PROG_ERROR;+ }++ // Check if decoding of the next Block can be started.+ // The memusage of the active threads must be low+ // enough, there must be a free buffer slot in the+ // output queue, and there must be a free thread+ // (that can be either created or an existing one+ // reused).+ //+ // NOTE: This is checked after reading the output+ // above because reading the output can free a slot in+ // the output queue and also reduce active memusage.+ //+ // NOTE: If output queue is empty, then input will+ // always be possible.+ if (input_is_possible != NULL+ && coder->memlimit_threading+ - coder->mem_in_use+ - coder->outq.mem_in_use+ >= coder->mem_next_block+ && lzma_outq_has_buf(&coder->outq)+ && (coder->threads_initialized+ < coder->threads_max+ || coder->threads_free+ != NULL)) {+ *input_is_possible = true;+ break;+ }++ // If the caller doesn't want us to block, return now.+ if (!waiting_allowed)+ break;++ // This check is needed only when input_is_possible+ // is NULL. We must return if we aren't waiting for+ // input to become possible and there is no more+ // output coming from the queue.+ if (lzma_outq_is_empty(&coder->outq)) {+ assert(input_is_possible == NULL);+ break;+ }++ // If there is more data available from the queue,+ // our out buffer must be full and we need to return+ // so that the application can provide more output+ // space.+ //+ // NOTE: In general lzma_outq_is_readable() can return+ // true also when there are no more bytes available.+ // This can happen when a Block has finished without+ // providing any new output. We know that this is not+ // the case because in the beginning of this loop we+ // tried to read as much as possible even when we had+ // no output space left and the mutex has been locked+ // all the time (so worker threads cannot have changed+ // anything). Thus there must be actual pending output+ // in the queue.+ if (lzma_outq_is_readable(&coder->outq)) {+ assert(*out_pos == out_size);+ break;+ }++ // If the application stops providing more input+ // in the middle of a Block, there will eventually+ // be one worker thread left that is stuck waiting for+ // more input (that might never arrive) and a matching+ // outbuf which the worker thread cannot finish due+ // to lack of input. We must detect this situation,+ // otherwise we would end up waiting indefinitely+ // (if no timeout is in use) or keep returning+ // LZMA_TIMED_OUT while making no progress. Thus, the+ // application would never get LZMA_BUF_ERROR from+ // lzma_code() which would tell the application that+ // no more progress is possible. No LZMA_BUF_ERROR+ // means that, for example, truncated .xz files could+ // cause an infinite loop.+ //+ // A worker thread doing partial updates will+ // store not only the output position in outbuf->pos+ // but also the matching input position in+ // outbuf->decoder_in_pos. Here we check if that+ // input position matches the amount of input that+ // the worker thread has been given (in_filled).+ // If so, we must return and not wait as no more+ // output will be coming without first getting more+ // input to the worker thread. If the application+ // keeps calling lzma_code() without providing more+ // input, it will eventually get LZMA_BUF_ERROR.+ //+ // NOTE: We can read partial_update and in_filled+ // without thr->mutex as only the main thread+ // modifies these variables. decoder_in_pos requires+ // coder->mutex which we are already holding.+ if (coder->thr != NULL && coder->thr->partial_update+ != PARTIAL_DISABLED) {+ // There is exactly one outbuf in the queue.+ assert(coder->thr->outbuf == coder->outq.head);+ assert(coder->thr->outbuf == coder->outq.tail);++ if (coder->thr->outbuf->decoder_in_pos+ == coder->thr->in_filled)+ break;+ }++ // Wait for input or output to become possible.+ if (coder->timeout != 0) {+ // See the comment in stream_encoder_mt.c+ // about why mythread_condtime_set() is used+ // like this.+ //+ // FIXME?+ // In contrast to the encoder, this calls+ // _condtime_set while the mutex is locked.+ if (!*has_blocked) {+ *has_blocked = true;+ mythread_condtime_set(wait_abs,+ &coder->cond,+ coder->timeout);+ }++ if (mythread_cond_timedwait(&coder->cond,+ &coder->mutex,+ wait_abs) != 0) {+ ret = LZMA_TIMED_OUT;+ break;+ }+ } else {+ mythread_cond_wait(&coder->cond,+ &coder->mutex);+ }+ } while (ret == LZMA_OK);+ }++ // If we are returning an error, then the application cannot get+ // more output from us and thus keeping the threads running is+ // useless and waste of CPU time.+ if (ret != LZMA_OK && ret != LZMA_TIMED_OUT)+ threads_stop(coder);++ return ret;+}+++static lzma_ret+decode_block_header(struct lzma_stream_coder *coder,+ const lzma_allocator *allocator, const uint8_t *restrict in,+ size_t *restrict in_pos, size_t in_size)+{+ if (*in_pos >= in_size)+ return LZMA_OK;++ if (coder->pos == 0) {+ // Detect if it's Index.+ if (in[*in_pos] == INDEX_INDICATOR)+ return LZMA_INDEX_DETECTED;++ // Calculate the size of the Block Header. Note that+ // Block Header decoder wants to see this byte too+ // so don't advance *in_pos.+ coder->block_options.header_size+ = lzma_block_header_size_decode(+ in[*in_pos]);+ }++ // Copy the Block Header to the internal buffer.+ lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,+ coder->block_options.header_size);++ // Return if we didn't get the whole Block Header yet.+ if (coder->pos < coder->block_options.header_size)+ return LZMA_OK;++ coder->pos = 0;++ // Version 1 is needed to support the .ignore_check option.+ coder->block_options.version = 1;++ // Block Header decoder will initialize all members of this array+ // so we don't need to do it here.+ coder->block_options.filters = coder->filters;++ // Decode the Block Header.+ return_if_error(lzma_block_header_decode(&coder->block_options,+ allocator, coder->buffer));++ // If LZMA_IGNORE_CHECK was used, this flag needs to be set.+ // It has to be set after lzma_block_header_decode() because+ // it always resets this to false.+ coder->block_options.ignore_check = coder->ignore_check;++ // coder->block_options is ready now.+ return LZMA_STREAM_END;+}+++/// Get the size of the Compressed Data + Block Padding + Check.+static size_t+comp_blk_size(const struct lzma_stream_coder *coder)+{+ return vli_ceil4(coder->block_options.compressed_size)+ + lzma_check_size(coder->stream_flags.check);+}+++/// Returns true if the size (compressed or uncompressed) is such that+/// threaded decompression cannot be used. Sizes that are too big compared+/// to SIZE_MAX must be rejected to avoid integer overflows and truncations+/// when lzma_vli is assigned to a size_t.+static bool+is_direct_mode_needed(lzma_vli size)+{+ return size == LZMA_VLI_UNKNOWN || size > SIZE_MAX / 3;+}+++static lzma_ret+stream_decoder_reset(struct lzma_stream_coder *coder,+ const lzma_allocator *allocator)+{+ // Initialize the Index hash used to verify the Index.+ coder->index_hash = lzma_index_hash_init(coder->index_hash, allocator);+ if (coder->index_hash == NULL)+ return LZMA_MEM_ERROR;++ // Reset the rest of the variables.+ coder->sequence = SEQ_STREAM_HEADER;+ coder->pos = 0;++ return LZMA_OK;+}+++static lzma_ret+stream_decode_mt(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size,+ uint8_t *restrict out, size_t *restrict out_pos,+ size_t out_size, lzma_action action)+{+ struct lzma_stream_coder *coder = coder_ptr;++ mythread_condtime wait_abs;+ bool has_blocked = false;++ // Determine if in SEQ_BLOCK_HEADER and SEQ_BLOCK_THR_RUN we should+ // tell read_output_and_wait() to wait until it can fill the output+ // buffer (or a timeout occurs). Two conditions must be met:+ //+ // (1) If the caller provided no new input. The reason for this+ // can be, for example, the end of the file or that there is+ // a pause in the input stream and more input is available+ // a little later. In this situation we should wait for output+ // because otherwise we would end up in a busy-waiting loop where+ // we make no progress and the application just calls us again+ // without providing any new input. This would then result in+ // LZMA_BUF_ERROR even though more output would be available+ // once the worker threads decode more data.+ //+ // (2) Even if (1) is true, we will not wait if the previous call to+ // this function managed to produce some output and the output+ // buffer became full. This is for compatibility with applications+ // that call lzma_code() in such a way that new input is provided+ // only when the output buffer didn't become full. Without this+ // trick such applications would have bad performance (bad+ // parallelization due to decoder not getting input fast enough).+ //+ // NOTE: Such loops might require that timeout is disabled (0)+ // if they assume that output-not-full implies that all input has+ // been consumed. If and only if timeout is enabled, we may return+ // when output isn't full *and* not all input has been consumed.+ //+ // However, if LZMA_FINISH is used, the above is ignored and we always+ // wait (timeout can still cause us to return) because we know that+ // we won't get any more input. This matters if the input file is+ // truncated and we are doing single-shot decoding, that is,+ // timeout = 0 and LZMA_FINISH is used on the first call to+ // lzma_code() and the output buffer is known to be big enough+ // to hold all uncompressed data:+ //+ // - If LZMA_FINISH wasn't handled specially, we could return+ // LZMA_OK before providing all output that is possible with the+ // truncated input. The rest would be available if lzma_code() was+ // called again but then it's not single-shot decoding anymore.+ //+ // - By handling LZMA_FINISH specially here, the first call will+ // produce all the output, matching the behavior of the+ // single-threaded decoder.+ //+ // So it's a very specific corner case but also easy to avoid. Note+ // that this special handling of LZMA_FINISH has no effect for+ // single-shot decoding when the input file is valid (not truncated);+ // premature LZMA_OK wouldn't be possible as long as timeout = 0.+ const bool waiting_allowed = action == LZMA_FINISH+ || (*in_pos == in_size && !coder->out_was_filled);+ coder->out_was_filled = false;++ while (true)+ switch (coder->sequence) {+ case SEQ_STREAM_HEADER: {+ // Copy the Stream Header to the internal buffer.+ const size_t in_old = *in_pos;+ lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,+ LZMA_STREAM_HEADER_SIZE);+ coder->progress_in += *in_pos - in_old;++ // Return if we didn't get the whole Stream Header yet.+ if (coder->pos < LZMA_STREAM_HEADER_SIZE)+ return LZMA_OK;++ coder->pos = 0;++ // Decode the Stream Header.+ const lzma_ret ret = lzma_stream_header_decode(+ &coder->stream_flags, coder->buffer);+ if (ret != LZMA_OK)+ return ret == LZMA_FORMAT_ERROR && !coder->first_stream+ ? LZMA_DATA_ERROR : ret;++ // If we are decoding concatenated Streams, and the later+ // Streams have invalid Header Magic Bytes, we give+ // LZMA_DATA_ERROR instead of LZMA_FORMAT_ERROR.+ coder->first_stream = false;++ // Copy the type of the Check so that Block Header and Block+ // decoders see it.+ coder->block_options.check = coder->stream_flags.check;++ // Even if we return LZMA_*_CHECK below, we want+ // to continue from Block Header decoding.+ coder->sequence = SEQ_BLOCK_HEADER;++ // Detect if there's no integrity check or if it is+ // unsupported if those were requested by the application.+ if (coder->tell_no_check && coder->stream_flags.check+ == LZMA_CHECK_NONE)+ return LZMA_NO_CHECK;++ if (coder->tell_unsupported_check+ && !lzma_check_is_supported(+ coder->stream_flags.check))+ return LZMA_UNSUPPORTED_CHECK;++ if (coder->tell_any_check)+ return LZMA_GET_CHECK;+ }++ // Fall through++ case SEQ_BLOCK_HEADER: {+ const size_t in_old = *in_pos;+ const lzma_ret ret = decode_block_header(coder, allocator,+ in, in_pos, in_size);+ coder->progress_in += *in_pos - in_old;++ if (ret == LZMA_OK) {+ // We didn't decode the whole Block Header yet.+ //+ // Read output from the queue before returning. This+ // is important because it is possible that the+ // application doesn't have any new input available+ // immediately. If we didn't try to copy output from+ // the output queue here, lzma_code() could end up+ // returning LZMA_BUF_ERROR even though queued output+ // is available.+ //+ // If the lzma_code() call provided at least one input+ // byte, only copy as much data from the output queue+ // as is available immediately. This way the+ // application will be able to provide more input+ // without a delay.+ //+ // On the other hand, if lzma_code() was called with+ // an empty input buffer(*), treat it specially: try+ // to fill the output buffer even if it requires+ // waiting for the worker threads to provide output+ // (timeout, if specified, can still cause us to+ // return).+ //+ // - This way the application will be able to get all+ // data that can be decoded from the input provided+ // so far.+ //+ // - We avoid both premature LZMA_BUF_ERROR and+ // busy-waiting where the application repeatedly+ // calls lzma_code() which immediately returns+ // LZMA_OK without providing new data.+ //+ // - If the queue becomes empty, we won't wait+ // anything and will return LZMA_OK immediately+ // (coder->timeout is completely ignored).+ //+ // (*) See the comment at the beginning of this+ // function how waiting_allowed is determined+ // and why there is an exception to the rule+ // of "called with an empty input buffer".+ assert(*in_pos == in_size);++ // If LZMA_FINISH was used we know that we won't get+ // more input, so the file must be truncated if we+ // get here. If worker threads don't detect any+ // errors, eventually there will be no more output+ // while we keep returning LZMA_OK which gets+ // converted to LZMA_BUF_ERROR in lzma_code().+ //+ // If fail-fast is enabled then we will return+ // immediately using LZMA_DATA_ERROR instead of+ // LZMA_OK or LZMA_BUF_ERROR. Rationale for the+ // error code:+ //+ // - Worker threads may have a large amount of+ // not-yet-decoded input data and we don't+ // know for sure if all data is valid. Bad+ // data there would result in LZMA_DATA_ERROR+ // when fail-fast isn't used.+ //+ // - Immediate LZMA_BUF_ERROR would be a bit weird+ // considering the older liblzma code. lzma_code()+ // even has an assertion to prevent coders from+ // returning LZMA_BUF_ERROR directly.+ //+ // The downside of this is that with fail-fast apps+ // cannot always distinguish between corrupt and+ // truncated files.+ if (action == LZMA_FINISH && coder->fail_fast) {+ // We won't produce any more output. Stop+ // the unfinished worker threads so they+ // won't waste CPU time.+ threads_stop(coder);+ return LZMA_DATA_ERROR;+ }++ // read_output_and_wait() will call threads_stop()+ // if needed so with that we can use return_if_error.+ return_if_error(read_output_and_wait(coder, allocator,+ out, out_pos, out_size,+ NULL, waiting_allowed,+ &wait_abs, &has_blocked));++ if (coder->pending_error != LZMA_OK) {+ coder->sequence = SEQ_ERROR;+ break;+ }++ return LZMA_OK;+ }++ if (ret == LZMA_INDEX_DETECTED) {+ coder->sequence = SEQ_INDEX_WAIT_OUTPUT;+ break;+ }++ // See if an error occurred.+ if (ret != LZMA_STREAM_END) {+ // NOTE: Here and in all other places where+ // pending_error is set, it may overwrite the value+ // (LZMA_PROG_ERROR) set by read_output_and_wait().+ // That function might overwrite value set here too.+ // These are fine because when read_output_and_wait()+ // sets pending_error, it actually works as a flag+ // variable only ("some error has occurred") and the+ // actual value of pending_error is not used in+ // SEQ_ERROR. In such cases SEQ_ERROR will eventually+ // get the correct error code from the return value of+ // a later read_output_and_wait() call.+ coder->pending_error = ret;+ coder->sequence = SEQ_ERROR;+ break;+ }++ // Calculate the memory usage of the filters / Block decoder.+ coder->mem_next_filters = lzma_raw_decoder_memusage(+ coder->filters);++ if (coder->mem_next_filters == UINT64_MAX) {+ // One or more unknown Filter IDs.+ coder->pending_error = LZMA_OPTIONS_ERROR;+ coder->sequence = SEQ_ERROR;+ break;+ }++ coder->sequence = SEQ_BLOCK_INIT;+ }++ // Fall through++ case SEQ_BLOCK_INIT: {+ // Check if decoding is possible at all with the current+ // memlimit_stop which we must never exceed.+ //+ // This needs to be the first thing in SEQ_BLOCK_INIT+ // to make it possible to restart decoding after increasing+ // memlimit_stop with lzma_memlimit_set().+ if (coder->mem_next_filters > coder->memlimit_stop) {+ // Flush pending output before returning+ // LZMA_MEMLIMIT_ERROR. If the application doesn't+ // want to increase the limit, at least it will get+ // all the output possible so far.+ return_if_error(read_output_and_wait(coder, allocator,+ out, out_pos, out_size,+ NULL, true, &wait_abs, &has_blocked));++ if (!lzma_outq_is_empty(&coder->outq))+ return LZMA_OK;++ return LZMA_MEMLIMIT_ERROR;+ }++ // Check if the size information is available in Block Header.+ // If it is, check if the sizes are small enough that we don't+ // need to worry *too* much about integer overflows later in+ // the code. If these conditions are not met, we must use the+ // single-threaded direct mode.+ if (is_direct_mode_needed(coder->block_options.compressed_size)+ || is_direct_mode_needed(+ coder->block_options.uncompressed_size)) {+ coder->sequence = SEQ_BLOCK_DIRECT_INIT;+ break;+ }++ // Calculate the amount of memory needed for the input and+ // output buffers in threaded mode.+ //+ // These cannot overflow because we already checked that+ // the sizes are small enough using is_direct_mode_needed().+ coder->mem_next_in = comp_blk_size(coder);+ const uint64_t mem_buffers = coder->mem_next_in+ + lzma_outq_outbuf_memusage(+ coder->block_options.uncompressed_size);++ // Add the amount needed by the filters.+ // Avoid integer overflows.+ if (UINT64_MAX - mem_buffers < coder->mem_next_filters) {+ // Use direct mode if the memusage would overflow.+ // This is a theoretical case that shouldn't happen+ // in practice unless the input file is weird (broken+ // or malicious).+ coder->sequence = SEQ_BLOCK_DIRECT_INIT;+ break;+ }++ // Amount of memory needed to decode this Block in+ // threaded mode:+ coder->mem_next_block = coder->mem_next_filters + mem_buffers;++ // If this alone would exceed memlimit_threading, then we must+ // use the single-threaded direct mode.+ if (coder->mem_next_block > coder->memlimit_threading) {+ coder->sequence = SEQ_BLOCK_DIRECT_INIT;+ break;+ }++ // Use the threaded mode. Free the direct mode decoder in+ // case it has been initialized.+ lzma_next_end(&coder->block_decoder, allocator);+ coder->mem_direct_mode = 0;++ // Since we already know what the sizes are supposed to be,+ // we can already add them to the Index hash. The Block+ // decoder will verify the values while decoding.+ const lzma_ret ret = lzma_index_hash_append(coder->index_hash,+ lzma_block_unpadded_size(+ &coder->block_options),+ coder->block_options.uncompressed_size);+ if (ret != LZMA_OK) {+ coder->pending_error = ret;+ coder->sequence = SEQ_ERROR;+ break;+ }++ coder->sequence = SEQ_BLOCK_THR_INIT;+ }++ // Fall through++ case SEQ_BLOCK_THR_INIT: {+ // We need to wait for a multiple conditions to become true+ // until we can initialize the Block decoder and let a worker+ // thread decode it:+ //+ // - Wait for the memory usage of the active threads to drop+ // so that starting the decoding of this Block won't make+ // us go over memlimit_threading.+ //+ // - Wait for at least one free output queue slot.+ //+ // - Wait for a free worker thread.+ //+ // While we wait, we must copy decompressed data to the out+ // buffer and catch possible decoder errors.+ //+ // read_output_and_wait() does all the above.+ bool block_can_start = false;++ return_if_error(read_output_and_wait(coder, allocator,+ out, out_pos, out_size,+ &block_can_start, true,+ &wait_abs, &has_blocked));++ if (coder->pending_error != LZMA_OK) {+ coder->sequence = SEQ_ERROR;+ break;+ }++ if (!block_can_start) {+ // It's not a timeout because return_if_error handles+ // it already. Output queue cannot be empty either+ // because in that case block_can_start would have+ // been true. Thus the output buffer must be full and+ // the queue isn't empty.+ assert(*out_pos == out_size);+ assert(!lzma_outq_is_empty(&coder->outq));+ return LZMA_OK;+ }++ // We know that we can start decoding this Block without+ // exceeding memlimit_threading. However, to stay below+ // memlimit_threading may require freeing some of the+ // cached memory.+ //+ // Get a local copy of variables that require locking the+ // mutex. It is fine if the worker threads modify the real+ // values after we read these as those changes can only be+ // towards more favorable conditions (less memory in use,+ // more in cache).+ //+ // These are initialized to silence warnings.+ uint64_t mem_in_use = 0;+ uint64_t mem_cached = 0;+ struct worker_thread *thr = NULL;++ mythread_sync(coder->mutex) {+ mem_in_use = coder->mem_in_use;+ mem_cached = coder->mem_cached;+ thr = coder->threads_free;+ }++ // The maximum amount of memory that can be held by other+ // threads and cached buffers while allowing us to start+ // decoding the next Block.+ const uint64_t mem_max = coder->memlimit_threading+ - coder->mem_next_block;++ // If the existing allocations are so large that starting+ // to decode this Block might exceed memlimit_threads,+ // try to free memory from the output queue cache first.+ //+ // NOTE: This math assumes the worst case. It's possible+ // that the limit wouldn't be exceeded if the existing cached+ // allocations are reused.+ if (mem_in_use + mem_cached + coder->outq.mem_allocated+ > mem_max) {+ // Clear the outq cache except leave one buffer in+ // the cache if its size is correct. That way we+ // don't free and almost immediately reallocate+ // an identical buffer.+ lzma_outq_clear_cache2(&coder->outq, allocator,+ coder->block_options.uncompressed_size);+ }++ // If there is at least one worker_thread in the cache and+ // the existing allocations are so large that starting to+ // decode this Block might exceed memlimit_threads, free+ // memory by freeing cached Block decoders.+ //+ // NOTE: The comparison is different here than above.+ // Here we don't care about cached buffers in outq anymore+ // and only look at memory actually in use. This is because+ // if there is something in outq cache, it's a single buffer+ // that can be used as is. We ensured this in the above+ // if-block.+ uint64_t mem_freed = 0;+ if (thr != NULL && mem_in_use + mem_cached+ + coder->outq.mem_in_use > mem_max) {+ // Don't free the first Block decoder if its memory+ // usage isn't greater than what this Block will need.+ // Typically the same filter chain is used for all+ // Blocks so this way the allocations can be reused+ // when get_thread() picks the first worker_thread+ // from the cache.+ if (thr->mem_filters <= coder->mem_next_filters)+ thr = thr->next;++ while (thr != NULL) {+ lzma_next_end(&thr->block_decoder, allocator);+ mem_freed += thr->mem_filters;+ thr->mem_filters = 0;+ thr = thr->next;+ }+ }++ // Update the memory usage counters. Note that coder->mem_*+ // may have changed since we read them so we must subtract+ // or add the changes.+ mythread_sync(coder->mutex) {+ coder->mem_cached -= mem_freed;++ // Memory needed for the filters and the input buffer.+ // The output queue takes care of its own counter so+ // we don't touch it here.+ //+ // NOTE: After this, coder->mem_in_use ++ // coder->mem_cached might count the same thing twice.+ // If so, this will get corrected in get_thread() when+ // a worker_thread is picked from coder->free_threads+ // and its memory usage is subtracted from mem_cached.+ coder->mem_in_use += coder->mem_next_in+ + coder->mem_next_filters;+ }++ // Allocate memory for the output buffer in the output queue.+ lzma_ret ret = lzma_outq_prealloc_buf(+ &coder->outq, allocator,+ coder->block_options.uncompressed_size);+ if (ret != LZMA_OK) {+ threads_stop(coder);+ return ret;+ }++ // Set up coder->thr.+ ret = get_thread(coder, allocator);+ if (ret != LZMA_OK) {+ threads_stop(coder);+ return ret;+ }++ // The new Block decoder memory usage is already counted in+ // coder->mem_in_use. Store it in the thread too.+ coder->thr->mem_filters = coder->mem_next_filters;++ // Initialize the Block decoder.+ coder->thr->block_options = coder->block_options;+ ret = lzma_block_decoder_init(+ &coder->thr->block_decoder, allocator,+ &coder->thr->block_options);++ // Free the allocated filter options since they are needed+ // only to initialize the Block decoder.+ lzma_filters_free(coder->filters, allocator);+ coder->thr->block_options.filters = NULL;++ // Check if memory usage calculation and Block encoder+ // initialization succeeded.+ if (ret != LZMA_OK) {+ coder->pending_error = ret;+ coder->sequence = SEQ_ERROR;+ break;+ }++ // Allocate the input buffer.+ coder->thr->in_size = coder->mem_next_in;+ coder->thr->in = lzma_alloc(coder->thr->in_size, allocator);+ if (coder->thr->in == NULL) {+ threads_stop(coder);+ return LZMA_MEM_ERROR;+ }++ // Get the preallocated output buffer.+ coder->thr->outbuf = lzma_outq_get_buf(+ &coder->outq, coder->thr);++ // Start the decoder.+ mythread_sync(coder->thr->mutex) {+ assert(coder->thr->state == THR_IDLE);+ coder->thr->state = THR_RUN;+ mythread_cond_signal(&coder->thr->cond);+ }++ // Enable output from the thread that holds the oldest output+ // buffer in the output queue (if such a thread exists).+ mythread_sync(coder->mutex) {+ lzma_outq_enable_partial_output(&coder->outq,+ &worker_enable_partial_update);+ }++ coder->sequence = SEQ_BLOCK_THR_RUN;+ }++ // Fall through++ case SEQ_BLOCK_THR_RUN: {+ if (action == LZMA_FINISH && coder->fail_fast) {+ // We know that we won't get more input and that+ // the caller wants fail-fast behavior. If we see+ // that we don't have enough input to finish this+ // Block, return LZMA_DATA_ERROR immediately.+ // See SEQ_BLOCK_HEADER for the error code rationale.+ const size_t in_avail = in_size - *in_pos;+ const size_t in_needed = coder->thr->in_size+ - coder->thr->in_filled;+ if (in_avail < in_needed) {+ threads_stop(coder);+ return LZMA_DATA_ERROR;+ }+ }++ // Copy input to the worker thread.+ size_t cur_in_filled = coder->thr->in_filled;+ lzma_bufcpy(in, in_pos, in_size, coder->thr->in,+ &cur_in_filled, coder->thr->in_size);++ // Tell the thread how much we copied.+ mythread_sync(coder->thr->mutex) {+ coder->thr->in_filled = cur_in_filled;++ // NOTE: Most of the time we are copying input faster+ // than the thread can decode so most of the time+ // calling mythread_cond_signal() is useless but+ // we cannot make it conditional because thr->in_pos+ // is updated without a mutex. And the overhead should+ // be very much negligible anyway.+ mythread_cond_signal(&coder->thr->cond);+ }++ // Read output from the output queue. Just like in+ // SEQ_BLOCK_HEADER, we wait to fill the output buffer+ // only if waiting_allowed was set to true in the beginning+ // of this function (see the comment there).+ return_if_error(read_output_and_wait(coder, allocator,+ out, out_pos, out_size,+ NULL, waiting_allowed,+ &wait_abs, &has_blocked));++ if (coder->pending_error != LZMA_OK) {+ coder->sequence = SEQ_ERROR;+ break;+ }++ // Return if the input didn't contain the whole Block.+ if (coder->thr->in_filled < coder->thr->in_size) {+ assert(*in_pos == in_size);+ return LZMA_OK;+ }++ // The whole Block has been copied to the thread-specific+ // buffer. Continue from the next Block Header or Index.+ coder->thr = NULL;+ coder->sequence = SEQ_BLOCK_HEADER;+ break;+ }++ case SEQ_BLOCK_DIRECT_INIT: {+ // Wait for the threads to finish and that all decoded data+ // has been copied to the output. That is, wait until the+ // output queue becomes empty.+ //+ // NOTE: No need to check for coder->pending_error as+ // we aren't consuming any input until the queue is empty+ // and if there is a pending error, read_output_and_wait()+ // will eventually return it before the queue is empty.+ return_if_error(read_output_and_wait(coder, allocator,+ out, out_pos, out_size,+ NULL, true, &wait_abs, &has_blocked));+ if (!lzma_outq_is_empty(&coder->outq))+ return LZMA_OK;++ // Free the cached output buffers.+ lzma_outq_clear_cache(&coder->outq, allocator);++ // Get rid of the worker threads, including the coder->threads+ // array.+ threads_end(coder, allocator);++ // Initialize the Block decoder.+ const lzma_ret ret = lzma_block_decoder_init(+ &coder->block_decoder, allocator,+ &coder->block_options);++ // Free the allocated filter options since they are needed+ // only to initialize the Block decoder.+ lzma_filters_free(coder->filters, allocator);+ coder->block_options.filters = NULL;++ // Check if Block decoder initialization succeeded.+ if (ret != LZMA_OK)+ return ret;++ // Make the memory usage visible to _memconfig().+ coder->mem_direct_mode = coder->mem_next_filters;++ coder->sequence = SEQ_BLOCK_DIRECT_RUN;+ }++ // Fall through++ case SEQ_BLOCK_DIRECT_RUN: {+ const size_t in_old = *in_pos;+ const size_t out_old = *out_pos;+ const lzma_ret ret = coder->block_decoder.code(+ coder->block_decoder.coder, allocator,+ in, in_pos, in_size, out, out_pos, out_size,+ action);+ coder->progress_in += *in_pos - in_old;+ coder->progress_out += *out_pos - out_old;++ if (ret != LZMA_STREAM_END)+ return ret;++ // Block decoded successfully. Add the new size pair to+ // the Index hash.+ return_if_error(lzma_index_hash_append(coder->index_hash,+ lzma_block_unpadded_size(+ &coder->block_options),+ coder->block_options.uncompressed_size));++ coder->sequence = SEQ_BLOCK_HEADER;+ break;+ }++ case SEQ_INDEX_WAIT_OUTPUT:+ // Flush the output from all worker threads so that we can+ // decode the Index without thinking about threading.+ return_if_error(read_output_and_wait(coder, allocator,+ out, out_pos, out_size,+ NULL, true, &wait_abs, &has_blocked));++ if (!lzma_outq_is_empty(&coder->outq))+ return LZMA_OK;++ coder->sequence = SEQ_INDEX_DECODE;++ // Fall through++ case SEQ_INDEX_DECODE: {+ // If we don't have any input, don't call+ // lzma_index_hash_decode() since it would return+ // LZMA_BUF_ERROR, which we must not do here.+ if (*in_pos >= in_size)+ return LZMA_OK;++ // Decode the Index and compare it to the hash calculated+ // from the sizes of the Blocks (if any).+ const size_t in_old = *in_pos;+ const lzma_ret ret = lzma_index_hash_decode(coder->index_hash,+ in, in_pos, in_size);+ coder->progress_in += *in_pos - in_old;+ if (ret != LZMA_STREAM_END)+ return ret;++ coder->sequence = SEQ_STREAM_FOOTER;+ }++ // Fall through++ case SEQ_STREAM_FOOTER: {+ // Copy the Stream Footer to the internal buffer.+ const size_t in_old = *in_pos;+ lzma_bufcpy(in, in_pos, in_size, coder->buffer, &coder->pos,+ LZMA_STREAM_HEADER_SIZE);+ coder->progress_in += *in_pos - in_old;++ // Return if we didn't get the whole Stream Footer yet.+ if (coder->pos < LZMA_STREAM_HEADER_SIZE)+ return LZMA_OK;++ coder->pos = 0;++ // Decode the Stream Footer. The decoder gives+ // LZMA_FORMAT_ERROR if the magic bytes don't match,+ // so convert that return code to LZMA_DATA_ERROR.+ lzma_stream_flags footer_flags;+ const lzma_ret ret = lzma_stream_footer_decode(+ &footer_flags, coder->buffer);+ if (ret != LZMA_OK)+ return ret == LZMA_FORMAT_ERROR+ ? LZMA_DATA_ERROR : ret;++ // Check that Index Size stored in the Stream Footer matches+ // the real size of the Index field.+ if (lzma_index_hash_size(coder->index_hash)+ != footer_flags.backward_size)+ return LZMA_DATA_ERROR;++ // Compare that the Stream Flags fields are identical in+ // both Stream Header and Stream Footer.+ return_if_error(lzma_stream_flags_compare(+ &coder->stream_flags, &footer_flags));++ if (!coder->concatenated)+ return LZMA_STREAM_END;++ coder->sequence = SEQ_STREAM_PADDING;+ }++ // Fall through++ case SEQ_STREAM_PADDING:+ assert(coder->concatenated);++ // Skip over possible Stream Padding.+ while (true) {+ if (*in_pos >= in_size) {+ // Unless LZMA_FINISH was used, we cannot+ // know if there's more input coming later.+ if (action != LZMA_FINISH)+ return LZMA_OK;++ // Stream Padding must be a multiple of+ // four bytes.+ return coder->pos == 0+ ? LZMA_STREAM_END+ : LZMA_DATA_ERROR;+ }++ // If the byte is not zero, it probably indicates+ // beginning of a new Stream (or the file is corrupt).+ if (in[*in_pos] != 0x00)+ break;++ ++*in_pos;+ ++coder->progress_in;+ coder->pos = (coder->pos + 1) & 3;+ }++ // Stream Padding must be a multiple of four bytes (empty+ // Stream Padding is OK).+ if (coder->pos != 0) {+ ++*in_pos;+ ++coder->progress_in;+ return LZMA_DATA_ERROR;+ }++ // Prepare to decode the next Stream.+ return_if_error(stream_decoder_reset(coder, allocator));+ break;++ case SEQ_ERROR:+ if (!coder->fail_fast) {+ // Let the application get all data before the point+ // where the error was detected. This matches the+ // behavior of single-threaded use.+ //+ // FIXME? Some errors (LZMA_MEM_ERROR) don't get here,+ // they are returned immediately. Thus in rare cases+ // the output will be less than in the single-threaded+ // mode. Maybe this doesn't matter much in practice.+ return_if_error(read_output_and_wait(coder, allocator,+ out, out_pos, out_size,+ NULL, true, &wait_abs, &has_blocked));++ // We get here only if the error happened in the main+ // thread, for example, unsupported Block Header.+ if (!lzma_outq_is_empty(&coder->outq))+ return LZMA_OK;+ }++ // We only get here if no errors were detected by the worker+ // threads. Errors from worker threads would have already been+ // returned by the call to read_output_and_wait() above.+ return coder->pending_error;++ default:+ assert(0);+ return LZMA_PROG_ERROR;+ }++ // Never reached+}+++static void+stream_decoder_mt_end(void *coder_ptr, const lzma_allocator *allocator)+{+ struct lzma_stream_coder *coder = coder_ptr;++ threads_end(coder, allocator);+ lzma_outq_end(&coder->outq, allocator);++ lzma_next_end(&coder->block_decoder, allocator);+ lzma_filters_free(coder->filters, allocator);+ lzma_index_hash_end(coder->index_hash, allocator);++ lzma_free(coder, allocator);+ return;+}+++static lzma_check+stream_decoder_mt_get_check(const void *coder_ptr)+{+ const struct lzma_stream_coder *coder = coder_ptr;+ return coder->stream_flags.check;+}+++static lzma_ret+stream_decoder_mt_memconfig(void *coder_ptr, uint64_t *memusage,+ uint64_t *old_memlimit, uint64_t new_memlimit)+{+ // NOTE: This function gets/sets memlimit_stop. For now,+ // memlimit_threading cannot be modified after initialization.+ //+ // *memusage will include cached memory too. Excluding cached memory+ // would be misleading and it wouldn't help the applications to+ // know how much memory is actually needed to decompress the file+ // because the higher the number of threads and the memlimits are+ // the more memory the decoder may use.+ //+ // Setting a new limit includes the cached memory too and too low+ // limits will be rejected. Alternative could be to free the cached+ // memory immediately if that helps to bring the limit down but+ // the current way is the simplest. It's unlikely that limit needs+ // to be lowered in the middle of a file anyway; the typical reason+ // to want a new limit is to increase after LZMA_MEMLIMIT_ERROR+ // and even such use isn't common.+ struct lzma_stream_coder *coder = coder_ptr;++ mythread_sync(coder->mutex) {+ *memusage = coder->mem_direct_mode+ + coder->mem_in_use+ + coder->mem_cached+ + coder->outq.mem_allocated;+ }++ // If no filter chains are allocated, *memusage may be zero.+ // Always return at least LZMA_MEMUSAGE_BASE.+ if (*memusage < LZMA_MEMUSAGE_BASE)+ *memusage = LZMA_MEMUSAGE_BASE;++ *old_memlimit = coder->memlimit_stop;++ if (new_memlimit != 0) {+ if (new_memlimit < *memusage)+ return LZMA_MEMLIMIT_ERROR;++ coder->memlimit_stop = new_memlimit;+ }++ return LZMA_OK;+}+++static void+stream_decoder_mt_get_progress(void *coder_ptr,+ uint64_t *progress_in, uint64_t *progress_out)+{+ struct lzma_stream_coder *coder = coder_ptr;++ // Lock coder->mutex to prevent finishing threads from moving their+ // progress info from the worker_thread structure to lzma_stream_coder.+ mythread_sync(coder->mutex) {+ *progress_in = coder->progress_in;+ *progress_out = coder->progress_out;++ for (size_t i = 0; i < coder->threads_initialized; ++i) {+ mythread_sync(coder->threads[i].mutex) {+ *progress_in += coder->threads[i].progress_in;+ *progress_out += coder->threads[i]+ .progress_out;+ }+ }+ }++ return;+}+++static lzma_ret+stream_decoder_mt_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_mt *options)+{+ struct lzma_stream_coder *coder;++ if (options->threads == 0 || options->threads > LZMA_THREADS_MAX)+ return LZMA_OPTIONS_ERROR;++ if (options->flags & ~LZMA_SUPPORTED_FLAGS)+ return LZMA_OPTIONS_ERROR;++ lzma_next_coder_init(&stream_decoder_mt_init, next, allocator);++ coder = next->coder;+ if (!coder) {+ coder = lzma_alloc(sizeof(struct lzma_stream_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;++ if (mythread_mutex_init(&coder->mutex)) {+ lzma_free(coder, allocator);+ return LZMA_MEM_ERROR;+ }++ if (mythread_cond_init(&coder->cond)) {+ mythread_mutex_destroy(&coder->mutex);+ lzma_free(coder, allocator);+ return LZMA_MEM_ERROR;+ }++ next->code = &stream_decode_mt;+ next->end = &stream_decoder_mt_end;+ next->get_check = &stream_decoder_mt_get_check;+ next->memconfig = &stream_decoder_mt_memconfig;+ next->get_progress = &stream_decoder_mt_get_progress;++ coder->filters[0].id = LZMA_VLI_UNKNOWN;+ memzero(&coder->outq, sizeof(coder->outq));++ coder->block_decoder = LZMA_NEXT_CODER_INIT;+ coder->mem_direct_mode = 0;++ coder->index_hash = NULL;+ coder->threads = NULL;+ coder->threads_free = NULL;+ coder->threads_initialized = 0;+ }++ // Cleanup old filter chain if one remains after unfinished decoding+ // of a previous Stream.+ lzma_filters_free(coder->filters, allocator);++ // By allocating threads from scratch we can start memory-usage+ // accounting from scratch, too. Changes in filter and block sizes may+ // affect number of threads.+ //+ // FIXME? Reusing should be easy but unlike the single-threaded+ // decoder, with some types of input file combinations reusing+ // could leave quite a lot of memory allocated but unused (first+ // file could allocate a lot, the next files could use fewer+ // threads and some of the allocations from the first file would not+ // get freed unless memlimit_threading forces us to clear caches).+ //+ // NOTE: The direct mode decoder isn't freed here if one exists.+ // It will be reused or freed as needed in the main loop.+ threads_end(coder, allocator);++ // All memusage counters start at 0 (including mem_direct_mode).+ // The little extra that is needed for the structs in this file+ // get accounted well enough by the filter chain memory usage+ // which adds LZMA_MEMUSAGE_BASE for each chain. However,+ // stream_decoder_mt_memconfig() has to handle this specially so that+ // it will never return less than LZMA_MEMUSAGE_BASE as memory usage.+ coder->mem_in_use = 0;+ coder->mem_cached = 0;+ coder->mem_next_block = 0;++ coder->progress_in = 0;+ coder->progress_out = 0;++ coder->sequence = SEQ_STREAM_HEADER;+ coder->thread_error = LZMA_OK;+ coder->pending_error = LZMA_OK;+ coder->thr = NULL;++ coder->timeout = options->timeout;++ coder->memlimit_threading = my_max(1, options->memlimit_threading);+ coder->memlimit_stop = my_max(1, options->memlimit_stop);+ if (coder->memlimit_threading > coder->memlimit_stop)+ coder->memlimit_threading = coder->memlimit_stop;++ coder->tell_no_check = (options->flags & LZMA_TELL_NO_CHECK) != 0;+ coder->tell_unsupported_check+ = (options->flags & LZMA_TELL_UNSUPPORTED_CHECK) != 0;+ coder->tell_any_check = (options->flags & LZMA_TELL_ANY_CHECK) != 0;+ coder->ignore_check = (options->flags & LZMA_IGNORE_CHECK) != 0;+ coder->concatenated = (options->flags & LZMA_CONCATENATED) != 0;+ coder->fail_fast = (options->flags & LZMA_FAIL_FAST) != 0;++ coder->first_stream = true;+ coder->out_was_filled = false;+ coder->pos = 0;++ coder->threads_max = options->threads;++ return_if_error(lzma_outq_init(&coder->outq, allocator,+ coder->threads_max));++ return stream_decoder_reset(coder, allocator);+}+++extern LZMA_API(lzma_ret)+lzma_stream_decoder_mt(lzma_stream *strm, const lzma_mt *options)+{+ lzma_next_strm_init(stream_decoder_mt_init, strm, options);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}
+ cbits/liblzma/common/stream_encoder.c view
@@ -0,0 +1,354 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file stream_encoder.c+/// \brief Encodes .xz Streams+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "block_encoder.h"+#include "index_encoder.h"+++typedef struct {+ enum {+ SEQ_STREAM_HEADER,+ SEQ_BLOCK_INIT,+ SEQ_BLOCK_HEADER,+ SEQ_BLOCK_ENCODE,+ SEQ_INDEX_ENCODE,+ SEQ_STREAM_FOOTER,+ } sequence;++ /// True if Block encoder has been initialized by+ /// stream_encoder_init() or stream_encoder_update()+ /// and thus doesn't need to be initialized in stream_encode().+ bool block_encoder_is_initialized;++ /// Block+ lzma_next_coder block_encoder;++ /// Options for the Block encoder+ lzma_block block_options;++ /// The filter chain currently in use+ lzma_filter filters[LZMA_FILTERS_MAX + 1];++ /// Index encoder. This is separate from Block encoder, because this+ /// doesn't take much memory, and when encoding multiple Streams+ /// with the same encoding options we avoid reallocating memory.+ lzma_next_coder index_encoder;++ /// Index to hold sizes of the Blocks+ lzma_index *index;++ /// Read position in buffer[]+ size_t buffer_pos;++ /// Total number of bytes in buffer[]+ size_t buffer_size;++ /// Buffer to hold Stream Header, Block Header, and Stream Footer.+ /// Block Header has biggest maximum size.+ uint8_t buffer[LZMA_BLOCK_HEADER_SIZE_MAX];+} lzma_stream_coder;+++static lzma_ret+block_encoder_init(lzma_stream_coder *coder, const lzma_allocator *allocator)+{+ // Prepare the Block options. Even though Block encoder doesn't need+ // compressed_size, uncompressed_size, and header_size to be+ // initialized, it is a good idea to do it here, because this way+ // we catch if someone gave us Filter ID that cannot be used in+ // Blocks/Streams.+ coder->block_options.compressed_size = LZMA_VLI_UNKNOWN;+ coder->block_options.uncompressed_size = LZMA_VLI_UNKNOWN;++ return_if_error(lzma_block_header_size(&coder->block_options));++ // Initialize the actual Block encoder.+ return lzma_block_encoder_init(&coder->block_encoder, allocator,+ &coder->block_options);+}+++static lzma_ret+stream_encode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size, lzma_action action)+{+ lzma_stream_coder *coder = coder_ptr;++ // Main loop+ while (*out_pos < out_size)+ switch (coder->sequence) {+ case SEQ_STREAM_HEADER:+ case SEQ_BLOCK_HEADER:+ case SEQ_STREAM_FOOTER:+ lzma_bufcpy(coder->buffer, &coder->buffer_pos,+ coder->buffer_size, out, out_pos, out_size);+ if (coder->buffer_pos < coder->buffer_size)+ return LZMA_OK;++ if (coder->sequence == SEQ_STREAM_FOOTER)+ return LZMA_STREAM_END;++ coder->buffer_pos = 0;+ ++coder->sequence;+ break;++ case SEQ_BLOCK_INIT: {+ if (*in_pos == in_size) {+ // If we are requested to flush or finish the current+ // Block, return LZMA_STREAM_END immediately since+ // there's nothing to do.+ if (action != LZMA_FINISH)+ return action == LZMA_RUN+ ? LZMA_OK : LZMA_STREAM_END;++ // The application had used LZMA_FULL_FLUSH to finish+ // the previous Block, but now wants to finish without+ // encoding new data, or it is simply creating an+ // empty Stream with no Blocks.+ //+ // Initialize the Index encoder, and continue to+ // actually encoding the Index.+ return_if_error(lzma_index_encoder_init(+ &coder->index_encoder, allocator,+ coder->index));+ coder->sequence = SEQ_INDEX_ENCODE;+ break;+ }++ // Initialize the Block encoder unless it was already+ // initialized by stream_encoder_init() or+ // stream_encoder_update().+ if (!coder->block_encoder_is_initialized)+ return_if_error(block_encoder_init(coder, allocator));++ // Make it false so that we don't skip the initialization+ // with the next Block.+ coder->block_encoder_is_initialized = false;++ // Encode the Block Header. This shouldn't fail since we have+ // already initialized the Block encoder.+ if (lzma_block_header_encode(&coder->block_options,+ coder->buffer) != LZMA_OK)+ return LZMA_PROG_ERROR;++ coder->buffer_size = coder->block_options.header_size;+ coder->sequence = SEQ_BLOCK_HEADER;+ break;+ }++ case SEQ_BLOCK_ENCODE: {+ static const lzma_action convert[LZMA_ACTION_MAX + 1] = {+ LZMA_RUN,+ LZMA_SYNC_FLUSH,+ LZMA_FINISH,+ LZMA_FINISH,+ LZMA_FINISH,+ };++ const lzma_ret ret = coder->block_encoder.code(+ coder->block_encoder.coder, allocator,+ in, in_pos, in_size,+ out, out_pos, out_size, convert[action]);+ if (ret != LZMA_STREAM_END || action == LZMA_SYNC_FLUSH)+ return ret;++ // Add a new Index Record.+ const lzma_vli unpadded_size = lzma_block_unpadded_size(+ &coder->block_options);+ assert(unpadded_size != 0);+ return_if_error(lzma_index_append(coder->index, allocator,+ unpadded_size,+ coder->block_options.uncompressed_size));++ coder->sequence = SEQ_BLOCK_INIT;+ break;+ }++ case SEQ_INDEX_ENCODE: {+ // Call the Index encoder. It doesn't take any input, so+ // those pointers can be NULL.+ const lzma_ret ret = coder->index_encoder.code(+ coder->index_encoder.coder, allocator,+ NULL, NULL, 0,+ out, out_pos, out_size, LZMA_RUN);+ if (ret != LZMA_STREAM_END)+ return ret;++ // Encode the Stream Footer into coder->buffer.+ const lzma_stream_flags stream_flags = {+ .version = 0,+ .backward_size = lzma_index_size(coder->index),+ .check = coder->block_options.check,+ };++ if (lzma_stream_footer_encode(&stream_flags, coder->buffer)+ != LZMA_OK)+ return LZMA_PROG_ERROR;++ coder->buffer_size = LZMA_STREAM_HEADER_SIZE;+ coder->sequence = SEQ_STREAM_FOOTER;+ break;+ }++ default:+ assert(0);+ return LZMA_PROG_ERROR;+ }++ return LZMA_OK;+}+++static void+stream_encoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_stream_coder *coder = coder_ptr;++ lzma_next_end(&coder->block_encoder, allocator);+ lzma_next_end(&coder->index_encoder, allocator);+ lzma_index_end(coder->index, allocator);++ lzma_filters_free(coder->filters, allocator);++ lzma_free(coder, allocator);+ return;+}+++static lzma_ret+stream_encoder_update(void *coder_ptr, const lzma_allocator *allocator,+ const lzma_filter *filters,+ const lzma_filter *reversed_filters)+{+ lzma_stream_coder *coder = coder_ptr;+ lzma_ret ret;++ // Make a copy to a temporary buffer first. This way it is easier+ // to keep the encoder state unchanged if an error occurs with+ // lzma_filters_copy().+ lzma_filter temp[LZMA_FILTERS_MAX + 1];+ return_if_error(lzma_filters_copy(filters, temp, allocator));++ if (coder->sequence <= SEQ_BLOCK_INIT) {+ // There is no incomplete Block waiting to be finished,+ // thus we can change the whole filter chain. Start by+ // trying to initialize the Block encoder with the new+ // chain. This way we detect if the chain is valid.+ coder->block_encoder_is_initialized = false;+ coder->block_options.filters = temp;+ ret = block_encoder_init(coder, allocator);+ coder->block_options.filters = coder->filters;+ if (ret != LZMA_OK)+ goto error;++ coder->block_encoder_is_initialized = true;++ } else if (coder->sequence <= SEQ_BLOCK_ENCODE) {+ // We are in the middle of a Block. Try to update only+ // the filter-specific options.+ ret = coder->block_encoder.update(+ coder->block_encoder.coder, allocator,+ filters, reversed_filters);+ if (ret != LZMA_OK)+ goto error;+ } else {+ // Trying to update the filter chain when we are already+ // encoding Index or Stream Footer.+ ret = LZMA_PROG_ERROR;+ goto error;+ }++ // Free the options of the old chain.+ lzma_filters_free(coder->filters, allocator);++ // Copy the new filter chain in place.+ memcpy(coder->filters, temp, sizeof(temp));++ return LZMA_OK;++error:+ lzma_filters_free(temp, allocator);+ return ret;+}+++static lzma_ret+stream_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter *filters, lzma_check check)+{+ lzma_next_coder_init(&stream_encoder_init, next, allocator);++ if (filters == NULL)+ return LZMA_PROG_ERROR;++ lzma_stream_coder *coder = next->coder;++ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_stream_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = &stream_encode;+ next->end = &stream_encoder_end;+ next->update = &stream_encoder_update;++ coder->filters[0].id = LZMA_VLI_UNKNOWN;+ coder->block_encoder = LZMA_NEXT_CODER_INIT;+ coder->index_encoder = LZMA_NEXT_CODER_INIT;+ coder->index = NULL;+ }++ // Basic initializations+ coder->sequence = SEQ_STREAM_HEADER;+ coder->block_options.version = 0;+ coder->block_options.check = check;++ // Initialize the Index+ lzma_index_end(coder->index, allocator);+ coder->index = lzma_index_init(allocator);+ if (coder->index == NULL)+ return LZMA_MEM_ERROR;++ // Encode the Stream Header+ lzma_stream_flags stream_flags = {+ .version = 0,+ .check = check,+ };+ return_if_error(lzma_stream_header_encode(+ &stream_flags, coder->buffer));++ coder->buffer_pos = 0;+ coder->buffer_size = LZMA_STREAM_HEADER_SIZE;++ // Initialize the Block encoder. This way we detect unsupported+ // filter chains when initializing the Stream encoder instead of+ // giving an error after Stream Header has already been written out.+ return stream_encoder_update(coder, allocator, filters, NULL);+}+++extern LZMA_API(lzma_ret)+lzma_stream_encoder(lzma_stream *strm,+ const lzma_filter *filters, lzma_check check)+{+ lzma_next_strm_init(stream_encoder_init, strm, filters, check);++ strm->internal->supported_actions[LZMA_RUN] = true;+ strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;+ strm->internal->supported_actions[LZMA_FULL_FLUSH] = true;+ strm->internal->supported_actions[LZMA_FULL_BARRIER] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}
+ cbits/liblzma/common/stream_encoder_mt.c view
@@ -0,0 +1,1280 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file stream_encoder_mt.c+/// \brief Multithreaded .xz Stream encoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "filter_encoder.h"+#include "easy_preset.h"+#include "block_encoder.h"+#include "block_buffer_encoder.h"+#include "index_encoder.h"+#include "outqueue.h"+++/// Maximum supported block size. This makes it simpler to prevent integer+/// overflows if we are given unusually large block size.+#define BLOCK_SIZE_MAX (UINT64_MAX / LZMA_THREADS_MAX)+++typedef enum {+ /// Waiting for work.+ THR_IDLE,++ /// Encoding is in progress.+ THR_RUN,++ /// Encoding is in progress but no more input data will+ /// be read.+ THR_FINISH,++ /// The main thread wants the thread to stop whatever it was doing+ /// but not exit.+ THR_STOP,++ /// The main thread wants the thread to exit. We could use+ /// cancellation but since there's stopped anyway, this is lazier.+ THR_EXIT,++} worker_state;++typedef struct lzma_stream_coder_s lzma_stream_coder;++typedef struct worker_thread_s worker_thread;+struct worker_thread_s {+ worker_state state;++ /// Input buffer of coder->block_size bytes. The main thread will+ /// put new input into this and update in_size accordingly. Once+ /// no more input is coming, state will be set to THR_FINISH.+ uint8_t *in;++ /// Amount of data available in the input buffer. This is modified+ /// only by the main thread.+ size_t in_size;++ /// Output buffer for this thread. This is set by the main+ /// thread every time a new Block is started with this thread+ /// structure.+ lzma_outbuf *outbuf;++ /// Pointer to the main structure is needed when putting this+ /// thread back to the stack of free threads.+ lzma_stream_coder *coder;++ /// The allocator is set by the main thread. Since a copy of the+ /// pointer is kept here, the application must not change the+ /// allocator before calling lzma_end().+ const lzma_allocator *allocator;++ /// Amount of uncompressed data that has already been compressed.+ uint64_t progress_in;++ /// Amount of compressed data that is ready.+ uint64_t progress_out;++ /// Block encoder+ lzma_next_coder block_encoder;++ /// Compression options for this Block+ lzma_block block_options;++ /// Filter chain for this thread. By copying the filters array+ /// to each thread it is possible to change the filter chain+ /// between Blocks using lzma_filters_update().+ lzma_filter filters[LZMA_FILTERS_MAX + 1];++ /// Next structure in the stack of free worker threads.+ worker_thread *next;++ mythread_mutex mutex;+ mythread_cond cond;++ /// The ID of this thread is used to join the thread+ /// when it's not needed anymore.+ mythread thread_id;+};+++struct lzma_stream_coder_s {+ enum {+ SEQ_STREAM_HEADER,+ SEQ_BLOCK,+ SEQ_INDEX,+ SEQ_STREAM_FOOTER,+ } sequence;++ /// Start a new Block every block_size bytes of input unless+ /// LZMA_FULL_FLUSH or LZMA_FULL_BARRIER is used earlier.+ size_t block_size;++ /// The filter chain to use for the next Block.+ /// This can be updated using lzma_filters_update()+ /// after LZMA_FULL_BARRIER or LZMA_FULL_FLUSH.+ lzma_filter filters[LZMA_FILTERS_MAX + 1];++ /// A copy of filters[] will be put here when attempting to get+ /// a new worker thread. This will be copied to a worker thread+ /// when a thread becomes free and then this cache is marked as+ /// empty by setting [0].id = LZMA_VLI_UNKNOWN. Without this cache+ /// the filter options from filters[] would get uselessly copied+ /// multiple times (allocated and freed) when waiting for a new free+ /// worker thread.+ ///+ /// This is freed if filters[] is updated via lzma_filters_update().+ lzma_filter filters_cache[LZMA_FILTERS_MAX + 1];+++ /// Index to hold sizes of the Blocks+ lzma_index *index;++ /// Index encoder+ lzma_next_coder index_encoder;+++ /// Stream Flags for encoding the Stream Header and Stream Footer.+ lzma_stream_flags stream_flags;++ /// Buffer to hold Stream Header and Stream Footer.+ uint8_t header[LZMA_STREAM_HEADER_SIZE];++ /// Read position in header[]+ size_t header_pos;+++ /// Output buffer queue for compressed data+ lzma_outq outq;++ /// How much memory to allocate for each lzma_outbuf.buf+ size_t outbuf_alloc_size;+++ /// Maximum wait time if cannot use all the input and cannot+ /// fill the output buffer. This is in milliseconds.+ uint32_t timeout;+++ /// Error code from a worker thread+ lzma_ret thread_error;++ /// Array of allocated thread-specific structures+ worker_thread *threads;++ /// Number of structures in "threads" above. This is also the+ /// number of threads that will be created at maximum.+ uint32_t threads_max;++ /// Number of thread structures that have been initialized, and+ /// thus the number of worker threads actually created so far.+ uint32_t threads_initialized;++ /// Stack of free threads. When a thread finishes, it puts itself+ /// back into this stack. This starts as empty because threads+ /// are created only when actually needed.+ worker_thread *threads_free;++ /// The most recent worker thread to which the main thread writes+ /// the new input from the application.+ worker_thread *thr;+++ /// Amount of uncompressed data in Blocks that have already+ /// been finished.+ uint64_t progress_in;++ /// Amount of compressed data in Stream Header + Blocks that+ /// have already been finished.+ uint64_t progress_out;+++ mythread_mutex mutex;+ mythread_cond cond;+};+++/// Tell the main thread that something has gone wrong.+static void+worker_error(worker_thread *thr, lzma_ret ret)+{+ assert(ret != LZMA_OK);+ assert(ret != LZMA_STREAM_END);++ mythread_sync(thr->coder->mutex) {+ if (thr->coder->thread_error == LZMA_OK)+ thr->coder->thread_error = ret;++ mythread_cond_signal(&thr->coder->cond);+ }++ return;+}+++static worker_state+worker_encode(worker_thread *thr, size_t *out_pos, worker_state state)+{+ assert(thr->progress_in == 0);+ assert(thr->progress_out == 0);++ // Set the Block options.+ thr->block_options = (lzma_block){+ .version = 0,+ .check = thr->coder->stream_flags.check,+ .compressed_size = thr->outbuf->allocated,+ .uncompressed_size = thr->coder->block_size,+ .filters = thr->filters,+ };++ // Calculate maximum size of the Block Header. This amount is+ // reserved in the beginning of the buffer so that Block Header+ // along with Compressed Size and Uncompressed Size can be+ // written there.+ lzma_ret ret = lzma_block_header_size(&thr->block_options);+ if (ret != LZMA_OK) {+ worker_error(thr, ret);+ return THR_STOP;+ }++ // Initialize the Block encoder.+ ret = lzma_block_encoder_init(&thr->block_encoder,+ thr->allocator, &thr->block_options);+ if (ret != LZMA_OK) {+ worker_error(thr, ret);+ return THR_STOP;+ }++ size_t in_pos = 0;+ size_t in_size = 0;++ *out_pos = thr->block_options.header_size;+ const size_t out_size = thr->outbuf->allocated;++ do {+ mythread_sync(thr->mutex) {+ // Store in_pos and *out_pos into *thr so that+ // an application may read them via+ // lzma_get_progress() to get progress information.+ //+ // NOTE: These aren't updated when the encoding+ // finishes. Instead, the final values are taken+ // later from thr->outbuf.+ thr->progress_in = in_pos;+ thr->progress_out = *out_pos;++ while (in_size == thr->in_size+ && thr->state == THR_RUN)+ mythread_cond_wait(&thr->cond, &thr->mutex);++ state = thr->state;+ in_size = thr->in_size;+ }++ // Return if we were asked to stop or exit.+ if (state >= THR_STOP)+ return state;++ lzma_action action = state == THR_FINISH+ ? LZMA_FINISH : LZMA_RUN;++ // Limit the amount of input given to the Block encoder+ // at once. This way this thread can react fairly quickly+ // if the main thread wants us to stop or exit.+ static const size_t in_chunk_max = 16384;+ size_t in_limit = in_size;+ if (in_size - in_pos > in_chunk_max) {+ in_limit = in_pos + in_chunk_max;+ action = LZMA_RUN;+ }++ ret = thr->block_encoder.code(+ thr->block_encoder.coder, thr->allocator,+ thr->in, &in_pos, in_limit, thr->outbuf->buf,+ out_pos, out_size, action);+ } while (ret == LZMA_OK && *out_pos < out_size);++ switch (ret) {+ case LZMA_STREAM_END:+ assert(state == THR_FINISH);++ // Encode the Block Header. By doing it after+ // the compression, we can store the Compressed Size+ // and Uncompressed Size fields.+ ret = lzma_block_header_encode(&thr->block_options,+ thr->outbuf->buf);+ if (ret != LZMA_OK) {+ worker_error(thr, ret);+ return THR_STOP;+ }++ break;++ case LZMA_OK:+ // The data was incompressible. Encode it using uncompressed+ // LZMA2 chunks.+ //+ // First wait that we have gotten all the input.+ mythread_sync(thr->mutex) {+ while (thr->state == THR_RUN)+ mythread_cond_wait(&thr->cond, &thr->mutex);++ state = thr->state;+ in_size = thr->in_size;+ }++ if (state >= THR_STOP)+ return state;++ // Do the encoding. This takes care of the Block Header too.+ *out_pos = 0;+ ret = lzma_block_uncomp_encode(&thr->block_options,+ thr->in, in_size, thr->outbuf->buf,+ out_pos, out_size);++ // It shouldn't fail.+ if (ret != LZMA_OK) {+ worker_error(thr, LZMA_PROG_ERROR);+ return THR_STOP;+ }++ break;++ default:+ worker_error(thr, ret);+ return THR_STOP;+ }++ // Set the size information that will be read by the main thread+ // to write the Index field.+ thr->outbuf->unpadded_size+ = lzma_block_unpadded_size(&thr->block_options);+ assert(thr->outbuf->unpadded_size != 0);+ thr->outbuf->uncompressed_size = thr->block_options.uncompressed_size;++ return THR_FINISH;+}+++static MYTHREAD_RET_TYPE+worker_start(void *thr_ptr)+{+ worker_thread *thr = thr_ptr;+ worker_state state = THR_IDLE; // Init to silence a warning++ while (true) {+ // Wait for work.+ mythread_sync(thr->mutex) {+ while (true) {+ // The thread is already idle so if we are+ // requested to stop, just set the state.+ if (thr->state == THR_STOP) {+ thr->state = THR_IDLE;+ mythread_cond_signal(&thr->cond);+ }++ state = thr->state;+ if (state != THR_IDLE)+ break;++ mythread_cond_wait(&thr->cond, &thr->mutex);+ }+ }++ size_t out_pos = 0;++ assert(state != THR_IDLE);+ assert(state != THR_STOP);++ if (state <= THR_FINISH)+ state = worker_encode(thr, &out_pos, state);++ if (state == THR_EXIT)+ break;++ // Mark the thread as idle unless the main thread has+ // told us to exit. Signal is needed for the case+ // where the main thread is waiting for the threads to stop.+ mythread_sync(thr->mutex) {+ if (thr->state != THR_EXIT) {+ thr->state = THR_IDLE;+ mythread_cond_signal(&thr->cond);+ }+ }++ mythread_sync(thr->coder->mutex) {+ // If no errors occurred, make the encoded data+ // available to be copied out.+ if (state == THR_FINISH) {+ thr->outbuf->pos = out_pos;+ thr->outbuf->finished = true;+ }++ // Update the main progress info.+ thr->coder->progress_in+ += thr->outbuf->uncompressed_size;+ thr->coder->progress_out += out_pos;+ thr->progress_in = 0;+ thr->progress_out = 0;++ // Return this thread to the stack of free threads.+ thr->next = thr->coder->threads_free;+ thr->coder->threads_free = thr;++ mythread_cond_signal(&thr->coder->cond);+ }+ }++ // Exiting, free the resources.+ lzma_filters_free(thr->filters, thr->allocator);++ mythread_mutex_destroy(&thr->mutex);+ mythread_cond_destroy(&thr->cond);++ lzma_next_end(&thr->block_encoder, thr->allocator);+ lzma_free(thr->in, thr->allocator);+ return MYTHREAD_RET_VALUE;+}+++/// Make the threads stop but not exit. Optionally wait for them to stop.+static void+threads_stop(lzma_stream_coder *coder, bool wait_for_threads)+{+ // Tell the threads to stop.+ for (uint32_t i = 0; i < coder->threads_initialized; ++i) {+ mythread_sync(coder->threads[i].mutex) {+ coder->threads[i].state = THR_STOP;+ mythread_cond_signal(&coder->threads[i].cond);+ }+ }++ if (!wait_for_threads)+ return;++ // Wait for the threads to settle in the idle state.+ for (uint32_t i = 0; i < coder->threads_initialized; ++i) {+ mythread_sync(coder->threads[i].mutex) {+ while (coder->threads[i].state != THR_IDLE)+ mythread_cond_wait(&coder->threads[i].cond,+ &coder->threads[i].mutex);+ }+ }++ return;+}+++/// Stop the threads and free the resources associated with them.+/// Wait until the threads have exited.+static void+threads_end(lzma_stream_coder *coder, const lzma_allocator *allocator)+{+ for (uint32_t i = 0; i < coder->threads_initialized; ++i) {+ mythread_sync(coder->threads[i].mutex) {+ coder->threads[i].state = THR_EXIT;+ mythread_cond_signal(&coder->threads[i].cond);+ }+ }++ for (uint32_t i = 0; i < coder->threads_initialized; ++i) {+ int ret = mythread_join(coder->threads[i].thread_id);+ assert(ret == 0);+ (void)ret;+ }++ lzma_free(coder->threads, allocator);+ return;+}+++/// Initialize a new worker_thread structure and create a new thread.+static lzma_ret+initialize_new_thread(lzma_stream_coder *coder,+ const lzma_allocator *allocator)+{+ worker_thread *thr = &coder->threads[coder->threads_initialized];++ thr->in = lzma_alloc(coder->block_size, allocator);+ if (thr->in == NULL)+ return LZMA_MEM_ERROR;++ if (mythread_mutex_init(&thr->mutex))+ goto error_mutex;++ if (mythread_cond_init(&thr->cond))+ goto error_cond;++ thr->state = THR_IDLE;+ thr->allocator = allocator;+ thr->coder = coder;+ thr->progress_in = 0;+ thr->progress_out = 0;+ thr->block_encoder = LZMA_NEXT_CODER_INIT;+ thr->filters[0].id = LZMA_VLI_UNKNOWN;++ if (mythread_create(&thr->thread_id, &worker_start, thr))+ goto error_thread;++ ++coder->threads_initialized;+ coder->thr = thr;++ return LZMA_OK;++error_thread:+ mythread_cond_destroy(&thr->cond);++error_cond:+ mythread_mutex_destroy(&thr->mutex);++error_mutex:+ lzma_free(thr->in, allocator);+ return LZMA_MEM_ERROR;+}+++static lzma_ret+get_thread(lzma_stream_coder *coder, const lzma_allocator *allocator)+{+ // If there are no free output subqueues, there is no+ // point to try getting a thread.+ if (!lzma_outq_has_buf(&coder->outq))+ return LZMA_OK;++ // That's also true if we cannot allocate memory for the output+ // buffer in the output queue.+ return_if_error(lzma_outq_prealloc_buf(&coder->outq, allocator,+ coder->outbuf_alloc_size));++ // Make a thread-specific copy of the filter chain. Put it in+ // the cache array first so that if we cannot get a new thread yet,+ // the allocation is ready when we try again.+ if (coder->filters_cache[0].id == LZMA_VLI_UNKNOWN)+ return_if_error(lzma_filters_copy(+ coder->filters, coder->filters_cache, allocator));++ // If there is a free structure on the stack, use it.+ mythread_sync(coder->mutex) {+ if (coder->threads_free != NULL) {+ coder->thr = coder->threads_free;+ coder->threads_free = coder->threads_free->next;+ }+ }++ if (coder->thr == NULL) {+ // If there are no uninitialized structures left, return.+ if (coder->threads_initialized == coder->threads_max)+ return LZMA_OK;++ // Initialize a new thread.+ return_if_error(initialize_new_thread(coder, allocator));+ }++ // Reset the parts of the thread state that have to be done+ // in the main thread.+ mythread_sync(coder->thr->mutex) {+ coder->thr->state = THR_RUN;+ coder->thr->in_size = 0;+ coder->thr->outbuf = lzma_outq_get_buf(&coder->outq, NULL);++ // Free the old thread-specific filter options and replace+ // them with the already-allocated new options from+ // coder->filters_cache[]. Then mark the cache as empty.+ lzma_filters_free(coder->thr->filters, allocator);+ memcpy(coder->thr->filters, coder->filters_cache,+ sizeof(coder->filters_cache));+ coder->filters_cache[0].id = LZMA_VLI_UNKNOWN;++ mythread_cond_signal(&coder->thr->cond);+ }++ return LZMA_OK;+}+++static lzma_ret+stream_encode_in(lzma_stream_coder *coder, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, lzma_action action)+{+ while (*in_pos < in_size+ || (coder->thr != NULL && action != LZMA_RUN)) {+ if (coder->thr == NULL) {+ // Get a new thread.+ const lzma_ret ret = get_thread(coder, allocator);+ if (coder->thr == NULL)+ return ret;+ }++ // Copy the input data to thread's buffer.+ size_t thr_in_size = coder->thr->in_size;+ lzma_bufcpy(in, in_pos, in_size, coder->thr->in,+ &thr_in_size, coder->block_size);++ // Tell the Block encoder to finish if+ // - it has got block_size bytes of input; or+ // - all input was used and LZMA_FINISH, LZMA_FULL_FLUSH,+ // or LZMA_FULL_BARRIER was used.+ //+ // TODO: LZMA_SYNC_FLUSH and LZMA_SYNC_BARRIER.+ const bool finish = thr_in_size == coder->block_size+ || (*in_pos == in_size && action != LZMA_RUN);++ bool block_error = false;++ mythread_sync(coder->thr->mutex) {+ if (coder->thr->state == THR_IDLE) {+ // Something has gone wrong with the Block+ // encoder. It has set coder->thread_error+ // which we will read a few lines later.+ block_error = true;+ } else {+ // Tell the Block encoder its new amount+ // of input and update the state if needed.+ coder->thr->in_size = thr_in_size;++ if (finish)+ coder->thr->state = THR_FINISH;++ mythread_cond_signal(&coder->thr->cond);+ }+ }++ if (block_error) {+ lzma_ret ret = LZMA_OK; // Init to silence a warning.++ mythread_sync(coder->mutex) {+ ret = coder->thread_error;+ }++ return ret;+ }++ if (finish)+ coder->thr = NULL;+ }++ return LZMA_OK;+}+++/// Wait until more input can be consumed, more output can be read, or+/// an optional timeout is reached.+static bool+wait_for_work(lzma_stream_coder *coder, mythread_condtime *wait_abs,+ bool *has_blocked, bool has_input)+{+ if (coder->timeout != 0 && !*has_blocked) {+ // Every time when stream_encode_mt() is called via+ // lzma_code(), *has_blocked starts as false. We set it+ // to true here and calculate the absolute time when+ // we must return if there's nothing to do.+ //+ // This way if we block multiple times for short moments+ // less than "timeout" milliseconds, we will return once+ // "timeout" amount of time has passed since the *first*+ // blocking occurred. If the absolute time was calculated+ // again every time we block, "timeout" would effectively+ // be meaningless if we never consecutively block longer+ // than "timeout" ms.+ *has_blocked = true;+ mythread_condtime_set(wait_abs, &coder->cond, coder->timeout);+ }++ bool timed_out = false;++ mythread_sync(coder->mutex) {+ // There are four things that we wait. If one of them+ // becomes possible, we return.+ // - If there is input left, we need to get a free+ // worker thread and an output buffer for it.+ // - Data ready to be read from the output queue.+ // - A worker thread indicates an error.+ // - Time out occurs.+ while ((!has_input || coder->threads_free == NULL+ || !lzma_outq_has_buf(&coder->outq))+ && !lzma_outq_is_readable(&coder->outq)+ && coder->thread_error == LZMA_OK+ && !timed_out) {+ if (coder->timeout != 0)+ timed_out = mythread_cond_timedwait(+ &coder->cond, &coder->mutex,+ wait_abs) != 0;+ else+ mythread_cond_wait(&coder->cond,+ &coder->mutex);+ }+ }++ return timed_out;+}+++static lzma_ret+stream_encode_mt(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size, lzma_action action)+{+ lzma_stream_coder *coder = coder_ptr;++ switch (coder->sequence) {+ case SEQ_STREAM_HEADER:+ lzma_bufcpy(coder->header, &coder->header_pos,+ sizeof(coder->header),+ out, out_pos, out_size);+ if (coder->header_pos < sizeof(coder->header))+ return LZMA_OK;++ coder->header_pos = 0;+ coder->sequence = SEQ_BLOCK;++ // Fall through++ case SEQ_BLOCK: {+ // Initialized to silence warnings.+ lzma_vli unpadded_size = 0;+ lzma_vli uncompressed_size = 0;+ lzma_ret ret = LZMA_OK;++ // These are for wait_for_work().+ bool has_blocked = false;+ mythread_condtime wait_abs = { 0 };++ while (true) {+ mythread_sync(coder->mutex) {+ // Check for Block encoder errors.+ ret = coder->thread_error;+ if (ret != LZMA_OK) {+ assert(ret != LZMA_STREAM_END);+ break; // Break out of mythread_sync.+ }++ // Try to read compressed data to out[].+ ret = lzma_outq_read(&coder->outq, allocator,+ out, out_pos, out_size,+ &unpadded_size,+ &uncompressed_size);+ }++ if (ret == LZMA_STREAM_END) {+ // End of Block. Add it to the Index.+ ret = lzma_index_append(coder->index,+ allocator, unpadded_size,+ uncompressed_size);+ if (ret != LZMA_OK) {+ threads_stop(coder, false);+ return ret;+ }++ // If we didn't fill the output buffer yet,+ // try to read more data. Maybe the next+ // outbuf has been finished already too.+ if (*out_pos < out_size)+ continue;+ }++ if (ret != LZMA_OK) {+ // coder->thread_error was set.+ threads_stop(coder, false);+ return ret;+ }++ // Try to give uncompressed data to a worker thread.+ ret = stream_encode_in(coder, allocator,+ in, in_pos, in_size, action);+ if (ret != LZMA_OK) {+ threads_stop(coder, false);+ return ret;+ }++ // See if we should wait or return.+ //+ // TODO: LZMA_SYNC_FLUSH and LZMA_SYNC_BARRIER.+ if (*in_pos == in_size) {+ // LZMA_RUN: More data is probably coming+ // so return to let the caller fill the+ // input buffer.+ if (action == LZMA_RUN)+ return LZMA_OK;++ // LZMA_FULL_BARRIER: The same as with+ // LZMA_RUN but tell the caller that the+ // barrier was completed.+ if (action == LZMA_FULL_BARRIER)+ return LZMA_STREAM_END;++ // Finishing or flushing isn't completed until+ // all input data has been encoded and copied+ // to the output buffer.+ if (lzma_outq_is_empty(&coder->outq)) {+ // LZMA_FINISH: Continue to encode+ // the Index field.+ if (action == LZMA_FINISH)+ break;++ // LZMA_FULL_FLUSH: Return to tell+ // the caller that flushing was+ // completed.+ if (action == LZMA_FULL_FLUSH)+ return LZMA_STREAM_END;+ }+ }++ // Return if there is no output space left.+ // This check must be done after testing the input+ // buffer, because we might want to use a different+ // return code.+ if (*out_pos == out_size)+ return LZMA_OK;++ // Neither in nor out has been used completely.+ // Wait until there's something we can do.+ if (wait_for_work(coder, &wait_abs, &has_blocked,+ *in_pos < in_size))+ return LZMA_TIMED_OUT;+ }++ // All Blocks have been encoded and the threads have stopped.+ // Prepare to encode the Index field.+ return_if_error(lzma_index_encoder_init(+ &coder->index_encoder, allocator,+ coder->index));+ coder->sequence = SEQ_INDEX;++ // Update the progress info to take the Index and+ // Stream Footer into account. Those are very fast to encode+ // so in terms of progress information they can be thought+ // to be ready to be copied out.+ coder->progress_out += lzma_index_size(coder->index)+ + LZMA_STREAM_HEADER_SIZE;+ }++ // Fall through++ case SEQ_INDEX: {+ // Call the Index encoder. It doesn't take any input, so+ // those pointers can be NULL.+ const lzma_ret ret = coder->index_encoder.code(+ coder->index_encoder.coder, allocator,+ NULL, NULL, 0,+ out, out_pos, out_size, LZMA_RUN);+ if (ret != LZMA_STREAM_END)+ return ret;++ // Encode the Stream Footer into coder->buffer.+ coder->stream_flags.backward_size+ = lzma_index_size(coder->index);+ if (lzma_stream_footer_encode(&coder->stream_flags,+ coder->header) != LZMA_OK)+ return LZMA_PROG_ERROR;++ coder->sequence = SEQ_STREAM_FOOTER;+ }++ // Fall through++ case SEQ_STREAM_FOOTER:+ lzma_bufcpy(coder->header, &coder->header_pos,+ sizeof(coder->header),+ out, out_pos, out_size);+ return coder->header_pos < sizeof(coder->header)+ ? LZMA_OK : LZMA_STREAM_END;+ }++ assert(0);+ return LZMA_PROG_ERROR;+}+++static void+stream_encoder_mt_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_stream_coder *coder = coder_ptr;++ // Threads must be killed before the output queue can be freed.+ threads_end(coder, allocator);+ lzma_outq_end(&coder->outq, allocator);++ lzma_filters_free(coder->filters, allocator);+ lzma_filters_free(coder->filters_cache, allocator);++ lzma_next_end(&coder->index_encoder, allocator);+ lzma_index_end(coder->index, allocator);++ mythread_cond_destroy(&coder->cond);+ mythread_mutex_destroy(&coder->mutex);++ lzma_free(coder, allocator);+ return;+}+++static lzma_ret+stream_encoder_mt_update(void *coder_ptr, const lzma_allocator *allocator,+ const lzma_filter *filters,+ const lzma_filter *reversed_filters+ lzma_attribute((__unused__)))+{+ lzma_stream_coder *coder = coder_ptr;++ // Applications shouldn't attempt to change the options when+ // we are already encoding the Index or Stream Footer.+ if (coder->sequence > SEQ_BLOCK)+ return LZMA_PROG_ERROR;++ // For now the threaded encoder doesn't support changing+ // the options in the middle of a Block.+ if (coder->thr != NULL)+ return LZMA_PROG_ERROR;++ // Check if the filter chain seems mostly valid. See the comment+ // in stream_encoder_mt_init().+ if (lzma_raw_encoder_memusage(filters) == UINT64_MAX)+ return LZMA_OPTIONS_ERROR;++ // Make a copy to a temporary buffer first. This way the encoder+ // state stays unchanged if an error occurs in lzma_filters_copy().+ lzma_filter temp[LZMA_FILTERS_MAX + 1];+ return_if_error(lzma_filters_copy(filters, temp, allocator));++ // Free the options of the old chain as well as the cache.+ lzma_filters_free(coder->filters, allocator);+ lzma_filters_free(coder->filters_cache, allocator);++ // Copy the new filter chain in place.+ memcpy(coder->filters, temp, sizeof(temp));++ return LZMA_OK;+}+++/// Options handling for lzma_stream_encoder_mt_init() and+/// lzma_stream_encoder_mt_memusage()+static lzma_ret+get_options(const lzma_mt *options, lzma_options_easy *opt_easy,+ const lzma_filter **filters, uint64_t *block_size,+ uint64_t *outbuf_size_max)+{+ // Validate some of the options.+ if (options == NULL)+ return LZMA_PROG_ERROR;++ if (options->flags != 0 || options->threads == 0+ || options->threads > LZMA_THREADS_MAX)+ return LZMA_OPTIONS_ERROR;++ if (options->filters != NULL) {+ // Filter chain was given, use it as is.+ *filters = options->filters;+ } else {+ // Use a preset.+ if (lzma_easy_preset(opt_easy, options->preset))+ return LZMA_OPTIONS_ERROR;++ *filters = opt_easy->filters;+ }++ // If the Block size is not set, determine it from the filter chain.+ if (options->block_size > 0)+ *block_size = options->block_size;+ else+ *block_size = lzma_mt_block_size(*filters);++ // UINT64_MAX > BLOCK_SIZE_MAX, so the second condition+ // should be optimized out by any reasonable compiler.+ // The second condition should be there in the unlikely event that+ // the macros change and UINT64_MAX < BLOCK_SIZE_MAX.+ if (*block_size > BLOCK_SIZE_MAX || *block_size == UINT64_MAX)+ return LZMA_OPTIONS_ERROR;++ // Calculate the maximum amount output that a single output buffer+ // may need to hold. This is the same as the maximum total size of+ // a Block.+ *outbuf_size_max = lzma_block_buffer_bound64(*block_size);+ if (*outbuf_size_max == 0)+ return LZMA_MEM_ERROR;++ return LZMA_OK;+}+++static void+get_progress(void *coder_ptr, uint64_t *progress_in, uint64_t *progress_out)+{+ lzma_stream_coder *coder = coder_ptr;++ // Lock coder->mutex to prevent finishing threads from moving their+ // progress info from the worker_thread structure to lzma_stream_coder.+ mythread_sync(coder->mutex) {+ *progress_in = coder->progress_in;+ *progress_out = coder->progress_out;++ for (size_t i = 0; i < coder->threads_initialized; ++i) {+ mythread_sync(coder->threads[i].mutex) {+ *progress_in += coder->threads[i].progress_in;+ *progress_out += coder->threads[i]+ .progress_out;+ }+ }+ }++ return;+}+++static lzma_ret+stream_encoder_mt_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_mt *options)+{+ lzma_next_coder_init(&stream_encoder_mt_init, next, allocator);++ // Get the filter chain.+ lzma_options_easy easy;+ const lzma_filter *filters;+ uint64_t block_size;+ uint64_t outbuf_size_max;+ return_if_error(get_options(options, &easy, &filters,+ &block_size, &outbuf_size_max));++#if SIZE_MAX < UINT64_MAX+ if (block_size > SIZE_MAX || outbuf_size_max > SIZE_MAX)+ return LZMA_MEM_ERROR;+#endif++ // Validate the filter chain so that we can give an error in this+ // function instead of delaying it to the first call to lzma_code().+ // The memory usage calculation verifies the filter chain as+ // a side effect so we take advantage of that. It's not a perfect+ // check though as raw encoder allows LZMA1 too but such problems+ // will be caught eventually with Block Header encoder.+ if (lzma_raw_encoder_memusage(filters) == UINT64_MAX)+ return LZMA_OPTIONS_ERROR;++ // Validate the Check ID.+ if ((unsigned int)(options->check) > LZMA_CHECK_ID_MAX)+ return LZMA_PROG_ERROR;++ if (!lzma_check_is_supported(options->check))+ return LZMA_UNSUPPORTED_CHECK;++ // Allocate and initialize the base structure if needed.+ lzma_stream_coder *coder = next->coder;+ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_stream_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;++ // For the mutex and condition variable initializations+ // the error handling has to be done here because+ // stream_encoder_mt_end() doesn't know if they have+ // already been initialized or not.+ if (mythread_mutex_init(&coder->mutex)) {+ lzma_free(coder, allocator);+ next->coder = NULL;+ return LZMA_MEM_ERROR;+ }++ if (mythread_cond_init(&coder->cond)) {+ mythread_mutex_destroy(&coder->mutex);+ lzma_free(coder, allocator);+ next->coder = NULL;+ return LZMA_MEM_ERROR;+ }++ next->code = &stream_encode_mt;+ next->end = &stream_encoder_mt_end;+ next->get_progress = &get_progress;+ next->update = &stream_encoder_mt_update;++ coder->filters[0].id = LZMA_VLI_UNKNOWN;+ coder->filters_cache[0].id = LZMA_VLI_UNKNOWN;+ coder->index_encoder = LZMA_NEXT_CODER_INIT;+ coder->index = NULL;+ memzero(&coder->outq, sizeof(coder->outq));+ coder->threads = NULL;+ coder->threads_max = 0;+ coder->threads_initialized = 0;+ }++ // Basic initializations+ coder->sequence = SEQ_STREAM_HEADER;+ coder->block_size = (size_t)(block_size);+ coder->outbuf_alloc_size = (size_t)(outbuf_size_max);+ coder->thread_error = LZMA_OK;+ coder->thr = NULL;++ // Allocate the thread-specific base structures.+ assert(options->threads > 0);+ if (coder->threads_max != options->threads) {+ threads_end(coder, allocator);++ coder->threads = NULL;+ coder->threads_max = 0;++ coder->threads_initialized = 0;+ coder->threads_free = NULL;++ coder->threads = lzma_alloc(+ options->threads * sizeof(worker_thread),+ allocator);+ if (coder->threads == NULL)+ return LZMA_MEM_ERROR;++ coder->threads_max = options->threads;+ } else {+ // Reuse the old structures and threads. Tell the running+ // threads to stop and wait until they have stopped.+ threads_stop(coder, true);+ }++ // Output queue+ return_if_error(lzma_outq_init(&coder->outq, allocator,+ options->threads));++ // Timeout+ coder->timeout = options->timeout;++ // Free the old filter chain and the cache.+ lzma_filters_free(coder->filters, allocator);+ lzma_filters_free(coder->filters_cache, allocator);++ // Copy the new filter chain.+ return_if_error(lzma_filters_copy(+ filters, coder->filters, allocator));++ // Index+ lzma_index_end(coder->index, allocator);+ coder->index = lzma_index_init(allocator);+ if (coder->index == NULL)+ return LZMA_MEM_ERROR;++ // Stream Header+ coder->stream_flags.version = 0;+ coder->stream_flags.check = options->check;+ return_if_error(lzma_stream_header_encode(+ &coder->stream_flags, coder->header));++ coder->header_pos = 0;++ // Progress info+ coder->progress_in = 0;+ coder->progress_out = LZMA_STREAM_HEADER_SIZE;++ return LZMA_OK;+}+++#ifdef HAVE_SYMBOL_VERSIONS_LINUX+// These are for compatibility with binaries linked against liblzma that+// has been patched with xz-5.2.2-compat-libs.patch from RHEL/CentOS 7.+// Actually that patch didn't create lzma_stream_encoder_mt@XZ_5.2.2+// but it has been added here anyway since someone might misread the+// RHEL patch and think both @XZ_5.1.2alpha and @XZ_5.2.2 exist.+LZMA_SYMVER_API("lzma_stream_encoder_mt@XZ_5.1.2alpha",+ lzma_ret, lzma_stream_encoder_mt_512a)(+ lzma_stream *strm, const lzma_mt *options)+ lzma_nothrow lzma_attr_warn_unused_result+ __attribute__((__alias__("lzma_stream_encoder_mt_52")));++LZMA_SYMVER_API("lzma_stream_encoder_mt@XZ_5.2.2",+ lzma_ret, lzma_stream_encoder_mt_522)(+ lzma_stream *strm, const lzma_mt *options)+ lzma_nothrow lzma_attr_warn_unused_result+ __attribute__((__alias__("lzma_stream_encoder_mt_52")));++LZMA_SYMVER_API("lzma_stream_encoder_mt@@XZ_5.2",+ lzma_ret, lzma_stream_encoder_mt_52)(+ lzma_stream *strm, const lzma_mt *options)+ lzma_nothrow lzma_attr_warn_unused_result;++#define lzma_stream_encoder_mt lzma_stream_encoder_mt_52+#endif+extern LZMA_API(lzma_ret)+lzma_stream_encoder_mt(lzma_stream *strm, const lzma_mt *options)+{+ lzma_next_strm_init(stream_encoder_mt_init, strm, options);++ strm->internal->supported_actions[LZMA_RUN] = true;+// strm->internal->supported_actions[LZMA_SYNC_FLUSH] = true;+ strm->internal->supported_actions[LZMA_FULL_FLUSH] = true;+ strm->internal->supported_actions[LZMA_FULL_BARRIER] = true;+ strm->internal->supported_actions[LZMA_FINISH] = true;++ return LZMA_OK;+}+++#ifdef HAVE_SYMBOL_VERSIONS_LINUX+LZMA_SYMVER_API("lzma_stream_encoder_mt_memusage@XZ_5.1.2alpha",+ uint64_t, lzma_stream_encoder_mt_memusage_512a)(+ const lzma_mt *options) lzma_nothrow lzma_attr_pure+ __attribute__((__alias__("lzma_stream_encoder_mt_memusage_52")));++LZMA_SYMVER_API("lzma_stream_encoder_mt_memusage@XZ_5.2.2",+ uint64_t, lzma_stream_encoder_mt_memusage_522)(+ const lzma_mt *options) lzma_nothrow lzma_attr_pure+ __attribute__((__alias__("lzma_stream_encoder_mt_memusage_52")));++LZMA_SYMVER_API("lzma_stream_encoder_mt_memusage@@XZ_5.2",+ uint64_t, lzma_stream_encoder_mt_memusage_52)(+ const lzma_mt *options) lzma_nothrow lzma_attr_pure;++#define lzma_stream_encoder_mt_memusage lzma_stream_encoder_mt_memusage_52+#endif+// This function name is a monster but it's consistent with the older+// monster names. :-( 31 chars is the max that C99 requires so in that+// sense it's not too long. ;-)+extern LZMA_API(uint64_t)+lzma_stream_encoder_mt_memusage(const lzma_mt *options)+{+ lzma_options_easy easy;+ const lzma_filter *filters;+ uint64_t block_size;+ uint64_t outbuf_size_max;++ if (get_options(options, &easy, &filters, &block_size,+ &outbuf_size_max) != LZMA_OK)+ return UINT64_MAX;++ // Memory usage of the input buffers+ const uint64_t inbuf_memusage = options->threads * block_size;++ // Memory usage of the filter encoders+ uint64_t filters_memusage = lzma_raw_encoder_memusage(filters);+ if (filters_memusage == UINT64_MAX)+ return UINT64_MAX;++ filters_memusage *= options->threads;++ // Memory usage of the output queue+ const uint64_t outq_memusage = lzma_outq_memusage(+ outbuf_size_max, options->threads);+ if (outq_memusage == UINT64_MAX)+ return UINT64_MAX;++ // Sum them with overflow checking.+ uint64_t total_memusage = LZMA_MEMUSAGE_BASE+ + sizeof(lzma_stream_coder)+ + options->threads * sizeof(worker_thread);++ if (UINT64_MAX - total_memusage < inbuf_memusage)+ return UINT64_MAX;++ total_memusage += inbuf_memusage;++ if (UINT64_MAX - total_memusage < filters_memusage)+ return UINT64_MAX;++ total_memusage += filters_memusage;++ if (UINT64_MAX - total_memusage < outq_memusage)+ return UINT64_MAX;++ return total_memusage + outq_memusage;+}
+ cbits/liblzma/common/stream_flags_common.c view
@@ -0,0 +1,46 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file stream_flags_common.c+/// \brief Common stuff for Stream flags coders+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "stream_flags_common.h"+++const uint8_t lzma_header_magic[6] = { 0xFD, 0x37, 0x7A, 0x58, 0x5A, 0x00 };+const uint8_t lzma_footer_magic[2] = { 0x59, 0x5A };+++extern LZMA_API(lzma_ret)+lzma_stream_flags_compare(+ const lzma_stream_flags *a, const lzma_stream_flags *b)+{+ // We can compare only version 0 structures.+ if (a->version != 0 || b->version != 0)+ return LZMA_OPTIONS_ERROR;++ // Check type+ if ((unsigned int)(a->check) > LZMA_CHECK_ID_MAX+ || (unsigned int)(b->check) > LZMA_CHECK_ID_MAX)+ return LZMA_PROG_ERROR;++ if (a->check != b->check)+ return LZMA_DATA_ERROR;++ // Backward Sizes are compared only if they are known in both.+ if (a->backward_size != LZMA_VLI_UNKNOWN+ && b->backward_size != LZMA_VLI_UNKNOWN) {+ if (!is_backward_size_valid(a) || !is_backward_size_valid(b))+ return LZMA_PROG_ERROR;++ if (a->backward_size != b->backward_size)+ return LZMA_DATA_ERROR;+ }++ return LZMA_OK;+}
+ cbits/liblzma/common/stream_flags_common.h view
@@ -0,0 +1,35 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file stream_flags_common.h+/// \brief Common stuff for Stream flags coders+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_STREAM_FLAGS_COMMON_H+#define LZMA_STREAM_FLAGS_COMMON_H++#include "common.h"++/// Size of the Stream Flags field+#define LZMA_STREAM_FLAGS_SIZE 2++lzma_attr_visibility_hidden+extern const uint8_t lzma_header_magic[6];++lzma_attr_visibility_hidden+extern const uint8_t lzma_footer_magic[2];+++static inline bool+is_backward_size_valid(const lzma_stream_flags *options)+{+ return options->backward_size >= LZMA_BACKWARD_SIZE_MIN+ && options->backward_size <= LZMA_BACKWARD_SIZE_MAX+ && (options->backward_size & 3) == 0;+}++#endif
+ cbits/liblzma/common/stream_flags_decoder.c view
@@ -0,0 +1,87 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file stream_flags_decoder.c+/// \brief Decodes Stream Header and Stream Footer from .xz files+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "stream_flags_common.h"+++static bool+stream_flags_decode(lzma_stream_flags *options, const uint8_t *in)+{+ // Reserved bits must be unset.+ if (in[0] != 0x00 || (in[1] & 0xF0))+ return true;++ options->version = 0;+ options->check = in[1] & 0x0F;++ return false;+}+++extern LZMA_API(lzma_ret)+lzma_stream_header_decode(lzma_stream_flags *options, const uint8_t *in)+{+ // Magic+ if (memcmp(in, lzma_header_magic, sizeof(lzma_header_magic)) != 0)+ return LZMA_FORMAT_ERROR;++ // Verify the CRC32 so we can distinguish between corrupt+ // and unsupported files.+ const uint32_t crc = lzma_crc32(in + sizeof(lzma_header_magic),+ LZMA_STREAM_FLAGS_SIZE, 0);+ if (crc != read32le(in + sizeof(lzma_header_magic)+ + LZMA_STREAM_FLAGS_SIZE)) {+#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION+ return LZMA_DATA_ERROR;+#endif+ }++ // Stream Flags+ if (stream_flags_decode(options, in + sizeof(lzma_header_magic)))+ return LZMA_OPTIONS_ERROR;++ // Set Backward Size to indicate unknown value. That way+ // lzma_stream_flags_compare() can be used to compare Stream Header+ // and Stream Footer while keeping it useful also for comparing+ // two Stream Footers.+ options->backward_size = LZMA_VLI_UNKNOWN;++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_stream_footer_decode(lzma_stream_flags *options, const uint8_t *in)+{+ // Magic+ if (memcmp(in + sizeof(uint32_t) * 2 + LZMA_STREAM_FLAGS_SIZE,+ lzma_footer_magic, sizeof(lzma_footer_magic)) != 0)+ return LZMA_FORMAT_ERROR;++ // CRC32+ const uint32_t crc = lzma_crc32(in + sizeof(uint32_t),+ sizeof(uint32_t) + LZMA_STREAM_FLAGS_SIZE, 0);+ if (crc != read32le(in)) {+#ifndef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION+ return LZMA_DATA_ERROR;+#endif+ }++ // Stream Flags+ if (stream_flags_decode(options, in + sizeof(uint32_t) * 2))+ return LZMA_OPTIONS_ERROR;++ // Backward Size+ options->backward_size = read32le(in + sizeof(uint32_t));+ options->backward_size = (options->backward_size + 1) * 4;++ return LZMA_OK;+}
+ cbits/liblzma/common/stream_flags_encoder.c view
@@ -0,0 +1,85 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file stream_flags_encoder.c+/// \brief Encodes Stream Header and Stream Footer for .xz files+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "stream_flags_common.h"+++static bool+stream_flags_encode(const lzma_stream_flags *options, uint8_t *out)+{+ if ((unsigned int)(options->check) > LZMA_CHECK_ID_MAX)+ return true;++ out[0] = 0x00;+ out[1] = options->check;++ return false;+}+++extern LZMA_API(lzma_ret)+lzma_stream_header_encode(const lzma_stream_flags *options, uint8_t *out)+{+ assert(sizeof(lzma_header_magic) + LZMA_STREAM_FLAGS_SIZE+ + 4 == LZMA_STREAM_HEADER_SIZE);++ if (options->version != 0)+ return LZMA_OPTIONS_ERROR;++ // Magic+ memcpy(out, lzma_header_magic, sizeof(lzma_header_magic));++ // Stream Flags+ if (stream_flags_encode(options, out + sizeof(lzma_header_magic)))+ return LZMA_PROG_ERROR;++ // CRC32 of the Stream Header+ const uint32_t crc = lzma_crc32(out + sizeof(lzma_header_magic),+ LZMA_STREAM_FLAGS_SIZE, 0);++ write32le(out + sizeof(lzma_header_magic) + LZMA_STREAM_FLAGS_SIZE,+ crc);++ return LZMA_OK;+}+++extern LZMA_API(lzma_ret)+lzma_stream_footer_encode(const lzma_stream_flags *options, uint8_t *out)+{+ assert(2 * 4 + LZMA_STREAM_FLAGS_SIZE + sizeof(lzma_footer_magic)+ == LZMA_STREAM_HEADER_SIZE);++ if (options->version != 0)+ return LZMA_OPTIONS_ERROR;++ // Backward Size+ if (!is_backward_size_valid(options))+ return LZMA_PROG_ERROR;++ write32le(out + 4, options->backward_size / 4 - 1);++ // Stream Flags+ if (stream_flags_encode(options, out + 2 * 4))+ return LZMA_PROG_ERROR;++ // CRC32+ const uint32_t crc = lzma_crc32(+ out + 4, 4 + LZMA_STREAM_FLAGS_SIZE, 0);++ write32le(out, crc);++ // Magic+ memcpy(out + 2 * 4 + LZMA_STREAM_FLAGS_SIZE,+ lzma_footer_magic, sizeof(lzma_footer_magic));++ return LZMA_OK;+}
+ cbits/liblzma/common/string_conversion.c view
@@ -0,0 +1,1338 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file string_conversion.c+/// \brief Conversion of strings to filter chain and vice versa+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "filter_common.h"+++/////////////////////+// String building //+/////////////////////++/// How much memory to allocate for strings. For now, no realloc is used+/// so this needs to be big enough even though there of course is+/// an overflow check still.+///+/// FIXME? Using a fixed size is wasteful if the application doesn't free+/// the string fairly quickly but this can be improved later if needed.+#define STR_ALLOC_SIZE 800+++typedef struct {+ char *buf;+ size_t pos;+} lzma_str;+++static lzma_ret+str_init(lzma_str *str, const lzma_allocator *allocator)+{+ str->buf = lzma_alloc(STR_ALLOC_SIZE, allocator);+ if (str->buf == NULL)+ return LZMA_MEM_ERROR;++ str->pos = 0;+ return LZMA_OK;+}+++static void+str_free(lzma_str *str, const lzma_allocator *allocator)+{+ lzma_free(str->buf, allocator);+ return;+}+++static bool+str_is_full(const lzma_str *str)+{+ return str->pos == STR_ALLOC_SIZE - 1;+}+++static lzma_ret+str_finish(char **dest, lzma_str *str, const lzma_allocator *allocator)+{+ if (str_is_full(str)) {+ // The preallocated buffer was too small.+ // This shouldn't happen as STR_ALLOC_SIZE should+ // be adjusted if new filters are added.+ lzma_free(str->buf, allocator);+ *dest = NULL;+ assert(0);+ return LZMA_PROG_ERROR;+ }++ str->buf[str->pos] = '\0';+ *dest = str->buf;+ return LZMA_OK;+}+++static void+str_append_str(lzma_str *str, const char *s)+{+ const size_t len = strlen(s);+ const size_t limit = STR_ALLOC_SIZE - 1 - str->pos;+ const size_t copy_size = my_min(len, limit);++ memcpy(str->buf + str->pos, s, copy_size);+ str->pos += copy_size;+ return;+}+++static void+str_append_u32(lzma_str *str, uint32_t v, bool use_byte_suffix)+{+ if (v == 0) {+ str_append_str(str, "0");+ } else {+ // NOTE: Don't use plain "B" because xz and the parser in this+ // file don't support it and at glance it may look like 8+ // (there cannot be a space before the suffix).+ static const char suffixes[4][4] = { "", "KiB", "MiB", "GiB" };++ size_t suf = 0;+ if (use_byte_suffix) {+ while ((v & 1023) == 0+ && suf < ARRAY_SIZE(suffixes) - 1) {+ v >>= 10;+ ++suf;+ }+ }++ // UINT32_MAX in base 10 would need 10 + 1 bytes. Remember+ // that initializing to "" initializes all elements to+ // zero so '\0'-termination gets handled by this.+ char buf[16] = "";+ size_t pos = sizeof(buf) - 1;++ do {+ buf[--pos] = '0' + (v % 10);+ v /= 10;+ } while (v != 0);++ str_append_str(str, buf + pos);+ str_append_str(str, suffixes[suf]);+ }++ return;+}+++//////////////////////////////////////////////+// Parsing and stringification declarations //+//////////////////////////////////////////////++/// Maximum length for filter and option names.+/// 11 chars + terminating '\0' + sizeof(uint32_t) = 16 bytes+#define NAME_LEN_MAX 11+++/// For option_map.flags: Use .u.map to do convert the input value+/// to an integer. Without this flag, .u.range.{min,max} are used+/// as the allowed range for the integer.+#define OPTMAP_USE_NAME_VALUE_MAP 0x01++/// For option_map.flags: Allow KiB/MiB/GiB in input string and use them in+/// the stringified output if the value is an exact multiple of these.+/// This is used e.g. for LZMA1/2 dictionary size.+#define OPTMAP_USE_BYTE_SUFFIX 0x02++/// For option_map.flags: If the integer value is zero then this option+/// won't be included in the stringified output. It's used e.g. for+/// BCJ filter start offset which usually is zero.+#define OPTMAP_NO_STRFY_ZERO 0x04++/// Possible values for option_map.type. Since OPTMAP_TYPE_UINT32 is 0,+/// it doesn't need to be specified in the initializers as it is+/// the implicit value.+enum {+ OPTMAP_TYPE_UINT32,+ OPTMAP_TYPE_LZMA_MODE,+ OPTMAP_TYPE_LZMA_MATCH_FINDER,+ OPTMAP_TYPE_LZMA_PRESET,+};+++/// This is for mapping string values in options to integers.+/// The last element of an array must have "" as the name.+/// It's used e.g. for match finder names in LZMA1/2.+typedef struct {+ const char name[NAME_LEN_MAX + 1];+ const uint32_t value;+} name_value_map;+++/// Each filter that has options needs an array of option_map structures.+/// The array doesn't need to be terminated as the functions take the+/// length of the array as an argument.+///+/// When converting a string to filter options structure, option values+/// will be handled in a few different ways:+///+/// (1) If .type equals OPTMAP_TYPE_LZMA_PRESET then LZMA1/2 preset string+/// is handled specially.+///+/// (2) If .flags has OPTMAP_USE_NAME_VALUE_MAP set then the string is+/// converted to an integer using the name_value_map pointed by .u.map.+/// The last element in .u.map must have .name = "" as the terminator.+///+/// (3) Otherwise the string is treated as a non-negative unsigned decimal+/// integer which must be in the range set in .u.range. If .flags has+/// OPTMAP_USE_BYTE_SUFFIX then KiB, MiB, and GiB suffixes are allowed.+///+/// The integer value from (2) or (3) is then stored to filter_options+/// at the offset specified in .offset using the type specified in .type+/// (default is uint32_t).+///+/// Stringifying a filter is done by processing a given number of options+/// in order from the beginning of an option_map array. The integer is+/// read from filter_options at .offset using the type from .type.+///+/// If the integer is zero and .flags has OPTMAP_NO_STRFY_ZERO then the+/// option is skipped.+///+/// If .flags has OPTMAP_USE_NAME_VALUE_MAP set then .u.map will be used+/// to convert the option to a string. If the map doesn't contain a string+/// for the integer value then "UNKNOWN" is used.+///+/// If .flags doesn't have OPTMAP_USE_NAME_VALUE_MAP set then the integer is+/// converted to a decimal value. If OPTMAP_USE_BYTE_SUFFIX is used then KiB,+/// MiB, or GiB suffix is used if the value is an exact multiple of these.+/// Plain "B" suffix is never used.+typedef struct {+ char name[NAME_LEN_MAX + 1];+ uint8_t type;+ uint8_t flags;+ uint16_t offset;++ union {+ // NVHPC has problems with unions that contain pointers that+ // are not the first members, so keep "map" at the top.+ const name_value_map *map;++ struct {+ uint32_t min;+ uint32_t max;+ } range;+ } u;+} option_map;+++static const char *parse_options(const char **const str, const char *str_end,+ void *filter_options,+ const option_map *const optmap, const size_t optmap_size);+++/////////+// BCJ //+/////////++#if defined(HAVE_ENCODER_X86) \+ || defined(HAVE_DECODER_X86) \+ || defined(HAVE_ENCODER_ARM) \+ || defined(HAVE_DECODER_ARM) \+ || defined(HAVE_ENCODER_ARMTHUMB) \+ || defined(HAVE_DECODER_ARMTHUMB) \+ || defined(HAVE_ENCODER_ARM64) \+ || defined(HAVE_DECODER_ARM64) \+ || defined(HAVE_ENCODER_POWERPC) \+ || defined(HAVE_DECODER_POWERPC) \+ || defined(HAVE_ENCODER_IA64) \+ || defined(HAVE_DECODER_IA64) \+ || defined(HAVE_ENCODER_SPARC) \+ || defined(HAVE_DECODER_SPARC) \+ || defined(HAVE_ENCODER_RISCV) \+ || defined(HAVE_DECODER_RISCV)+static const option_map bcj_optmap[] = {+ {+ .name = "start",+ .flags = OPTMAP_NO_STRFY_ZERO | OPTMAP_USE_BYTE_SUFFIX,+ .offset = offsetof(lzma_options_bcj, start_offset),+ .u.range.min = 0,+ .u.range.max = UINT32_MAX,+ }+};+++static const char *+parse_bcj(const char **const str, const char *str_end, void *filter_options)+{+ // filter_options was zeroed on allocation and that is enough+ // for the default value.+ return parse_options(str, str_end, filter_options,+ bcj_optmap, ARRAY_SIZE(bcj_optmap));+}+#endif+++///////////+// Delta //+///////////++#if defined(HAVE_ENCODER_DELTA) || defined(HAVE_DECODER_DELTA)+static const option_map delta_optmap[] = {+ {+ .name = "dist",+ .offset = offsetof(lzma_options_delta, dist),+ .u.range.min = LZMA_DELTA_DIST_MIN,+ .u.range.max = LZMA_DELTA_DIST_MAX,+ }+};+++static const char *+parse_delta(const char **const str, const char *str_end, void *filter_options)+{+ lzma_options_delta *opts = filter_options;+ opts->type = LZMA_DELTA_TYPE_BYTE;+ opts->dist = LZMA_DELTA_DIST_MIN;++ return parse_options(str, str_end, filter_options,+ delta_optmap, ARRAY_SIZE(delta_optmap));+}+#endif+++///////////////////+// LZMA1 & LZMA2 //+///////////////////++/// Help string for presets+#define LZMA12_PRESET_STR "0-9[e]"+++static const char *+parse_lzma12_preset(const char **const str, const char *str_end,+ uint32_t *preset)+{+ assert(*str < str_end);+ *preset = (uint32_t)(**str - '0');++ // NOTE: Remember to update LZMA12_PRESET_STR if this is modified!+ while (++*str < str_end) {+ switch (**str) {+ case 'e':+ *preset |= LZMA_PRESET_EXTREME;+ break;++ default:+ return "Unsupported preset flag";+ }+ }++ return NULL;+}+++static const char *+set_lzma12_preset(const char **const str, const char *str_end,+ void *filter_options)+{+ uint32_t preset;+ const char *errmsg = parse_lzma12_preset(str, str_end, &preset);+ if (errmsg != NULL)+ return errmsg;++ lzma_options_lzma *opts = filter_options;+ if (lzma_lzma_preset(opts, preset))+ return "Unsupported preset";++ return NULL;+}+++static const name_value_map lzma12_mode_map[] = {+ { "fast", LZMA_MODE_FAST },+ { "normal", LZMA_MODE_NORMAL },+ { "", 0 }+};+++static const name_value_map lzma12_mf_map[] = {+ { "hc3", LZMA_MF_HC3 },+ { "hc4", LZMA_MF_HC4 },+ { "bt2", LZMA_MF_BT2 },+ { "bt3", LZMA_MF_BT3 },+ { "bt4", LZMA_MF_BT4 },+ { "", 0 }+};+++static const option_map lzma12_optmap[] = {+ {+ .name = "preset",+ .type = OPTMAP_TYPE_LZMA_PRESET,+ }, {+ .name = "dict",+ .flags = OPTMAP_USE_BYTE_SUFFIX,+ .offset = offsetof(lzma_options_lzma, dict_size),+ .u.range.min = LZMA_DICT_SIZE_MIN,+ // FIXME? The max is really max for encoding but decoding+ // would allow 4 GiB - 1 B.+ .u.range.max = (UINT32_C(1) << 30) + (UINT32_C(1) << 29),+ }, {+ .name = "lc",+ .offset = offsetof(lzma_options_lzma, lc),+ .u.range.min = LZMA_LCLP_MIN,+ .u.range.max = LZMA_LCLP_MAX,+ }, {+ .name = "lp",+ .offset = offsetof(lzma_options_lzma, lp),+ .u.range.min = LZMA_LCLP_MIN,+ .u.range.max = LZMA_LCLP_MAX,+ }, {+ .name = "pb",+ .offset = offsetof(lzma_options_lzma, pb),+ .u.range.min = LZMA_PB_MIN,+ .u.range.max = LZMA_PB_MAX,+ }, {+ .name = "mode",+ .type = OPTMAP_TYPE_LZMA_MODE,+ .flags = OPTMAP_USE_NAME_VALUE_MAP,+ .offset = offsetof(lzma_options_lzma, mode),+ .u.map = lzma12_mode_map,+ }, {+ .name = "nice",+ .offset = offsetof(lzma_options_lzma, nice_len),+ .u.range.min = 2,+ .u.range.max = 273,+ }, {+ .name = "mf",+ .type = OPTMAP_TYPE_LZMA_MATCH_FINDER,+ .flags = OPTMAP_USE_NAME_VALUE_MAP,+ .offset = offsetof(lzma_options_lzma, mf),+ .u.map = lzma12_mf_map,+ }, {+ .name = "depth",+ .offset = offsetof(lzma_options_lzma, depth),+ .u.range.min = 0,+ .u.range.max = UINT32_MAX,+ }+};+++static const char *+parse_lzma12(const char **const str, const char *str_end, void *filter_options)+{+ lzma_options_lzma *opts = filter_options;++ // It cannot fail.+ const bool preset_ret = lzma_lzma_preset(opts, LZMA_PRESET_DEFAULT);+ assert(!preset_ret);+ (void)preset_ret;++ const char *errmsg = parse_options(str, str_end, filter_options,+ lzma12_optmap, ARRAY_SIZE(lzma12_optmap));+ if (errmsg != NULL)+ return errmsg;++ if (opts->lc + opts->lp > LZMA_LCLP_MAX)+ return "The sum of lc and lp must not exceed 4";++ return NULL;+}+++/////////////////////////////////////////+// Generic parsing and stringification //+/////////////////////////////////////////++static const struct {+ /// Name of the filter+ char name[NAME_LEN_MAX + 1];++ /// For lzma_str_to_filters:+ /// Size of the filter-specific options structure.+ uint32_t opts_size;++ /// Filter ID+ lzma_vli id;++ /// For lzma_str_to_filters:+ /// Function to parse the filter-specific options. The filter_options+ /// will already have been allocated using lzma_alloc_zero().+ const char *(*parse)(const char **str, const char *str_end,+ void *filter_options);++ /// For lzma_str_from_filters:+ /// If the flag LZMA_STR_ENCODER is used then the first+ /// strfy_encoder elements of optmap are stringified.+ /// With LZMA_STR_DECODER strfy_decoder is used.+ /// Currently encoders use all options that decoders do but if+ /// that changes then this needs to be changed too, for example,+ /// add a new OPTMAP flag to skip printing some decoder-only options.+ const option_map *optmap;+ uint8_t strfy_encoder;+ uint8_t strfy_decoder;++ /// For lzma_str_from_filters:+ /// If true, lzma_filter.options is allowed to be NULL. In that case,+ /// only the filter name is printed without any options.+ bool allow_null;++} filter_name_map[] = {+#if defined (HAVE_ENCODER_LZMA1) || defined(HAVE_DECODER_LZMA1)+ { "lzma1", sizeof(lzma_options_lzma), LZMA_FILTER_LZMA1,+ &parse_lzma12, lzma12_optmap, 9, 5, false },+#endif++#if defined(HAVE_ENCODER_LZMA2) || defined(HAVE_DECODER_LZMA2)+ { "lzma2", sizeof(lzma_options_lzma), LZMA_FILTER_LZMA2,+ &parse_lzma12, lzma12_optmap, 9, 2, false },+#endif++#if defined(HAVE_ENCODER_X86) || defined(HAVE_DECODER_X86)+ { "x86", sizeof(lzma_options_bcj), LZMA_FILTER_X86,+ &parse_bcj, bcj_optmap, 1, 1, true },+#endif++#if defined(HAVE_ENCODER_ARM) || defined(HAVE_DECODER_ARM)+ { "arm", sizeof(lzma_options_bcj), LZMA_FILTER_ARM,+ &parse_bcj, bcj_optmap, 1, 1, true },+#endif++#if defined(HAVE_ENCODER_ARMTHUMB) || defined(HAVE_DECODER_ARMTHUMB)+ { "armthumb", sizeof(lzma_options_bcj), LZMA_FILTER_ARMTHUMB,+ &parse_bcj, bcj_optmap, 1, 1, true },+#endif++#if defined(HAVE_ENCODER_ARM64) || defined(HAVE_DECODER_ARM64)+ { "arm64", sizeof(lzma_options_bcj), LZMA_FILTER_ARM64,+ &parse_bcj, bcj_optmap, 1, 1, true },+#endif++#if defined(HAVE_ENCODER_RISCV) || defined(HAVE_DECODER_RISCV)+ { "riscv", sizeof(lzma_options_bcj), LZMA_FILTER_RISCV,+ &parse_bcj, bcj_optmap, 1, 1, true },+#endif++#if defined(HAVE_ENCODER_POWERPC) || defined(HAVE_DECODER_POWERPC)+ { "powerpc", sizeof(lzma_options_bcj), LZMA_FILTER_POWERPC,+ &parse_bcj, bcj_optmap, 1, 1, true },+#endif++#if defined(HAVE_ENCODER_IA64) || defined(HAVE_DECODER_IA64)+ { "ia64", sizeof(lzma_options_bcj), LZMA_FILTER_IA64,+ &parse_bcj, bcj_optmap, 1, 1, true },+#endif++#if defined(HAVE_ENCODER_SPARC) || defined(HAVE_DECODER_SPARC)+ { "sparc", sizeof(lzma_options_bcj), LZMA_FILTER_SPARC,+ &parse_bcj, bcj_optmap, 1, 1, true },+#endif++#if defined(HAVE_ENCODER_DELTA) || defined(HAVE_DECODER_DELTA)+ { "delta", sizeof(lzma_options_delta), LZMA_FILTER_DELTA,+ &parse_delta, delta_optmap, 1, 1, false },+#endif+};+++/// Decodes options from a string for one filter (name1=value1,name2=value2).+/// Caller must have allocated memory for filter_options already and set+/// the initial default values. This is called from the filter-specific+/// parse_* functions.+///+/// The input string starts at *str and the address in str_end is the first+/// char that is not part of the string anymore. So no '\0' terminator is+/// used. *str is advanced every time something has been decoded successfully.+static const char *+parse_options(const char **const str, const char *str_end,+ void *filter_options,+ const option_map *const optmap, const size_t optmap_size)+{+ while (*str < str_end && **str != '\0') {+ // Each option is of the form name=value.+ // Commas (',') separate options. Extra commas are ignored.+ // Ignoring extra commas makes it simpler if an optional+ // option stored in a shell variable which can be empty.+ if (**str == ',') {+ ++*str;+ continue;+ }++ // Find where the next name=value ends.+ const size_t str_len = (size_t)(str_end - *str);+ const char *name_eq_value_end = memchr(*str, ',', str_len);+ if (name_eq_value_end == NULL)+ name_eq_value_end = str_end;++ const char *equals_sign = memchr(*str, '=',+ (size_t)(name_eq_value_end - *str));++ // Fail if the '=' wasn't found or the option name is missing+ // (the first char is '=').+ if (equals_sign == NULL || **str == '=')+ return "Options must be 'name=value' pairs separated "+ "with commas";++ // Reject a too long option name so that the memcmp()+ // in the loop below won't read past the end of the+ // string in optmap[i].name.+ const size_t name_len = (size_t)(equals_sign - *str);+ if (name_len > NAME_LEN_MAX)+ return "Unknown option name";++ // Find the option name from optmap[].+ size_t i = 0;+ while (true) {+ if (i == optmap_size)+ return "Unknown option name";++ if (memcmp(*str, optmap[i].name, name_len) == 0+ && optmap[i].name[name_len] == '\0')+ break;++ ++i;+ }++ // The input string is good at least until the start of+ // the option value.+ *str = equals_sign + 1;++ // The code assumes that the option value isn't an empty+ // string so check it here.+ const size_t value_len = (size_t)(name_eq_value_end - *str);+ if (value_len == 0)+ return "Option value cannot be empty";++ // LZMA1/2 preset has its own parsing function.+ if (optmap[i].type == OPTMAP_TYPE_LZMA_PRESET) {+ const char *errmsg = set_lzma12_preset(str,+ name_eq_value_end, filter_options);+ if (errmsg != NULL)+ return errmsg;++ continue;+ }++ // It's an integer value.+ uint32_t v;+ if (optmap[i].flags & OPTMAP_USE_NAME_VALUE_MAP) {+ // The integer is picked from a string-to-integer map.+ //+ // Reject a too long value string so that the memcmp()+ // in the loop below won't read past the end of the+ // string in optmap[i].u.map[j].name.+ if (value_len > NAME_LEN_MAX)+ return "Invalid option value";++ const name_value_map *map = optmap[i].u.map;+ size_t j = 0;+ while (true) {+ // The array is terminated with an empty name.+ if (map[j].name[0] == '\0')+ return "Invalid option value";++ if (memcmp(*str, map[j].name, value_len) == 0+ && map[j].name[value_len]+ == '\0') {+ v = map[j].value;+ break;+ }++ ++j;+ }+ } else if (**str < '0' || **str > '9') {+ // Note that "max" isn't supported while it is+ // supported in xz. It's not useful here.+ return "Value is not a non-negative decimal integer";+ } else {+ // strtoul() has locale-specific behavior so it cannot+ // be relied on to get reproducible results since we+ // cannot change the locate in a thread-safe library.+ // It also needs '\0'-termination.+ //+ // Use a temporary pointer so that *str will point+ // to the beginning of the value string in case+ // an error occurs.+ const char *p = *str;+ v = 0;+ do {+ if (v > UINT32_MAX / 10)+ return "Value out of range";++ v *= 10;++ const uint32_t add = (uint32_t)(*p - '0');+ if (UINT32_MAX - add < v)+ return "Value out of range";++ v += add;+ ++p;+ } while (p < name_eq_value_end+ && *p >= '0' && *p <= '9');++ if (p < name_eq_value_end) {+ // Remember this position so that it can be+ // used for error messages that are+ // specifically about the suffix. (Out of+ // range values are about the whole value+ // and those error messages point to the+ // beginning of the number part,+ // not to the suffix.)+ const char *multiplier_start = p;++ // If multiplier suffix shouldn't be used+ // then don't allow them even if the value+ // would stay within limits. This is a somewhat+ // unnecessary check but it rejects silly+ // things like lzma2:pb=0MiB which xz allows.+ if ((optmap[i].flags & OPTMAP_USE_BYTE_SUFFIX)+ == 0) {+ *str = multiplier_start;+ return "This option does not support "+ "any integer suffixes";+ }++ uint32_t shift;++ switch (*p) {+ case 'k':+ case 'K':+ shift = 10;+ break;++ case 'm':+ case 'M':+ shift = 20;+ break;++ case 'g':+ case 'G':+ shift = 30;+ break;++ default:+ *str = multiplier_start;+ return "Invalid multiplier suffix "+ "(KiB, MiB, or GiB)";+ }++ ++p;++ // Allow "M", "Mi", "MB", "MiB" and the same+ // for the other five characters from the+ // switch-statement above. All are handled+ // as base-2 (perhaps a mistake, perhaps not).+ // Note that 'i' and 'B' are case sensitive.+ if (p < name_eq_value_end && *p == 'i')+ ++p;++ if (p < name_eq_value_end && *p == 'B')+ ++p;++ // Now we must have no chars remaining.+ if (p < name_eq_value_end) {+ *str = multiplier_start;+ return "Invalid multiplier suffix "+ "(KiB, MiB, or GiB)";+ }++ if (v > (UINT32_MAX >> shift))+ return "Value out of range";++ v <<= shift;+ }++ if (v < optmap[i].u.range.min+ || v > optmap[i].u.range.max)+ return "Value out of range";+ }++ // Set the value in filter_options. Enums are handled+ // specially since the underlying type isn't the same+ // as uint32_t on all systems.+ void *ptr = (char *)filter_options + optmap[i].offset;+ switch (optmap[i].type) {+ case OPTMAP_TYPE_LZMA_MODE:+ *(lzma_mode *)ptr = (lzma_mode)v;+ break;++ case OPTMAP_TYPE_LZMA_MATCH_FINDER:+ *(lzma_match_finder *)ptr = (lzma_match_finder)v;+ break;++ default:+ *(uint32_t *)ptr = v;+ break;+ }++ // This option has been successfully handled.+ *str = name_eq_value_end;+ }++ // No errors.+ return NULL;+}+++/// Finds the name of the filter at the beginning of the string and+/// calls filter_name_map[i].parse() to decode the filter-specific options.+/// The caller must have set str_end so that exactly one filter and its+/// options are present without any trailing characters.+static const char *+parse_filter(const char **const str, const char *str_end, lzma_filter *filter,+ const lzma_allocator *allocator, bool only_xz)+{+ // Search for a colon or equals sign that would separate the filter+ // name from filter options. If neither is found, then the input+ // string only contains a filter name and there are no options.+ //+ // First assume that a colon or equals sign won't be found:+ const char *name_end = str_end;+ const char *opts_start = str_end;++ for (const char *p = *str; p < str_end; ++p) {+ if (*p == ':' || *p == '=') {+ name_end = p;++ // Filter options (name1=value1,name2=value2,...)+ // begin after the colon or equals sign.+ opts_start = p + 1;+ break;+ }+ }++ // Reject a too long filter name so that the memcmp()+ // in the loop below won't read past the end of the+ // string in filter_name_map[i].name.+ const size_t name_len = (size_t)(name_end - *str);+ if (name_len > NAME_LEN_MAX)+ return "Unknown filter name";++ for (size_t i = 0; i < ARRAY_SIZE(filter_name_map); ++i) {+ if (memcmp(*str, filter_name_map[i].name, name_len) == 0+ && filter_name_map[i].name[name_len] == '\0') {+ if (only_xz && filter_name_map[i].id+ >= LZMA_FILTER_RESERVED_START)+ return "This filter cannot be used in "+ "the .xz format";++ // Allocate the filter-specific options and+ // initialize the memory with zeros.+ void *options = lzma_alloc_zero(+ filter_name_map[i].opts_size,+ allocator);+ if (options == NULL)+ return "Memory allocation failed";++ // Filter name was found so the input string is good+ // at least this far.+ *str = opts_start;++ const char *errmsg = filter_name_map[i].parse(+ str, str_end, options);+ if (errmsg != NULL) {+ lzma_free(options, allocator);+ return errmsg;+ }++ // *filter is modified only when parsing is successful.+ filter->id = filter_name_map[i].id;+ filter->options = options;+ return NULL;+ }+ }++ return "Unknown filter name";+}+++/// Converts the string to a filter chain (array of lzma_filter structures).+///+/// *str is advanced every time something has been decoded successfully.+/// This way the caller knows where in the string a possible error occurred.+static const char *+str_to_filters(const char **const str, lzma_filter *filters, uint32_t flags,+ const lzma_allocator *allocator)+{+ const char *errmsg;++ // Skip leading spaces.+ while (**str == ' ')+ ++*str;++ if (**str == '\0')+ return "Empty string is not allowed, "+ "try \"6\" if a default value is needed";++ // Detect the type of the string.+ //+ // A string beginning with a digit or a string beginning with+ // one dash and a digit are treated as presets. Trailing spaces+ // will be ignored too (leading spaces were already ignored above).+ //+ // For example, "6", "7 ", "-9e", or " -3 " are treated as presets.+ // Strings like "-" or "- " aren't preset.+#define MY_IS_DIGIT(c) ((c) >= '0' && (c) <= '9')+ if (MY_IS_DIGIT(**str) || (**str == '-' && MY_IS_DIGIT((*str)[1]))) {+ if (**str == '-')+ ++*str;++ // Ignore trailing spaces.+ const size_t str_len = strlen(*str);+ const char *str_end = memchr(*str, ' ', str_len);+ if (str_end != NULL) {+ // There is at least one trailing space. Check that+ // there are no chars other than spaces.+ for (size_t i = 1; str_end[i] != '\0'; ++i)+ if (str_end[i] != ' ')+ return "Unsupported preset";+ } else {+ // There are no trailing spaces. Use the whole string.+ str_end = *str + str_len;+ }++ uint32_t preset;+ errmsg = parse_lzma12_preset(str, str_end, &preset);+ if (errmsg != NULL)+ return errmsg;++ lzma_options_lzma *opts = lzma_alloc(sizeof(*opts), allocator);+ if (opts == NULL)+ return "Memory allocation failed";++ if (lzma_lzma_preset(opts, preset)) {+ lzma_free(opts, allocator);+ return "Unsupported preset";+ }++ filters[0].id = LZMA_FILTER_LZMA2;+ filters[0].options = opts;+ filters[1].id = LZMA_VLI_UNKNOWN;+ filters[1].options = NULL;++ return NULL;+ }++ // Not a preset so it must be a filter chain.+ //+ // If LZMA_STR_ALL_FILTERS isn't used we allow only filters that+ // can be used in .xz.+ const bool only_xz = (flags & LZMA_STR_ALL_FILTERS) == 0;++ // Use a temporary array so that we don't modify the caller-supplied+ // one until we know that no errors occurred.+ lzma_filter temp_filters[LZMA_FILTERS_MAX + 1];++ size_t i = 0;+ do {+ if (i == LZMA_FILTERS_MAX) {+ errmsg = "The maximum number of filters is four";+ goto error;+ }++ // Skip "--" if present.+ if ((*str)[0] == '-' && (*str)[1] == '-')+ *str += 2;++ // Locate the end of "filter:name1=value1,name2=value2",+ // stopping at the first "--" or a single space.+ const char *filter_end = *str;+ while (filter_end[0] != '\0') {+ if ((filter_end[0] == '-' && filter_end[1] == '-')+ || filter_end[0] == ' ')+ break;++ ++filter_end;+ }++ // Inputs that have "--" at the end or "-- " in the middle+ // will result in an empty filter name.+ if (filter_end == *str) {+ errmsg = "Filter name is missing";+ goto error;+ }++ errmsg = parse_filter(str, filter_end, &temp_filters[i],+ allocator, only_xz);+ if (errmsg != NULL)+ goto error;++ // Skip trailing spaces.+ while (**str == ' ')+ ++*str;++ ++i;+ } while (**str != '\0');++ // Seems to be good, terminate the array so that+ // basic validation can be done.+ temp_filters[i].id = LZMA_VLI_UNKNOWN;+ temp_filters[i].options = NULL;++ // Do basic validation if the application didn't prohibit it.+ if ((flags & LZMA_STR_NO_VALIDATION) == 0) {+ size_t dummy;+ const lzma_ret ret = lzma_validate_chain(temp_filters, &dummy);+ assert(ret == LZMA_OK || ret == LZMA_OPTIONS_ERROR);+ if (ret != LZMA_OK) {+ errmsg = "Invalid filter chain "+ "('lzma2' missing at the end?)";+ goto error;+ }+ }++ // All good. Copy the filters to the application supplied array.+ memcpy(filters, temp_filters, (i + 1) * sizeof(lzma_filter));+ return NULL;++error:+ // Free the filter options that were successfully decoded.+ while (i-- > 0)+ lzma_free(temp_filters[i].options, allocator);++ return errmsg;+}+++extern LZMA_API(const char *)+lzma_str_to_filters(const char *str, int *error_pos, lzma_filter *filters,+ uint32_t flags, const lzma_allocator *allocator)+{+ // If error_pos isn't NULL, *error_pos must always be set.+ // liblzma <= 5.4.6 and <= 5.6.1 have a bug and don't do this+ // when str == NULL or filters == NULL or flags are unsupported.+ if (error_pos != NULL)+ *error_pos = 0;++ if (str == NULL || filters == NULL)+ return "Unexpected NULL pointer argument(s) "+ "to lzma_str_to_filters()";++ // Validate the flags.+ const uint32_t supported_flags+ = LZMA_STR_ALL_FILTERS+ | LZMA_STR_NO_VALIDATION;++ if (flags & ~supported_flags)+ return "Unsupported flags to lzma_str_to_filters()";++ const char *used = str;+ const char *errmsg = str_to_filters(&used, filters, flags, allocator);++ if (error_pos != NULL) {+ const size_t n = (size_t)(used - str);+ *error_pos = n > INT_MAX ? INT_MAX : (int)n;+ }++ return errmsg;+}+++/// Converts options of one filter to a string.+///+/// The caller must have already put the filter name in the destination+/// string. Since it is possible that no options will be needed, the caller+/// won't have put a delimiter character (':' or '=') in the string yet.+/// We will add it if at least one option will be added to the string.+static void+strfy_filter(lzma_str *dest, const char *delimiter,+ const option_map *optmap, size_t optmap_count,+ const void *filter_options)+{+ for (size_t i = 0; i < optmap_count; ++i) {+ // No attempt is made to reverse LZMA1/2 preset.+ if (optmap[i].type == OPTMAP_TYPE_LZMA_PRESET)+ continue;++ // All options have integer values, some just are mapped+ // to a string with a name_value_map. LZMA1/2 preset+ // isn't reversed back to preset=PRESET form.+ uint32_t v;+ const void *ptr+ = (const char *)filter_options + optmap[i].offset;+ switch (optmap[i].type) {+ case OPTMAP_TYPE_LZMA_MODE:+ v = *(const lzma_mode *)ptr;+ break;++ case OPTMAP_TYPE_LZMA_MATCH_FINDER:+ v = *(const lzma_match_finder *)ptr;+ break;++ default:+ v = *(const uint32_t *)ptr;+ break;+ }++ // Skip this if this option should be omitted from+ // the string when the value is zero.+ if (v == 0 && (optmap[i].flags & OPTMAP_NO_STRFY_ZERO))+ continue;++ // Before the first option we add whatever delimiter+ // the caller gave us. For later options a comma is used.+ str_append_str(dest, delimiter);+ delimiter = ",";++ // Add the option name and equals sign.+ str_append_str(dest, optmap[i].name);+ str_append_str(dest, "=");++ if (optmap[i].flags & OPTMAP_USE_NAME_VALUE_MAP) {+ const name_value_map *map = optmap[i].u.map;+ size_t j = 0;+ while (true) {+ if (map[j].name[0] == '\0') {+ str_append_str(dest, "UNKNOWN");+ break;+ }++ if (map[j].value == v) {+ str_append_str(dest, map[j].name);+ break;+ }++ ++j;+ }+ } else {+ str_append_u32(dest, v,+ optmap[i].flags & OPTMAP_USE_BYTE_SUFFIX);+ }+ }++ return;+}+++extern LZMA_API(lzma_ret)+lzma_str_from_filters(char **output_str, const lzma_filter *filters,+ uint32_t flags, const lzma_allocator *allocator)+{+ // On error *output_str is always set to NULL.+ // Do it as the very first step.+ if (output_str == NULL)+ return LZMA_PROG_ERROR;++ *output_str = NULL;++ if (filters == NULL)+ return LZMA_PROG_ERROR;++ // Validate the flags.+ const uint32_t supported_flags+ = LZMA_STR_ENCODER+ | LZMA_STR_DECODER+ | LZMA_STR_GETOPT_LONG+ | LZMA_STR_NO_SPACES;++ if (flags & ~supported_flags)+ return LZMA_OPTIONS_ERROR;++ // There must be at least one filter.+ if (filters[0].id == LZMA_VLI_UNKNOWN)+ return LZMA_OPTIONS_ERROR;++ // Allocate memory for the output string.+ lzma_str dest;+ return_if_error(str_init(&dest, allocator));++ const bool show_opts = (flags & (LZMA_STR_ENCODER | LZMA_STR_DECODER));++ const char *opt_delim = (flags & LZMA_STR_GETOPT_LONG) ? "=" : ":";++ for (size_t i = 0; filters[i].id != LZMA_VLI_UNKNOWN; ++i) {+ // If we reach LZMA_FILTERS_MAX, then the filters array+ // is too large since the ID cannot be LZMA_VLI_UNKNOWN here.+ if (i == LZMA_FILTERS_MAX) {+ str_free(&dest, allocator);+ return LZMA_OPTIONS_ERROR;+ }++ // Don't add a space between filters if the caller+ // doesn't want them.+ if (i > 0 && !(flags & LZMA_STR_NO_SPACES))+ str_append_str(&dest, " ");++ // Use dashes for xz getopt_long() compatible syntax but also+ // use dashes to separate filters when spaces weren't wanted.+ if ((flags & LZMA_STR_GETOPT_LONG)+ || (i > 0 && (flags & LZMA_STR_NO_SPACES)))+ str_append_str(&dest, "--");++ size_t j = 0;+ while (true) {+ if (j == ARRAY_SIZE(filter_name_map)) {+ // Filter ID in filters[i].id isn't supported.+ str_free(&dest, allocator);+ return LZMA_OPTIONS_ERROR;+ }++ if (filter_name_map[j].id == filters[i].id) {+ // Add the filter name.+ str_append_str(&dest, filter_name_map[j].name);++ // If only the filter names were wanted then+ // skip to the next filter. In this case+ // .options is ignored and may be NULL even+ // when the filter doesn't allow NULL options.+ if (!show_opts)+ break;++ if (filters[i].options == NULL) {+ if (!filter_name_map[j].allow_null) {+ // Filter-specific options+ // are missing but with+ // this filter the options+ // structure is mandatory.+ str_free(&dest, allocator);+ return LZMA_OPTIONS_ERROR;+ }++ // .options is allowed to be NULL.+ // There is no need to add any+ // options to the string.+ break;+ }++ // Options structure is available. Add+ // the filter options to the string.+ const size_t optmap_count+ = (flags & LZMA_STR_ENCODER)+ ? filter_name_map[j].strfy_encoder+ : filter_name_map[j].strfy_decoder;+ strfy_filter(&dest, opt_delim,+ filter_name_map[j].optmap,+ optmap_count,+ filters[i].options);+ break;+ }++ ++j;+ }+ }++ return str_finish(output_str, &dest, allocator);+}+++extern LZMA_API(lzma_ret)+lzma_str_list_filters(char **output_str, lzma_vli filter_id, uint32_t flags,+ const lzma_allocator *allocator)+{+ // On error *output_str is always set to NULL.+ // Do it as the very first step.+ if (output_str == NULL)+ return LZMA_PROG_ERROR;++ *output_str = NULL;++ // Validate the flags.+ const uint32_t supported_flags+ = LZMA_STR_ALL_FILTERS+ | LZMA_STR_ENCODER+ | LZMA_STR_DECODER+ | LZMA_STR_GETOPT_LONG;++ if (flags & ~supported_flags)+ return LZMA_OPTIONS_ERROR;++ // Allocate memory for the output string.+ lzma_str dest;+ return_if_error(str_init(&dest, allocator));++ // If only listing the filter names then separate them with spaces.+ // Otherwise use newlines.+ const bool show_opts = (flags & (LZMA_STR_ENCODER | LZMA_STR_DECODER));+ const char *filter_delim = show_opts ? "\n" : " ";++ const char *opt_delim = (flags & LZMA_STR_GETOPT_LONG) ? "=" : ":";+ bool first_filter_printed = false;++ for (size_t i = 0; i < ARRAY_SIZE(filter_name_map); ++i) {+ // If we are printing only one filter then skip others.+ if (filter_id != LZMA_VLI_UNKNOWN+ && filter_id != filter_name_map[i].id)+ continue;++ // If we are printing only .xz filters then skip the others.+ if (filter_name_map[i].id >= LZMA_FILTER_RESERVED_START+ && (flags & LZMA_STR_ALL_FILTERS) == 0+ && filter_id == LZMA_VLI_UNKNOWN)+ continue;++ // Add a new line if this isn't the first filter being+ // written to the string.+ if (first_filter_printed)+ str_append_str(&dest, filter_delim);++ first_filter_printed = true;++ if (flags & LZMA_STR_GETOPT_LONG)+ str_append_str(&dest, "--");++ str_append_str(&dest, filter_name_map[i].name);++ // If only the filter names were wanted then continue+ // to the next filter.+ if (!show_opts)+ continue;++ const option_map *optmap = filter_name_map[i].optmap;+ const char *d = opt_delim;++ const size_t end = (flags & LZMA_STR_ENCODER)+ ? filter_name_map[i].strfy_encoder+ : filter_name_map[i].strfy_decoder;++ for (size_t j = 0; j < end; ++j) {+ // The first option is delimited from the filter+ // name using "=" or ":" and the rest of the options+ // are separated with ",".+ str_append_str(&dest, d);+ d = ",";++ // optname=<possible_values>+ str_append_str(&dest, optmap[j].name);+ str_append_str(&dest, "=<");++ if (optmap[j].type == OPTMAP_TYPE_LZMA_PRESET) {+ // LZMA1/2 preset has its custom help string.+ str_append_str(&dest, LZMA12_PRESET_STR);+ } else if (optmap[j].flags+ & OPTMAP_USE_NAME_VALUE_MAP) {+ // Separate the possible option values by "|".+ const name_value_map *m = optmap[j].u.map;+ for (size_t k = 0; m[k].name[0] != '\0'; ++k) {+ if (k > 0)+ str_append_str(&dest, "|");++ str_append_str(&dest, m[k].name);+ }+ } else {+ // Integer range is shown as min-max.+ const bool use_byte_suffix = optmap[j].flags+ & OPTMAP_USE_BYTE_SUFFIX;+ str_append_u32(&dest, optmap[j].u.range.min,+ use_byte_suffix);+ str_append_str(&dest, "-");+ str_append_u32(&dest, optmap[j].u.range.max,+ use_byte_suffix);+ }++ str_append_str(&dest, ">");+ }+ }++ // If no filters were added to the string then it must be because+ // the caller provided an unsupported Filter ID.+ if (!first_filter_printed) {+ str_free(&dest, allocator);+ return LZMA_OPTIONS_ERROR;+ }++ return str_finish(output_str, &dest, allocator);+}
+ cbits/liblzma/common/vli_decoder.c view
@@ -0,0 +1,85 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file vli_decoder.c+/// \brief Decodes variable-length integers+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+++extern LZMA_API(lzma_ret)+lzma_vli_decode(lzma_vli *restrict vli, size_t *vli_pos,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size)+{+ // If we haven't been given vli_pos, work in single-call mode.+ size_t vli_pos_internal = 0;+ if (vli_pos == NULL) {+ vli_pos = &vli_pos_internal;+ *vli = 0;++ // If there's no input, use LZMA_DATA_ERROR. This way it is+ // easy to decode VLIs from buffers that have known size,+ // and get the correct error code in case the buffer is+ // too short.+ if (*in_pos >= in_size)+ return LZMA_DATA_ERROR;++ } else {+ // Initialize *vli when starting to decode a new integer.+ if (*vli_pos == 0)+ *vli = 0;++ // Validate the arguments.+ if (*vli_pos >= LZMA_VLI_BYTES_MAX+ || (*vli >> (*vli_pos * 7)) != 0)+ return LZMA_PROG_ERROR;;++ if (*in_pos >= in_size)+ return LZMA_BUF_ERROR;+ }++ do {+ // Read the next byte. Use a temporary variable so that we+ // can update *in_pos immediately.+ const uint8_t byte = in[*in_pos];+ ++*in_pos;++ // Add the newly read byte to *vli.+ *vli += (lzma_vli)(byte & 0x7F) << (*vli_pos * 7);+ ++*vli_pos;++ // Check if this is the last byte of a multibyte integer.+ if ((byte & 0x80) == 0) {+ // We don't allow using variable-length integers as+ // padding i.e. the encoding must use the most the+ // compact form.+ if (byte == 0x00 && *vli_pos > 1)+ return LZMA_DATA_ERROR;++ return vli_pos == &vli_pos_internal+ ? LZMA_OK : LZMA_STREAM_END;+ }++ // There is at least one more byte coming. If we have already+ // read maximum number of bytes, the integer is considered+ // corrupt.+ //+ // If we need bigger integers in future, old versions liblzma+ // will confusingly indicate the file being corrupt instead of+ // unsupported. I suppose it's still better this way, because+ // in the foreseeable future (writing this in 2008) the only+ // reason why files would appear having over 63-bit integers+ // is that the files are simply corrupt.+ if (*vli_pos == LZMA_VLI_BYTES_MAX)+ return LZMA_DATA_ERROR;++ } while (*in_pos < in_size);++ return vli_pos == &vli_pos_internal ? LZMA_DATA_ERROR : LZMA_OK;+}
+ cbits/liblzma/common/vli_encoder.c view
@@ -0,0 +1,68 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file vli_encoder.c+/// \brief Encodes variable-length integers+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+++extern LZMA_API(lzma_ret)+lzma_vli_encode(lzma_vli vli, size_t *vli_pos,+ uint8_t *restrict out, size_t *restrict out_pos,+ size_t out_size)+{+ // If we haven't been given vli_pos, work in single-call mode.+ size_t vli_pos_internal = 0;+ if (vli_pos == NULL) {+ vli_pos = &vli_pos_internal;++ // In single-call mode, we expect that the caller has+ // reserved enough output space.+ if (*out_pos >= out_size)+ return LZMA_PROG_ERROR;+ } else {+ // This never happens when we are called by liblzma, but+ // may happen if called directly from an application.+ if (*out_pos >= out_size)+ return LZMA_BUF_ERROR;+ }++ // Validate the arguments.+ if (*vli_pos >= LZMA_VLI_BYTES_MAX || vli > LZMA_VLI_MAX)+ return LZMA_PROG_ERROR;++ // Shift vli so that the next bits to encode are the lowest. In+ // single-call mode this never changes vli since *vli_pos is zero.+ vli >>= *vli_pos * 7;++ // Write the non-last bytes in a loop.+ while (vli >= 0x80) {+ // We don't need *vli_pos during this function call anymore,+ // but update it here so that it is ready if we need to+ // return before the whole integer has been decoded.+ ++*vli_pos;+ assert(*vli_pos < LZMA_VLI_BYTES_MAX);++ // Write the next byte.+ out[*out_pos] = (uint8_t)(vli) | 0x80;+ vli >>= 7;++ if (++*out_pos == out_size)+ return vli_pos == &vli_pos_internal+ ? LZMA_PROG_ERROR : LZMA_OK;+ }++ // Write the last byte.+ out[*out_pos] = (uint8_t)(vli);+ ++*out_pos;+ ++*vli_pos;++ return vli_pos == &vli_pos_internal ? LZMA_OK : LZMA_STREAM_END;++}
+ cbits/liblzma/common/vli_size.c view
@@ -0,0 +1,29 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file vli_size.c+/// \brief Calculates the encoded size of a variable-length integer+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+++extern LZMA_API(uint32_t)+lzma_vli_size(lzma_vli vli)+{+ if (vli > LZMA_VLI_MAX)+ return 0;++ uint32_t i = 0;+ do {+ vli >>= 7;+ ++i;+ } while (vli != 0);++ assert(i <= LZMA_VLI_BYTES_MAX);+ return i;+}
+ cbits/liblzma/delta/delta_common.c view
@@ -0,0 +1,72 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file delta_common.c+/// \brief Common stuff for Delta encoder and decoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "delta_common.h"+#include "delta_private.h"+++static void+delta_coder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_delta_coder *coder = coder_ptr;+ lzma_next_end(&coder->next, allocator);+ lzma_free(coder, allocator);+ return;+}+++extern lzma_ret+lzma_delta_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ // Allocate memory for the decoder if needed.+ lzma_delta_coder *coder = next->coder;+ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_delta_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;++ // End function is the same for encoder and decoder.+ next->end = &delta_coder_end;+ coder->next = LZMA_NEXT_CODER_INIT;+ }++ // Validate the options.+ if (lzma_delta_coder_memusage(filters[0].options) == UINT64_MAX)+ return LZMA_OPTIONS_ERROR;++ // Set the delta distance.+ const lzma_options_delta *opt = filters[0].options;+ coder->distance = opt->dist;++ // Initialize the rest of the variables.+ coder->pos = 0;+ memzero(coder->history, LZMA_DELTA_DIST_MAX);++ // Initialize the next decoder in the chain, if any.+ return lzma_next_filter_init(&coder->next, allocator, filters + 1);+}+++extern uint64_t+lzma_delta_coder_memusage(const void *options)+{+ const lzma_options_delta *opt = options;++ if (opt == NULL || opt->type != LZMA_DELTA_TYPE_BYTE+ || opt->dist < LZMA_DELTA_DIST_MIN+ || opt->dist > LZMA_DELTA_DIST_MAX)+ return UINT64_MAX;++ return sizeof(lzma_delta_coder);+}
+ cbits/liblzma/delta/delta_common.h view
@@ -0,0 +1,19 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file delta_common.h+/// \brief Common stuff for Delta encoder and decoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_DELTA_COMMON_H+#define LZMA_DELTA_COMMON_H++#include "common.h"++extern uint64_t lzma_delta_coder_memusage(const void *options);++#endif
+ cbits/liblzma/delta/delta_decoder.c view
@@ -0,0 +1,87 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file delta_decoder.c+/// \brief Delta filter decoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "delta_decoder.h"+#include "delta_private.h"+++static void+decode_buffer(lzma_delta_coder *coder, uint8_t *buffer, size_t size)+{+ const size_t distance = coder->distance;++ for (size_t i = 0; i < size; ++i) {+ buffer[i] += coder->history[(distance + coder->pos) & 0xFF];+ coder->history[coder->pos-- & 0xFF] = buffer[i];+ }+}+++// For an unknown reason NVIDIA HPC Compiler needs this pragma+// to produce working code.+#ifdef __NVCOMPILER+# pragma routine novector+#endif+static lzma_ret+delta_decode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size, lzma_action action)+{+ lzma_delta_coder *coder = coder_ptr;++ assert(coder->next.code != NULL);++ const size_t out_start = *out_pos;++ const lzma_ret ret = coder->next.code(coder->next.coder, allocator,+ in, in_pos, in_size, out, out_pos, out_size,+ action);++ // out might be NULL. In that case size == 0. Null pointer + 0 is+ // undefined behavior so skip the call in that case as it would+ // do nothing anyway.+ const size_t size = *out_pos - out_start;+ if (size > 0)+ decode_buffer(coder, out + out_start, size);++ return ret;+}+++extern lzma_ret+lzma_delta_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ next->code = &delta_decode;+ return lzma_delta_coder_init(next, allocator, filters);+}+++extern lzma_ret+lzma_delta_props_decode(void **options, const lzma_allocator *allocator,+ const uint8_t *props, size_t props_size)+{+ if (props_size != 1)+ return LZMA_OPTIONS_ERROR;++ lzma_options_delta *opt+ = lzma_alloc(sizeof(lzma_options_delta), allocator);+ if (opt == NULL)+ return LZMA_MEM_ERROR;++ opt->type = LZMA_DELTA_TYPE_BYTE;+ opt->dist = props[0] + 1U;++ *options = opt;++ return LZMA_OK;+}
+ cbits/liblzma/delta/delta_decoder.h view
@@ -0,0 +1,25 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file delta_decoder.h+/// \brief Delta filter decoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_DELTA_DECODER_H+#define LZMA_DELTA_DECODER_H++#include "delta_common.h"++extern lzma_ret lzma_delta_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++extern lzma_ret lzma_delta_props_decode(+ void **options, const lzma_allocator *allocator,+ const uint8_t *props, size_t props_size);++#endif
+ cbits/liblzma/delta/delta_encoder.c view
@@ -0,0 +1,132 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file delta_encoder.c+/// \brief Delta filter encoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "delta_encoder.h"+#include "delta_private.h"+++/// Copies and encodes the data at the same time. This is used when Delta+/// is the first filter in the chain (and thus the last filter in the+/// encoder's filter stack).+static void+copy_and_encode(lzma_delta_coder *coder,+ const uint8_t *restrict in, uint8_t *restrict out, size_t size)+{+ const size_t distance = coder->distance;++ for (size_t i = 0; i < size; ++i) {+ const uint8_t tmp = coder->history[+ (distance + coder->pos) & 0xFF];+ coder->history[coder->pos-- & 0xFF] = in[i];+ out[i] = in[i] - tmp;+ }+}+++/// Encodes the data in place. This is used when we are the last filter+/// in the chain (and thus non-last filter in the encoder's filter stack).+static void+encode_in_place(lzma_delta_coder *coder, uint8_t *buffer, size_t size)+{+ const size_t distance = coder->distance;++ for (size_t i = 0; i < size; ++i) {+ const uint8_t tmp = coder->history[+ (distance + coder->pos) & 0xFF];+ coder->history[coder->pos-- & 0xFF] = buffer[i];+ buffer[i] -= tmp;+ }+}+++static lzma_ret+delta_encode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size, lzma_action action)+{+ lzma_delta_coder *coder = coder_ptr;++ lzma_ret ret;++ if (coder->next.code == NULL) {+ const size_t in_avail = in_size - *in_pos;+ const size_t out_avail = out_size - *out_pos;+ const size_t size = my_min(in_avail, out_avail);++ // in and out might be NULL. In such cases size == 0.+ // Null pointer + 0 is undefined behavior so skip+ // the call in that case as it would do nothing anyway.+ if (size > 0)+ copy_and_encode(coder, in + *in_pos, out + *out_pos,+ size);++ *in_pos += size;+ *out_pos += size;++ ret = action != LZMA_RUN && *in_pos == in_size+ ? LZMA_STREAM_END : LZMA_OK;++ } else {+ const size_t out_start = *out_pos;++ ret = coder->next.code(coder->next.coder, allocator,+ in, in_pos, in_size, out, out_pos, out_size,+ action);++ // Like above, avoid null pointer + 0.+ const size_t size = *out_pos - out_start;+ if (size > 0)+ encode_in_place(coder, out + out_start, size);+ }++ return ret;+}+++static lzma_ret+delta_encoder_update(void *coder_ptr, const lzma_allocator *allocator,+ const lzma_filter *filters_null lzma_attribute((__unused__)),+ const lzma_filter *reversed_filters)+{+ lzma_delta_coder *coder = coder_ptr;++ // Delta doesn't and will never support changing the options in+ // the middle of encoding. If the app tries to change them, we+ // simply ignore them.+ return lzma_next_filter_update(+ &coder->next, allocator, reversed_filters + 1);+}+++extern lzma_ret+lzma_delta_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ next->code = &delta_encode;+ next->update = &delta_encoder_update;+ return lzma_delta_coder_init(next, allocator, filters);+}+++extern lzma_ret+lzma_delta_props_encode(const void *options, uint8_t *out)+{+ // The caller must have already validated the options, so it's+ // LZMA_PROG_ERROR if they are invalid.+ if (lzma_delta_coder_memusage(options) == UINT64_MAX)+ return LZMA_PROG_ERROR;++ const lzma_options_delta *opt = options;+ out[0] = opt->dist - LZMA_DELTA_DIST_MIN;++ return LZMA_OK;+}
+ cbits/liblzma/delta/delta_encoder.h view
@@ -0,0 +1,23 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file delta_encoder.h+/// \brief Delta filter encoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_DELTA_ENCODER_H+#define LZMA_DELTA_ENCODER_H++#include "delta_common.h"++extern lzma_ret lzma_delta_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++extern lzma_ret lzma_delta_props_encode(const void *options, uint8_t *out);++#endif
+ cbits/liblzma/delta/delta_private.h view
@@ -0,0 +1,36 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file delta_private.h+/// \brief Private common stuff for Delta encoder and decoder+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_DELTA_PRIVATE_H+#define LZMA_DELTA_PRIVATE_H++#include "delta_common.h"++typedef struct {+ /// Next coder in the chain+ lzma_next_coder next;++ /// Delta distance+ size_t distance;++ /// Position in history[]+ uint8_t pos;++ /// Buffer to hold history of the original data+ uint8_t history[LZMA_DELTA_DIST_MAX];+} lzma_delta_coder;+++extern lzma_ret lzma_delta_coder_init(+ lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters);++#endif
+ cbits/liblzma/lz/lz_decoder.c view
@@ -0,0 +1,324 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lz_decoder.c+/// \brief LZ out window+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++// liblzma supports multiple LZ77-based filters. The LZ part is shared+// between these filters. The LZ code takes care of dictionary handling+// and passing the data between filters in the chain. The filter-specific+// part decodes from the input buffer to the dictionary.+++#include "lz_decoder.h"+++typedef struct {+ /// Dictionary (history buffer)+ lzma_dict dict;++ /// The actual LZ-based decoder e.g. LZMA+ lzma_lz_decoder lz;++ /// Next filter in the chain, if any. Note that LZMA and LZMA2 are+ /// only allowed as the last filter, but the long-range filter in+ /// future can be in the middle of the chain.+ lzma_next_coder next;++ /// True if the next filter in the chain has returned LZMA_STREAM_END.+ bool next_finished;++ /// True if the LZ decoder (e.g. LZMA) has detected end of payload+ /// marker. This may become true before next_finished becomes true.+ bool this_finished;++ /// Temporary buffer needed when the LZ-based filter is not the last+ /// filter in the chain. The output of the next filter is first+ /// decoded into buffer[], which is then used as input for the actual+ /// LZ-based decoder.+ struct {+ size_t pos;+ size_t size;+ uint8_t buffer[LZMA_BUFFER_SIZE];+ } temp;+} lzma_coder;+++static void+lz_decoder_reset(lzma_coder *coder)+{+ coder->dict.pos = 2 * LZ_DICT_REPEAT_MAX;+ coder->dict.full = 0;+ coder->dict.buf[2 * LZ_DICT_REPEAT_MAX - 1] = '\0';+ coder->dict.has_wrapped = false;+ coder->dict.need_reset = false;+ return;+}+++static lzma_ret+decode_buffer(lzma_coder *coder,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size)+{+ while (true) {+ // Wrap the dictionary if needed.+ if (coder->dict.pos == coder->dict.size) {+ // See the comment of #define LZ_DICT_REPEAT_MAX.+ coder->dict.pos = LZ_DICT_REPEAT_MAX;+ coder->dict.has_wrapped = true;+ memcpy(coder->dict.buf, coder->dict.buf+ + coder->dict.size+ - LZ_DICT_REPEAT_MAX,+ LZ_DICT_REPEAT_MAX);+ }++ // Store the current dictionary position. It is needed to know+ // where to start copying to the out[] buffer.+ const size_t dict_start = coder->dict.pos;++ // Calculate how much we allow coder->lz.code() to decode.+ // It must not decode past the end of the dictionary+ // buffer, and we don't want it to decode more than is+ // actually needed to fill the out[] buffer.+ coder->dict.limit = coder->dict.pos+ + my_min(out_size - *out_pos,+ coder->dict.size - coder->dict.pos);++ // Call the coder->lz.code() to do the actual decoding.+ const lzma_ret ret = coder->lz.code(+ coder->lz.coder, &coder->dict,+ in, in_pos, in_size);++ // Copy the decoded data from the dictionary to the out[]+ // buffer. Do it conditionally because out can be NULL+ // (in which case copy_size is always 0). Calling memcpy()+ // with a null-pointer is undefined even if the third+ // argument is 0.+ const size_t copy_size = coder->dict.pos - dict_start;+ assert(copy_size <= out_size - *out_pos);++ if (copy_size > 0)+ memcpy(out + *out_pos, coder->dict.buf + dict_start,+ copy_size);++ *out_pos += copy_size;++ // Reset the dictionary if so requested by coder->lz.code().+ if (coder->dict.need_reset) {+ lz_decoder_reset(coder);++ // Since we reset dictionary, we don't check if+ // dictionary became full.+ if (ret != LZMA_OK || *out_pos == out_size)+ return ret;+ } else {+ // Return if everything got decoded or an error+ // occurred, or if there's no more data to decode.+ //+ // Note that detecting if there's something to decode+ // is done by looking if dictionary become full+ // instead of looking if *in_pos == in_size. This+ // is because it is possible that all the input was+ // consumed already but some data is pending to be+ // written to the dictionary.+ if (ret != LZMA_OK || *out_pos == out_size+ || coder->dict.pos < coder->dict.size)+ return ret;+ }+ }+}+++static lzma_ret+lz_decode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size,+ lzma_action action)+{+ lzma_coder *coder = coder_ptr;++ if (coder->next.code == NULL)+ return decode_buffer(coder, in, in_pos, in_size,+ out, out_pos, out_size);++ // We aren't the last coder in the chain, we need to decode+ // our input to a temporary buffer.+ while (*out_pos < out_size) {+ // Fill the temporary buffer if it is empty.+ if (!coder->next_finished+ && coder->temp.pos == coder->temp.size) {+ coder->temp.pos = 0;+ coder->temp.size = 0;++ const lzma_ret ret = coder->next.code(+ coder->next.coder,+ allocator, in, in_pos, in_size,+ coder->temp.buffer, &coder->temp.size,+ LZMA_BUFFER_SIZE, action);++ if (ret == LZMA_STREAM_END)+ coder->next_finished = true;+ else if (ret != LZMA_OK || coder->temp.size == 0)+ return ret;+ }++ if (coder->this_finished) {+ if (coder->temp.size != 0)+ return LZMA_DATA_ERROR;++ if (coder->next_finished)+ return LZMA_STREAM_END;++ return LZMA_OK;+ }++ const lzma_ret ret = decode_buffer(coder, coder->temp.buffer,+ &coder->temp.pos, coder->temp.size,+ out, out_pos, out_size);++ if (ret == LZMA_STREAM_END)+ coder->this_finished = true;+ else if (ret != LZMA_OK)+ return ret;+ else if (coder->next_finished && *out_pos < out_size)+ return LZMA_DATA_ERROR;+ }++ return LZMA_OK;+}+++static void+lz_decoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_coder *coder = coder_ptr;++ lzma_next_end(&coder->next, allocator);+ lzma_free(coder->dict.buf, allocator);++ if (coder->lz.end != NULL)+ coder->lz.end(coder->lz.coder, allocator);+ else+ lzma_free(coder->lz.coder, allocator);++ lzma_free(coder, allocator);+ return;+}+++extern lzma_ret+lzma_lz_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters,+ lzma_ret (*lz_init)(lzma_lz_decoder *lz,+ const lzma_allocator *allocator,+ lzma_vli id, const void *options,+ lzma_lz_options *lz_options))+{+ // Allocate the base structure if it isn't already allocated.+ lzma_coder *coder = next->coder;+ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = &lz_decode;+ next->end = &lz_decoder_end;++ coder->dict.buf = NULL;+ coder->dict.size = 0;+ coder->lz = LZMA_LZ_DECODER_INIT;+ coder->next = LZMA_NEXT_CODER_INIT;+ }++ // Allocate and initialize the LZ-based decoder. It will also give+ // us the dictionary size.+ lzma_lz_options lz_options;+ return_if_error(lz_init(&coder->lz, allocator,+ filters[0].id, filters[0].options, &lz_options));++ // If the dictionary size is very small, increase it to 4096 bytes.+ // This is to prevent constant wrapping of the dictionary, which+ // would slow things down. The downside is that since we don't check+ // separately for the real dictionary size, we may happily accept+ // corrupt files.+ if (lz_options.dict_size < 4096)+ lz_options.dict_size = 4096;++ // Make dictionary size a multiple of 16. Some LZ-based decoders like+ // LZMA use the lowest bits lzma_dict.pos to know the alignment of the+ // data. Aligned buffer is also good when memcpying from the+ // dictionary to the output buffer, since applications are+ // recommended to give aligned buffers to liblzma.+ //+ // Reserve 2 * LZ_DICT_REPEAT_MAX bytes of extra space which is+ // needed for alloc_size.+ //+ // Avoid integer overflow.+ if (lz_options.dict_size > SIZE_MAX - 15 - 2 * LZ_DICT_REPEAT_MAX)+ return LZMA_MEM_ERROR;++ lz_options.dict_size = (lz_options.dict_size + 15) & ~((size_t)(15));++ // Reserve extra space as explained in the comment+ // of #define LZ_DICT_REPEAT_MAX.+ const size_t alloc_size+ = lz_options.dict_size + 2 * LZ_DICT_REPEAT_MAX;++ // Allocate and initialize the dictionary.+ if (coder->dict.size != alloc_size) {+ lzma_free(coder->dict.buf, allocator);+ coder->dict.buf = lzma_alloc(alloc_size, allocator);+ if (coder->dict.buf == NULL)+ return LZMA_MEM_ERROR;++ // NOTE: Yes, alloc_size, not lz_options.dict_size. The way+ // coder->dict.full is updated will take care that we will+ // still reject distances larger than lz_options.dict_size.+ coder->dict.size = alloc_size;+ }++ lz_decoder_reset(next->coder);++ // Use the preset dictionary if it was given to us.+ if (lz_options.preset_dict != NULL+ && lz_options.preset_dict_size > 0) {+ // If the preset dictionary is bigger than the actual+ // dictionary, copy only the tail.+ const size_t copy_size = my_min(lz_options.preset_dict_size,+ lz_options.dict_size);+ const size_t offset = lz_options.preset_dict_size - copy_size;+ memcpy(coder->dict.buf + coder->dict.pos,+ lz_options.preset_dict + offset,+ copy_size);++ // dict.pos isn't zero after lz_decoder_reset().+ coder->dict.pos += copy_size;+ coder->dict.full = copy_size;+ }++ // Miscellaneous initializations+ coder->next_finished = false;+ coder->this_finished = false;+ coder->temp.pos = 0;+ coder->temp.size = 0;++ // Initialize the next filter in the chain, if any.+ return lzma_next_filter_init(&coder->next, allocator, filters + 1);+}+++extern uint64_t+lzma_lz_decoder_memusage(size_t dictionary_size)+{+ return sizeof(lzma_coder) + (uint64_t)(dictionary_size);+}
+ cbits/liblzma/lz/lz_decoder.h view
@@ -0,0 +1,250 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lz_decoder.h+/// \brief LZ out window+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_LZ_DECODER_H+#define LZMA_LZ_DECODER_H++#include "common.h"+++/// Maximum length of a match rounded up to a nice power of 2 which is+/// a good size for aligned memcpy(). The allocated dictionary buffer will+/// be 2 * LZ_DICT_REPEAT_MAX bytes larger than the actual dictionary size:+///+/// (1) Every time the decoder reaches the end of the dictionary buffer,+/// the last LZ_DICT_REPEAT_MAX bytes will be copied to the beginning.+/// This way dict_repeat() will only need to copy from one place,+/// never from both the end and beginning of the buffer.+///+/// (2) The other LZ_DICT_REPEAT_MAX bytes is kept as a buffer between+/// the oldest byte still in the dictionary and the current write+/// position. This way dict_repeat(dict, dict->size - 1, &len)+/// won't need memmove() as the copying cannot overlap.+///+/// Note that memcpy() still cannot be used if distance < len.+///+/// LZMA's longest match length is 273 so pick a multiple of 16 above that.+#define LZ_DICT_REPEAT_MAX 288+++typedef struct {+ /// Pointer to the dictionary buffer.+ uint8_t *buf;++ /// Write position in dictionary. The next byte will be written to+ /// buf[pos].+ size_t pos;++ /// Indicates how full the dictionary is. This is used by+ /// dict_is_distance_valid() to detect corrupt files that would+ /// read beyond the beginning of the dictionary.+ size_t full;++ /// Write limit+ size_t limit;++ /// Allocated size of buf. This is 2 * LZ_DICT_REPEAT_MAX bytes+ /// larger than the actual dictionary size. This is enforced by+ /// how the value for "full" is set; it can be at most+ /// "size - 2 * LZ_DICT_REPEAT_MAX".+ size_t size;++ /// True once the dictionary has become full and the writing position+ /// has been wrapped in decode_buffer() in lz_decoder.c.+ bool has_wrapped;++ /// True when dictionary should be reset before decoding more data.+ bool need_reset;++} lzma_dict;+++typedef struct {+ size_t dict_size;+ const uint8_t *preset_dict;+ size_t preset_dict_size;+} lzma_lz_options;+++typedef struct {+ /// Data specific to the LZ-based decoder+ void *coder;++ /// Function to decode from in[] to *dict+ lzma_ret (*code)(void *coder,+ lzma_dict *restrict dict, const uint8_t *restrict in,+ size_t *restrict in_pos, size_t in_size);++ void (*reset)(void *coder, const void *options);++ /// Set the uncompressed size. If uncompressed_size == LZMA_VLI_UNKNOWN+ /// then allow_eopm will always be true.+ void (*set_uncompressed)(void *coder, lzma_vli uncompressed_size,+ bool allow_eopm);++ /// Free allocated resources+ void (*end)(void *coder, const lzma_allocator *allocator);++} lzma_lz_decoder;+++#define LZMA_LZ_DECODER_INIT \+ (lzma_lz_decoder){ \+ .coder = NULL, \+ .code = NULL, \+ .reset = NULL, \+ .set_uncompressed = NULL, \+ .end = NULL, \+ }+++extern lzma_ret lzma_lz_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters,+ lzma_ret (*lz_init)(lzma_lz_decoder *lz,+ const lzma_allocator *allocator,+ lzma_vli id, const void *options,+ lzma_lz_options *lz_options));++extern uint64_t lzma_lz_decoder_memusage(size_t dictionary_size);+++//////////////////////+// Inline functions //+//////////////////////++/// Get a byte from the history buffer.+static inline uint8_t+dict_get(const lzma_dict *const dict, const uint32_t distance)+{+ return dict->buf[dict->pos - distance - 1+ + (distance < dict->pos+ ? 0 : dict->size - LZ_DICT_REPEAT_MAX)];+}+++/// Optimized version of dict_get(dict, 0)+static inline uint8_t+dict_get0(const lzma_dict *const dict)+{+ return dict->buf[dict->pos - 1];+}+++/// Test if dictionary is empty.+static inline bool+dict_is_empty(const lzma_dict *const dict)+{+ return dict->full == 0;+}+++/// Validate the match distance+static inline bool+dict_is_distance_valid(const lzma_dict *const dict, const size_t distance)+{+ return dict->full > distance;+}+++/// Repeat *len bytes at distance.+static inline bool+dict_repeat(lzma_dict *dict, uint32_t distance, uint32_t *len)+{+ // Don't write past the end of the dictionary.+ const size_t dict_avail = dict->limit - dict->pos;+ uint32_t left = my_min(dict_avail, *len);+ *len -= left;++ size_t back = dict->pos - distance - 1;+ if (distance >= dict->pos)+ back += dict->size - LZ_DICT_REPEAT_MAX;++ // Repeat a block of data from the history. Because memcpy() is faster+ // than copying byte by byte in a loop, the copying process gets split+ // into two cases.+ if (distance < left) {+ // Source and target areas overlap, thus we can't use+ // memcpy() nor even memmove() safely.+ do {+ dict->buf[dict->pos++] = dict->buf[back++];+ } while (--left > 0);+ } else {+ memcpy(dict->buf + dict->pos, dict->buf + back, left);+ dict->pos += left;+ }++ // Update how full the dictionary is.+ if (!dict->has_wrapped)+ dict->full = dict->pos - 2 * LZ_DICT_REPEAT_MAX;++ return *len != 0;+}+++static inline void+dict_put(lzma_dict *dict, uint8_t byte)+{+ dict->buf[dict->pos++] = byte;++ if (!dict->has_wrapped)+ dict->full = dict->pos - 2 * LZ_DICT_REPEAT_MAX;+}+++/// Puts one byte into the dictionary. Returns true if the dictionary was+/// already full and the byte couldn't be added.+static inline bool+dict_put_safe(lzma_dict *dict, uint8_t byte)+{+ if (unlikely(dict->pos == dict->limit))+ return true;++ dict_put(dict, byte);+ return false;+}+++/// Copies arbitrary amount of data into the dictionary.+static inline void+dict_write(lzma_dict *restrict dict, const uint8_t *restrict in,+ size_t *restrict in_pos, size_t in_size,+ size_t *restrict left)+{+ // NOTE: If we are being given more data than the size of the+ // dictionary, it could be possible to optimize the LZ decoder+ // so that not everything needs to go through the dictionary.+ // This shouldn't be very common thing in practice though, and+ // the slowdown of one extra memcpy() isn't bad compared to how+ // much time it would have taken if the data were compressed.++ if (in_size - *in_pos > *left)+ in_size = *in_pos + *left;++ *left -= lzma_bufcpy(in, in_pos, in_size,+ dict->buf, &dict->pos, dict->limit);++ if (!dict->has_wrapped)+ dict->full = dict->pos - 2 * LZ_DICT_REPEAT_MAX;++ return;+}+++static inline void+dict_reset(lzma_dict *dict)+{+ dict->need_reset = true;+ return;+}++#endif
+ cbits/liblzma/lz/lz_encoder.c view
@@ -0,0 +1,632 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lz_encoder.c+/// \brief LZ in window+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "lz_encoder.h"+#include "lz_encoder_hash.h"++// See lz_encoder_hash.h. This is a bit hackish but avoids making+// endianness a conditional in makefiles.+#if defined(WORDS_BIGENDIAN) && !defined(HAVE_SMALL)+# include "lz_encoder_hash_table.h"+#endif++#include "memcmplen.h"+++typedef struct {+ /// LZ-based encoder e.g. LZMA+ lzma_lz_encoder lz;++ /// History buffer and match finder+ lzma_mf mf;++ /// Next coder in the chain+ lzma_next_coder next;+} lzma_coder;+++/// \brief Moves the data in the input window to free space for new data+///+/// mf->buffer is a sliding input window, which keeps mf->keep_size_before+/// bytes of input history available all the time. Now and then we need to+/// "slide" the buffer to make space for the new data to the end of the+/// buffer. At the same time, data older than keep_size_before is dropped.+///+static void+move_window(lzma_mf *mf)+{+ // Align the move to a multiple of 16 bytes. Some LZ-based encoders+ // like LZMA use the lowest bits of mf->read_pos to know the+ // alignment of the uncompressed data. We also get better speed+ // for memmove() with aligned buffers.+ assert(mf->read_pos > mf->keep_size_before);+ const uint32_t move_offset+ = (mf->read_pos - mf->keep_size_before) & ~UINT32_C(15);++ assert(mf->write_pos > move_offset);+ const size_t move_size = mf->write_pos - move_offset;++ assert(move_offset + move_size <= mf->size);++ memmove(mf->buffer, mf->buffer + move_offset, move_size);++ mf->offset += move_offset;+ mf->read_pos -= move_offset;+ mf->read_limit -= move_offset;+ mf->write_pos -= move_offset;++ return;+}+++/// \brief Tries to fill the input window (mf->buffer)+///+/// If we are the last encoder in the chain, our input data is in in[].+/// Otherwise we call the next filter in the chain to process in[] and+/// write its output to mf->buffer.+///+/// This function must not be called once it has returned LZMA_STREAM_END.+///+static lzma_ret+fill_window(lzma_coder *coder, const lzma_allocator *allocator,+ const uint8_t *in, size_t *in_pos, size_t in_size,+ lzma_action action)+{+ assert(coder->mf.read_pos <= coder->mf.write_pos);++ // Move the sliding window if needed.+ if (coder->mf.read_pos >= coder->mf.size - coder->mf.keep_size_after)+ move_window(&coder->mf);++ // Maybe this is ugly, but lzma_mf uses uint32_t for most things+ // (which I find cleanest), but we need size_t here when filling+ // the history window.+ size_t write_pos = coder->mf.write_pos;+ lzma_ret ret;+ if (coder->next.code == NULL) {+ // Not using a filter, simply memcpy() as much as possible.+ lzma_bufcpy(in, in_pos, in_size, coder->mf.buffer,+ &write_pos, coder->mf.size);++ ret = action != LZMA_RUN && *in_pos == in_size+ ? LZMA_STREAM_END : LZMA_OK;++ } else {+ ret = coder->next.code(coder->next.coder, allocator,+ in, in_pos, in_size,+ coder->mf.buffer, &write_pos,+ coder->mf.size, action);+ }++ coder->mf.write_pos = write_pos;++ // Silence Valgrind. lzma_memcmplen() can read extra bytes+ // and Valgrind will give warnings if those bytes are uninitialized+ // because Valgrind cannot see that the values of the uninitialized+ // bytes are eventually ignored.+ memzero(coder->mf.buffer + write_pos, LZMA_MEMCMPLEN_EXTRA);++ // If end of stream has been reached or flushing completed, we allow+ // the encoder to process all the input (that is, read_pos is allowed+ // to reach write_pos). Otherwise we keep keep_size_after bytes+ // available as prebuffer.+ if (ret == LZMA_STREAM_END) {+ assert(*in_pos == in_size);+ ret = LZMA_OK;+ coder->mf.action = action;+ coder->mf.read_limit = coder->mf.write_pos;++ } else if (coder->mf.write_pos > coder->mf.keep_size_after) {+ // This needs to be done conditionally, because if we got+ // only little new input, there may be too little input+ // to do any encoding yet.+ coder->mf.read_limit = coder->mf.write_pos+ - coder->mf.keep_size_after;+ }++ // Restart the match finder after finished LZMA_SYNC_FLUSH.+ if (coder->mf.pending > 0+ && coder->mf.read_pos < coder->mf.read_limit) {+ // Match finder may update coder->pending and expects it to+ // start from zero, so use a temporary variable.+ const uint32_t pending = coder->mf.pending;+ coder->mf.pending = 0;++ // Rewind read_pos so that the match finder can hash+ // the pending bytes.+ assert(coder->mf.read_pos >= pending);+ coder->mf.read_pos -= pending;++ // Call the skip function directly instead of using+ // mf_skip(), since we don't want to touch mf->read_ahead.+ coder->mf.skip(&coder->mf, pending);+ }++ return ret;+}+++static lzma_ret+lz_encode(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size,+ uint8_t *restrict out, size_t *restrict out_pos,+ size_t out_size, lzma_action action)+{+ lzma_coder *coder = coder_ptr;++ while (*out_pos < out_size+ && (*in_pos < in_size || action != LZMA_RUN)) {+ // Read more data to coder->mf.buffer if needed.+ if (coder->mf.action == LZMA_RUN && coder->mf.read_pos+ >= coder->mf.read_limit)+ return_if_error(fill_window(coder, allocator,+ in, in_pos, in_size, action));++ // Encode+ const lzma_ret ret = coder->lz.code(coder->lz.coder,+ &coder->mf, out, out_pos, out_size);+ if (ret != LZMA_OK) {+ // Setting this to LZMA_RUN for cases when we are+ // flushing. It doesn't matter when finishing or if+ // an error occurred.+ coder->mf.action = LZMA_RUN;+ return ret;+ }+ }++ return LZMA_OK;+}+++static bool+lz_encoder_prepare(lzma_mf *mf, const lzma_allocator *allocator,+ const lzma_lz_options *lz_options)+{+ // For now, the dictionary size is limited to 1.5 GiB. This may grow+ // in the future if needed, but it needs a little more work than just+ // changing this check.+ if (!IS_ENC_DICT_SIZE_VALID(lz_options->dict_size)+ || lz_options->nice_len > lz_options->match_len_max)+ return true;++ mf->keep_size_before = lz_options->before_size + lz_options->dict_size;++ mf->keep_size_after = lz_options->after_size+ + lz_options->match_len_max;++ // To avoid constant memmove()s, allocate some extra space. Since+ // memmove()s become more expensive when the size of the buffer+ // increases, we reserve more space when a large dictionary is+ // used to make the memmove() calls rarer.+ //+ // This works with dictionaries up to about 3 GiB. If bigger+ // dictionary is wanted, some extra work is needed:+ // - Several variables in lzma_mf have to be changed from uint32_t+ // to size_t.+ // - Memory usage calculation needs something too, e.g. use uint64_t+ // for mf->size.+ uint32_t reserve = lz_options->dict_size / 2;+ if (reserve > (UINT32_C(1) << 30))+ reserve /= 2;++ reserve += (lz_options->before_size + lz_options->match_len_max+ + lz_options->after_size) / 2 + (UINT32_C(1) << 19);++ const uint32_t old_size = mf->size;+ mf->size = mf->keep_size_before + reserve + mf->keep_size_after;++ // Deallocate the old history buffer if it exists but has different+ // size than what is needed now.+ if (mf->buffer != NULL && old_size != mf->size) {+ lzma_free(mf->buffer, allocator);+ mf->buffer = NULL;+ }++ // Match finder options+ mf->match_len_max = lz_options->match_len_max;+ mf->nice_len = lz_options->nice_len;++ // cyclic_size has to stay smaller than 2 Gi. Note that this doesn't+ // mean limiting dictionary size to less than 2 GiB. With a match+ // finder that uses multibyte resolution (hashes start at e.g. every+ // fourth byte), cyclic_size would stay below 2 Gi even when+ // dictionary size is greater than 2 GiB.+ //+ // It would be possible to allow cyclic_size >= 2 Gi, but then we+ // would need to be careful to use 64-bit types in various places+ // (size_t could do since we would need bigger than 32-bit address+ // space anyway). It would also require either zeroing a multigigabyte+ // buffer at initialization (waste of time and RAM) or allow+ // normalization in lz_encoder_mf.c to access uninitialized+ // memory to keep the code simpler. The current way is simple and+ // still allows pretty big dictionaries, so I don't expect these+ // limits to change.+ mf->cyclic_size = lz_options->dict_size + 1;++ // Validate the match finder ID and setup the function pointers.+ switch (lz_options->match_finder) {+#ifdef HAVE_MF_HC3+ case LZMA_MF_HC3:+ mf->find = &lzma_mf_hc3_find;+ mf->skip = &lzma_mf_hc3_skip;+ break;+#endif+#ifdef HAVE_MF_HC4+ case LZMA_MF_HC4:+ mf->find = &lzma_mf_hc4_find;+ mf->skip = &lzma_mf_hc4_skip;+ break;+#endif+#ifdef HAVE_MF_BT2+ case LZMA_MF_BT2:+ mf->find = &lzma_mf_bt2_find;+ mf->skip = &lzma_mf_bt2_skip;+ break;+#endif+#ifdef HAVE_MF_BT3+ case LZMA_MF_BT3:+ mf->find = &lzma_mf_bt3_find;+ mf->skip = &lzma_mf_bt3_skip;+ break;+#endif+#ifdef HAVE_MF_BT4+ case LZMA_MF_BT4:+ mf->find = &lzma_mf_bt4_find;+ mf->skip = &lzma_mf_bt4_skip;+ break;+#endif++ default:+ return true;+ }++ // Calculate the sizes of mf->hash and mf->son.+ //+ // NOTE: Since 5.3.5beta the LZMA encoder ensures that nice_len+ // is big enough for the selected match finder. This makes it+ // easier for applications as nice_len = 2 will always be accepted+ // even though the effective value can be slightly bigger.+ const uint32_t hash_bytes+ = mf_get_hash_bytes(lz_options->match_finder);+ assert(hash_bytes <= mf->nice_len);++ const bool is_bt = (lz_options->match_finder & 0x10) != 0;+ uint32_t hs;++ if (hash_bytes == 2) {+ hs = 0xFFFF;+ } else {+ // Round dictionary size up to the next 2^n - 1 so it can+ // be used as a hash mask.+ hs = lz_options->dict_size - 1;+ hs |= hs >> 1;+ hs |= hs >> 2;+ hs |= hs >> 4;+ hs |= hs >> 8;+ hs >>= 1;+ hs |= 0xFFFF;++ if (hs > (UINT32_C(1) << 24)) {+ if (hash_bytes == 3)+ hs = (UINT32_C(1) << 24) - 1;+ else+ hs >>= 1;+ }+ }++ mf->hash_mask = hs;++ ++hs;+ if (hash_bytes > 2)+ hs += HASH_2_SIZE;+ if (hash_bytes > 3)+ hs += HASH_3_SIZE;+/*+ No match finder uses this at the moment.+ if (mf->hash_bytes > 4)+ hs += HASH_4_SIZE;+*/++ const uint32_t old_hash_count = mf->hash_count;+ const uint32_t old_sons_count = mf->sons_count;+ mf->hash_count = hs;+ mf->sons_count = mf->cyclic_size;+ if (is_bt)+ mf->sons_count *= 2;++ // Deallocate the old hash array if it exists and has different size+ // than what is needed now.+ if (old_hash_count != mf->hash_count+ || old_sons_count != mf->sons_count) {+ lzma_free(mf->hash, allocator);+ mf->hash = NULL;++ lzma_free(mf->son, allocator);+ mf->son = NULL;+ }++ // Maximum number of match finder cycles+ mf->depth = lz_options->depth;+ if (mf->depth == 0) {+ if (is_bt)+ mf->depth = 16 + mf->nice_len / 2;+ else+ mf->depth = 4 + mf->nice_len / 4;+ }++ return false;+}+++static bool+lz_encoder_init(lzma_mf *mf, const lzma_allocator *allocator,+ const lzma_lz_options *lz_options)+{+ // Allocate the history buffer.+ if (mf->buffer == NULL) {+ // lzma_memcmplen() is used for the dictionary buffer+ // so we need to allocate a few extra bytes to prevent+ // it from reading past the end of the buffer.+ mf->buffer = lzma_alloc(mf->size + LZMA_MEMCMPLEN_EXTRA,+ allocator);+ if (mf->buffer == NULL)+ return true;++ // Keep Valgrind happy with lzma_memcmplen() and initialize+ // the extra bytes whose value may get read but which will+ // effectively get ignored.+ memzero(mf->buffer + mf->size, LZMA_MEMCMPLEN_EXTRA);+ }++ // Use cyclic_size as initial mf->offset. This allows+ // avoiding a few branches in the match finders. The downside is+ // that match finder needs to be normalized more often, which may+ // hurt performance with huge dictionaries.+ mf->offset = mf->cyclic_size;+ mf->read_pos = 0;+ mf->read_ahead = 0;+ mf->read_limit = 0;+ mf->write_pos = 0;+ mf->pending = 0;++#if UINT32_MAX >= SIZE_MAX / 4+ // Check for integer overflow. (Huge dictionaries are not+ // possible on 32-bit CPU.)+ if (mf->hash_count > SIZE_MAX / sizeof(uint32_t)+ || mf->sons_count > SIZE_MAX / sizeof(uint32_t))+ return true;+#endif++ // Allocate and initialize the hash table. Since EMPTY_HASH_VALUE+ // is zero, we can use lzma_alloc_zero() or memzero() for mf->hash.+ //+ // We don't need to initialize mf->son, but not doing that may+ // make Valgrind complain in normalization (see normalize() in+ // lz_encoder_mf.c). Skipping the initialization is *very* good+ // when big dictionary is used but only small amount of data gets+ // actually compressed: most of the mf->son won't get actually+ // allocated by the kernel, so we avoid wasting RAM and improve+ // initialization speed a lot.+ if (mf->hash == NULL) {+ mf->hash = lzma_alloc_zero(mf->hash_count * sizeof(uint32_t),+ allocator);+ mf->son = lzma_alloc(mf->sons_count * sizeof(uint32_t),+ allocator);++ if (mf->hash == NULL || mf->son == NULL) {+ lzma_free(mf->hash, allocator);+ mf->hash = NULL;++ lzma_free(mf->son, allocator);+ mf->son = NULL;++ return true;+ }+ } else {+/*+ for (uint32_t i = 0; i < mf->hash_count; ++i)+ mf->hash[i] = EMPTY_HASH_VALUE;+*/+ memzero(mf->hash, mf->hash_count * sizeof(uint32_t));+ }++ mf->cyclic_pos = 0;++ // Handle preset dictionary.+ if (lz_options->preset_dict != NULL+ && lz_options->preset_dict_size > 0) {+ // If the preset dictionary is bigger than the actual+ // dictionary, use only the tail.+ mf->write_pos = my_min(lz_options->preset_dict_size, mf->size);+ memcpy(mf->buffer, lz_options->preset_dict+ + lz_options->preset_dict_size - mf->write_pos,+ mf->write_pos);+ mf->action = LZMA_SYNC_FLUSH;+ mf->skip(mf, mf->write_pos);+ }++ mf->action = LZMA_RUN;++ return false;+}+++extern uint64_t+lzma_lz_encoder_memusage(const lzma_lz_options *lz_options)+{+ // Old buffers must not exist when calling lz_encoder_prepare().+ lzma_mf mf = {+ .buffer = NULL,+ .hash = NULL,+ .son = NULL,+ .hash_count = 0,+ .sons_count = 0,+ };++ // Setup the size information into mf.+ if (lz_encoder_prepare(&mf, NULL, lz_options))+ return UINT64_MAX;++ // Calculate the memory usage.+ return ((uint64_t)(mf.hash_count) + mf.sons_count) * sizeof(uint32_t)+ + mf.size + sizeof(lzma_coder);+}+++static void+lz_encoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_coder *coder = coder_ptr;++ lzma_next_end(&coder->next, allocator);++ lzma_free(coder->mf.son, allocator);+ lzma_free(coder->mf.hash, allocator);+ lzma_free(coder->mf.buffer, allocator);++ if (coder->lz.end != NULL)+ coder->lz.end(coder->lz.coder, allocator);+ else+ lzma_free(coder->lz.coder, allocator);++ lzma_free(coder, allocator);+ return;+}+++static lzma_ret+lz_encoder_update(void *coder_ptr, const lzma_allocator *allocator,+ const lzma_filter *filters_null lzma_attribute((__unused__)),+ const lzma_filter *reversed_filters)+{+ lzma_coder *coder = coder_ptr;++ if (coder->lz.options_update == NULL)+ return LZMA_PROG_ERROR;++ return_if_error(coder->lz.options_update(+ coder->lz.coder, reversed_filters));++ return lzma_next_filter_update(+ &coder->next, allocator, reversed_filters + 1);+}+++static lzma_ret+lz_encoder_set_out_limit(void *coder_ptr, uint64_t *uncomp_size,+ uint64_t out_limit)+{+ lzma_coder *coder = coder_ptr;++ // This is supported only if there are no other filters chained.+ if (coder->next.code == NULL && coder->lz.set_out_limit != NULL)+ return coder->lz.set_out_limit(+ coder->lz.coder, uncomp_size, out_limit);++ return LZMA_OPTIONS_ERROR;+}+++extern lzma_ret+lzma_lz_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters,+ lzma_ret (*lz_init)(lzma_lz_encoder *lz,+ const lzma_allocator *allocator,+ lzma_vli id, const void *options,+ lzma_lz_options *lz_options))+{+#if defined(HAVE_SMALL) && !defined(HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR)+ // The CRC32 table must be initialized.+ lzma_crc32_init();+#endif++ // Allocate and initialize the base data structure.+ lzma_coder *coder = next->coder;+ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = &lz_encode;+ next->end = &lz_encoder_end;+ next->update = &lz_encoder_update;+ next->set_out_limit = &lz_encoder_set_out_limit;++ coder->lz.coder = NULL;+ coder->lz.code = NULL;+ coder->lz.end = NULL;+ coder->lz.options_update = NULL;+ coder->lz.set_out_limit = NULL;++ // mf.size is initialized to silence Valgrind+ // when used on optimized binaries (GCC may reorder+ // code in a way that Valgrind gets unhappy).+ coder->mf.buffer = NULL;+ coder->mf.size = 0;+ coder->mf.hash = NULL;+ coder->mf.son = NULL;+ coder->mf.hash_count = 0;+ coder->mf.sons_count = 0;++ coder->next = LZMA_NEXT_CODER_INIT;+ }++ // Initialize the LZ-based encoder.+ lzma_lz_options lz_options;+ return_if_error(lz_init(&coder->lz, allocator,+ filters[0].id, filters[0].options, &lz_options));++ // Setup the size information into coder->mf and deallocate+ // old buffers if they have wrong size.+ if (lz_encoder_prepare(&coder->mf, allocator, &lz_options))+ return LZMA_OPTIONS_ERROR;++ // Allocate new buffers if needed, and do the rest of+ // the initialization.+ if (lz_encoder_init(&coder->mf, allocator, &lz_options))+ return LZMA_MEM_ERROR;++ // Initialize the next filter in the chain, if any.+ return lzma_next_filter_init(&coder->next, allocator, filters + 1);+}+++extern LZMA_API(lzma_bool)+lzma_mf_is_supported(lzma_match_finder mf)+{+ switch (mf) {+#ifdef HAVE_MF_HC3+ case LZMA_MF_HC3:+ return true;+#endif+#ifdef HAVE_MF_HC4+ case LZMA_MF_HC4:+ return true;+#endif+#ifdef HAVE_MF_BT2+ case LZMA_MF_BT2:+ return true;+#endif+#ifdef HAVE_MF_BT3+ case LZMA_MF_BT3:+ return true;+#endif+#ifdef HAVE_MF_BT4+ case LZMA_MF_BT4:+ return true;+#endif+ default:+ return false;+ }+}
+ cbits/liblzma/lz/lz_encoder.h view
@@ -0,0 +1,352 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lz_encoder.h+/// \brief LZ in window and match finder API+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_LZ_ENCODER_H+#define LZMA_LZ_ENCODER_H++#include "common.h"+++// For now, the dictionary size is limited to 1.5 GiB. This may grow+// in the future if needed, but it needs a little more work than just+// changing this check.+#define IS_ENC_DICT_SIZE_VALID(size) \+ ((size) >= LZMA_DICT_SIZE_MIN \+ && (size) <= (UINT32_C(1) << 30) + (UINT32_C(1) << 29))+++/// A table of these is used by the LZ-based encoder to hold+/// the length-distance pairs found by the match finder.+typedef struct {+ uint32_t len;+ uint32_t dist;+} lzma_match;+++typedef struct lzma_mf_s lzma_mf;+struct lzma_mf_s {+ ///////////////+ // In Window //+ ///////////////++ /// Pointer to buffer with data to be compressed+ uint8_t *buffer;++ /// Total size of the allocated buffer (that is, including all+ /// the extra space)+ uint32_t size;++ /// Number of bytes that must be kept available in our input history.+ /// That is, once keep_size_before bytes have been processed,+ /// buffer[read_pos - keep_size_before] is the oldest byte that+ /// must be available for reading.+ uint32_t keep_size_before;++ /// Number of bytes that must be kept in buffer after read_pos.+ /// That is, read_pos <= write_pos - keep_size_after as long as+ /// action is LZMA_RUN; when action != LZMA_RUN, read_pos is allowed+ /// to reach write_pos so that the last bytes get encoded too.+ uint32_t keep_size_after;++ /// Match finders store locations of matches using 32-bit integers.+ /// To avoid adjusting several megabytes of integers every time the+ /// input window is moved with move_window, we only adjust the+ /// offset of the buffer. Thus, buffer[value_in_hash_table - offset]+ /// is the byte pointed by value_in_hash_table.+ uint32_t offset;++ /// buffer[read_pos] is the next byte to run through the match+ /// finder. This is incremented in the match finder once the byte+ /// has been processed.+ uint32_t read_pos;++ /// Number of bytes that have been ran through the match finder, but+ /// which haven't been encoded by the LZ-based encoder yet.+ uint32_t read_ahead;++ /// As long as read_pos is less than read_limit, there is enough+ /// input available in buffer for at least one encoding loop.+ ///+ /// Because of the stateful API, read_limit may and will get greater+ /// than read_pos quite often. This is taken into account when+ /// calculating the value for keep_size_after.+ uint32_t read_limit;++ /// buffer[write_pos] is the first byte that doesn't contain valid+ /// uncompressed data; that is, the next input byte will be copied+ /// to buffer[write_pos].+ uint32_t write_pos;++ /// Number of bytes not hashed before read_pos. This is needed to+ /// restart the match finder after LZMA_SYNC_FLUSH.+ uint32_t pending;++ //////////////////+ // Match Finder //+ //////////////////++ /// Find matches. Returns the number of distance-length pairs written+ /// to the matches array. This is called only via lzma_mf_find().+ uint32_t (*find)(lzma_mf *mf, lzma_match *matches);++ /// Skips num bytes. This is like find() but doesn't make the+ /// distance-length pairs available, thus being a little faster.+ /// This is called only via mf_skip().+ void (*skip)(lzma_mf *mf, uint32_t num);++ uint32_t *hash;+ uint32_t *son;+ uint32_t cyclic_pos;+ uint32_t cyclic_size; // Must be dictionary size + 1.+ uint32_t hash_mask;++ /// Maximum number of loops in the match finder+ uint32_t depth;++ /// Maximum length of a match that the match finder will try to find.+ uint32_t nice_len;++ /// Maximum length of a match supported by the LZ-based encoder.+ /// If the longest match found by the match finder is nice_len,+ /// mf_find() tries to expand it up to match_len_max bytes.+ uint32_t match_len_max;++ /// When running out of input, binary tree match finders need to know+ /// if it is due to flushing or finishing. The action is used also+ /// by the LZ-based encoders themselves.+ lzma_action action;++ /// Number of elements in hash[]+ uint32_t hash_count;++ /// Number of elements in son[]+ uint32_t sons_count;+};+++typedef struct {+ /// Extra amount of data to keep available before the "actual"+ /// dictionary.+ size_t before_size;++ /// Size of the history buffer+ size_t dict_size;++ /// Extra amount of data to keep available after the "actual"+ /// dictionary.+ size_t after_size;++ /// Maximum length of a match that the LZ-based encoder can accept.+ /// This is used to extend matches of length nice_len to the+ /// maximum possible length.+ size_t match_len_max;++ /// Match finder will search matches up to this length.+ /// This must be less than or equal to match_len_max.+ size_t nice_len;++ /// Type of the match finder to use+ lzma_match_finder match_finder;++ /// Maximum search depth+ uint32_t depth;++ /// Initial dictionary for the match finder to search.+ const uint8_t *preset_dict;++ /// If the preset dictionary is NULL, this value is ignored.+ /// Otherwise this member must indicate the preset dictionary's+ /// buffer size. If this size is larger than dict_size, then only+ /// the dict_size sized tail of the preset_dict will be used.+ uint32_t preset_dict_size;++} lzma_lz_options;+++// The total usable buffer space at any moment outside the match finder:+// before_size + dict_size + after_size + match_len_max+//+// In reality, there's some extra space allocated to prevent the number of+// memmove() calls reasonable. The bigger the dict_size is, the bigger+// this extra buffer will be since with bigger dictionaries memmove() would+// also take longer.+//+// A single encoder loop in the LZ-based encoder may call the match finder+// (mf_find() or mf_skip()) at most after_size times. In other words,+// a single encoder loop may increment lzma_mf.read_pos at most after_size+// times. Since matches are looked up to+// lzma_mf.buffer[lzma_mf.read_pos + match_len_max - 1], the total+// amount of extra buffer needed after dict_size becomes+// after_size + match_len_max.+//+// before_size has two uses. The first one is to keep literals available+// in cases when the LZ-based encoder has made some read ahead.+// TODO: Maybe this could be changed by making the LZ-based encoders to+// store the actual literals as they do with length-distance pairs.+//+// Algorithms such as LZMA2 first try to compress a chunk, and then check+// if the encoded result is smaller than the uncompressed one. If the chunk+// was incompressible, it is better to store it in uncompressed form in+// the output stream. To do this, the whole uncompressed chunk has to be+// still available in the history buffer. before_size achieves that.+++typedef struct {+ /// Data specific to the LZ-based encoder+ void *coder;++ /// Function to encode from *dict to out[]+ lzma_ret (*code)(void *coder,+ lzma_mf *restrict mf, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size);++ /// Free allocated resources+ void (*end)(void *coder, const lzma_allocator *allocator);++ /// Update the options in the middle of the encoding.+ lzma_ret (*options_update)(void *coder, const lzma_filter *filter);++ /// Set maximum allowed output size+ lzma_ret (*set_out_limit)(void *coder, uint64_t *uncomp_size,+ uint64_t out_limit);++} lzma_lz_encoder;+++// Basic steps:+// 1. Input gets copied into the dictionary.+// 2. Data in dictionary gets run through the match finder byte by byte.+// 3. The literals and matches are encoded using e.g. LZMA.+//+// The bytes that have been ran through the match finder, but not encoded yet,+// are called 'read ahead'.+++/// Get how many bytes the match finder hashes in its initial step.+/// This is also the minimum nice_len value with the match finder.+static inline uint32_t+mf_get_hash_bytes(lzma_match_finder match_finder)+{+ return (uint32_t)match_finder & 0x0F;+}+++/// Get pointer to the first byte not ran through the match finder+static inline const uint8_t *+mf_ptr(const lzma_mf *mf)+{+ return mf->buffer + mf->read_pos;+}+++/// Get the number of bytes that haven't been ran through the match finder yet.+static inline uint32_t+mf_avail(const lzma_mf *mf)+{+ return mf->write_pos - mf->read_pos;+}+++/// Get the number of bytes that haven't been encoded yet (some of these+/// bytes may have been ran through the match finder though).+static inline uint32_t+mf_unencoded(const lzma_mf *mf)+{+ return mf->write_pos - mf->read_pos + mf->read_ahead;+}+++/// Calculate the absolute offset from the beginning of the most recent+/// dictionary reset. Only the lowest four bits are important, so there's no+/// problem that we don't know the 64-bit size of the data encoded so far.+///+/// NOTE: When moving the input window, we need to do it so that the lowest+/// bits of dict->read_pos are not modified to keep this macro working+/// as intended.+static inline uint32_t+mf_position(const lzma_mf *mf)+{+ return mf->read_pos - mf->read_ahead;+}+++/// Since everything else begins with mf_, use it also for lzma_mf_find().+#define mf_find lzma_mf_find+++/// Skip the given number of bytes. This is used when a good match was found.+/// For example, if mf_find() finds a match of 200 bytes long, the first byte+/// of that match was already consumed by mf_find(), and the rest 199 bytes+/// have to be skipped with mf_skip(mf, 199).+static inline void+mf_skip(lzma_mf *mf, uint32_t amount)+{+ if (amount != 0) {+ mf->skip(mf, amount);+ mf->read_ahead += amount;+ }+}+++/// Copies at most *left number of bytes from the history buffer+/// to out[]. This is needed by LZMA2 to encode uncompressed chunks.+static inline void+mf_read(lzma_mf *mf, uint8_t *out, size_t *out_pos, size_t out_size,+ size_t *left)+{+ const size_t out_avail = out_size - *out_pos;+ const size_t copy_size = my_min(out_avail, *left);++ assert(mf->read_ahead == 0);+ assert(mf->read_pos >= *left);++ memcpy(out + *out_pos, mf->buffer + mf->read_pos - *left,+ copy_size);++ *out_pos += copy_size;+ *left -= copy_size;+ return;+}+++extern lzma_ret lzma_lz_encoder_init(+ lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters,+ lzma_ret (*lz_init)(lzma_lz_encoder *lz,+ const lzma_allocator *allocator,+ lzma_vli id, const void *options,+ lzma_lz_options *lz_options));+++extern uint64_t lzma_lz_encoder_memusage(const lzma_lz_options *lz_options);+++// These are only for LZ encoder's internal use.+extern uint32_t lzma_mf_find(+ lzma_mf *mf, uint32_t *count, lzma_match *matches);++extern uint32_t lzma_mf_hc3_find(lzma_mf *dict, lzma_match *matches);+extern void lzma_mf_hc3_skip(lzma_mf *dict, uint32_t amount);++extern uint32_t lzma_mf_hc4_find(lzma_mf *dict, lzma_match *matches);+extern void lzma_mf_hc4_skip(lzma_mf *dict, uint32_t amount);++extern uint32_t lzma_mf_bt2_find(lzma_mf *dict, lzma_match *matches);+extern void lzma_mf_bt2_skip(lzma_mf *dict, uint32_t amount);++extern uint32_t lzma_mf_bt3_find(lzma_mf *dict, lzma_match *matches);+extern void lzma_mf_bt3_skip(lzma_mf *dict, uint32_t amount);++extern uint32_t lzma_mf_bt4_find(lzma_mf *dict, lzma_match *matches);+extern void lzma_mf_bt4_skip(lzma_mf *dict, uint32_t amount);++#endif
+ cbits/liblzma/lz/lz_encoder_hash.h view
@@ -0,0 +1,108 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lz_encoder_hash.h+/// \brief Hash macros for match finders+//+// Author: Igor Pavlov+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_LZ_ENCODER_HASH_H+#define LZMA_LZ_ENCODER_HASH_H++#if defined(WORDS_BIGENDIAN) && !defined(HAVE_SMALL)+ // This is to make liblzma produce the same output on big endian+ // systems that it does on little endian systems. lz_encoder.c+ // takes care of including the actual table.+ lzma_attr_visibility_hidden+ extern const uint32_t lzma_lz_hash_table[256];+# define hash_table lzma_lz_hash_table+#else+# include "check.h"+# define hash_table lzma_crc32_table[0]+#endif++#define HASH_2_SIZE (UINT32_C(1) << 10)+#define HASH_3_SIZE (UINT32_C(1) << 16)+#define HASH_4_SIZE (UINT32_C(1) << 20)++#define HASH_2_MASK (HASH_2_SIZE - 1)+#define HASH_3_MASK (HASH_3_SIZE - 1)+#define HASH_4_MASK (HASH_4_SIZE - 1)++#define FIX_3_HASH_SIZE (HASH_2_SIZE)+#define FIX_4_HASH_SIZE (HASH_2_SIZE + HASH_3_SIZE)+#define FIX_5_HASH_SIZE (HASH_2_SIZE + HASH_3_SIZE + HASH_4_SIZE)++// Endianness doesn't matter in hash_2_calc() (no effect on the output).+#ifdef TUKLIB_FAST_UNALIGNED_ACCESS+# define hash_2_calc() \+ const uint32_t hash_value = read16ne(cur)+#else+# define hash_2_calc() \+ const uint32_t hash_value \+ = (uint32_t)(cur[0]) | ((uint32_t)(cur[1]) << 8)+#endif++#define hash_3_calc() \+ const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \+ const uint32_t hash_2_value = temp & HASH_2_MASK; \+ const uint32_t hash_value \+ = (temp ^ ((uint32_t)(cur[2]) << 8)) & mf->hash_mask++#define hash_4_calc() \+ const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \+ const uint32_t hash_2_value = temp & HASH_2_MASK; \+ const uint32_t hash_3_value \+ = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \+ const uint32_t hash_value = (temp ^ ((uint32_t)(cur[2]) << 8) \+ ^ (hash_table[cur[3]] << 5)) & mf->hash_mask+++// The following are not currently used.++#define hash_5_calc() \+ const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \+ const uint32_t hash_2_value = temp & HASH_2_MASK; \+ const uint32_t hash_3_value \+ = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \+ uint32_t hash_4_value = (temp ^ ((uint32_t)(cur[2]) << 8) ^ \+ ^ hash_table[cur[3]] << 5); \+ const uint32_t hash_value \+ = (hash_4_value ^ (hash_table[cur[4]] << 3)) \+ & mf->hash_mask; \+ hash_4_value &= HASH_4_MASK++/*+#define hash_zip_calc() \+ const uint32_t hash_value \+ = (((uint32_t)(cur[0]) | ((uint32_t)(cur[1]) << 8)) \+ ^ hash_table[cur[2]]) & 0xFFFF+*/++#define hash_zip_calc() \+ const uint32_t hash_value \+ = (((uint32_t)(cur[2]) | ((uint32_t)(cur[0]) << 8)) \+ ^ hash_table[cur[1]]) & 0xFFFF++#define mt_hash_2_calc() \+ const uint32_t hash_2_value \+ = (hash_table[cur[0]] ^ cur[1]) & HASH_2_MASK++#define mt_hash_3_calc() \+ const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \+ const uint32_t hash_2_value = temp & HASH_2_MASK; \+ const uint32_t hash_3_value \+ = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK++#define mt_hash_4_calc() \+ const uint32_t temp = hash_table[cur[0]] ^ cur[1]; \+ const uint32_t hash_2_value = temp & HASH_2_MASK; \+ const uint32_t hash_3_value \+ = (temp ^ ((uint32_t)(cur[2]) << 8)) & HASH_3_MASK; \+ const uint32_t hash_4_value = (temp ^ ((uint32_t)(cur[2]) << 8) ^ \+ (hash_table[cur[3]] << 5)) & HASH_4_MASK++#endif
+ cbits/liblzma/lz/lz_encoder_hash_table.h view
@@ -0,0 +1,70 @@+// SPDX-License-Identifier: 0BSD++// This file has been generated by crc32_tablegen.c.++const uint32_t lzma_lz_hash_table[256] = {+ 0x00000000, 0x77073096, 0xEE0E612C, 0x990951BA,+ 0x076DC419, 0x706AF48F, 0xE963A535, 0x9E6495A3,+ 0x0EDB8832, 0x79DCB8A4, 0xE0D5E91E, 0x97D2D988,+ 0x09B64C2B, 0x7EB17CBD, 0xE7B82D07, 0x90BF1D91,+ 0x1DB71064, 0x6AB020F2, 0xF3B97148, 0x84BE41DE,+ 0x1ADAD47D, 0x6DDDE4EB, 0xF4D4B551, 0x83D385C7,+ 0x136C9856, 0x646BA8C0, 0xFD62F97A, 0x8A65C9EC,+ 0x14015C4F, 0x63066CD9, 0xFA0F3D63, 0x8D080DF5,+ 0x3B6E20C8, 0x4C69105E, 0xD56041E4, 0xA2677172,+ 0x3C03E4D1, 0x4B04D447, 0xD20D85FD, 0xA50AB56B,+ 0x35B5A8FA, 0x42B2986C, 0xDBBBC9D6, 0xACBCF940,+ 0x32D86CE3, 0x45DF5C75, 0xDCD60DCF, 0xABD13D59,+ 0x26D930AC, 0x51DE003A, 0xC8D75180, 0xBFD06116,+ 0x21B4F4B5, 0x56B3C423, 0xCFBA9599, 0xB8BDA50F,+ 0x2802B89E, 0x5F058808, 0xC60CD9B2, 0xB10BE924,+ 0x2F6F7C87, 0x58684C11, 0xC1611DAB, 0xB6662D3D,+ 0x76DC4190, 0x01DB7106, 0x98D220BC, 0xEFD5102A,+ 0x71B18589, 0x06B6B51F, 0x9FBFE4A5, 0xE8B8D433,+ 0x7807C9A2, 0x0F00F934, 0x9609A88E, 0xE10E9818,+ 0x7F6A0DBB, 0x086D3D2D, 0x91646C97, 0xE6635C01,+ 0x6B6B51F4, 0x1C6C6162, 0x856530D8, 0xF262004E,+ 0x6C0695ED, 0x1B01A57B, 0x8208F4C1, 0xF50FC457,+ 0x65B0D9C6, 0x12B7E950, 0x8BBEB8EA, 0xFCB9887C,+ 0x62DD1DDF, 0x15DA2D49, 0x8CD37CF3, 0xFBD44C65,+ 0x4DB26158, 0x3AB551CE, 0xA3BC0074, 0xD4BB30E2,+ 0x4ADFA541, 0x3DD895D7, 0xA4D1C46D, 0xD3D6F4FB,+ 0x4369E96A, 0x346ED9FC, 0xAD678846, 0xDA60B8D0,+ 0x44042D73, 0x33031DE5, 0xAA0A4C5F, 0xDD0D7CC9,+ 0x5005713C, 0x270241AA, 0xBE0B1010, 0xC90C2086,+ 0x5768B525, 0x206F85B3, 0xB966D409, 0xCE61E49F,+ 0x5EDEF90E, 0x29D9C998, 0xB0D09822, 0xC7D7A8B4,+ 0x59B33D17, 0x2EB40D81, 0xB7BD5C3B, 0xC0BA6CAD,+ 0xEDB88320, 0x9ABFB3B6, 0x03B6E20C, 0x74B1D29A,+ 0xEAD54739, 0x9DD277AF, 0x04DB2615, 0x73DC1683,+ 0xE3630B12, 0x94643B84, 0x0D6D6A3E, 0x7A6A5AA8,+ 0xE40ECF0B, 0x9309FF9D, 0x0A00AE27, 0x7D079EB1,+ 0xF00F9344, 0x8708A3D2, 0x1E01F268, 0x6906C2FE,+ 0xF762575D, 0x806567CB, 0x196C3671, 0x6E6B06E7,+ 0xFED41B76, 0x89D32BE0, 0x10DA7A5A, 0x67DD4ACC,+ 0xF9B9DF6F, 0x8EBEEFF9, 0x17B7BE43, 0x60B08ED5,+ 0xD6D6A3E8, 0xA1D1937E, 0x38D8C2C4, 0x4FDFF252,+ 0xD1BB67F1, 0xA6BC5767, 0x3FB506DD, 0x48B2364B,+ 0xD80D2BDA, 0xAF0A1B4C, 0x36034AF6, 0x41047A60,+ 0xDF60EFC3, 0xA867DF55, 0x316E8EEF, 0x4669BE79,+ 0xCB61B38C, 0xBC66831A, 0x256FD2A0, 0x5268E236,+ 0xCC0C7795, 0xBB0B4703, 0x220216B9, 0x5505262F,+ 0xC5BA3BBE, 0xB2BD0B28, 0x2BB45A92, 0x5CB36A04,+ 0xC2D7FFA7, 0xB5D0CF31, 0x2CD99E8B, 0x5BDEAE1D,+ 0x9B64C2B0, 0xEC63F226, 0x756AA39C, 0x026D930A,+ 0x9C0906A9, 0xEB0E363F, 0x72076785, 0x05005713,+ 0x95BF4A82, 0xE2B87A14, 0x7BB12BAE, 0x0CB61B38,+ 0x92D28E9B, 0xE5D5BE0D, 0x7CDCEFB7, 0x0BDBDF21,+ 0x86D3D2D4, 0xF1D4E242, 0x68DDB3F8, 0x1FDA836E,+ 0x81BE16CD, 0xF6B9265B, 0x6FB077E1, 0x18B74777,+ 0x88085AE6, 0xFF0F6A70, 0x66063BCA, 0x11010B5C,+ 0x8F659EFF, 0xF862AE69, 0x616BFFD3, 0x166CCF45,+ 0xA00AE278, 0xD70DD2EE, 0x4E048354, 0x3903B3C2,+ 0xA7672661, 0xD06016F7, 0x4969474D, 0x3E6E77DB,+ 0xAED16A4A, 0xD9D65ADC, 0x40DF0B66, 0x37D83BF0,+ 0xA9BCAE53, 0xDEBB9EC5, 0x47B2CF7F, 0x30B5FFE9,+ 0xBDBDF21C, 0xCABAC28A, 0x53B39330, 0x24B4A3A6,+ 0xBAD03605, 0xCDD70693, 0x54DE5729, 0x23D967BF,+ 0xB3667A2E, 0xC4614AB8, 0x5D681B02, 0x2A6F2B94,+ 0xB40BBE37, 0xC30C8EA1, 0x5A05DF1B, 0x2D02EF8D+};
+ cbits/liblzma/lz/lz_encoder_mf.c view
@@ -0,0 +1,744 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lz_encoder_mf.c+/// \brief Match finders+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "lz_encoder.h"+#include "lz_encoder_hash.h"+#include "memcmplen.h"+++/// \brief Find matches starting from the current byte+///+/// \return The length of the longest match found+extern uint32_t+lzma_mf_find(lzma_mf *mf, uint32_t *count_ptr, lzma_match *matches)+{+ // Call the match finder. It returns the number of length-distance+ // pairs found.+ // FIXME: Minimum count is zero, what _exactly_ is the maximum?+ const uint32_t count = mf->find(mf, matches);++ // Length of the longest match; assume that no matches were found+ // and thus the maximum length is zero.+ uint32_t len_best = 0;++ if (count > 0) {+#ifndef NDEBUG+ // Validate the matches.+ for (uint32_t i = 0; i < count; ++i) {+ assert(matches[i].len <= mf->nice_len);+ assert(matches[i].dist < mf->read_pos);+ assert(memcmp(mf_ptr(mf) - 1,+ mf_ptr(mf) - matches[i].dist - 2,+ matches[i].len) == 0);+ }+#endif++ // The last used element in the array contains+ // the longest match.+ len_best = matches[count - 1].len;++ // If a match of maximum search length was found, try to+ // extend the match to maximum possible length.+ if (len_best == mf->nice_len) {+ // The limit for the match length is either the+ // maximum match length supported by the LZ-based+ // encoder or the number of bytes left in the+ // dictionary, whichever is smaller.+ uint32_t limit = mf_avail(mf) + 1;+ if (limit > mf->match_len_max)+ limit = mf->match_len_max;++ // Pointer to the byte we just ran through+ // the match finder.+ const uint8_t *p1 = mf_ptr(mf) - 1;++ // Pointer to the beginning of the match. We need -1+ // here because the match distances are zero based.+ const uint8_t *p2 = p1 - matches[count - 1].dist - 1;++ len_best = lzma_memcmplen(p1, p2, len_best, limit);+ }+ }++ *count_ptr = count;++ // Finally update the read position to indicate that match finder was+ // run for this dictionary offset.+ ++mf->read_ahead;++ return len_best;+}+++/// Hash value to indicate unused element in the hash. Since we start the+/// positions from dict_size + 1, zero is always too far to qualify+/// as usable match position.+#define EMPTY_HASH_VALUE 0+++/// Normalization must be done when lzma_mf.offset + lzma_mf.read_pos+/// reaches MUST_NORMALIZE_POS.+#define MUST_NORMALIZE_POS UINT32_MAX+++/// \brief Normalizes hash values+///+/// The hash arrays store positions of match candidates. The positions are+/// relative to an arbitrary offset that is not the same as the absolute+/// offset in the input stream. The relative position of the current byte+/// is lzma_mf.offset + lzma_mf.read_pos. The distances of the matches are+/// the differences of the current read position and the position found from+/// the hash.+///+/// To prevent integer overflows of the offsets stored in the hash arrays,+/// we need to "normalize" the stored values now and then. During the+/// normalization, we drop values that indicate distance greater than the+/// dictionary size, thus making space for new values.+static void+normalize(lzma_mf *mf)+{+ assert(mf->read_pos + mf->offset == MUST_NORMALIZE_POS);++ // In future we may not want to touch the lowest bits, because there+ // may be match finders that use larger resolution than one byte.+ const uint32_t subvalue+ = (MUST_NORMALIZE_POS - mf->cyclic_size);+ // & ~((UINT32_C(1) << 10) - 1);++ for (uint32_t i = 0; i < mf->hash_count; ++i) {+ // If the distance is greater than the dictionary size,+ // we can simply mark the hash element as empty.+ if (mf->hash[i] <= subvalue)+ mf->hash[i] = EMPTY_HASH_VALUE;+ else+ mf->hash[i] -= subvalue;+ }++ for (uint32_t i = 0; i < mf->sons_count; ++i) {+ // Do the same for mf->son.+ //+ // NOTE: There may be uninitialized elements in mf->son.+ // Valgrind may complain that the "if" below depends on+ // an uninitialized value. In this case it is safe to ignore+ // the warning. See also the comments in lz_encoder_init()+ // in lz_encoder.c.+ if (mf->son[i] <= subvalue)+ mf->son[i] = EMPTY_HASH_VALUE;+ else+ mf->son[i] -= subvalue;+ }++ // Update offset to match the new locations.+ mf->offset -= subvalue;++ return;+}+++/// Mark the current byte as processed from point of view of the match finder.+static void+move_pos(lzma_mf *mf)+{+ if (++mf->cyclic_pos == mf->cyclic_size)+ mf->cyclic_pos = 0;++ ++mf->read_pos;+ assert(mf->read_pos <= mf->write_pos);++ if (unlikely(mf->read_pos + mf->offset == UINT32_MAX))+ normalize(mf);+}+++/// When flushing, we cannot run the match finder unless there is nice_len+/// bytes available in the dictionary. Instead, we skip running the match+/// finder (indicating that no match was found), and count how many bytes we+/// have ignored this way.+///+/// When new data is given after the flushing was completed, the match finder+/// is restarted by rewinding mf->read_pos backwards by mf->pending. Then+/// the missed bytes are added to the hash using the match finder's skip+/// function (with small amount of input, it may start using mf->pending+/// again if flushing).+///+/// Due to this rewinding, we don't touch cyclic_pos or test for+/// normalization. It will be done when the match finder's skip function+/// catches up after a flush.+static void+move_pending(lzma_mf *mf)+{+ ++mf->read_pos;+ assert(mf->read_pos <= mf->write_pos);+ ++mf->pending;+}+++/// Calculate len_limit and determine if there is enough input to run+/// the actual match finder code. Sets up "cur" and "pos". This macro+/// is used by all find functions and binary tree skip functions. Hash+/// chain skip function doesn't need len_limit so a simpler code is used+/// in them.+#define header(is_bt, len_min, ret_op) \+ uint32_t len_limit = mf_avail(mf); \+ if (mf->nice_len <= len_limit) { \+ len_limit = mf->nice_len; \+ } else if (len_limit < (len_min) \+ || (is_bt && mf->action == LZMA_SYNC_FLUSH)) { \+ assert(mf->action != LZMA_RUN); \+ move_pending(mf); \+ ret_op; \+ } \+ const uint8_t *cur = mf_ptr(mf); \+ const uint32_t pos = mf->read_pos + mf->offset+++/// Header for find functions. "return 0" indicates that zero matches+/// were found.+#define header_find(is_bt, len_min) \+ header(is_bt, len_min, return 0); \+ uint32_t matches_count = 0+++/// Header for a loop in a skip function. "continue" tells to skip the rest+/// of the code in the loop.+#define header_skip(is_bt, len_min) \+ header(is_bt, len_min, continue)+++/// Calls hc_find_func() or bt_find_func() and calculates the total number+/// of matches found. Updates the dictionary position and returns the number+/// of matches found.+#define call_find(func, len_best) \+do { \+ matches_count = (uint32_t)(func(len_limit, pos, cur, cur_match, \+ mf->depth, mf->son, \+ mf->cyclic_pos, mf->cyclic_size, \+ matches + matches_count, len_best) \+ - matches); \+ move_pos(mf); \+ return matches_count; \+} while (0)+++////////////////+// Hash Chain //+////////////////++#if defined(HAVE_MF_HC3) || defined(HAVE_MF_HC4)+///+///+/// \param len_limit Don't look for matches longer than len_limit.+/// \param pos lzma_mf.read_pos + lzma_mf.offset+/// \param cur Pointer to current byte (mf_ptr(mf))+/// \param cur_match Start position of the current match candidate+/// \param depth Maximum length of the hash chain+/// \param son lzma_mf.son (contains the hash chain)+/// \param cyclic_pos lzma_mf.cyclic_pos+/// \param cyclic_size lzma_mf_cyclic_size+/// \param matches Array to hold the matches.+/// \param len_best The length of the longest match found so far.+static lzma_match *+hc_find_func(+ const uint32_t len_limit,+ const uint32_t pos,+ const uint8_t *const cur,+ uint32_t cur_match,+ uint32_t depth,+ uint32_t *const son,+ const uint32_t cyclic_pos,+ const uint32_t cyclic_size,+ lzma_match *matches,+ uint32_t len_best)+{+ son[cyclic_pos] = cur_match;++ while (true) {+ const uint32_t delta = pos - cur_match;+ if (depth-- == 0 || delta >= cyclic_size)+ return matches;++ const uint8_t *const pb = cur - delta;+ cur_match = son[cyclic_pos - delta+ + (delta > cyclic_pos ? cyclic_size : 0)];++ if (pb[len_best] == cur[len_best] && pb[0] == cur[0]) {+ uint32_t len = lzma_memcmplen(pb, cur, 1, len_limit);++ if (len_best < len) {+ len_best = len;+ matches->len = len;+ matches->dist = delta - 1;+ ++matches;++ if (len == len_limit)+ return matches;+ }+ }+ }+}+++#define hc_find(len_best) \+ call_find(hc_find_func, len_best)+++#define hc_skip() \+do { \+ mf->son[mf->cyclic_pos] = cur_match; \+ move_pos(mf); \+} while (0)++#endif+++#ifdef HAVE_MF_HC3+extern uint32_t+lzma_mf_hc3_find(lzma_mf *mf, lzma_match *matches)+{+ header_find(false, 3);++ hash_3_calc();++ const uint32_t delta2 = pos - mf->hash[hash_2_value];+ const uint32_t cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value];++ mf->hash[hash_2_value] = pos;+ mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;++ uint32_t len_best = 2;++ if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {+ len_best = lzma_memcmplen(cur - delta2, cur,+ len_best, len_limit);++ matches[0].len = len_best;+ matches[0].dist = delta2 - 1;+ matches_count = 1;++ if (len_best == len_limit) {+ hc_skip();+ return 1; // matches_count+ }+ }++ hc_find(len_best);+}+++extern void+lzma_mf_hc3_skip(lzma_mf *mf, uint32_t amount)+{+ do {+ if (mf_avail(mf) < 3) {+ move_pending(mf);+ continue;+ }++ const uint8_t *cur = mf_ptr(mf);+ const uint32_t pos = mf->read_pos + mf->offset;++ hash_3_calc();++ const uint32_t cur_match+ = mf->hash[FIX_3_HASH_SIZE + hash_value];++ mf->hash[hash_2_value] = pos;+ mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;++ hc_skip();++ } while (--amount != 0);+}+#endif+++#ifdef HAVE_MF_HC4+extern uint32_t+lzma_mf_hc4_find(lzma_mf *mf, lzma_match *matches)+{+ header_find(false, 4);++ hash_4_calc();++ uint32_t delta2 = pos - mf->hash[hash_2_value];+ const uint32_t delta3+ = pos - mf->hash[FIX_3_HASH_SIZE + hash_3_value];+ const uint32_t cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value];++ mf->hash[hash_2_value ] = pos;+ mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;+ mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;++ uint32_t len_best = 1;++ if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {+ len_best = 2;+ matches[0].len = 2;+ matches[0].dist = delta2 - 1;+ matches_count = 1;+ }++ if (delta2 != delta3 && delta3 < mf->cyclic_size+ && *(cur - delta3) == *cur) {+ len_best = 3;+ matches[matches_count++].dist = delta3 - 1;+ delta2 = delta3;+ }++ if (matches_count != 0) {+ len_best = lzma_memcmplen(cur - delta2, cur,+ len_best, len_limit);++ matches[matches_count - 1].len = len_best;++ if (len_best == len_limit) {+ hc_skip();+ return matches_count;+ }+ }++ if (len_best < 3)+ len_best = 3;++ hc_find(len_best);+}+++extern void+lzma_mf_hc4_skip(lzma_mf *mf, uint32_t amount)+{+ do {+ if (mf_avail(mf) < 4) {+ move_pending(mf);+ continue;+ }++ const uint8_t *cur = mf_ptr(mf);+ const uint32_t pos = mf->read_pos + mf->offset;++ hash_4_calc();++ const uint32_t cur_match+ = mf->hash[FIX_4_HASH_SIZE + hash_value];++ mf->hash[hash_2_value] = pos;+ mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;+ mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;++ hc_skip();++ } while (--amount != 0);+}+#endif+++/////////////////+// Binary Tree //+/////////////////++#if defined(HAVE_MF_BT2) || defined(HAVE_MF_BT3) || defined(HAVE_MF_BT4)+static lzma_match *+bt_find_func(+ const uint32_t len_limit,+ const uint32_t pos,+ const uint8_t *const cur,+ uint32_t cur_match,+ uint32_t depth,+ uint32_t *const son,+ const uint32_t cyclic_pos,+ const uint32_t cyclic_size,+ lzma_match *matches,+ uint32_t len_best)+{+ uint32_t *ptr0 = son + (cyclic_pos << 1) + 1;+ uint32_t *ptr1 = son + (cyclic_pos << 1);++ uint32_t len0 = 0;+ uint32_t len1 = 0;++ while (true) {+ const uint32_t delta = pos - cur_match;+ if (depth-- == 0 || delta >= cyclic_size) {+ *ptr0 = EMPTY_HASH_VALUE;+ *ptr1 = EMPTY_HASH_VALUE;+ return matches;+ }++ uint32_t *const pair = son + ((cyclic_pos - delta+ + (delta > cyclic_pos ? cyclic_size : 0))+ << 1);++ const uint8_t *const pb = cur - delta;+ uint32_t len = my_min(len0, len1);++ if (pb[len] == cur[len]) {+ len = lzma_memcmplen(pb, cur, len + 1, len_limit);++ if (len_best < len) {+ len_best = len;+ matches->len = len;+ matches->dist = delta - 1;+ ++matches;++ if (len == len_limit) {+ *ptr1 = pair[0];+ *ptr0 = pair[1];+ return matches;+ }+ }+ }++ if (pb[len] < cur[len]) {+ *ptr1 = cur_match;+ ptr1 = pair + 1;+ cur_match = *ptr1;+ len1 = len;+ } else {+ *ptr0 = cur_match;+ ptr0 = pair;+ cur_match = *ptr0;+ len0 = len;+ }+ }+}+++static void+bt_skip_func(+ const uint32_t len_limit,+ const uint32_t pos,+ const uint8_t *const cur,+ uint32_t cur_match,+ uint32_t depth,+ uint32_t *const son,+ const uint32_t cyclic_pos,+ const uint32_t cyclic_size)+{+ uint32_t *ptr0 = son + (cyclic_pos << 1) + 1;+ uint32_t *ptr1 = son + (cyclic_pos << 1);++ uint32_t len0 = 0;+ uint32_t len1 = 0;++ while (true) {+ const uint32_t delta = pos - cur_match;+ if (depth-- == 0 || delta >= cyclic_size) {+ *ptr0 = EMPTY_HASH_VALUE;+ *ptr1 = EMPTY_HASH_VALUE;+ return;+ }++ uint32_t *pair = son + ((cyclic_pos - delta+ + (delta > cyclic_pos ? cyclic_size : 0))+ << 1);+ const uint8_t *pb = cur - delta;+ uint32_t len = my_min(len0, len1);++ if (pb[len] == cur[len]) {+ len = lzma_memcmplen(pb, cur, len + 1, len_limit);++ if (len == len_limit) {+ *ptr1 = pair[0];+ *ptr0 = pair[1];+ return;+ }+ }++ if (pb[len] < cur[len]) {+ *ptr1 = cur_match;+ ptr1 = pair + 1;+ cur_match = *ptr1;+ len1 = len;+ } else {+ *ptr0 = cur_match;+ ptr0 = pair;+ cur_match = *ptr0;+ len0 = len;+ }+ }+}+++#define bt_find(len_best) \+ call_find(bt_find_func, len_best)++#define bt_skip() \+do { \+ bt_skip_func(len_limit, pos, cur, cur_match, mf->depth, \+ mf->son, mf->cyclic_pos, \+ mf->cyclic_size); \+ move_pos(mf); \+} while (0)++#endif+++#ifdef HAVE_MF_BT2+extern uint32_t+lzma_mf_bt2_find(lzma_mf *mf, lzma_match *matches)+{+ header_find(true, 2);++ hash_2_calc();++ const uint32_t cur_match = mf->hash[hash_value];+ mf->hash[hash_value] = pos;++ bt_find(1);+}+++extern void+lzma_mf_bt2_skip(lzma_mf *mf, uint32_t amount)+{+ do {+ header_skip(true, 2);++ hash_2_calc();++ const uint32_t cur_match = mf->hash[hash_value];+ mf->hash[hash_value] = pos;++ bt_skip();++ } while (--amount != 0);+}+#endif+++#ifdef HAVE_MF_BT3+extern uint32_t+lzma_mf_bt3_find(lzma_mf *mf, lzma_match *matches)+{+ header_find(true, 3);++ hash_3_calc();++ const uint32_t delta2 = pos - mf->hash[hash_2_value];+ const uint32_t cur_match = mf->hash[FIX_3_HASH_SIZE + hash_value];++ mf->hash[hash_2_value] = pos;+ mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;++ uint32_t len_best = 2;++ if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {+ len_best = lzma_memcmplen(+ cur, cur - delta2, len_best, len_limit);++ matches[0].len = len_best;+ matches[0].dist = delta2 - 1;+ matches_count = 1;++ if (len_best == len_limit) {+ bt_skip();+ return 1; // matches_count+ }+ }++ bt_find(len_best);+}+++extern void+lzma_mf_bt3_skip(lzma_mf *mf, uint32_t amount)+{+ do {+ header_skip(true, 3);++ hash_3_calc();++ const uint32_t cur_match+ = mf->hash[FIX_3_HASH_SIZE + hash_value];++ mf->hash[hash_2_value] = pos;+ mf->hash[FIX_3_HASH_SIZE + hash_value] = pos;++ bt_skip();++ } while (--amount != 0);+}+#endif+++#ifdef HAVE_MF_BT4+extern uint32_t+lzma_mf_bt4_find(lzma_mf *mf, lzma_match *matches)+{+ header_find(true, 4);++ hash_4_calc();++ uint32_t delta2 = pos - mf->hash[hash_2_value];+ const uint32_t delta3+ = pos - mf->hash[FIX_3_HASH_SIZE + hash_3_value];+ const uint32_t cur_match = mf->hash[FIX_4_HASH_SIZE + hash_value];++ mf->hash[hash_2_value] = pos;+ mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;+ mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;++ uint32_t len_best = 1;++ if (delta2 < mf->cyclic_size && *(cur - delta2) == *cur) {+ len_best = 2;+ matches[0].len = 2;+ matches[0].dist = delta2 - 1;+ matches_count = 1;+ }++ if (delta2 != delta3 && delta3 < mf->cyclic_size+ && *(cur - delta3) == *cur) {+ len_best = 3;+ matches[matches_count++].dist = delta3 - 1;+ delta2 = delta3;+ }++ if (matches_count != 0) {+ len_best = lzma_memcmplen(+ cur, cur - delta2, len_best, len_limit);++ matches[matches_count - 1].len = len_best;++ if (len_best == len_limit) {+ bt_skip();+ return matches_count;+ }+ }++ if (len_best < 3)+ len_best = 3;++ bt_find(len_best);+}+++extern void+lzma_mf_bt4_skip(lzma_mf *mf, uint32_t amount)+{+ do {+ header_skip(true, 4);++ hash_4_calc();++ const uint32_t cur_match+ = mf->hash[FIX_4_HASH_SIZE + hash_value];++ mf->hash[hash_2_value] = pos;+ mf->hash[FIX_3_HASH_SIZE + hash_3_value] = pos;+ mf->hash[FIX_4_HASH_SIZE + hash_value] = pos;++ bt_skip();++ } while (--amount != 0);+}+#endif
+ cbits/liblzma/lzma/fastpos.h view
@@ -0,0 +1,141 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file fastpos.h+/// \brief Kind of two-bit version of bit scan reverse+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_FASTPOS_H+#define LZMA_FASTPOS_H++// LZMA encodes match distances by storing the highest two bits using+// a six-bit value [0, 63], and then the missing lower bits.+// Dictionary size is also stored using this encoding in the .xz+// file format header.+//+// fastpos.h provides a way to quickly find out the correct six-bit+// values. The following table gives some examples of this encoding:+//+// dist return+// 0 0+// 1 1+// 2 2+// 3 3+// 4 4+// 5 4+// 6 5+// 7 5+// 8 6+// 11 6+// 12 7+// ... ...+// 15 7+// 16 8+// 17 8+// ... ...+// 23 8+// 24 9+// 25 9+// ... ...+//+//+// Provided functions or macros+// ----------------------------+//+// get_dist_slot(dist) is the basic version. get_dist_slot_2(dist)+// assumes that dist >= FULL_DISTANCES, thus the result is at least+// FULL_DISTANCES_BITS * 2. Using get_dist_slot(dist) instead of+// get_dist_slot_2(dist) would give the same result, but get_dist_slot_2(dist)+// should be tiny bit faster due to the assumption being made.+//+//+// Size vs. speed+// --------------+//+// With some CPUs that have fast BSR (bit scan reverse) instruction, the+// size optimized version is slightly faster than the bigger table based+// approach. Such CPUs include Intel Pentium Pro, Pentium II, Pentium III+// and Core 2 (possibly others). AMD K7 seems to have slower BSR, but that+// would still have speed roughly comparable to the table version. Older+// x86 CPUs like the original Pentium have very slow BSR; on those systems+// the table version is a lot faster.+//+// On some CPUs, the table version is a lot faster when using position+// dependent code, but with position independent code the size optimized+// version is slightly faster. This occurs at least on 32-bit SPARC (no+// ASM optimizations).+//+// I'm making the table version the default, because that has good speed+// on all systems I have tried. The size optimized version is sometimes+// slightly faster, but sometimes it is a lot slower.++#ifdef HAVE_SMALL+# define get_dist_slot(dist) \+ ((dist) <= 4 ? (dist) : get_dist_slot_2(dist))++static inline uint32_t+get_dist_slot_2(uint32_t dist)+{+ const uint32_t i = bsr32(dist);+ return (i + i) + ((dist >> (i - 1)) & 1);+}+++#else++#define FASTPOS_BITS 13++lzma_attr_visibility_hidden+extern const uint8_t lzma_fastpos[1 << FASTPOS_BITS];+++#define fastpos_shift(extra, n) \+ ((extra) + (n) * (FASTPOS_BITS - 1))++#define fastpos_limit(extra, n) \+ (UINT32_C(1) << (FASTPOS_BITS + fastpos_shift(extra, n)))++#define fastpos_result(dist, extra, n) \+ (uint32_t)(lzma_fastpos[(dist) >> fastpos_shift(extra, n)]) \+ + 2 * fastpos_shift(extra, n)+++static inline uint32_t+get_dist_slot(uint32_t dist)+{+ // If it is small enough, we can pick the result directly from+ // the precalculated table.+ if (dist < fastpos_limit(0, 0))+ return lzma_fastpos[dist];++ if (dist < fastpos_limit(0, 1))+ return fastpos_result(dist, 0, 1);++ return fastpos_result(dist, 0, 2);+}+++#ifdef FULL_DISTANCES_BITS+static inline uint32_t+get_dist_slot_2(uint32_t dist)+{+ assert(dist >= FULL_DISTANCES);++ if (dist < fastpos_limit(FULL_DISTANCES_BITS - 1, 0))+ return fastpos_result(dist, FULL_DISTANCES_BITS - 1, 0);++ if (dist < fastpos_limit(FULL_DISTANCES_BITS - 1, 1))+ return fastpos_result(dist, FULL_DISTANCES_BITS - 1, 1);++ return fastpos_result(dist, FULL_DISTANCES_BITS - 1, 2);+}+#endif++#endif++#endif
+ cbits/liblzma/lzma/fastpos_table.c view
@@ -0,0 +1,521 @@+// SPDX-License-Identifier: 0BSD++// This file has been generated by fastpos_tablegen.c.++#include "common.h"+#include "fastpos.h"++const uint8_t lzma_fastpos[1 << FASTPOS_BITS] = {+ 0, 1, 2, 3, 4, 4, 5, 5, 6, 6, 6, 6, 7, 7, 7, 7,+ 8, 8, 8, 8, 8, 8, 8, 8, 9, 9, 9, 9, 9, 9, 9, 9,+ 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,+ 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11, 11,+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,+ 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12,+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,+ 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14, 14,+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,+ 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15, 15,+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,+ 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17, 17,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18, 18,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19, 19,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20, 20,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22, 22,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,+ 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25+};
+ cbits/liblzma/lzma/fastpos_tablegen.c view
@@ -0,0 +1,58 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file fastpos_tablegen.c+/// \brief Generates the lzma_fastpos[] lookup table+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include <inttypes.h>+#include <stdio.h>++#define lzma_attr_visibility_hidden+#include "fastpos.h"+++int+main(void)+{+ uint8_t fastpos[1 << FASTPOS_BITS];++ const uint8_t fast_slots = 2 * FASTPOS_BITS;+ uint32_t c = 2;++ fastpos[0] = 0;+ fastpos[1] = 1;++ for (uint8_t slot_fast = 2; slot_fast < fast_slots; ++slot_fast) {+ const uint32_t k = 1 << ((slot_fast >> 1) - 1);+ for (uint32_t j = 0; j < k; ++j, ++c)+ fastpos[c] = slot_fast;+ }++ // Split the SPDX string so that it won't accidentally match+ // when tools search for the string.+ printf("// SPDX" "-License-Identifier" ": 0BSD\n\n"+ "// This file has been generated by fastpos_tablegen.c.\n\n"+ "#include \"common.h\"\n"+ "#include \"fastpos.h\"\n\n"+ "const uint8_t lzma_fastpos[1 << FASTPOS_BITS] = {");++ for (size_t i = 0; i < (1 << FASTPOS_BITS); ++i) {+ if (i % 16 == 0)+ printf("\n\t");++ printf("%3u", (unsigned int)(fastpos[i]));++ if (i != (1 << FASTPOS_BITS) - 1)+ printf(",");+ }++ printf("\n};\n");++ return 0;+}
+ cbits/liblzma/lzma/lzma2_decoder.c view
@@ -0,0 +1,310 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzma2_decoder.c+/// \brief LZMA2 decoder+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "lzma2_decoder.h"+#include "lz_decoder.h"+#include "lzma_decoder.h"+++typedef struct {+ enum sequence {+ SEQ_CONTROL,+ SEQ_UNCOMPRESSED_1,+ SEQ_UNCOMPRESSED_2,+ SEQ_COMPRESSED_0,+ SEQ_COMPRESSED_1,+ SEQ_PROPERTIES,+ SEQ_LZMA,+ SEQ_COPY,+ } sequence;++ /// Sequence after the size fields have been decoded.+ enum sequence next_sequence;++ /// LZMA decoder+ lzma_lz_decoder lzma;++ /// Uncompressed size of LZMA chunk+ size_t uncompressed_size;++ /// Compressed size of the chunk (naturally equals to uncompressed+ /// size of uncompressed chunk)+ size_t compressed_size;++ /// True if properties are needed. This is false before the+ /// first LZMA chunk.+ bool need_properties;++ /// True if dictionary reset is needed. This is false before the+ /// first chunk (LZMA or uncompressed).+ bool need_dictionary_reset;++ lzma_options_lzma options;+} lzma_lzma2_coder;+++static lzma_ret+lzma2_decode(void *coder_ptr, lzma_dict *restrict dict,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size)+{+ lzma_lzma2_coder *restrict coder = coder_ptr;++ // With SEQ_LZMA it is possible that no new input is needed to do+ // some progress. The rest of the sequences assume that there is+ // at least one byte of input.+ while (*in_pos < in_size || coder->sequence == SEQ_LZMA)+ switch (coder->sequence) {+ case SEQ_CONTROL: {+ const uint32_t control = in[*in_pos];+ ++*in_pos;++ // End marker+ if (control == 0x00)+ return LZMA_STREAM_END;++ if (control >= 0xE0 || control == 1) {+ // Dictionary reset implies that next LZMA chunk has+ // to set new properties.+ coder->need_properties = true;+ coder->need_dictionary_reset = true;+ } else if (coder->need_dictionary_reset) {+ return LZMA_DATA_ERROR;+ }++ if (control >= 0x80) {+ // LZMA chunk. The highest five bits of the+ // uncompressed size are taken from the control byte.+ coder->uncompressed_size = (control & 0x1F) << 16;+ coder->sequence = SEQ_UNCOMPRESSED_1;++ // See if there are new properties or if we need to+ // reset the state.+ if (control >= 0xC0) {+ // When there are new properties, state reset+ // is done at SEQ_PROPERTIES.+ coder->need_properties = false;+ coder->next_sequence = SEQ_PROPERTIES;++ } else if (coder->need_properties) {+ return LZMA_DATA_ERROR;++ } else {+ coder->next_sequence = SEQ_LZMA;++ // If only state reset is wanted with old+ // properties, do the resetting here for+ // simplicity.+ if (control >= 0xA0)+ coder->lzma.reset(coder->lzma.coder,+ &coder->options);+ }+ } else {+ // Invalid control values+ if (control > 2)+ return LZMA_DATA_ERROR;++ // It's uncompressed chunk+ coder->sequence = SEQ_COMPRESSED_0;+ coder->next_sequence = SEQ_COPY;+ }++ if (coder->need_dictionary_reset) {+ // Finish the dictionary reset and let the caller+ // flush the dictionary to the actual output buffer.+ coder->need_dictionary_reset = false;+ dict_reset(dict);+ return LZMA_OK;+ }++ break;+ }++ case SEQ_UNCOMPRESSED_1:+ coder->uncompressed_size += (uint32_t)(in[(*in_pos)++]) << 8;+ coder->sequence = SEQ_UNCOMPRESSED_2;+ break;++ case SEQ_UNCOMPRESSED_2:+ coder->uncompressed_size += in[(*in_pos)++] + 1U;+ coder->sequence = SEQ_COMPRESSED_0;+ coder->lzma.set_uncompressed(coder->lzma.coder,+ coder->uncompressed_size, false);+ break;++ case SEQ_COMPRESSED_0:+ coder->compressed_size = (uint32_t)(in[(*in_pos)++]) << 8;+ coder->sequence = SEQ_COMPRESSED_1;+ break;++ case SEQ_COMPRESSED_1:+ coder->compressed_size += in[(*in_pos)++] + 1U;+ coder->sequence = coder->next_sequence;+ break;++ case SEQ_PROPERTIES:+ if (lzma_lzma_lclppb_decode(&coder->options, in[(*in_pos)++]))+ return LZMA_DATA_ERROR;++ coder->lzma.reset(coder->lzma.coder, &coder->options);++ coder->sequence = SEQ_LZMA;+ break;++ case SEQ_LZMA: {+ // Store the start offset so that we can update+ // coder->compressed_size later.+ const size_t in_start = *in_pos;++ // Decode from in[] to *dict.+ const lzma_ret ret = coder->lzma.code(coder->lzma.coder,+ dict, in, in_pos, in_size);++ // Validate and update coder->compressed_size.+ const size_t in_used = *in_pos - in_start;+ if (in_used > coder->compressed_size)+ return LZMA_DATA_ERROR;++ coder->compressed_size -= in_used;++ // Return if we didn't finish the chunk, or an error occurred.+ if (ret != LZMA_STREAM_END)+ return ret;++ // The LZMA decoder must have consumed the whole chunk now.+ // We don't need to worry about uncompressed size since it+ // is checked by the LZMA decoder.+ if (coder->compressed_size != 0)+ return LZMA_DATA_ERROR;++ coder->sequence = SEQ_CONTROL;+ break;+ }++ case SEQ_COPY: {+ // Copy from input to the dictionary as is.+ dict_write(dict, in, in_pos, in_size, &coder->compressed_size);+ if (coder->compressed_size != 0)+ return LZMA_OK;++ coder->sequence = SEQ_CONTROL;+ break;+ }++ default:+ assert(0);+ return LZMA_PROG_ERROR;+ }++ return LZMA_OK;+}+++static void+lzma2_decoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_lzma2_coder *coder = coder_ptr;++ assert(coder->lzma.end == NULL);+ lzma_free(coder->lzma.coder, allocator);++ lzma_free(coder, allocator);++ return;+}+++static lzma_ret+lzma2_decoder_init(lzma_lz_decoder *lz, const lzma_allocator *allocator,+ lzma_vli id lzma_attribute((__unused__)), const void *opt,+ lzma_lz_options *lz_options)+{+ lzma_lzma2_coder *coder = lz->coder;+ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_lzma2_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ lz->coder = coder;+ lz->code = &lzma2_decode;+ lz->end = &lzma2_decoder_end;++ coder->lzma = LZMA_LZ_DECODER_INIT;+ }++ const lzma_options_lzma *options = opt;++ coder->sequence = SEQ_CONTROL;+ coder->need_properties = true;+ coder->need_dictionary_reset = options->preset_dict == NULL+ || options->preset_dict_size == 0;++ return lzma_lzma_decoder_create(&coder->lzma,+ allocator, options, lz_options);+}+++extern lzma_ret+lzma_lzma2_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ // LZMA2 can only be the last filter in the chain. This is enforced+ // by the raw_decoder initialization.+ assert(filters[1].init == NULL);++ return lzma_lz_decoder_init(next, allocator, filters,+ &lzma2_decoder_init);+}+++extern uint64_t+lzma_lzma2_decoder_memusage(const void *options)+{+ return sizeof(lzma_lzma2_coder)+ + lzma_lzma_decoder_memusage_nocheck(options);+}+++extern lzma_ret+lzma_lzma2_props_decode(void **options, const lzma_allocator *allocator,+ const uint8_t *props, size_t props_size)+{+ if (props_size != 1)+ return LZMA_OPTIONS_ERROR;++ // Check that reserved bits are unset.+ if (props[0] & 0xC0)+ return LZMA_OPTIONS_ERROR;++ // Decode the dictionary size.+ if (props[0] > 40)+ return LZMA_OPTIONS_ERROR;++ lzma_options_lzma *opt = lzma_alloc(+ sizeof(lzma_options_lzma), allocator);+ if (opt == NULL)+ return LZMA_MEM_ERROR;++ if (props[0] == 40) {+ opt->dict_size = UINT32_MAX;+ } else {+ opt->dict_size = 2 | (props[0] & 1U);+ opt->dict_size <<= props[0] / 2U + 11;+ }++ opt->preset_dict = NULL;+ opt->preset_dict_size = 0;++ *options = opt;++ return LZMA_OK;+}
+ cbits/liblzma/lzma/lzma2_decoder.h view
@@ -0,0 +1,28 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzma2_decoder.h+/// \brief LZMA2 decoder+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_LZMA2_DECODER_H+#define LZMA_LZMA2_DECODER_H++#include "common.h"++extern lzma_ret lzma_lzma2_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++extern uint64_t lzma_lzma2_decoder_memusage(const void *options);++extern lzma_ret lzma_lzma2_props_decode(+ void **options, const lzma_allocator *allocator,+ const uint8_t *props, size_t props_size);++#endif
+ cbits/liblzma/lzma/lzma2_encoder.c view
@@ -0,0 +1,416 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzma2_encoder.c+/// \brief LZMA2 encoder+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "lz_encoder.h"+#include "lzma_encoder.h"+#include "fastpos.h"+#include "lzma2_encoder.h"+++typedef struct {+ enum {+ SEQ_INIT,+ SEQ_LZMA_ENCODE,+ SEQ_LZMA_COPY,+ SEQ_UNCOMPRESSED_HEADER,+ SEQ_UNCOMPRESSED_COPY,+ } sequence;++ /// LZMA encoder+ void *lzma;++ /// LZMA options currently in use.+ lzma_options_lzma opt_cur;++ bool need_properties;+ bool need_state_reset;+ bool need_dictionary_reset;++ /// Uncompressed size of a chunk+ size_t uncompressed_size;++ /// Compressed size of a chunk (excluding headers); this is also used+ /// to indicate the end of buf[] in SEQ_LZMA_COPY.+ size_t compressed_size;++ /// Read position in buf[]+ size_t buf_pos;++ /// Buffer to hold the chunk header and LZMA compressed data+ uint8_t buf[LZMA2_HEADER_MAX + LZMA2_CHUNK_MAX];+} lzma_lzma2_coder;+++static void+lzma2_header_lzma(lzma_lzma2_coder *coder)+{+ assert(coder->uncompressed_size > 0);+ assert(coder->uncompressed_size <= LZMA2_UNCOMPRESSED_MAX);+ assert(coder->compressed_size > 0);+ assert(coder->compressed_size <= LZMA2_CHUNK_MAX);++ size_t pos;++ if (coder->need_properties) {+ pos = 0;++ if (coder->need_dictionary_reset)+ coder->buf[pos] = 0x80 + (3 << 5);+ else+ coder->buf[pos] = 0x80 + (2 << 5);+ } else {+ pos = 1;++ if (coder->need_state_reset)+ coder->buf[pos] = 0x80 + (1 << 5);+ else+ coder->buf[pos] = 0x80;+ }++ // Set the start position for copying.+ coder->buf_pos = pos;++ // Uncompressed size+ size_t size = coder->uncompressed_size - 1;+ coder->buf[pos++] += size >> 16;+ coder->buf[pos++] = (size >> 8) & 0xFF;+ coder->buf[pos++] = size & 0xFF;++ // Compressed size+ size = coder->compressed_size - 1;+ coder->buf[pos++] = size >> 8;+ coder->buf[pos++] = size & 0xFF;++ // Properties, if needed+ if (coder->need_properties)+ lzma_lzma_lclppb_encode(&coder->opt_cur, coder->buf + pos);++ coder->need_properties = false;+ coder->need_state_reset = false;+ coder->need_dictionary_reset = false;++ // The copying code uses coder->compressed_size to indicate the end+ // of coder->buf[], so we need add the maximum size of the header here.+ coder->compressed_size += LZMA2_HEADER_MAX;++ return;+}+++static void+lzma2_header_uncompressed(lzma_lzma2_coder *coder)+{+ assert(coder->uncompressed_size > 0);+ assert(coder->uncompressed_size <= LZMA2_CHUNK_MAX);++ // If this is the first chunk, we need to include dictionary+ // reset indicator.+ if (coder->need_dictionary_reset)+ coder->buf[0] = 1;+ else+ coder->buf[0] = 2;++ coder->need_dictionary_reset = false;++ // "Compressed" size+ coder->buf[1] = (coder->uncompressed_size - 1) >> 8;+ coder->buf[2] = (coder->uncompressed_size - 1) & 0xFF;++ // Set the start position for copying.+ coder->buf_pos = 0;+ return;+}+++static lzma_ret+lzma2_encode(void *coder_ptr, lzma_mf *restrict mf,+ uint8_t *restrict out, size_t *restrict out_pos,+ size_t out_size)+{+ lzma_lzma2_coder *restrict coder = coder_ptr;++ while (*out_pos < out_size)+ switch (coder->sequence) {+ case SEQ_INIT:+ // If there's no input left and we are flushing or finishing,+ // don't start a new chunk.+ if (mf_unencoded(mf) == 0) {+ // Write end of payload marker if finishing.+ if (mf->action == LZMA_FINISH)+ out[(*out_pos)++] = 0;++ return mf->action == LZMA_RUN+ ? LZMA_OK : LZMA_STREAM_END;+ }++ if (coder->need_state_reset)+ return_if_error(lzma_lzma_encoder_reset(+ coder->lzma, &coder->opt_cur));++ coder->uncompressed_size = 0;+ coder->compressed_size = 0;+ coder->sequence = SEQ_LZMA_ENCODE;++ // Fall through++ case SEQ_LZMA_ENCODE: {+ // Calculate how much more uncompressed data this chunk+ // could accept.+ const uint32_t left = LZMA2_UNCOMPRESSED_MAX+ - coder->uncompressed_size;+ uint32_t limit;++ if (left < mf->match_len_max) {+ // Must flush immediately since the next LZMA symbol+ // could make the uncompressed size of the chunk too+ // big.+ limit = 0;+ } else {+ // Calculate maximum read_limit that is OK from point+ // of view of LZMA2 chunk size.+ limit = mf->read_pos - mf->read_ahead+ + left - mf->match_len_max;+ }++ // Save the start position so that we can update+ // coder->uncompressed_size.+ const uint32_t read_start = mf->read_pos - mf->read_ahead;++ // Call the LZMA encoder until the chunk is finished.+ const lzma_ret ret = lzma_lzma_encode(coder->lzma, mf,+ coder->buf + LZMA2_HEADER_MAX,+ &coder->compressed_size,+ LZMA2_CHUNK_MAX, limit);++ coder->uncompressed_size += mf->read_pos - mf->read_ahead+ - read_start;++ assert(coder->compressed_size <= LZMA2_CHUNK_MAX);+ assert(coder->uncompressed_size <= LZMA2_UNCOMPRESSED_MAX);++ if (ret != LZMA_STREAM_END)+ return LZMA_OK;++ // See if the chunk compressed. If it didn't, we encode it+ // as uncompressed chunk. This saves a few bytes of space+ // and makes decoding faster.+ if (coder->compressed_size >= coder->uncompressed_size) {+ coder->uncompressed_size += mf->read_ahead;+ assert(coder->uncompressed_size+ <= LZMA2_UNCOMPRESSED_MAX);+ mf->read_ahead = 0;+ lzma2_header_uncompressed(coder);+ coder->need_state_reset = true;+ coder->sequence = SEQ_UNCOMPRESSED_HEADER;+ break;+ }++ // The chunk did compress at least by one byte, so we store+ // the chunk as LZMA.+ lzma2_header_lzma(coder);++ coder->sequence = SEQ_LZMA_COPY;+ }++ // Fall through++ case SEQ_LZMA_COPY:+ // Copy the compressed chunk along its headers to the+ // output buffer.+ lzma_bufcpy(coder->buf, &coder->buf_pos,+ coder->compressed_size,+ out, out_pos, out_size);+ if (coder->buf_pos != coder->compressed_size)+ return LZMA_OK;++ coder->sequence = SEQ_INIT;+ break;++ case SEQ_UNCOMPRESSED_HEADER:+ // Copy the three-byte header to indicate uncompressed chunk.+ lzma_bufcpy(coder->buf, &coder->buf_pos,+ LZMA2_HEADER_UNCOMPRESSED,+ out, out_pos, out_size);+ if (coder->buf_pos != LZMA2_HEADER_UNCOMPRESSED)+ return LZMA_OK;++ coder->sequence = SEQ_UNCOMPRESSED_COPY;++ // Fall through++ case SEQ_UNCOMPRESSED_COPY:+ // Copy the uncompressed data as is from the dictionary+ // to the output buffer.+ mf_read(mf, out, out_pos, out_size, &coder->uncompressed_size);+ if (coder->uncompressed_size != 0)+ return LZMA_OK;++ coder->sequence = SEQ_INIT;+ break;+ }++ return LZMA_OK;+}+++static void+lzma2_encoder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_lzma2_coder *coder = coder_ptr;+ lzma_free(coder->lzma, allocator);+ lzma_free(coder, allocator);+ return;+}+++static lzma_ret+lzma2_encoder_options_update(void *coder_ptr, const lzma_filter *filter)+{+ lzma_lzma2_coder *coder = coder_ptr;++ // New options can be set only when there is no incomplete chunk.+ // This is the case at the beginning of the raw stream and right+ // after LZMA_SYNC_FLUSH.+ if (filter->options == NULL || coder->sequence != SEQ_INIT)+ return LZMA_PROG_ERROR;++ // Look if there are new options. At least for now,+ // only lc/lp/pb can be changed.+ const lzma_options_lzma *opt = filter->options;+ if (coder->opt_cur.lc != opt->lc || coder->opt_cur.lp != opt->lp+ || coder->opt_cur.pb != opt->pb) {+ // Validate the options.+ if (opt->lc > LZMA_LCLP_MAX || opt->lp > LZMA_LCLP_MAX+ || opt->lc + opt->lp > LZMA_LCLP_MAX+ || opt->pb > LZMA_PB_MAX)+ return LZMA_OPTIONS_ERROR;++ // The new options will be used when the encoder starts+ // a new LZMA2 chunk.+ coder->opt_cur.lc = opt->lc;+ coder->opt_cur.lp = opt->lp;+ coder->opt_cur.pb = opt->pb;+ coder->need_properties = true;+ coder->need_state_reset = true;+ }++ return LZMA_OK;+}+++static lzma_ret+lzma2_encoder_init(lzma_lz_encoder *lz, const lzma_allocator *allocator,+ lzma_vli id lzma_attribute((__unused__)), const void *options,+ lzma_lz_options *lz_options)+{+ if (options == NULL)+ return LZMA_PROG_ERROR;++ lzma_lzma2_coder *coder = lz->coder;+ if (coder == NULL) {+ coder = lzma_alloc(sizeof(lzma_lzma2_coder), allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ lz->coder = coder;+ lz->code = &lzma2_encode;+ lz->end = &lzma2_encoder_end;+ lz->options_update = &lzma2_encoder_options_update;++ coder->lzma = NULL;+ }++ coder->opt_cur = *(const lzma_options_lzma *)(options);++ coder->sequence = SEQ_INIT;+ coder->need_properties = true;+ coder->need_state_reset = false;+ coder->need_dictionary_reset+ = coder->opt_cur.preset_dict == NULL+ || coder->opt_cur.preset_dict_size == 0;++ // Initialize LZMA encoder+ return_if_error(lzma_lzma_encoder_create(&coder->lzma, allocator,+ LZMA_FILTER_LZMA2, &coder->opt_cur, lz_options));++ // Make sure that we will always have enough history available in+ // case we need to use uncompressed chunks. They are used when the+ // compressed size of a chunk is not smaller than the uncompressed+ // size, so we need to have at least LZMA2_COMPRESSED_MAX bytes+ // history available.+ if (lz_options->before_size + lz_options->dict_size < LZMA2_CHUNK_MAX)+ lz_options->before_size+ = LZMA2_CHUNK_MAX - lz_options->dict_size;++ return LZMA_OK;+}+++extern lzma_ret+lzma_lzma2_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return lzma_lz_encoder_init(+ next, allocator, filters, &lzma2_encoder_init);+}+++extern uint64_t+lzma_lzma2_encoder_memusage(const void *options)+{+ const uint64_t lzma_mem = lzma_lzma_encoder_memusage(options);+ if (lzma_mem == UINT64_MAX)+ return UINT64_MAX;++ return sizeof(lzma_lzma2_coder) + lzma_mem;+}+++extern lzma_ret+lzma_lzma2_props_encode(const void *options, uint8_t *out)+{+ if (options == NULL)+ return LZMA_PROG_ERROR;++ const lzma_options_lzma *const opt = options;+ uint32_t d = my_max(opt->dict_size, LZMA_DICT_SIZE_MIN);++ // Round up to the next 2^n - 1 or 2^n + 2^(n - 1) - 1 depending+ // on which one is the next:+ --d;+ d |= d >> 2;+ d |= d >> 3;+ d |= d >> 4;+ d |= d >> 8;+ d |= d >> 16;++ // Get the highest two bits using the proper encoding:+ if (d == UINT32_MAX)+ out[0] = 40;+ else+ out[0] = get_dist_slot(d + 1) - 24;++ return LZMA_OK;+}+++extern uint64_t+lzma_lzma2_block_size(const void *options)+{+ const lzma_options_lzma *const opt = options;++ if (!IS_ENC_DICT_SIZE_VALID(opt->dict_size))+ return UINT64_MAX;++ // Use at least 1 MiB to keep compression ratio better.+ return my_max((uint64_t)(opt->dict_size) * 3, UINT64_C(1) << 20);+}
+ cbits/liblzma/lzma/lzma2_encoder.h view
@@ -0,0 +1,42 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzma2_encoder.h+/// \brief LZMA2 encoder+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_LZMA2_ENCODER_H+#define LZMA_LZMA2_ENCODER_H++#include "common.h"+++/// Maximum number of bytes of actual data per chunk (no headers)+#define LZMA2_CHUNK_MAX (UINT32_C(1) << 16)++/// Maximum uncompressed size of LZMA chunk (no headers)+#define LZMA2_UNCOMPRESSED_MAX (UINT32_C(1) << 21)++/// Maximum size of LZMA2 headers+#define LZMA2_HEADER_MAX 6++/// Size of a header for uncompressed chunk+#define LZMA2_HEADER_UNCOMPRESSED 3+++extern lzma_ret lzma_lzma2_encoder_init(+ lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters);++extern uint64_t lzma_lzma2_encoder_memusage(const void *options);++extern lzma_ret lzma_lzma2_props_encode(const void *options, uint8_t *out);++extern uint64_t lzma_lzma2_block_size(const void *options);++#endif
+ cbits/liblzma/lzma/lzma_common.h view
@@ -0,0 +1,240 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzma_common.h+/// \brief Private definitions common to LZMA encoder and decoder+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_LZMA_COMMON_H+#define LZMA_LZMA_COMMON_H++#include "common.h"+#include "range_common.h"+++///////////////////+// Miscellaneous //+///////////////////++/// Maximum number of position states. A position state is the lowest pos bits+/// number of bits of the current uncompressed offset. In some places there+/// are different sets of probabilities for different pos states.+#define POS_STATES_MAX (1 << LZMA_PB_MAX)+++/// Validates lc, lp, and pb.+static inline bool+is_lclppb_valid(const lzma_options_lzma *options)+{+ return options->lc <= LZMA_LCLP_MAX && options->lp <= LZMA_LCLP_MAX+ && options->lc + options->lp <= LZMA_LCLP_MAX+ && options->pb <= LZMA_PB_MAX;+}+++///////////+// State //+///////////++/// This enum is used to track which events have occurred most recently and+/// in which order. This information is used to predict the next event.+///+/// Events:+/// - Literal: One 8-bit byte+/// - Match: Repeat a chunk of data at some distance+/// - Long repeat: Multi-byte match at a recently seen distance+/// - Short repeat: One-byte repeat at a recently seen distance+///+/// The event names are in from STATE_oldest_older_previous. REP means+/// either short or long repeated match, and NONLIT means any non-literal.+typedef enum {+ STATE_LIT_LIT,+ STATE_MATCH_LIT_LIT,+ STATE_REP_LIT_LIT,+ STATE_SHORTREP_LIT_LIT,+ STATE_MATCH_LIT,+ STATE_REP_LIT,+ STATE_SHORTREP_LIT,+ STATE_LIT_MATCH,+ STATE_LIT_LONGREP,+ STATE_LIT_SHORTREP,+ STATE_NONLIT_MATCH,+ STATE_NONLIT_REP,+} lzma_lzma_state;+++/// Total number of states+#define STATES 12++/// The lowest 7 states indicate that the previous state was a literal.+#define LIT_STATES 7+++/// Indicate that the latest state was a literal.+#define update_literal(state) \+ state = ((state) <= STATE_SHORTREP_LIT_LIT \+ ? STATE_LIT_LIT \+ : ((state) <= STATE_LIT_SHORTREP \+ ? (state) - 3 \+ : (state) - 6))++/// Like update_literal(state) but when it is already known that+/// is_literal_state(state) is true.+#define update_literal_normal(state) \+ state = ((state) <= STATE_SHORTREP_LIT_LIT \+ ? STATE_LIT_LIT \+ : (state) - 3);++/// Like update_literal(state) but when it is already known that+/// is_literal_state(state) is false.+#define update_literal_matched(state) \+ state = ((state) <= STATE_LIT_SHORTREP \+ ? (state) - 3 \+ : (state) - 6);++/// Indicate that the latest state was a match.+#define update_match(state) \+ state = ((state) < LIT_STATES ? STATE_LIT_MATCH : STATE_NONLIT_MATCH)++/// Indicate that the latest state was a long repeated match.+#define update_long_rep(state) \+ state = ((state) < LIT_STATES ? STATE_LIT_LONGREP : STATE_NONLIT_REP)++/// Indicate that the latest state was a short match.+#define update_short_rep(state) \+ state = ((state) < LIT_STATES ? STATE_LIT_SHORTREP : STATE_NONLIT_REP)++/// Test if the previous state was a literal.+#define is_literal_state(state) \+ ((state) < LIT_STATES)+++/////////////+// Literal //+/////////////++/// Each literal coder is divided in three sections:+/// - 0x001-0x0FF: Without match byte+/// - 0x101-0x1FF: With match byte; match bit is 0+/// - 0x201-0x2FF: With match byte; match bit is 1+///+/// Match byte is used when the previous LZMA symbol was something else than+/// a literal (that is, it was some kind of match).+#define LITERAL_CODER_SIZE UINT32_C(0x300)++/// Maximum number of literal coders+#define LITERAL_CODERS_MAX (1 << LZMA_LCLP_MAX)++/// Calculates the literal_mask that literal_subcoder() needs.+#define literal_mask_calc(lc, lp) \+ ((UINT32_C(0x100) << (lp)) - (UINT32_C(0x100) >> (lc)))++/// Locate the literal coder for the next literal byte. The choice depends on+/// - the lowest literal_pos_bits bits of the position of the current+/// byte; and+/// - the highest literal_context_bits bits of the previous byte.+#define literal_subcoder(probs, lc, literal_mask, pos, prev_byte) \+ ((probs) + UINT32_C(3) * \+ (((((pos) << 8) + (prev_byte)) & (literal_mask)) << (lc)))+++static inline void+literal_init(probability *probs, uint32_t lc, uint32_t lp)+{+ assert(lc + lp <= LZMA_LCLP_MAX);++ const size_t coders = LITERAL_CODER_SIZE << (lc + lp);++ for (size_t i = 0; i < coders; ++i)+ bit_reset(probs[i]);++ return;+}+++//////////////////+// Match length //+//////////////////++// Minimum length of a match is two bytes.+#define MATCH_LEN_MIN 2++// Match length is encoded with 4, 5, or 10 bits.+//+// Length Bits+// 2-9 4 = Choice=0 + 3 bits+// 10-17 5 = Choice=1 + Choice2=0 + 3 bits+// 18-273 10 = Choice=1 + Choice2=1 + 8 bits+#define LEN_LOW_BITS 3+#define LEN_LOW_SYMBOLS (1 << LEN_LOW_BITS)+#define LEN_MID_BITS 3+#define LEN_MID_SYMBOLS (1 << LEN_MID_BITS)+#define LEN_HIGH_BITS 8+#define LEN_HIGH_SYMBOLS (1 << LEN_HIGH_BITS)+#define LEN_SYMBOLS (LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS + LEN_HIGH_SYMBOLS)++// Maximum length of a match is 273 which is a result of the encoding+// described above.+#define MATCH_LEN_MAX (MATCH_LEN_MIN + LEN_SYMBOLS - 1)+++////////////////////+// Match distance //+////////////////////++// Different sets of probabilities are used for match distances that have very+// short match length: Lengths of 2, 3, and 4 bytes have a separate set of+// probabilities for each length. The matches with longer length use a shared+// set of probabilities.+#define DIST_STATES 4++// Macro to get the index of the appropriate probability array.+#define get_dist_state(len) \+ ((len) < DIST_STATES + MATCH_LEN_MIN \+ ? (len) - MATCH_LEN_MIN \+ : DIST_STATES - 1)++// The highest two bits of a match distance (distance slot) are encoded+// using six bits. See fastpos.h for more explanation.+#define DIST_SLOT_BITS 6+#define DIST_SLOTS (1 << DIST_SLOT_BITS)++// Match distances up to 127 are fully encoded using probabilities. Since+// the highest two bits (distance slot) are always encoded using six bits,+// the distances 0-3 don't need any additional bits to encode, since the+// distance slot itself is the same as the actual distance. DIST_MODEL_START+// indicates the first distance slot where at least one additional bit is+// needed.+#define DIST_MODEL_START 4++// Match distances greater than 127 are encoded in three pieces:+// - distance slot: the highest two bits+// - direct bits: 2-26 bits below the highest two bits+// - alignment bits: four lowest bits+//+// Direct bits don't use any probabilities.+//+// The distance slot value of 14 is for distances 128-191 (see the table in+// fastpos.h to understand why).+#define DIST_MODEL_END 14++// Distance slots that indicate a distance <= 127.+#define FULL_DISTANCES_BITS (DIST_MODEL_END / 2)+#define FULL_DISTANCES (1 << FULL_DISTANCES_BITS)++// For match distances greater than 127, only the highest two bits and the+// lowest four bits (alignment) is encoded using probabilities.+#define ALIGN_BITS 4+#define ALIGN_SIZE (1 << ALIGN_BITS)+#define ALIGN_MASK (ALIGN_SIZE - 1)++// LZMA remembers the four most recent match distances. Reusing these distances+// tends to take less space than re-encoding the actual distance value.+#define REPS 4++#endif
+ cbits/liblzma/lzma/lzma_decoder.c view
@@ -0,0 +1,1263 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzma_decoder.c+/// \brief LZMA decoder+///+// Authors: Igor Pavlov+// Lasse Collin+// Jia Tan+//+///////////////////////////////////////////////////////////////////////////////++#include "lz_decoder.h"+#include "lzma_common.h"+#include "lzma_decoder.h"+#include "range_decoder.h"++// The macros unroll loops with switch statements.+// Silence warnings about missing fall-through comments.+#if TUKLIB_GNUC_REQ(7, 0)+# pragma GCC diagnostic ignored "-Wimplicit-fallthrough"+#endif++// Minimum number of input bytes to safely decode one LZMA symbol.+// The worst case is that we decode 22 bits using probabilities and 26+// direct bits. This may decode at maximum 20 bytes of input.+#define LZMA_IN_REQUIRED 20+++// Macros for (somewhat) size-optimized code.+// This is used to decode the match length (how many bytes must be repeated+// from the dictionary). This version is used in the Resumable mode and+// does not unroll any loops.+#define len_decode(target, ld, pos_state, seq) \+do { \+case seq ## _CHOICE: \+ rc_if_0_safe(ld.choice, seq ## _CHOICE) { \+ rc_update_0(ld.choice); \+ probs = ld.low[pos_state];\+ limit = LEN_LOW_SYMBOLS; \+ target = MATCH_LEN_MIN; \+ } else { \+ rc_update_1(ld.choice); \+case seq ## _CHOICE2: \+ rc_if_0_safe(ld.choice2, seq ## _CHOICE2) { \+ rc_update_0(ld.choice2); \+ probs = ld.mid[pos_state]; \+ limit = LEN_MID_SYMBOLS; \+ target = MATCH_LEN_MIN + LEN_LOW_SYMBOLS; \+ } else { \+ rc_update_1(ld.choice2); \+ probs = ld.high; \+ limit = LEN_HIGH_SYMBOLS; \+ target = MATCH_LEN_MIN + LEN_LOW_SYMBOLS \+ + LEN_MID_SYMBOLS; \+ } \+ } \+ symbol = 1; \+case seq ## _BITTREE: \+ do { \+ rc_bit_safe(probs[symbol], , , seq ## _BITTREE); \+ } while (symbol < limit); \+ target += symbol - limit; \+} while (0)+++// This is the faster version of the match length decoder that does not+// worry about being resumable. It unrolls the bittree decoding loop.+#define len_decode_fast(target, ld, pos_state) \+do { \+ symbol = 1; \+ rc_if_0(ld.choice) { \+ rc_update_0(ld.choice); \+ rc_bittree3(ld.low[pos_state], \+ -LEN_LOW_SYMBOLS + MATCH_LEN_MIN); \+ target = symbol; \+ } else { \+ rc_update_1(ld.choice); \+ rc_if_0(ld.choice2) { \+ rc_update_0(ld.choice2); \+ rc_bittree3(ld.mid[pos_state], -LEN_MID_SYMBOLS \+ + MATCH_LEN_MIN + LEN_LOW_SYMBOLS); \+ target = symbol; \+ } else { \+ rc_update_1(ld.choice2); \+ rc_bittree8(ld.high, -LEN_HIGH_SYMBOLS \+ + MATCH_LEN_MIN \+ + LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS); \+ target = symbol; \+ } \+ } \+} while (0)+++/// Length decoder probabilities; see comments in lzma_common.h.+typedef struct {+ probability choice;+ probability choice2;+ probability low[POS_STATES_MAX][LEN_LOW_SYMBOLS];+ probability mid[POS_STATES_MAX][LEN_MID_SYMBOLS];+ probability high[LEN_HIGH_SYMBOLS];+} lzma_length_decoder;+++typedef struct {+ ///////////////////+ // Probabilities //+ ///////////////////++ /// Literals; see comments in lzma_common.h.+ probability literal[LITERAL_CODERS_MAX * LITERAL_CODER_SIZE];++ /// If 1, it's a match. Otherwise it's a single 8-bit literal.+ probability is_match[STATES][POS_STATES_MAX];++ /// If 1, it's a repeated match. The distance is one of rep0 .. rep3.+ probability is_rep[STATES];++ /// If 0, distance of a repeated match is rep0.+ /// Otherwise check is_rep1.+ probability is_rep0[STATES];++ /// If 0, distance of a repeated match is rep1.+ /// Otherwise check is_rep2.+ probability is_rep1[STATES];++ /// If 0, distance of a repeated match is rep2. Otherwise it is rep3.+ probability is_rep2[STATES];++ /// If 1, the repeated match has length of one byte. Otherwise+ /// the length is decoded from rep_len_decoder.+ probability is_rep0_long[STATES][POS_STATES_MAX];++ /// Probability tree for the highest two bits of the match distance.+ /// There is a separate probability tree for match lengths of+ /// 2 (i.e. MATCH_LEN_MIN), 3, 4, and [5, 273].+ probability dist_slot[DIST_STATES][DIST_SLOTS];++ /// Probability trees for additional bits for match distance when the+ /// distance is in the range [4, 127].+ probability pos_special[FULL_DISTANCES - DIST_MODEL_END];++ /// Probability tree for the lowest four bits of a match distance+ /// that is equal to or greater than 128.+ probability pos_align[ALIGN_SIZE];++ /// Length of a normal match+ lzma_length_decoder match_len_decoder;++ /// Length of a repeated match+ lzma_length_decoder rep_len_decoder;++ ///////////////////+ // Decoder state //+ ///////////////////++ // Range coder+ lzma_range_decoder rc;++ // Types of the most recently seen LZMA symbols+ lzma_lzma_state state;++ uint32_t rep0; ///< Distance of the latest match+ uint32_t rep1; ///< Distance of second latest match+ uint32_t rep2; ///< Distance of third latest match+ uint32_t rep3; ///< Distance of fourth latest match++ uint32_t pos_mask; // (1U << pb) - 1+ uint32_t literal_context_bits;+ uint32_t literal_mask;++ /// Uncompressed size as bytes, or LZMA_VLI_UNKNOWN if end of+ /// payload marker is expected.+ lzma_vli uncompressed_size;++ /// True if end of payload marker (EOPM) is allowed even when+ /// uncompressed_size is known; false if EOPM must not be present.+ /// This is ignored if uncompressed_size == LZMA_VLI_UNKNOWN.+ bool allow_eopm;++ ////////////////////////////////+ // State of incomplete symbol //+ ////////////////////////////////++ /// Position where to continue the decoder loop+ enum {+ SEQ_NORMALIZE,+ SEQ_IS_MATCH,+ SEQ_LITERAL,+ SEQ_LITERAL_MATCHED,+ SEQ_LITERAL_WRITE,+ SEQ_IS_REP,+ SEQ_MATCH_LEN_CHOICE,+ SEQ_MATCH_LEN_CHOICE2,+ SEQ_MATCH_LEN_BITTREE,+ SEQ_DIST_SLOT,+ SEQ_DIST_MODEL,+ SEQ_DIRECT,+ SEQ_ALIGN,+ SEQ_EOPM,+ SEQ_IS_REP0,+ SEQ_SHORTREP,+ SEQ_IS_REP0_LONG,+ SEQ_IS_REP1,+ SEQ_IS_REP2,+ SEQ_REP_LEN_CHOICE,+ SEQ_REP_LEN_CHOICE2,+ SEQ_REP_LEN_BITTREE,+ SEQ_COPY,+ } sequence;++ /// Base of the current probability tree+ probability *probs;++ /// Symbol being decoded. This is also used as an index variable in+ /// bittree decoders: probs[symbol]+ uint32_t symbol;++ /// Used as a loop termination condition on bittree decoders and+ /// direct bits decoder.+ uint32_t limit;++ /// Matched literal decoder: 0x100 or 0 to help avoiding branches.+ /// Bittree reverse decoders: Offset of the next bit: 1 << offset+ uint32_t offset;++ /// If decoding a literal: match byte.+ /// If decoding a match: length of the match.+ uint32_t len;+} lzma_lzma1_decoder;+++static lzma_ret+lzma_decode(void *coder_ptr, lzma_dict *restrict dictptr,+ const uint8_t *restrict in,+ size_t *restrict in_pos, size_t in_size)+{+ lzma_lzma1_decoder *restrict coder = coder_ptr;++ ////////////////////+ // Initialization //+ ////////////////////++ {+ const lzma_ret ret = rc_read_init(+ &coder->rc, in, in_pos, in_size);+ if (ret != LZMA_STREAM_END)+ return ret;+ }++ ///////////////+ // Variables //+ ///////////////++ // Making local copies of often-used variables improves both+ // speed and readability.++ lzma_dict dict = *dictptr;++ const size_t dict_start = dict.pos;++ // Range decoder+ rc_to_local(coder->rc, *in_pos, LZMA_IN_REQUIRED);++ // State+ uint32_t state = coder->state;+ uint32_t rep0 = coder->rep0;+ uint32_t rep1 = coder->rep1;+ uint32_t rep2 = coder->rep2;+ uint32_t rep3 = coder->rep3;++ const uint32_t pos_mask = coder->pos_mask;++ // These variables are actually needed only if we last time ran+ // out of input in the middle of the decoder loop.+ probability *probs = coder->probs;+ uint32_t symbol = coder->symbol;+ uint32_t limit = coder->limit;+ uint32_t offset = coder->offset;+ uint32_t len = coder->len;++ const uint32_t literal_mask = coder->literal_mask;+ const uint32_t literal_context_bits = coder->literal_context_bits;++ // Temporary variables+ uint32_t pos_state = dict.pos & pos_mask;++ lzma_ret ret = LZMA_OK;++ // This is true when the next LZMA symbol is allowed to be EOPM.+ // That is, if this is false, then EOPM is considered+ // an invalid symbol and we will return LZMA_DATA_ERROR.+ //+ // EOPM is always required (not just allowed) when+ // the uncompressed size isn't known. When uncompressed size+ // is known, eopm_is_valid may be set to true later.+ bool eopm_is_valid = coder->uncompressed_size == LZMA_VLI_UNKNOWN;++ // If uncompressed size is known and there is enough output space+ // to decode all the data, limit the available buffer space so that+ // the main loop won't try to decode past the end of the stream.+ bool might_finish_without_eopm = false;+ if (coder->uncompressed_size != LZMA_VLI_UNKNOWN+ && coder->uncompressed_size <= dict.limit - dict.pos) {+ dict.limit = dict.pos + (size_t)(coder->uncompressed_size);+ might_finish_without_eopm = true;+ }++ // The main decoder loop. The "switch" is used to resume the decoder at+ // correct location. Once resumed, the "switch" is no longer used.+ // The decoder loops is split into two modes:+ //+ // 1 - Non-resumable mode (fast). This is used when it is guaranteed+ // there is enough input to decode the next symbol. If the output+ // limit is reached, then the decoder loop will save the place+ // for the resumable mode to continue. This mode is not used if+ // HAVE_SMALL is defined. This is faster than Resumable mode+ // because it reduces the number of branches needed and allows+ // for more compiler optimizations.+ //+ // 2 - Resumable mode (slow). This is used when a previous decoder+ // loop did not have enough space in the input or output buffers+ // to complete. It uses sequence enum values to set remind+ // coder->sequence where to resume in the decoder loop. This+ // is the only mode used when HAVE_SMALL is defined.++ switch (coder->sequence)+ while (true) {+ // Calculate new pos_state. This is skipped on the first loop+ // since we already calculated it when setting up the local+ // variables.+ pos_state = dict.pos & pos_mask;++#ifndef HAVE_SMALL++ ///////////////////////////////+ // Non-resumable Mode (fast) //+ ///////////////////////////////++ // Go to Resumable mode (1) if there is not enough input to+ // safely decode any possible LZMA symbol or (2) if the+ // dictionary is full, which may need special checks that+ // are only done in the Resumable mode.+ if (unlikely(!rc_is_fast_allowed()+ || dict.pos == dict.limit))+ goto slow;++ // Decode the first bit from the next LZMA symbol.+ // If the bit is a 0, then we handle it as a literal.+ // If the bit is a 1, then it is a match of previously+ // decoded data.+ rc_if_0(coder->is_match[state][pos_state]) {+ /////////////////////+ // Decode literal. //+ /////////////////////++ // Update the RC that we have decoded a 0.+ rc_update_0(coder->is_match[state][pos_state]);++ // Get the correct probability array from lp and+ // lc params.+ probs = literal_subcoder(coder->literal,+ literal_context_bits, literal_mask,+ dict.pos, dict_get0(&dict));++ if (is_literal_state(state)) {+ update_literal_normal(state);++ // Decode literal without match byte.+ rc_bittree8(probs, 0);+ } else {+ update_literal_matched(state);++ // Decode literal with match byte.+ rc_matched_literal(probs,+ dict_get(&dict, rep0));+ }++ // Write decoded literal to dictionary+ dict_put(&dict, symbol);+ continue;+ }++ ///////////////////+ // Decode match. //+ ///////////////////++ // Instead of a new byte we are going to decode a+ // distance-length pair. The distance represents how far+ // back in the dictionary to begin copying. The length+ // represents how many bytes to copy.++ rc_update_1(coder->is_match[state][pos_state]);++ rc_if_0(coder->is_rep[state]) {+ ///////////////////+ // Simple match. //+ ///////////////////++ // Not a repeated match. In this case,+ // the length (how many bytes to copy) must be+ // decoded first. Then, the distance (where to+ // start copying) is decoded.+ //+ // This is also how we know when we are done+ // decoding. If the distance decodes to UINT32_MAX,+ // then we know to stop decoding (end of payload+ // marker).++ rc_update_0(coder->is_rep[state]);+ update_match(state);++ // The latest three match distances are kept in+ // memory in case there are repeated matches.+ rep3 = rep2;+ rep2 = rep1;+ rep1 = rep0;++ // Decode the length of the match.+ len_decode_fast(len, coder->match_len_decoder,+ pos_state);++ // Next, decode the distance into rep0.++ // The next 6 bits determine how to decode the+ // rest of the distance.+ probs = coder->dist_slot[get_dist_state(len)];++ rc_bittree6(probs, -DIST_SLOTS);+ assert(symbol <= 63);++ if (symbol < DIST_MODEL_START) {+ // If the decoded symbol is < DIST_MODEL_START+ // then we use its value directly as the+ // match distance. No other bits are needed.+ // The only possible distance values+ // are [0, 3].+ rep0 = symbol;+ } else {+ // Use the first two bits of symbol as the+ // highest bits of the match distance.++ // "limit" represents the number of low bits+ // to decode.+ limit = (symbol >> 1) - 1;+ assert(limit >= 1 && limit <= 30);+ rep0 = 2 + (symbol & 1);++ if (symbol < DIST_MODEL_END) {+ // When symbol is > DIST_MODEL_START,+ // but symbol < DIST_MODEL_END, then+ // it can decode distances between+ // [4, 127].+ assert(limit <= 5);+ rep0 <<= limit;+ assert(rep0 <= 96);++ // -1 is fine, because we start+ // decoding at probs[1], not probs[0].+ // NOTE: This violates the C standard,+ // since we are doing pointer+ // arithmetic past the beginning of+ // the array.+ assert((int32_t)(rep0 - symbol - 1)+ >= -1);+ assert((int32_t)(rep0 - symbol - 1)+ <= 82);+ probs = coder->pos_special + rep0+ - symbol - 1;+ symbol = 1;+ offset = 1;++ // Variable number (1-5) of bits+ // from a reverse bittree. This+ // isn't worth manual unrolling.+ //+ // NOTE: Making one or many of the+ // variables (probs, symbol, offset,+ // or limit) local here (instead of+ // using those declared outside the+ // main loop) can affect code size+ // and performance which isn't a+ // surprise but it's not so clear+ // what is the best.+ do {+ rc_bit_add_if_1(probs,+ rep0, offset);+ offset <<= 1;+ } while (--limit > 0);+ } else {+ // The distance is >= 128. Decode the+ // lower bits without probabilities+ // except the lowest four bits.+ assert(symbol >= 14);+ assert(limit >= 6);++ limit -= ALIGN_BITS;+ assert(limit >= 2);++ rc_direct(rep0, limit);++ // Decode the lowest four bits using+ // probabilities.+ rep0 <<= ALIGN_BITS;+ rc_bittree_rev4(coder->pos_align);+ rep0 += symbol;++ // If the end of payload marker (EOPM)+ // is detected, jump to the safe code.+ // The EOPM handling isn't speed+ // critical at all.+ //+ // A final normalization is needed+ // after the EOPM (there can be a+ // dummy byte to read in some cases).+ // If the normalization was done here+ // in the fast code, it would need to+ // be taken into account in the value+ // of LZMA_IN_REQUIRED. Using the+ // safe code allows keeping+ // LZMA_IN_REQUIRED as 20 instead of+ // 21.+ if (rep0 == UINT32_MAX)+ goto eopm;+ }+ }++ // Validate the distance we just decoded.+ if (unlikely(!dict_is_distance_valid(&dict, rep0))) {+ ret = LZMA_DATA_ERROR;+ goto out;+ }++ } else {+ rc_update_1(coder->is_rep[state]);++ /////////////////////+ // Repeated match. //+ /////////////////////++ // The match distance is a value that we have decoded+ // recently. The latest four match distances are+ // available as rep0, rep1, rep2 and rep3. We will+ // now decode which of them is the new distance.+ //+ // There cannot be a match if we haven't produced+ // any output, so check that first.+ if (unlikely(!dict_is_distance_valid(&dict, 0))) {+ ret = LZMA_DATA_ERROR;+ goto out;+ }++ rc_if_0(coder->is_rep0[state]) {+ rc_update_0(coder->is_rep0[state]);+ // The distance is rep0.++ // Decode the next bit to determine if 1 byte+ // should be copied from rep0 distance or+ // if the number of bytes needs to be decoded.++ // If the next bit is 0, then it is a+ // "Short Rep Match" and only 1 bit is copied.+ // Otherwise, the length of the match is+ // decoded after the "else" statement.+ rc_if_0(coder->is_rep0_long[state][pos_state]) {+ rc_update_0(coder->is_rep0_long[+ state][pos_state]);++ update_short_rep(state);+ dict_put(&dict, dict_get(&dict, rep0));+ continue;+ }++ // Repeating more than one byte at+ // distance of rep0.+ rc_update_1(coder->is_rep0_long[+ state][pos_state]);++ } else {+ rc_update_1(coder->is_rep0[state]);++ // The distance is rep1, rep2 or rep3. Once+ // we find out which one of these three, it+ // is stored to rep0 and rep1, rep2 and rep3+ // are updated accordingly. There is no+ // "Short Rep Match" option, so the length+ // of the match must always be decoded next.+ rc_if_0(coder->is_rep1[state]) {+ // The distance is rep1.+ rc_update_0(coder->is_rep1[state]);++ const uint32_t distance = rep1;+ rep1 = rep0;+ rep0 = distance;++ } else {+ rc_update_1(coder->is_rep1[state]);++ rc_if_0(coder->is_rep2[state]) {+ // The distance is rep2.+ rc_update_0(coder->is_rep2[+ state]);++ const uint32_t distance = rep2;+ rep2 = rep1;+ rep1 = rep0;+ rep0 = distance;++ } else {+ // The distance is rep3.+ rc_update_1(coder->is_rep2[+ state]);++ const uint32_t distance = rep3;+ rep3 = rep2;+ rep2 = rep1;+ rep1 = rep0;+ rep0 = distance;+ }+ }+ }++ update_long_rep(state);++ // Decode the length of the repeated match.+ len_decode_fast(len, coder->rep_len_decoder,+ pos_state);+ }++ /////////////////////////////////+ // Repeat from history buffer. //+ /////////////////////////////////++ // The length is always between these limits. There is no way+ // to trigger the algorithm to set len outside this range.+ assert(len >= MATCH_LEN_MIN);+ assert(len <= MATCH_LEN_MAX);++ // Repeat len bytes from distance of rep0.+ if (unlikely(dict_repeat(&dict, rep0, &len))) {+ coder->sequence = SEQ_COPY;+ goto out;+ }++ continue;++slow:+#endif+ ///////////////////////////+ // Resumable Mode (slow) //+ ///////////////////////////++ // This is very similar to Non-resumable Mode, so most of the+ // comments are not repeated. The main differences are:+ // - case labels are used to resume at the correct location.+ // - Loops are not unrolled.+ // - Range coder macros take an extra sequence argument+ // so they can save to coder->sequence the location to+ // resume in case there is not enough input.+ case SEQ_NORMALIZE:+ case SEQ_IS_MATCH:+ if (unlikely(might_finish_without_eopm+ && dict.pos == dict.limit)) {+ // In rare cases there is a useless byte that needs+ // to be read anyway.+ rc_normalize_safe(SEQ_NORMALIZE);++ // If the range decoder state is such that we can+ // be at the end of the LZMA stream, then the+ // decoding is finished.+ if (rc_is_finished(rc)) {+ ret = LZMA_STREAM_END;+ goto out;+ }++ // If the caller hasn't allowed EOPM to be present+ // together with known uncompressed size, then the+ // LZMA stream is corrupt.+ if (!coder->allow_eopm) {+ ret = LZMA_DATA_ERROR;+ goto out;+ }++ // Otherwise continue decoding with the expectation+ // that the next LZMA symbol is EOPM.+ eopm_is_valid = true;+ }++ rc_if_0_safe(coder->is_match[state][pos_state], SEQ_IS_MATCH) {+ /////////////////////+ // Decode literal. //+ /////////////////////++ rc_update_0(coder->is_match[state][pos_state]);++ probs = literal_subcoder(coder->literal,+ literal_context_bits, literal_mask,+ dict.pos, dict_get0(&dict));+ symbol = 1;++ if (is_literal_state(state)) {+ update_literal_normal(state);++ // Decode literal without match byte.+ // The "slow" version does not unroll+ // the loop.+ case SEQ_LITERAL:+ do {+ rc_bit_safe(probs[symbol], , ,+ SEQ_LITERAL);+ } while (symbol < (1 << 8));+ } else {+ update_literal_matched(state);++ // Decode literal with match byte.+ len = (uint32_t)(dict_get(&dict, rep0)) << 1;++ offset = 0x100;++ case SEQ_LITERAL_MATCHED:+ do {+ const uint32_t match_bit+ = len & offset;+ const uint32_t subcoder_index+ = offset + match_bit+ + symbol;++ rc_bit_safe(probs[subcoder_index],+ offset &= ~match_bit,+ offset &= match_bit,+ SEQ_LITERAL_MATCHED);++ // It seems to be faster to do this+ // here instead of putting it to the+ // beginning of the loop and then+ // putting the "case" in the middle+ // of the loop.+ len <<= 1;++ } while (symbol < (1 << 8));+ }++ case SEQ_LITERAL_WRITE:+ if (dict_put_safe(&dict, symbol)) {+ coder->sequence = SEQ_LITERAL_WRITE;+ goto out;+ }++ continue;+ }++ ///////////////////+ // Decode match. //+ ///////////////////++ rc_update_1(coder->is_match[state][pos_state]);++ case SEQ_IS_REP:+ rc_if_0_safe(coder->is_rep[state], SEQ_IS_REP) {+ ///////////////////+ // Simple match. //+ ///////////////////++ rc_update_0(coder->is_rep[state]);+ update_match(state);++ rep3 = rep2;+ rep2 = rep1;+ rep1 = rep0;++ len_decode(len, coder->match_len_decoder,+ pos_state, SEQ_MATCH_LEN);++ probs = coder->dist_slot[get_dist_state(len)];+ symbol = 1;++ case SEQ_DIST_SLOT:+ do {+ rc_bit_safe(probs[symbol], , , SEQ_DIST_SLOT);+ } while (symbol < DIST_SLOTS);++ symbol -= DIST_SLOTS;+ assert(symbol <= 63);++ if (symbol < DIST_MODEL_START) {+ rep0 = symbol;+ } else {+ limit = (symbol >> 1) - 1;+ assert(limit >= 1 && limit <= 30);+ rep0 = 2 + (symbol & 1);++ if (symbol < DIST_MODEL_END) {+ assert(limit <= 5);+ rep0 <<= limit;+ assert(rep0 <= 96);+ // -1 is fine, because we start+ // decoding at probs[1], not probs[0].+ // NOTE: This violates the C standard,+ // since we are doing pointer+ // arithmetic past the beginning of+ // the array.+ assert((int32_t)(rep0 - symbol - 1)+ >= -1);+ assert((int32_t)(rep0 - symbol - 1)+ <= 82);+ probs = coder->pos_special + rep0+ - symbol - 1;+ symbol = 1;+ offset = 0;+ case SEQ_DIST_MODEL:+ do {+ rc_bit_safe(probs[symbol], ,+ rep0 += 1U << offset,+ SEQ_DIST_MODEL);+ } while (++offset < limit);+ } else {+ assert(symbol >= 14);+ assert(limit >= 6);+ limit -= ALIGN_BITS;+ assert(limit >= 2);+ case SEQ_DIRECT:+ rc_direct_safe(rep0, limit,+ SEQ_DIRECT);++ rep0 <<= ALIGN_BITS;+ symbol = 0;+ offset = 1;+ case SEQ_ALIGN:+ do {+ rc_bit_last_safe(+ coder->pos_align[+ offset+ + symbol],+ ,+ symbol += offset,+ SEQ_ALIGN);+ offset <<= 1;+ } while (offset < ALIGN_SIZE);++ rep0 += symbol;++ if (rep0 == UINT32_MAX) {+ // End of payload marker was+ // found. It may only be+ // present if+ // - uncompressed size is+ // unknown or+ // - after known uncompressed+ // size amount of bytes has+ // been decompressed and+ // caller has indicated+ // that EOPM might be used+ // (it's not allowed in+ // LZMA2).+#ifndef HAVE_SMALL+eopm:+#endif+ if (!eopm_is_valid) {+ ret = LZMA_DATA_ERROR;+ goto out;+ }++ case SEQ_EOPM:+ // LZMA1 stream with+ // end-of-payload marker.+ rc_normalize_safe(SEQ_EOPM);+ ret = rc_is_finished(rc)+ ? LZMA_STREAM_END+ : LZMA_DATA_ERROR;+ goto out;+ }+ }+ }++ if (unlikely(!dict_is_distance_valid(&dict, rep0))) {+ ret = LZMA_DATA_ERROR;+ goto out;+ }++ } else {+ /////////////////////+ // Repeated match. //+ /////////////////////++ rc_update_1(coder->is_rep[state]);++ if (unlikely(!dict_is_distance_valid(&dict, 0))) {+ ret = LZMA_DATA_ERROR;+ goto out;+ }++ case SEQ_IS_REP0:+ rc_if_0_safe(coder->is_rep0[state], SEQ_IS_REP0) {+ rc_update_0(coder->is_rep0[state]);++ case SEQ_IS_REP0_LONG:+ rc_if_0_safe(coder->is_rep0_long+ [state][pos_state],+ SEQ_IS_REP0_LONG) {+ rc_update_0(coder->is_rep0_long[+ state][pos_state]);++ update_short_rep(state);++ case SEQ_SHORTREP:+ if (dict_put_safe(&dict,+ dict_get(&dict,+ rep0))) {+ coder->sequence = SEQ_SHORTREP;+ goto out;+ }++ continue;+ }++ rc_update_1(coder->is_rep0_long[+ state][pos_state]);++ } else {+ rc_update_1(coder->is_rep0[state]);++ case SEQ_IS_REP1:+ rc_if_0_safe(coder->is_rep1[state], SEQ_IS_REP1) {+ rc_update_0(coder->is_rep1[state]);++ const uint32_t distance = rep1;+ rep1 = rep0;+ rep0 = distance;++ } else {+ rc_update_1(coder->is_rep1[state]);+ case SEQ_IS_REP2:+ rc_if_0_safe(coder->is_rep2[state],+ SEQ_IS_REP2) {+ rc_update_0(coder->is_rep2[+ state]);++ const uint32_t distance = rep2;+ rep2 = rep1;+ rep1 = rep0;+ rep0 = distance;++ } else {+ rc_update_1(coder->is_rep2[+ state]);++ const uint32_t distance = rep3;+ rep3 = rep2;+ rep2 = rep1;+ rep1 = rep0;+ rep0 = distance;+ }+ }+ }++ update_long_rep(state);++ len_decode(len, coder->rep_len_decoder,+ pos_state, SEQ_REP_LEN);+ }++ /////////////////////////////////+ // Repeat from history buffer. //+ /////////////////////////////////++ assert(len >= MATCH_LEN_MIN);+ assert(len <= MATCH_LEN_MAX);++ case SEQ_COPY:+ if (unlikely(dict_repeat(&dict, rep0, &len))) {+ coder->sequence = SEQ_COPY;+ goto out;+ }+ }++out:+ // Save state++ // NOTE: Must not copy dict.limit.+ dictptr->pos = dict.pos;+ dictptr->full = dict.full;++ rc_from_local(coder->rc, *in_pos);++ coder->state = state;+ coder->rep0 = rep0;+ coder->rep1 = rep1;+ coder->rep2 = rep2;+ coder->rep3 = rep3;++ coder->probs = probs;+ coder->symbol = symbol;+ coder->limit = limit;+ coder->offset = offset;+ coder->len = len;++ // Update the remaining amount of uncompressed data if uncompressed+ // size was known.+ if (coder->uncompressed_size != LZMA_VLI_UNKNOWN) {+ coder->uncompressed_size -= dict.pos - dict_start;++ // If we have gotten all the output but the decoder wants+ // to write more output, the file is corrupt. There are+ // three SEQ values where output is produced.+ if (coder->uncompressed_size == 0 && ret == LZMA_OK+ && (coder->sequence == SEQ_LITERAL_WRITE+ || coder->sequence == SEQ_SHORTREP+ || coder->sequence == SEQ_COPY))+ ret = LZMA_DATA_ERROR;+ }++ if (ret == LZMA_STREAM_END) {+ // Reset the range decoder so that it is ready to reinitialize+ // for a new LZMA2 chunk.+ rc_reset(coder->rc);+ coder->sequence = SEQ_IS_MATCH;+ }++ return ret;+}+++static void+lzma_decoder_uncompressed(void *coder_ptr, lzma_vli uncompressed_size,+ bool allow_eopm)+{+ lzma_lzma1_decoder *coder = coder_ptr;+ coder->uncompressed_size = uncompressed_size;+ coder->allow_eopm = allow_eopm;+}+++static void+lzma_decoder_reset(void *coder_ptr, const void *opt)+{+ lzma_lzma1_decoder *coder = coder_ptr;+ const lzma_options_lzma *options = opt;++ // NOTE: We assume that lc/lp/pb are valid since they were+ // successfully decoded with lzma_lzma_decode_properties().++ // Calculate pos_mask. We don't need pos_bits as is for anything.+ coder->pos_mask = (1U << options->pb) - 1;++ // Initialize the literal decoder.+ literal_init(coder->literal, options->lc, options->lp);++ coder->literal_context_bits = options->lc;+ coder->literal_mask = literal_mask_calc(options->lc, options->lp);++ // State+ coder->state = STATE_LIT_LIT;+ coder->rep0 = 0;+ coder->rep1 = 0;+ coder->rep2 = 0;+ coder->rep3 = 0;+ coder->pos_mask = (1U << options->pb) - 1;++ // Range decoder+ rc_reset(coder->rc);++ // Bit and bittree decoders+ for (uint32_t i = 0; i < STATES; ++i) {+ for (uint32_t j = 0; j <= coder->pos_mask; ++j) {+ bit_reset(coder->is_match[i][j]);+ bit_reset(coder->is_rep0_long[i][j]);+ }++ bit_reset(coder->is_rep[i]);+ bit_reset(coder->is_rep0[i]);+ bit_reset(coder->is_rep1[i]);+ bit_reset(coder->is_rep2[i]);+ }++ for (uint32_t i = 0; i < DIST_STATES; ++i)+ bittree_reset(coder->dist_slot[i], DIST_SLOT_BITS);++ for (uint32_t i = 0; i < FULL_DISTANCES - DIST_MODEL_END; ++i)+ bit_reset(coder->pos_special[i]);++ bittree_reset(coder->pos_align, ALIGN_BITS);++ // Len decoders (also bit/bittree)+ const uint32_t num_pos_states = 1U << options->pb;+ bit_reset(coder->match_len_decoder.choice);+ bit_reset(coder->match_len_decoder.choice2);+ bit_reset(coder->rep_len_decoder.choice);+ bit_reset(coder->rep_len_decoder.choice2);++ for (uint32_t pos_state = 0; pos_state < num_pos_states; ++pos_state) {+ bittree_reset(coder->match_len_decoder.low[pos_state],+ LEN_LOW_BITS);+ bittree_reset(coder->match_len_decoder.mid[pos_state],+ LEN_MID_BITS);++ bittree_reset(coder->rep_len_decoder.low[pos_state],+ LEN_LOW_BITS);+ bittree_reset(coder->rep_len_decoder.mid[pos_state],+ LEN_MID_BITS);+ }++ bittree_reset(coder->match_len_decoder.high, LEN_HIGH_BITS);+ bittree_reset(coder->rep_len_decoder.high, LEN_HIGH_BITS);++ coder->sequence = SEQ_IS_MATCH;+ coder->probs = NULL;+ coder->symbol = 0;+ coder->limit = 0;+ coder->offset = 0;+ coder->len = 0;++ return;+}+++extern lzma_ret+lzma_lzma_decoder_create(lzma_lz_decoder *lz, const lzma_allocator *allocator,+ const lzma_options_lzma *options, lzma_lz_options *lz_options)+{+ if (lz->coder == NULL) {+ lz->coder = lzma_alloc(sizeof(lzma_lzma1_decoder), allocator);+ if (lz->coder == NULL)+ return LZMA_MEM_ERROR;++ lz->code = &lzma_decode;+ lz->reset = &lzma_decoder_reset;+ lz->set_uncompressed = &lzma_decoder_uncompressed;+ }++ // All dictionary sizes are OK here. LZ decoder will take care of+ // the special cases.+ lz_options->dict_size = options->dict_size;+ lz_options->preset_dict = options->preset_dict;+ lz_options->preset_dict_size = options->preset_dict_size;++ return LZMA_OK;+}+++/// Allocate and initialize LZMA decoder. This is used only via LZ+/// initialization (lzma_lzma_decoder_init() passes function pointer to+/// the LZ initialization).+static lzma_ret+lzma_decoder_init(lzma_lz_decoder *lz, const lzma_allocator *allocator,+ lzma_vli id, const void *options, lzma_lz_options *lz_options)+{+ if (!is_lclppb_valid(options))+ return LZMA_PROG_ERROR;++ lzma_vli uncomp_size = LZMA_VLI_UNKNOWN;+ bool allow_eopm = true;++ if (id == LZMA_FILTER_LZMA1EXT) {+ const lzma_options_lzma *opt = options;++ // Only one flag is supported.+ if (opt->ext_flags & ~LZMA_LZMA1EXT_ALLOW_EOPM)+ return LZMA_OPTIONS_ERROR;++ // FIXME? Using lzma_vli instead of uint64_t is weird because+ // this has nothing to do with .xz headers and variable-length+ // integer encoding. On the other hand, using LZMA_VLI_UNKNOWN+ // instead of UINT64_MAX is clearer when unknown size is+ // meant. A problem with using lzma_vli is that now we+ // allow > LZMA_VLI_MAX which is fine in this file but+ // it's still confusing. Note that alone_decoder.c also+ // allows > LZMA_VLI_MAX when setting uncompressed size.+ uncomp_size = opt->ext_size_low+ + ((uint64_t)(opt->ext_size_high) << 32);+ allow_eopm = (opt->ext_flags & LZMA_LZMA1EXT_ALLOW_EOPM) != 0+ || uncomp_size == LZMA_VLI_UNKNOWN;+ }++ return_if_error(lzma_lzma_decoder_create(+ lz, allocator, options, lz_options));++ lzma_decoder_reset(lz->coder, options);+ lzma_decoder_uncompressed(lz->coder, uncomp_size, allow_eopm);++ return LZMA_OK;+}+++extern lzma_ret+lzma_lzma_decoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ // LZMA can only be the last filter in the chain. This is enforced+ // by the raw_decoder initialization.+ assert(filters[1].init == NULL);++ return lzma_lz_decoder_init(next, allocator, filters,+ &lzma_decoder_init);+}+++extern bool+lzma_lzma_lclppb_decode(lzma_options_lzma *options, uint8_t byte)+{+ if (byte > (4 * 5 + 4) * 9 + 8)+ return true;++ // See the file format specification to understand this.+ options->pb = byte / (9 * 5);+ byte -= options->pb * 9 * 5;+ options->lp = byte / 9;+ options->lc = byte - options->lp * 9;++ return options->lc + options->lp > LZMA_LCLP_MAX;+}+++extern uint64_t+lzma_lzma_decoder_memusage_nocheck(const void *options)+{+ const lzma_options_lzma *const opt = options;+ return sizeof(lzma_lzma1_decoder)+ + lzma_lz_decoder_memusage(opt->dict_size);+}+++extern uint64_t+lzma_lzma_decoder_memusage(const void *options)+{+ if (!is_lclppb_valid(options))+ return UINT64_MAX;++ return lzma_lzma_decoder_memusage_nocheck(options);+}+++extern lzma_ret+lzma_lzma_props_decode(void **options, const lzma_allocator *allocator,+ const uint8_t *props, size_t props_size)+{+ if (props_size != 5)+ return LZMA_OPTIONS_ERROR;++ lzma_options_lzma *opt+ = lzma_alloc(sizeof(lzma_options_lzma), allocator);+ if (opt == NULL)+ return LZMA_MEM_ERROR;++ if (lzma_lzma_lclppb_decode(opt, props[0]))+ goto error;++ // All dictionary sizes are accepted, including zero. LZ decoder+ // will automatically use a dictionary at least a few KiB even if+ // a smaller dictionary is requested.+ opt->dict_size = read32le(props + 1);++ opt->preset_dict = NULL;+ opt->preset_dict_size = 0;++ *options = opt;++ return LZMA_OK;++error:+ lzma_free(opt, allocator);+ return LZMA_OPTIONS_ERROR;+}
+ cbits/liblzma/lzma/lzma_decoder.h view
@@ -0,0 +1,52 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzma_decoder.h+/// \brief LZMA decoder API+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_LZMA_DECODER_H+#define LZMA_LZMA_DECODER_H++#include "common.h"+++/// Allocates and initializes LZMA decoder+extern lzma_ret lzma_lzma_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++extern uint64_t lzma_lzma_decoder_memusage(const void *options);++extern lzma_ret lzma_lzma_props_decode(+ void **options, const lzma_allocator *allocator,+ const uint8_t *props, size_t props_size);+++/// \brief Decodes the LZMA Properties byte (lc/lp/pb)+///+/// \return true if error occurred, false on success+///+extern bool lzma_lzma_lclppb_decode(+ lzma_options_lzma *options, uint8_t byte);+++#ifdef LZMA_LZ_DECODER_H+/// Allocate and setup function pointers only. This is used by LZMA1 and+/// LZMA2 decoders.+extern lzma_ret lzma_lzma_decoder_create(+ lzma_lz_decoder *lz, const lzma_allocator *allocator,+ const lzma_options_lzma *opt, lzma_lz_options *lz_options);++/// Gets memory usage without validating lc/lp/pb. This is used by LZMA2+/// decoder, because raw LZMA2 decoding doesn't need lc/lp/pb.+extern uint64_t lzma_lzma_decoder_memusage_nocheck(const void *options);++#endif++#endif
+ cbits/liblzma/lzma/lzma_encoder.c view
@@ -0,0 +1,786 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzma_encoder.c+/// \brief LZMA encoder+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "lzma2_encoder.h"+#include "lzma_encoder_private.h"+#include "fastpos.h"+++/////////////+// Literal //+/////////////++static inline void+literal_matched(lzma_range_encoder *rc, probability *subcoder,+ uint32_t match_byte, uint32_t symbol)+{+ uint32_t offset = 0x100;+ symbol += UINT32_C(1) << 8;++ do {+ match_byte <<= 1;+ const uint32_t match_bit = match_byte & offset;+ const uint32_t subcoder_index+ = offset + match_bit + (symbol >> 8);+ const uint32_t bit = (symbol >> 7) & 1;+ rc_bit(rc, &subcoder[subcoder_index], bit);++ symbol <<= 1;+ offset &= ~(match_byte ^ symbol);++ } while (symbol < (UINT32_C(1) << 16));+}+++static inline void+literal(lzma_lzma1_encoder *coder, lzma_mf *mf, uint32_t position)+{+ // Locate the literal byte to be encoded and the subcoder.+ const uint8_t cur_byte = mf->buffer[+ mf->read_pos - mf->read_ahead];+ probability *subcoder = literal_subcoder(coder->literal,+ coder->literal_context_bits, coder->literal_mask,+ position, mf->buffer[mf->read_pos - mf->read_ahead - 1]);++ if (is_literal_state(coder->state)) {+ // Previous LZMA-symbol was a literal. Encode a normal+ // literal without a match byte.+ update_literal_normal(coder->state);+ rc_bittree(&coder->rc, subcoder, 8, cur_byte);+ } else {+ // Previous LZMA-symbol was a match. Use the last byte of+ // the match as a "match byte". That is, compare the bits+ // of the current literal and the match byte.+ update_literal_matched(coder->state);+ const uint8_t match_byte = mf->buffer[+ mf->read_pos - coder->reps[0] - 1+ - mf->read_ahead];+ literal_matched(&coder->rc, subcoder, match_byte, cur_byte);+ }+}+++//////////////////+// Match length //+//////////////////++static void+length_update_prices(lzma_length_encoder *lc, const uint32_t pos_state)+{+ const uint32_t table_size = lc->table_size;+ lc->counters[pos_state] = table_size;++ const uint32_t a0 = rc_bit_0_price(lc->choice);+ const uint32_t a1 = rc_bit_1_price(lc->choice);+ const uint32_t b0 = a1 + rc_bit_0_price(lc->choice2);+ const uint32_t b1 = a1 + rc_bit_1_price(lc->choice2);+ uint32_t *const prices = lc->prices[pos_state];++ uint32_t i;+ for (i = 0; i < table_size && i < LEN_LOW_SYMBOLS; ++i)+ prices[i] = a0 + rc_bittree_price(lc->low[pos_state],+ LEN_LOW_BITS, i);++ for (; i < table_size && i < LEN_LOW_SYMBOLS + LEN_MID_SYMBOLS; ++i)+ prices[i] = b0 + rc_bittree_price(lc->mid[pos_state],+ LEN_MID_BITS, i - LEN_LOW_SYMBOLS);++ for (; i < table_size; ++i)+ prices[i] = b1 + rc_bittree_price(lc->high, LEN_HIGH_BITS,+ i - LEN_LOW_SYMBOLS - LEN_MID_SYMBOLS);++ return;+}+++static inline void+length(lzma_range_encoder *rc, lzma_length_encoder *lc,+ const uint32_t pos_state, uint32_t len, const bool fast_mode)+{+ assert(len <= MATCH_LEN_MAX);+ len -= MATCH_LEN_MIN;++ if (len < LEN_LOW_SYMBOLS) {+ rc_bit(rc, &lc->choice, 0);+ rc_bittree(rc, lc->low[pos_state], LEN_LOW_BITS, len);+ } else {+ rc_bit(rc, &lc->choice, 1);+ len -= LEN_LOW_SYMBOLS;++ if (len < LEN_MID_SYMBOLS) {+ rc_bit(rc, &lc->choice2, 0);+ rc_bittree(rc, lc->mid[pos_state], LEN_MID_BITS, len);+ } else {+ rc_bit(rc, &lc->choice2, 1);+ len -= LEN_MID_SYMBOLS;+ rc_bittree(rc, lc->high, LEN_HIGH_BITS, len);+ }+ }++ // Only getoptimum uses the prices so don't update the table when+ // in fast mode.+ if (!fast_mode)+ if (--lc->counters[pos_state] == 0)+ length_update_prices(lc, pos_state);+}+++///////////+// Match //+///////////++static inline void+match(lzma_lzma1_encoder *coder, const uint32_t pos_state,+ const uint32_t distance, const uint32_t len)+{+ update_match(coder->state);++ length(&coder->rc, &coder->match_len_encoder, pos_state, len,+ coder->fast_mode);++ const uint32_t dist_slot = get_dist_slot(distance);+ const uint32_t dist_state = get_dist_state(len);+ rc_bittree(&coder->rc, coder->dist_slot[dist_state],+ DIST_SLOT_BITS, dist_slot);++ if (dist_slot >= DIST_MODEL_START) {+ const uint32_t footer_bits = (dist_slot >> 1) - 1;+ const uint32_t base = (2 | (dist_slot & 1)) << footer_bits;+ const uint32_t dist_reduced = distance - base;++ if (dist_slot < DIST_MODEL_END) {+ // Careful here: base - dist_slot - 1 can be -1, but+ // rc_bittree_reverse starts at probs[1], not probs[0].+ rc_bittree_reverse(&coder->rc,+ coder->dist_special + base - dist_slot - 1,+ footer_bits, dist_reduced);+ } else {+ rc_direct(&coder->rc, dist_reduced >> ALIGN_BITS,+ footer_bits - ALIGN_BITS);+ rc_bittree_reverse(+ &coder->rc, coder->dist_align,+ ALIGN_BITS, dist_reduced & ALIGN_MASK);+ ++coder->align_price_count;+ }+ }++ coder->reps[3] = coder->reps[2];+ coder->reps[2] = coder->reps[1];+ coder->reps[1] = coder->reps[0];+ coder->reps[0] = distance;+ ++coder->match_price_count;+}+++////////////////////+// Repeated match //+////////////////////++static inline void+rep_match(lzma_lzma1_encoder *coder, const uint32_t pos_state,+ const uint32_t rep, const uint32_t len)+{+ if (rep == 0) {+ rc_bit(&coder->rc, &coder->is_rep0[coder->state], 0);+ rc_bit(&coder->rc,+ &coder->is_rep0_long[coder->state][pos_state],+ len != 1);+ } else {+ const uint32_t distance = coder->reps[rep];+ rc_bit(&coder->rc, &coder->is_rep0[coder->state], 1);++ if (rep == 1) {+ rc_bit(&coder->rc, &coder->is_rep1[coder->state], 0);+ } else {+ rc_bit(&coder->rc, &coder->is_rep1[coder->state], 1);+ rc_bit(&coder->rc, &coder->is_rep2[coder->state],+ rep - 2);++ if (rep == 3)+ coder->reps[3] = coder->reps[2];++ coder->reps[2] = coder->reps[1];+ }++ coder->reps[1] = coder->reps[0];+ coder->reps[0] = distance;+ }++ if (len == 1) {+ update_short_rep(coder->state);+ } else {+ length(&coder->rc, &coder->rep_len_encoder, pos_state, len,+ coder->fast_mode);+ update_long_rep(coder->state);+ }+}+++//////////+// Main //+//////////++static void+encode_symbol(lzma_lzma1_encoder *coder, lzma_mf *mf,+ uint32_t back, uint32_t len, uint32_t position)+{+ const uint32_t pos_state = position & coder->pos_mask;++ if (back == UINT32_MAX) {+ // Literal i.e. eight-bit byte+ assert(len == 1);+ rc_bit(&coder->rc,+ &coder->is_match[coder->state][pos_state], 0);+ literal(coder, mf, position);+ } else {+ // Some type of match+ rc_bit(&coder->rc,+ &coder->is_match[coder->state][pos_state], 1);++ if (back < REPS) {+ // It's a repeated match i.e. the same distance+ // has been used earlier.+ rc_bit(&coder->rc, &coder->is_rep[coder->state], 1);+ rep_match(coder, pos_state, back, len);+ } else {+ // Normal match+ rc_bit(&coder->rc, &coder->is_rep[coder->state], 0);+ match(coder, pos_state, back - REPS, len);+ }+ }++ assert(mf->read_ahead >= len);+ mf->read_ahead -= len;+}+++static bool+encode_init(lzma_lzma1_encoder *coder, lzma_mf *mf)+{+ assert(mf_position(mf) == 0);+ assert(coder->uncomp_size == 0);++ if (mf->read_pos == mf->read_limit) {+ if (mf->action == LZMA_RUN)+ return false; // We cannot do anything.++ // We are finishing (we cannot get here when flushing).+ assert(mf->write_pos == mf->read_pos);+ assert(mf->action == LZMA_FINISH);+ } else {+ // Do the actual initialization. The first LZMA symbol must+ // always be a literal.+ mf_skip(mf, 1);+ mf->read_ahead = 0;+ rc_bit(&coder->rc, &coder->is_match[0][0], 0);+ rc_bittree(&coder->rc, coder->literal + 0, 8, mf->buffer[0]);+ ++coder->uncomp_size;+ }++ // Initialization is done (except if empty file).+ coder->is_initialized = true;++ return true;+}+++static void+encode_eopm(lzma_lzma1_encoder *coder, uint32_t position)+{+ const uint32_t pos_state = position & coder->pos_mask;+ rc_bit(&coder->rc, &coder->is_match[coder->state][pos_state], 1);+ rc_bit(&coder->rc, &coder->is_rep[coder->state], 0);+ match(coder, pos_state, UINT32_MAX, MATCH_LEN_MIN);+}+++/// Number of bytes that a single encoding loop in lzma_lzma_encode() can+/// consume from the dictionary. This limit comes from lzma_lzma_optimum()+/// and may need to be updated if that function is significantly modified.+#define LOOP_INPUT_MAX (OPTS + 1)+++extern lzma_ret+lzma_lzma_encode(lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf,+ uint8_t *restrict out, size_t *restrict out_pos,+ size_t out_size, uint32_t limit)+{+ // Initialize the stream if no data has been encoded yet.+ if (!coder->is_initialized && !encode_init(coder, mf))+ return LZMA_OK;++ // Encode pending output bytes from the range encoder.+ // At the start of the stream, encode_init() encodes one literal.+ // Later there can be pending output only with LZMA1 because LZMA2+ // ensures that there is always enough output space. Thus when using+ // LZMA2, rc_encode() calls in this function will always return false.+ if (rc_encode(&coder->rc, out, out_pos, out_size)) {+ // We don't get here with LZMA2.+ assert(limit == UINT32_MAX);+ return LZMA_OK;+ }++ // If the range encoder was flushed in an earlier call to this+ // function but there wasn't enough output buffer space, those+ // bytes would have now been encoded by the above rc_encode() call+ // and the stream has now been finished. This can only happen with+ // LZMA1 as LZMA2 always provides enough output buffer space.+ if (coder->is_flushed) {+ assert(limit == UINT32_MAX);+ return LZMA_STREAM_END;+ }++ while (true) {+ // With LZMA2 we need to take care that compressed size of+ // a chunk doesn't get too big.+ // FIXME? Check if this could be improved.+ if (limit != UINT32_MAX+ && (mf->read_pos - mf->read_ahead >= limit+ || *out_pos + rc_pending(&coder->rc)+ >= LZMA2_CHUNK_MAX+ - LOOP_INPUT_MAX))+ break;++ // Check that there is some input to process.+ if (mf->read_pos >= mf->read_limit) {+ if (mf->action == LZMA_RUN)+ return LZMA_OK;++ if (mf->read_ahead == 0)+ break;+ }++ // Get optimal match (repeat position and length).+ // Value ranges for pos:+ // - [0, REPS): repeated match+ // - [REPS, UINT32_MAX):+ // match at (pos - REPS)+ // - UINT32_MAX: not a match but a literal+ // Value ranges for len:+ // - [MATCH_LEN_MIN, MATCH_LEN_MAX]+ uint32_t len;+ uint32_t back;++ if (coder->fast_mode)+ lzma_lzma_optimum_fast(coder, mf, &back, &len);+ else+ lzma_lzma_optimum_normal(coder, mf, &back, &len,+ (uint32_t)(coder->uncomp_size));++ encode_symbol(coder, mf, back, len,+ (uint32_t)(coder->uncomp_size));++ // If output size limiting is active (out_limit != 0), check+ // if encoding this LZMA symbol would make the output size+ // exceed the specified limit.+ if (coder->out_limit != 0 && rc_encode_dummy(+ &coder->rc, coder->out_limit)) {+ // The most recent LZMA symbol would make the output+ // too big. Throw it away.+ rc_forget(&coder->rc);++ // FIXME: Tell the LZ layer to not read more input as+ // it would be waste of time. This doesn't matter if+ // output-size-limited encoding is done with a single+ // call though.++ break;+ }++ // This symbol will be encoded so update the uncompressed size.+ coder->uncomp_size += len;++ // Encode the LZMA symbol.+ if (rc_encode(&coder->rc, out, out_pos, out_size)) {+ // Once again, this can only happen with LZMA1.+ assert(limit == UINT32_MAX);+ return LZMA_OK;+ }+ }++ // Make the uncompressed size available to the application.+ if (coder->uncomp_size_ptr != NULL)+ *coder->uncomp_size_ptr = coder->uncomp_size;++ // LZMA2 doesn't use EOPM at LZMA level.+ //+ // Plain LZMA streams without EOPM aren't supported except when+ // output size limiting is enabled.+ if (coder->use_eopm)+ encode_eopm(coder, (uint32_t)(coder->uncomp_size));++ // Flush the remaining bytes from the range encoder.+ rc_flush(&coder->rc);++ // Copy the remaining bytes to the output buffer. If there+ // isn't enough output space, we will copy out the remaining+ // bytes on the next call to this function.+ if (rc_encode(&coder->rc, out, out_pos, out_size)) {+ // This cannot happen with LZMA2.+ assert(limit == UINT32_MAX);++ coder->is_flushed = true;+ return LZMA_OK;+ }++ return LZMA_STREAM_END;+}+++static lzma_ret+lzma_encode(void *coder, lzma_mf *restrict mf,+ uint8_t *restrict out, size_t *restrict out_pos,+ size_t out_size)+{+ // Plain LZMA has no support for sync-flushing.+ if (unlikely(mf->action == LZMA_SYNC_FLUSH))+ return LZMA_OPTIONS_ERROR;++ return lzma_lzma_encode(coder, mf, out, out_pos, out_size, UINT32_MAX);+}+++static lzma_ret+lzma_lzma_set_out_limit(+ void *coder_ptr, uint64_t *uncomp_size, uint64_t out_limit)+{+ // Minimum output size is 5 bytes but that cannot hold any output+ // so we use 6 bytes.+ if (out_limit < 6)+ return LZMA_BUF_ERROR;++ lzma_lzma1_encoder *coder = coder_ptr;+ coder->out_limit = out_limit;+ coder->uncomp_size_ptr = uncomp_size;+ coder->use_eopm = false;+ return LZMA_OK;+}+++////////////////////+// Initialization //+////////////////////++static bool+is_options_valid(const lzma_options_lzma *options)+{+ // Validate some of the options. LZ encoder validates nice_len too+ // but we need a valid value here earlier.+ return is_lclppb_valid(options)+ && options->nice_len >= MATCH_LEN_MIN+ && options->nice_len <= MATCH_LEN_MAX+ && (options->mode == LZMA_MODE_FAST+ || options->mode == LZMA_MODE_NORMAL);+}+++static void+set_lz_options(lzma_lz_options *lz_options, const lzma_options_lzma *options)+{+ // LZ encoder initialization does the validation for these so we+ // don't need to validate here.+ lz_options->before_size = OPTS;+ lz_options->dict_size = options->dict_size;+ lz_options->after_size = LOOP_INPUT_MAX;+ lz_options->match_len_max = MATCH_LEN_MAX;+ lz_options->nice_len = my_max(mf_get_hash_bytes(options->mf),+ options->nice_len);+ lz_options->match_finder = options->mf;+ lz_options->depth = options->depth;+ lz_options->preset_dict = options->preset_dict;+ lz_options->preset_dict_size = options->preset_dict_size;+ return;+}+++static void+length_encoder_reset(lzma_length_encoder *lencoder,+ const uint32_t num_pos_states, const bool fast_mode)+{+ bit_reset(lencoder->choice);+ bit_reset(lencoder->choice2);++ for (size_t pos_state = 0; pos_state < num_pos_states; ++pos_state) {+ bittree_reset(lencoder->low[pos_state], LEN_LOW_BITS);+ bittree_reset(lencoder->mid[pos_state], LEN_MID_BITS);+ }++ bittree_reset(lencoder->high, LEN_HIGH_BITS);++ if (!fast_mode)+ for (uint32_t pos_state = 0; pos_state < num_pos_states;+ ++pos_state)+ length_update_prices(lencoder, pos_state);++ return;+}+++extern lzma_ret+lzma_lzma_encoder_reset(lzma_lzma1_encoder *coder,+ const lzma_options_lzma *options)+{+ if (!is_options_valid(options))+ return LZMA_OPTIONS_ERROR;++ coder->pos_mask = (1U << options->pb) - 1;+ coder->literal_context_bits = options->lc;+ coder->literal_mask = literal_mask_calc(options->lc, options->lp);++ // Range coder+ rc_reset(&coder->rc);++ // State+ coder->state = STATE_LIT_LIT;+ for (size_t i = 0; i < REPS; ++i)+ coder->reps[i] = 0;++ literal_init(coder->literal, options->lc, options->lp);++ // Bit encoders+ for (size_t i = 0; i < STATES; ++i) {+ for (size_t j = 0; j <= coder->pos_mask; ++j) {+ bit_reset(coder->is_match[i][j]);+ bit_reset(coder->is_rep0_long[i][j]);+ }++ bit_reset(coder->is_rep[i]);+ bit_reset(coder->is_rep0[i]);+ bit_reset(coder->is_rep1[i]);+ bit_reset(coder->is_rep2[i]);+ }++ for (size_t i = 0; i < FULL_DISTANCES - DIST_MODEL_END; ++i)+ bit_reset(coder->dist_special[i]);++ // Bit tree encoders+ for (size_t i = 0; i < DIST_STATES; ++i)+ bittree_reset(coder->dist_slot[i], DIST_SLOT_BITS);++ bittree_reset(coder->dist_align, ALIGN_BITS);++ // Length encoders+ length_encoder_reset(&coder->match_len_encoder,+ 1U << options->pb, coder->fast_mode);++ length_encoder_reset(&coder->rep_len_encoder,+ 1U << options->pb, coder->fast_mode);++ // Price counts are incremented every time appropriate probabilities+ // are changed. price counts are set to zero when the price tables+ // are updated, which is done when the appropriate price counts have+ // big enough value, and lzma_mf.read_ahead == 0 which happens at+ // least every OPTS (a few thousand) possible price count increments.+ //+ // By resetting price counts to UINT32_MAX / 2, we make sure that the+ // price tables will be initialized before they will be used (since+ // the value is definitely big enough), and that it is OK to increment+ // price counts without risk of integer overflow (since UINT32_MAX / 2+ // is small enough). The current code doesn't increment price counts+ // before initializing price tables, but it maybe done in future if+ // we add support for saving the state between LZMA2 chunks.+ coder->match_price_count = UINT32_MAX / 2;+ coder->align_price_count = UINT32_MAX / 2;++ coder->opts_end_index = 0;+ coder->opts_current_index = 0;++ return LZMA_OK;+}+++extern lzma_ret+lzma_lzma_encoder_create(void **coder_ptr, const lzma_allocator *allocator,+ lzma_vli id, const lzma_options_lzma *options,+ lzma_lz_options *lz_options)+{+ assert(id == LZMA_FILTER_LZMA1 || id == LZMA_FILTER_LZMA1EXT+ || id == LZMA_FILTER_LZMA2);++ // Allocate lzma_lzma1_encoder if it wasn't already allocated.+ if (*coder_ptr == NULL) {+ *coder_ptr = lzma_alloc(sizeof(lzma_lzma1_encoder), allocator);+ if (*coder_ptr == NULL)+ return LZMA_MEM_ERROR;+ }++ lzma_lzma1_encoder *coder = *coder_ptr;++ // Set compression mode. Note that we haven't validated the options+ // yet. Invalid options will get rejected by lzma_lzma_encoder_reset()+ // call at the end of this function.+ switch (options->mode) {+ case LZMA_MODE_FAST:+ coder->fast_mode = true;+ break;++ case LZMA_MODE_NORMAL: {+ coder->fast_mode = false;++ // Set dist_table_size.+ // Round the dictionary size up to next 2^n.+ //+ // Currently the maximum encoder dictionary size+ // is 1.5 GiB due to lz_encoder.c and here we need+ // to be below 2 GiB to make the rounded up value+ // fit in an uint32_t and avoid an infinite while-loop+ // (and undefined behavior due to a too large shift).+ // So do the same check as in LZ encoder,+ // limiting to 1.5 GiB.+ if (options->dict_size > (UINT32_C(1) << 30)+ + (UINT32_C(1) << 29))+ return LZMA_OPTIONS_ERROR;++ uint32_t log_size = 0;+ while ((UINT32_C(1) << log_size) < options->dict_size)+ ++log_size;++ coder->dist_table_size = log_size * 2;++ // Length encoders' price table size+ const uint32_t nice_len = my_max(+ mf_get_hash_bytes(options->mf),+ options->nice_len);++ coder->match_len_encoder.table_size+ = nice_len + 1 - MATCH_LEN_MIN;+ coder->rep_len_encoder.table_size+ = nice_len + 1 - MATCH_LEN_MIN;+ break;+ }++ default:+ return LZMA_OPTIONS_ERROR;+ }++ // We don't need to write the first byte as literal if there is+ // a non-empty preset dictionary. encode_init() wouldn't even work+ // if there is a non-empty preset dictionary, because encode_init()+ // assumes that position is zero and previous byte is also zero.+ coder->is_initialized = options->preset_dict != NULL+ && options->preset_dict_size > 0;+ coder->is_flushed = false;+ coder->uncomp_size = 0;+ coder->uncomp_size_ptr = NULL;++ // Output size limiting is disabled by default.+ coder->out_limit = 0;++ // Determine if end marker is wanted:+ // - It is never used with LZMA2.+ // - It is always used with LZMA_FILTER_LZMA1 (unless+ // lzma_lzma_set_out_limit() is called later).+ // - LZMA_FILTER_LZMA1EXT has a flag for it in the options.+ coder->use_eopm = (id == LZMA_FILTER_LZMA1);+ if (id == LZMA_FILTER_LZMA1EXT) {+ // Check if unsupported flags are present.+ if (options->ext_flags & ~LZMA_LZMA1EXT_ALLOW_EOPM)+ return LZMA_OPTIONS_ERROR;++ coder->use_eopm = (options->ext_flags+ & LZMA_LZMA1EXT_ALLOW_EOPM) != 0;++ // TODO? As long as there are no filters that change the size+ // of the data, it is enough to look at lzma_stream.total_in+ // after encoding has been finished to know the uncompressed+ // size of the LZMA1 stream. But in the future there could be+ // filters that change the size of the data and then total_in+ // doesn't work as the LZMA1 stream size might be different+ // due to another filter in the chain. The problem is simple+ // to solve: Add another flag to ext_flags and then set+ // coder->uncomp_size_ptr to the address stored in+ // lzma_options_lzma.reserved_ptr2 (or _ptr1).+ }++ set_lz_options(lz_options, options);++ return lzma_lzma_encoder_reset(coder, options);+}+++static lzma_ret+lzma_encoder_init(lzma_lz_encoder *lz, const lzma_allocator *allocator,+ lzma_vli id, const void *options, lzma_lz_options *lz_options)+{+ if (options == NULL)+ return LZMA_PROG_ERROR;++ lz->code = &lzma_encode;+ lz->set_out_limit = &lzma_lzma_set_out_limit;+ return lzma_lzma_encoder_create(+ &lz->coder, allocator, id, options, lz_options);+}+++extern lzma_ret+lzma_lzma_encoder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return lzma_lz_encoder_init(+ next, allocator, filters, &lzma_encoder_init);+}+++extern uint64_t+lzma_lzma_encoder_memusage(const void *options)+{+ if (!is_options_valid(options))+ return UINT64_MAX;++ lzma_lz_options lz_options;+ set_lz_options(&lz_options, options);++ const uint64_t lz_memusage = lzma_lz_encoder_memusage(&lz_options);+ if (lz_memusage == UINT64_MAX)+ return UINT64_MAX;++ return (uint64_t)(sizeof(lzma_lzma1_encoder)) + lz_memusage;+}+++extern bool+lzma_lzma_lclppb_encode(const lzma_options_lzma *options, uint8_t *byte)+{+ if (!is_lclppb_valid(options))+ return true;++ *byte = (options->pb * 5 + options->lp) * 9 + options->lc;+ assert(*byte <= (4 * 5 + 4) * 9 + 8);++ return false;+}+++#ifdef HAVE_ENCODER_LZMA1+extern lzma_ret+lzma_lzma_props_encode(const void *options, uint8_t *out)+{+ if (options == NULL)+ return LZMA_PROG_ERROR;++ const lzma_options_lzma *const opt = options;++ if (lzma_lzma_lclppb_encode(opt, out))+ return LZMA_PROG_ERROR;++ write32le(out + 1, opt->dict_size);++ return LZMA_OK;+}+#endif+++extern LZMA_API(lzma_bool)+lzma_mode_is_supported(lzma_mode mode)+{+ return mode == LZMA_MODE_FAST || mode == LZMA_MODE_NORMAL;+}
+ cbits/liblzma/lzma/lzma_encoder.h view
@@ -0,0 +1,58 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzma_encoder.h+/// \brief LZMA encoder API+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_LZMA_ENCODER_H+#define LZMA_LZMA_ENCODER_H++#include "common.h"+++typedef struct lzma_lzma1_encoder_s lzma_lzma1_encoder;+++extern lzma_ret lzma_lzma_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);+++extern uint64_t lzma_lzma_encoder_memusage(const void *options);++extern lzma_ret lzma_lzma_props_encode(const void *options, uint8_t *out);+++/// Encodes lc/lp/pb into one byte. Returns false on success and true on error.+extern bool lzma_lzma_lclppb_encode(+ const lzma_options_lzma *options, uint8_t *byte);+++#ifdef LZMA_LZ_ENCODER_H++/// Initializes raw LZMA encoder; this is used by LZMA2.+extern lzma_ret lzma_lzma_encoder_create(+ void **coder_ptr, const lzma_allocator *allocator,+ lzma_vli id, const lzma_options_lzma *options,+ lzma_lz_options *lz_options);+++/// Resets an already initialized LZMA encoder; this is used by LZMA2.+extern lzma_ret lzma_lzma_encoder_reset(+ lzma_lzma1_encoder *coder, const lzma_options_lzma *options);+++extern lzma_ret lzma_lzma_encode(lzma_lzma1_encoder *restrict coder,+ lzma_mf *restrict mf, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size,+ uint32_t read_limit);++#endif++#endif
+ cbits/liblzma/lzma/lzma_encoder_optimum_fast.c view
@@ -0,0 +1,169 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzma_encoder_optimum_fast.c+//+// Author: Igor Pavlov+//+///////////////////////////////////////////////////////////////////////////////++#include "lzma_encoder_private.h"+#include "memcmplen.h"+++#define change_pair(small_dist, big_dist) \+ (((big_dist) >> 7) > (small_dist))+++extern void+lzma_lzma_optimum_fast(lzma_lzma1_encoder *restrict coder,+ lzma_mf *restrict mf,+ uint32_t *restrict back_res, uint32_t *restrict len_res)+{+ const uint32_t nice_len = mf->nice_len;++ uint32_t len_main;+ uint32_t matches_count;+ if (mf->read_ahead == 0) {+ len_main = mf_find(mf, &matches_count, coder->matches);+ } else {+ assert(mf->read_ahead == 1);+ len_main = coder->longest_match_length;+ matches_count = coder->matches_count;+ }++ const uint8_t *buf = mf_ptr(mf) - 1;+ const uint32_t buf_avail = my_min(mf_avail(mf) + 1, MATCH_LEN_MAX);++ if (buf_avail < 2) {+ // There's not enough input left to encode a match.+ *back_res = UINT32_MAX;+ *len_res = 1;+ return;+ }++ // Look for repeated matches; scan the previous four match distances+ uint32_t rep_len = 0;+ uint32_t rep_index = 0;++ for (uint32_t i = 0; i < REPS; ++i) {+ // Pointer to the beginning of the match candidate+ const uint8_t *const buf_back = buf - coder->reps[i] - 1;++ // If the first two bytes (2 == MATCH_LEN_MIN) do not match,+ // this rep is not useful.+ if (not_equal_16(buf, buf_back))+ continue;++ // The first two bytes matched.+ // Calculate the length of the match.+ const uint32_t len = lzma_memcmplen(+ buf, buf_back, 2, buf_avail);++ // If we have found a repeated match that is at least+ // nice_len long, return it immediately.+ if (len >= nice_len) {+ *back_res = i;+ *len_res = len;+ mf_skip(mf, len - 1);+ return;+ }++ if (len > rep_len) {+ rep_index = i;+ rep_len = len;+ }+ }++ // We didn't find a long enough repeated match. Encode it as a normal+ // match if the match length is at least nice_len.+ if (len_main >= nice_len) {+ *back_res = coder->matches[matches_count - 1].dist + REPS;+ *len_res = len_main;+ mf_skip(mf, len_main - 1);+ return;+ }++ uint32_t back_main = 0;+ if (len_main >= 2) {+ back_main = coder->matches[matches_count - 1].dist;++ while (matches_count > 1 && len_main ==+ coder->matches[matches_count - 2].len + 1) {+ if (!change_pair(coder->matches[+ matches_count - 2].dist,+ back_main))+ break;++ --matches_count;+ len_main = coder->matches[matches_count - 1].len;+ back_main = coder->matches[matches_count - 1].dist;+ }++ if (len_main == 2 && back_main >= 0x80)+ len_main = 1;+ }++ if (rep_len >= 2) {+ if (rep_len + 1 >= len_main+ || (rep_len + 2 >= len_main+ && back_main > (UINT32_C(1) << 9))+ || (rep_len + 3 >= len_main+ && back_main > (UINT32_C(1) << 15))) {+ *back_res = rep_index;+ *len_res = rep_len;+ mf_skip(mf, rep_len - 1);+ return;+ }+ }++ if (len_main < 2 || buf_avail <= 2) {+ *back_res = UINT32_MAX;+ *len_res = 1;+ return;+ }++ // Get the matches for the next byte. If we find a better match,+ // the current byte is encoded as a literal.+ coder->longest_match_length = mf_find(mf,+ &coder->matches_count, coder->matches);++ if (coder->longest_match_length >= 2) {+ const uint32_t new_dist = coder->matches[+ coder->matches_count - 1].dist;++ if ((coder->longest_match_length >= len_main+ && new_dist < back_main)+ || (coder->longest_match_length == len_main + 1+ && !change_pair(back_main, new_dist))+ || (coder->longest_match_length > len_main + 1)+ || (coder->longest_match_length + 1 >= len_main+ && len_main >= 3+ && change_pair(new_dist, back_main))) {+ *back_res = UINT32_MAX;+ *len_res = 1;+ return;+ }+ }++ // In contrast to LZMA SDK, dictionary could not have been moved+ // between mf_find() calls, thus it is safe to just increment+ // the old buf pointer instead of recalculating it with mf_ptr().+ ++buf;++ const uint32_t limit = my_max(2, len_main - 1);++ for (uint32_t i = 0; i < REPS; ++i) {+ if (memcmp(buf, buf - coder->reps[i] - 1, limit) == 0) {+ *back_res = UINT32_MAX;+ *len_res = 1;+ return;+ }+ }++ *back_res = back_main + REPS;+ *len_res = len_main;+ mf_skip(mf, len_main - 2);+ return;+}
+ cbits/liblzma/lzma/lzma_encoder_optimum_normal.c view
@@ -0,0 +1,858 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzma_encoder_optimum_normal.c+//+// Author: Igor Pavlov+//+///////////////////////////////////////////////////////////////////////////////++#include "lzma_encoder_private.h"+#include "fastpos.h"+#include "memcmplen.h"+++////////////+// Prices //+////////////++static uint32_t+get_literal_price(const lzma_lzma1_encoder *const coder, const uint32_t pos,+ const uint32_t prev_byte, const bool match_mode,+ uint32_t match_byte, uint32_t symbol)+{+ const probability *const subcoder = literal_subcoder(coder->literal,+ coder->literal_context_bits, coder->literal_mask,+ pos, prev_byte);++ uint32_t price = 0;++ if (!match_mode) {+ price = rc_bittree_price(subcoder, 8, symbol);+ } else {+ uint32_t offset = 0x100;+ symbol += UINT32_C(1) << 8;++ do {+ match_byte <<= 1;++ const uint32_t match_bit = match_byte & offset;+ const uint32_t subcoder_index+ = offset + match_bit + (symbol >> 8);+ const uint32_t bit = (symbol >> 7) & 1;+ price += rc_bit_price(subcoder[subcoder_index], bit);++ symbol <<= 1;+ offset &= ~(match_byte ^ symbol);++ } while (symbol < (UINT32_C(1) << 16));+ }++ return price;+}+++static inline uint32_t+get_len_price(const lzma_length_encoder *const lencoder,+ const uint32_t len, const uint32_t pos_state)+{+ // NOTE: Unlike the other price tables, length prices are updated+ // in lzma_encoder.c+ return lencoder->prices[pos_state][len - MATCH_LEN_MIN];+}+++static inline uint32_t+get_short_rep_price(const lzma_lzma1_encoder *const coder,+ const lzma_lzma_state state, const uint32_t pos_state)+{+ return rc_bit_0_price(coder->is_rep0[state])+ + rc_bit_0_price(coder->is_rep0_long[state][pos_state]);+}+++static inline uint32_t+get_pure_rep_price(const lzma_lzma1_encoder *const coder, const uint32_t rep_index,+ const lzma_lzma_state state, uint32_t pos_state)+{+ uint32_t price;++ if (rep_index == 0) {+ price = rc_bit_0_price(coder->is_rep0[state]);+ price += rc_bit_1_price(coder->is_rep0_long[state][pos_state]);+ } else {+ price = rc_bit_1_price(coder->is_rep0[state]);++ if (rep_index == 1) {+ price += rc_bit_0_price(coder->is_rep1[state]);+ } else {+ price += rc_bit_1_price(coder->is_rep1[state]);+ price += rc_bit_price(coder->is_rep2[state],+ rep_index - 2);+ }+ }++ return price;+}+++static inline uint32_t+get_rep_price(const lzma_lzma1_encoder *const coder, const uint32_t rep_index,+ const uint32_t len, const lzma_lzma_state state,+ const uint32_t pos_state)+{+ return get_len_price(&coder->rep_len_encoder, len, pos_state)+ + get_pure_rep_price(coder, rep_index, state, pos_state);+}+++static inline uint32_t+get_dist_len_price(const lzma_lzma1_encoder *const coder, const uint32_t dist,+ const uint32_t len, const uint32_t pos_state)+{+ const uint32_t dist_state = get_dist_state(len);+ uint32_t price;++ if (dist < FULL_DISTANCES) {+ price = coder->dist_prices[dist_state][dist];+ } else {+ const uint32_t dist_slot = get_dist_slot_2(dist);+ price = coder->dist_slot_prices[dist_state][dist_slot]+ + coder->align_prices[dist & ALIGN_MASK];+ }++ price += get_len_price(&coder->match_len_encoder, len, pos_state);++ return price;+}+++static void+fill_dist_prices(lzma_lzma1_encoder *coder)+{+ for (uint32_t dist_state = 0; dist_state < DIST_STATES; ++dist_state) {++ uint32_t *const dist_slot_prices+ = coder->dist_slot_prices[dist_state];++ // Price to encode the dist_slot.+ for (uint32_t dist_slot = 0;+ dist_slot < coder->dist_table_size; ++dist_slot)+ dist_slot_prices[dist_slot] = rc_bittree_price(+ coder->dist_slot[dist_state],+ DIST_SLOT_BITS, dist_slot);++ // For matches with distance >= FULL_DISTANCES, add the price+ // of the direct bits part of the match distance. (Align bits+ // are handled by fill_align_prices()).+ for (uint32_t dist_slot = DIST_MODEL_END;+ dist_slot < coder->dist_table_size;+ ++dist_slot)+ dist_slot_prices[dist_slot] += rc_direct_price(+ ((dist_slot >> 1) - 1) - ALIGN_BITS);++ // Distances in the range [0, 3] are fully encoded with+ // dist_slot, so they are used for coder->dist_prices+ // as is.+ for (uint32_t i = 0; i < DIST_MODEL_START; ++i)+ coder->dist_prices[dist_state][i]+ = dist_slot_prices[i];+ }++ // Distances in the range [4, 127] depend on dist_slot and+ // dist_special. We do this in a loop separate from the above+ // loop to avoid redundant calls to get_dist_slot().+ for (uint32_t i = DIST_MODEL_START; i < FULL_DISTANCES; ++i) {+ const uint32_t dist_slot = get_dist_slot(i);+ const uint32_t footer_bits = ((dist_slot >> 1) - 1);+ const uint32_t base = (2 | (dist_slot & 1)) << footer_bits;+ const uint32_t price = rc_bittree_reverse_price(+ coder->dist_special + base - dist_slot - 1,+ footer_bits, i - base);++ for (uint32_t dist_state = 0; dist_state < DIST_STATES;+ ++dist_state)+ coder->dist_prices[dist_state][i]+ = price + coder->dist_slot_prices[+ dist_state][dist_slot];+ }++ coder->match_price_count = 0;+ return;+}+++static void+fill_align_prices(lzma_lzma1_encoder *coder)+{+ for (uint32_t i = 0; i < ALIGN_SIZE; ++i)+ coder->align_prices[i] = rc_bittree_reverse_price(+ coder->dist_align, ALIGN_BITS, i);++ coder->align_price_count = 0;+ return;+}+++/////////////+// Optimal //+/////////////++static inline void+make_literal(lzma_optimal *optimal)+{+ optimal->back_prev = UINT32_MAX;+ optimal->prev_1_is_literal = false;+}+++static inline void+make_short_rep(lzma_optimal *optimal)+{+ optimal->back_prev = 0;+ optimal->prev_1_is_literal = false;+}+++#define is_short_rep(optimal) \+ ((optimal).back_prev == 0)+++static void+backward(lzma_lzma1_encoder *restrict coder, uint32_t *restrict len_res,+ uint32_t *restrict back_res, uint32_t cur)+{+ coder->opts_end_index = cur;++ uint32_t pos_mem = coder->opts[cur].pos_prev;+ uint32_t back_mem = coder->opts[cur].back_prev;++ do {+ if (coder->opts[cur].prev_1_is_literal) {+ make_literal(&coder->opts[pos_mem]);+ coder->opts[pos_mem].pos_prev = pos_mem - 1;++ if (coder->opts[cur].prev_2) {+ coder->opts[pos_mem - 1].prev_1_is_literal+ = false;+ coder->opts[pos_mem - 1].pos_prev+ = coder->opts[cur].pos_prev_2;+ coder->opts[pos_mem - 1].back_prev+ = coder->opts[cur].back_prev_2;+ }+ }++ const uint32_t pos_prev = pos_mem;+ const uint32_t back_cur = back_mem;++ back_mem = coder->opts[pos_prev].back_prev;+ pos_mem = coder->opts[pos_prev].pos_prev;++ coder->opts[pos_prev].back_prev = back_cur;+ coder->opts[pos_prev].pos_prev = cur;+ cur = pos_prev;++ } while (cur != 0);++ coder->opts_current_index = coder->opts[0].pos_prev;+ *len_res = coder->opts[0].pos_prev;+ *back_res = coder->opts[0].back_prev;++ return;+}+++//////////+// Main //+//////////++static inline uint32_t+helper1(lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf,+ uint32_t *restrict back_res, uint32_t *restrict len_res,+ uint32_t position)+{+ const uint32_t nice_len = mf->nice_len;++ uint32_t len_main;+ uint32_t matches_count;++ if (mf->read_ahead == 0) {+ len_main = mf_find(mf, &matches_count, coder->matches);+ } else {+ assert(mf->read_ahead == 1);+ len_main = coder->longest_match_length;+ matches_count = coder->matches_count;+ }++ const uint32_t buf_avail = my_min(mf_avail(mf) + 1, MATCH_LEN_MAX);+ if (buf_avail < 2) {+ *back_res = UINT32_MAX;+ *len_res = 1;+ return UINT32_MAX;+ }++ const uint8_t *const buf = mf_ptr(mf) - 1;++ uint32_t rep_lens[REPS];+ uint32_t rep_max_index = 0;++ for (uint32_t i = 0; i < REPS; ++i) {+ const uint8_t *const buf_back = buf - coder->reps[i] - 1;++ if (not_equal_16(buf, buf_back)) {+ rep_lens[i] = 0;+ continue;+ }++ rep_lens[i] = lzma_memcmplen(buf, buf_back, 2, buf_avail);++ if (rep_lens[i] > rep_lens[rep_max_index])+ rep_max_index = i;+ }++ if (rep_lens[rep_max_index] >= nice_len) {+ *back_res = rep_max_index;+ *len_res = rep_lens[rep_max_index];+ mf_skip(mf, *len_res - 1);+ return UINT32_MAX;+ }+++ if (len_main >= nice_len) {+ *back_res = coder->matches[matches_count - 1].dist + REPS;+ *len_res = len_main;+ mf_skip(mf, len_main - 1);+ return UINT32_MAX;+ }++ const uint8_t current_byte = *buf;+ const uint8_t match_byte = *(buf - coder->reps[0] - 1);++ if (len_main < 2 && current_byte != match_byte+ && rep_lens[rep_max_index] < 2) {+ *back_res = UINT32_MAX;+ *len_res = 1;+ return UINT32_MAX;+ }++ coder->opts[0].state = coder->state;++ const uint32_t pos_state = position & coder->pos_mask;++ coder->opts[1].price = rc_bit_0_price(+ coder->is_match[coder->state][pos_state])+ + get_literal_price(coder, position, buf[-1],+ !is_literal_state(coder->state),+ match_byte, current_byte);++ make_literal(&coder->opts[1]);++ const uint32_t match_price = rc_bit_1_price(+ coder->is_match[coder->state][pos_state]);+ const uint32_t rep_match_price = match_price+ + rc_bit_1_price(coder->is_rep[coder->state]);++ if (match_byte == current_byte) {+ const uint32_t short_rep_price = rep_match_price+ + get_short_rep_price(+ coder, coder->state, pos_state);++ if (short_rep_price < coder->opts[1].price) {+ coder->opts[1].price = short_rep_price;+ make_short_rep(&coder->opts[1]);+ }+ }++ const uint32_t len_end = my_max(len_main, rep_lens[rep_max_index]);++ if (len_end < 2) {+ *back_res = coder->opts[1].back_prev;+ *len_res = 1;+ return UINT32_MAX;+ }++ coder->opts[1].pos_prev = 0;++ for (uint32_t i = 0; i < REPS; ++i)+ coder->opts[0].backs[i] = coder->reps[i];++ uint32_t len = len_end;+ do {+ coder->opts[len].price = RC_INFINITY_PRICE;+ } while (--len >= 2);+++ for (uint32_t i = 0; i < REPS; ++i) {+ uint32_t rep_len = rep_lens[i];+ if (rep_len < 2)+ continue;++ const uint32_t price = rep_match_price + get_pure_rep_price(+ coder, i, coder->state, pos_state);++ do {+ const uint32_t cur_and_len_price = price+ + get_len_price(+ &coder->rep_len_encoder,+ rep_len, pos_state);++ if (cur_and_len_price < coder->opts[rep_len].price) {+ coder->opts[rep_len].price = cur_and_len_price;+ coder->opts[rep_len].pos_prev = 0;+ coder->opts[rep_len].back_prev = i;+ coder->opts[rep_len].prev_1_is_literal = false;+ }+ } while (--rep_len >= 2);+ }+++ const uint32_t normal_match_price = match_price+ + rc_bit_0_price(coder->is_rep[coder->state]);++ len = rep_lens[0] >= 2 ? rep_lens[0] + 1 : 2;+ if (len <= len_main) {+ uint32_t i = 0;+ while (len > coder->matches[i].len)+ ++i;++ for(; ; ++len) {+ const uint32_t dist = coder->matches[i].dist;+ const uint32_t cur_and_len_price = normal_match_price+ + get_dist_len_price(coder,+ dist, len, pos_state);++ if (cur_and_len_price < coder->opts[len].price) {+ coder->opts[len].price = cur_and_len_price;+ coder->opts[len].pos_prev = 0;+ coder->opts[len].back_prev = dist + REPS;+ coder->opts[len].prev_1_is_literal = false;+ }++ if (len == coder->matches[i].len)+ if (++i == matches_count)+ break;+ }+ }++ return len_end;+}+++static inline uint32_t+helper2(lzma_lzma1_encoder *coder, uint32_t *reps, const uint8_t *buf,+ uint32_t len_end, uint32_t position, const uint32_t cur,+ const uint32_t nice_len, const uint32_t buf_avail_full)+{+ uint32_t matches_count = coder->matches_count;+ uint32_t new_len = coder->longest_match_length;+ uint32_t pos_prev = coder->opts[cur].pos_prev;+ lzma_lzma_state state;++ if (coder->opts[cur].prev_1_is_literal) {+ --pos_prev;++ if (coder->opts[cur].prev_2) {+ state = coder->opts[coder->opts[cur].pos_prev_2].state;++ if (coder->opts[cur].back_prev_2 < REPS)+ update_long_rep(state);+ else+ update_match(state);++ } else {+ state = coder->opts[pos_prev].state;+ }++ update_literal(state);++ } else {+ state = coder->opts[pos_prev].state;+ }++ if (pos_prev == cur - 1) {+ if (is_short_rep(coder->opts[cur]))+ update_short_rep(state);+ else+ update_literal(state);+ } else {+ uint32_t pos;+ if (coder->opts[cur].prev_1_is_literal+ && coder->opts[cur].prev_2) {+ pos_prev = coder->opts[cur].pos_prev_2;+ pos = coder->opts[cur].back_prev_2;+ update_long_rep(state);+ } else {+ pos = coder->opts[cur].back_prev;+ if (pos < REPS)+ update_long_rep(state);+ else+ update_match(state);+ }++ if (pos < REPS) {+ reps[0] = coder->opts[pos_prev].backs[pos];++ uint32_t i;+ for (i = 1; i <= pos; ++i)+ reps[i] = coder->opts[pos_prev].backs[i - 1];++ for (; i < REPS; ++i)+ reps[i] = coder->opts[pos_prev].backs[i];++ } else {+ reps[0] = pos - REPS;++ for (uint32_t i = 1; i < REPS; ++i)+ reps[i] = coder->opts[pos_prev].backs[i - 1];+ }+ }++ coder->opts[cur].state = state;++ for (uint32_t i = 0; i < REPS; ++i)+ coder->opts[cur].backs[i] = reps[i];++ const uint32_t cur_price = coder->opts[cur].price;++ const uint8_t current_byte = *buf;+ const uint8_t match_byte = *(buf - reps[0] - 1);++ const uint32_t pos_state = position & coder->pos_mask;++ const uint32_t cur_and_1_price = cur_price+ + rc_bit_0_price(coder->is_match[state][pos_state])+ + get_literal_price(coder, position, buf[-1],+ !is_literal_state(state), match_byte, current_byte);++ bool next_is_literal = false;++ if (cur_and_1_price < coder->opts[cur + 1].price) {+ coder->opts[cur + 1].price = cur_and_1_price;+ coder->opts[cur + 1].pos_prev = cur;+ make_literal(&coder->opts[cur + 1]);+ next_is_literal = true;+ }++ const uint32_t match_price = cur_price+ + rc_bit_1_price(coder->is_match[state][pos_state]);+ const uint32_t rep_match_price = match_price+ + rc_bit_1_price(coder->is_rep[state]);++ if (match_byte == current_byte+ && !(coder->opts[cur + 1].pos_prev < cur+ && coder->opts[cur + 1].back_prev == 0)) {++ const uint32_t short_rep_price = rep_match_price+ + get_short_rep_price(coder, state, pos_state);++ if (short_rep_price <= coder->opts[cur + 1].price) {+ coder->opts[cur + 1].price = short_rep_price;+ coder->opts[cur + 1].pos_prev = cur;+ make_short_rep(&coder->opts[cur + 1]);+ next_is_literal = true;+ }+ }++ if (buf_avail_full < 2)+ return len_end;++ const uint32_t buf_avail = my_min(buf_avail_full, nice_len);++ if (!next_is_literal && match_byte != current_byte) { // speed optimization+ // try literal + rep0+ const uint8_t *const buf_back = buf - reps[0] - 1;+ const uint32_t limit = my_min(buf_avail_full, nice_len + 1);++ const uint32_t len_test = lzma_memcmplen(buf, buf_back, 1, limit) - 1;++ if (len_test >= 2) {+ lzma_lzma_state state_2 = state;+ update_literal(state_2);++ const uint32_t pos_state_next = (position + 1) & coder->pos_mask;+ const uint32_t next_rep_match_price = cur_and_1_price+ + rc_bit_1_price(coder->is_match[state_2][pos_state_next])+ + rc_bit_1_price(coder->is_rep[state_2]);++ //for (; len_test >= 2; --len_test) {+ const uint32_t offset = cur + 1 + len_test;++ while (len_end < offset)+ coder->opts[++len_end].price = RC_INFINITY_PRICE;++ const uint32_t cur_and_len_price = next_rep_match_price+ + get_rep_price(coder, 0, len_test,+ state_2, pos_state_next);++ if (cur_and_len_price < coder->opts[offset].price) {+ coder->opts[offset].price = cur_and_len_price;+ coder->opts[offset].pos_prev = cur + 1;+ coder->opts[offset].back_prev = 0;+ coder->opts[offset].prev_1_is_literal = true;+ coder->opts[offset].prev_2 = false;+ }+ //}+ }+ }+++ uint32_t start_len = 2; // speed optimization++ for (uint32_t rep_index = 0; rep_index < REPS; ++rep_index) {+ const uint8_t *const buf_back = buf - reps[rep_index] - 1;+ if (not_equal_16(buf, buf_back))+ continue;++ uint32_t len_test = lzma_memcmplen(buf, buf_back, 2, buf_avail);++ while (len_end < cur + len_test)+ coder->opts[++len_end].price = RC_INFINITY_PRICE;++ const uint32_t len_test_temp = len_test;+ const uint32_t price = rep_match_price + get_pure_rep_price(+ coder, rep_index, state, pos_state);++ do {+ const uint32_t cur_and_len_price = price+ + get_len_price(&coder->rep_len_encoder,+ len_test, pos_state);++ if (cur_and_len_price < coder->opts[cur + len_test].price) {+ coder->opts[cur + len_test].price = cur_and_len_price;+ coder->opts[cur + len_test].pos_prev = cur;+ coder->opts[cur + len_test].back_prev = rep_index;+ coder->opts[cur + len_test].prev_1_is_literal = false;+ }+ } while (--len_test >= 2);++ len_test = len_test_temp;++ if (rep_index == 0)+ start_len = len_test + 1;+++ uint32_t len_test_2 = len_test + 1;+ const uint32_t limit = my_min(buf_avail_full,+ len_test_2 + nice_len);+ // NOTE: len_test_2 may be greater than limit so the call to+ // lzma_memcmplen() must be done conditionally.+ if (len_test_2 < limit)+ len_test_2 = lzma_memcmplen(buf, buf_back, len_test_2, limit);++ len_test_2 -= len_test + 1;++ if (len_test_2 >= 2) {+ lzma_lzma_state state_2 = state;+ update_long_rep(state_2);++ uint32_t pos_state_next = (position + len_test) & coder->pos_mask;++ const uint32_t cur_and_len_literal_price = price+ + get_len_price(&coder->rep_len_encoder,+ len_test, pos_state)+ + rc_bit_0_price(coder->is_match[state_2][pos_state_next])+ + get_literal_price(coder, position + len_test,+ buf[len_test - 1], true,+ buf_back[len_test], buf[len_test]);++ update_literal(state_2);++ pos_state_next = (position + len_test + 1) & coder->pos_mask;++ const uint32_t next_rep_match_price = cur_and_len_literal_price+ + rc_bit_1_price(coder->is_match[state_2][pos_state_next])+ + rc_bit_1_price(coder->is_rep[state_2]);++ //for(; len_test_2 >= 2; len_test_2--) {+ const uint32_t offset = cur + len_test + 1 + len_test_2;++ while (len_end < offset)+ coder->opts[++len_end].price = RC_INFINITY_PRICE;++ const uint32_t cur_and_len_price = next_rep_match_price+ + get_rep_price(coder, 0, len_test_2,+ state_2, pos_state_next);++ if (cur_and_len_price < coder->opts[offset].price) {+ coder->opts[offset].price = cur_and_len_price;+ coder->opts[offset].pos_prev = cur + len_test + 1;+ coder->opts[offset].back_prev = 0;+ coder->opts[offset].prev_1_is_literal = true;+ coder->opts[offset].prev_2 = true;+ coder->opts[offset].pos_prev_2 = cur;+ coder->opts[offset].back_prev_2 = rep_index;+ }+ //}+ }+ }+++ //for (uint32_t len_test = 2; len_test <= new_len; ++len_test)+ if (new_len > buf_avail) {+ new_len = buf_avail;++ matches_count = 0;+ while (new_len > coder->matches[matches_count].len)+ ++matches_count;++ coder->matches[matches_count++].len = new_len;+ }+++ if (new_len >= start_len) {+ const uint32_t normal_match_price = match_price+ + rc_bit_0_price(coder->is_rep[state]);++ while (len_end < cur + new_len)+ coder->opts[++len_end].price = RC_INFINITY_PRICE;++ uint32_t i = 0;+ while (start_len > coder->matches[i].len)+ ++i;++ for (uint32_t len_test = start_len; ; ++len_test) {+ const uint32_t cur_back = coder->matches[i].dist;+ uint32_t cur_and_len_price = normal_match_price+ + get_dist_len_price(coder,+ cur_back, len_test, pos_state);++ if (cur_and_len_price < coder->opts[cur + len_test].price) {+ coder->opts[cur + len_test].price = cur_and_len_price;+ coder->opts[cur + len_test].pos_prev = cur;+ coder->opts[cur + len_test].back_prev+ = cur_back + REPS;+ coder->opts[cur + len_test].prev_1_is_literal = false;+ }++ if (len_test == coder->matches[i].len) {+ // Try Match + Literal + Rep0+ const uint8_t *const buf_back = buf - cur_back - 1;+ uint32_t len_test_2 = len_test + 1;+ const uint32_t limit = my_min(buf_avail_full,+ len_test_2 + nice_len);++ // NOTE: len_test_2 may be greater than limit+ // so the call to lzma_memcmplen() must be+ // done conditionally.+ if (len_test_2 < limit)+ len_test_2 = lzma_memcmplen(buf, buf_back,+ len_test_2, limit);++ len_test_2 -= len_test + 1;++ if (len_test_2 >= 2) {+ lzma_lzma_state state_2 = state;+ update_match(state_2);+ uint32_t pos_state_next+ = (position + len_test) & coder->pos_mask;++ const uint32_t cur_and_len_literal_price = cur_and_len_price+ + rc_bit_0_price(+ coder->is_match[state_2][pos_state_next])+ + get_literal_price(coder,+ position + len_test,+ buf[len_test - 1],+ true,+ buf_back[len_test],+ buf[len_test]);++ update_literal(state_2);+ pos_state_next = (pos_state_next + 1) & coder->pos_mask;++ const uint32_t next_rep_match_price+ = cur_and_len_literal_price+ + rc_bit_1_price(+ coder->is_match[state_2][pos_state_next])+ + rc_bit_1_price(coder->is_rep[state_2]);++ // for(; len_test_2 >= 2; --len_test_2) {+ const uint32_t offset = cur + len_test + 1 + len_test_2;++ while (len_end < offset)+ coder->opts[++len_end].price = RC_INFINITY_PRICE;++ cur_and_len_price = next_rep_match_price+ + get_rep_price(coder, 0, len_test_2,+ state_2, pos_state_next);++ if (cur_and_len_price < coder->opts[offset].price) {+ coder->opts[offset].price = cur_and_len_price;+ coder->opts[offset].pos_prev = cur + len_test + 1;+ coder->opts[offset].back_prev = 0;+ coder->opts[offset].prev_1_is_literal = true;+ coder->opts[offset].prev_2 = true;+ coder->opts[offset].pos_prev_2 = cur;+ coder->opts[offset].back_prev_2+ = cur_back + REPS;+ }+ //}+ }++ if (++i == matches_count)+ break;+ }+ }+ }++ return len_end;+}+++extern void+lzma_lzma_optimum_normal(lzma_lzma1_encoder *restrict coder,+ lzma_mf *restrict mf,+ uint32_t *restrict back_res, uint32_t *restrict len_res,+ uint32_t position)+{+ // If we have symbols pending, return the next pending symbol.+ if (coder->opts_end_index != coder->opts_current_index) {+ assert(mf->read_ahead > 0);+ *len_res = coder->opts[coder->opts_current_index].pos_prev+ - coder->opts_current_index;+ *back_res = coder->opts[coder->opts_current_index].back_prev;+ coder->opts_current_index = coder->opts[+ coder->opts_current_index].pos_prev;+ return;+ }++ // Update the price tables. In LZMA SDK <= 4.60 (and possibly later)+ // this was done in both initialization function and in the main loop.+ // In liblzma they were moved into this single place.+ if (mf->read_ahead == 0) {+ if (coder->match_price_count >= (1 << 7))+ fill_dist_prices(coder);++ if (coder->align_price_count >= ALIGN_SIZE)+ fill_align_prices(coder);+ }++ // TODO: This needs quite a bit of cleaning still. But splitting+ // the original function into two pieces makes it at least a little+ // more readable, since those two parts don't share many variables.++ uint32_t len_end = helper1(coder, mf, back_res, len_res, position);+ if (len_end == UINT32_MAX)+ return;++ uint32_t reps[REPS];+ memcpy(reps, coder->reps, sizeof(reps));++ uint32_t cur;+ for (cur = 1; cur < len_end; ++cur) {+ assert(cur < OPTS);++ coder->longest_match_length = mf_find(+ mf, &coder->matches_count, coder->matches);++ if (coder->longest_match_length >= mf->nice_len)+ break;++ len_end = helper2(coder, reps, mf_ptr(mf) - 1, len_end,+ position + cur, cur, mf->nice_len,+ my_min(mf_avail(mf) + 1, OPTS - 1 - cur));+ }++ backward(coder, len_res, back_res, cur);+ return;+}
+ cbits/liblzma/lzma/lzma_encoder_presets.c view
@@ -0,0 +1,63 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzma_encoder_presets.c+/// \brief Encoder presets+/// \note xz needs this even when only decoding is enabled.+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "common.h"+++extern LZMA_API(lzma_bool)+lzma_lzma_preset(lzma_options_lzma *options, uint32_t preset)+{+ const uint32_t level = preset & LZMA_PRESET_LEVEL_MASK;+ const uint32_t flags = preset & ~LZMA_PRESET_LEVEL_MASK;+ const uint32_t supported_flags = LZMA_PRESET_EXTREME;++ if (level > 9 || (flags & ~supported_flags))+ return true;++ options->preset_dict = NULL;+ options->preset_dict_size = 0;++ options->lc = LZMA_LC_DEFAULT;+ options->lp = LZMA_LP_DEFAULT;+ options->pb = LZMA_PB_DEFAULT;++ static const uint8_t dict_pow2[]+ = { 18, 20, 21, 22, 22, 23, 23, 24, 25, 26 };+ options->dict_size = UINT32_C(1) << dict_pow2[level];++ if (level <= 3) {+ options->mode = LZMA_MODE_FAST;+ options->mf = level == 0 ? LZMA_MF_HC3 : LZMA_MF_HC4;+ options->nice_len = level <= 1 ? 128 : 273;+ static const uint8_t depths[] = { 4, 8, 24, 48 };+ options->depth = depths[level];+ } else {+ options->mode = LZMA_MODE_NORMAL;+ options->mf = LZMA_MF_BT4;+ options->nice_len = level == 4 ? 16 : level == 5 ? 32 : 64;+ options->depth = 0;+ }++ if (flags & LZMA_PRESET_EXTREME) {+ options->mode = LZMA_MODE_NORMAL;+ options->mf = LZMA_MF_BT4;+ if (level == 3 || level == 5) {+ options->nice_len = 192;+ options->depth = 0;+ } else {+ options->nice_len = 273;+ options->depth = 512;+ }+ }++ return false;+}
+ cbits/liblzma/lzma/lzma_encoder_private.h view
@@ -0,0 +1,161 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file lzma_encoder_private.h+/// \brief Private definitions for LZMA encoder+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_LZMA_ENCODER_PRIVATE_H+#define LZMA_LZMA_ENCODER_PRIVATE_H++#include "lz_encoder.h"+#include "range_encoder.h"+#include "lzma_common.h"+#include "lzma_encoder.h"+++// Macro to compare if the first two bytes in two buffers differ. This is+// needed in lzma_lzma_optimum_*() to test if the match is at least+// MATCH_LEN_MIN bytes. Unaligned access gives tiny gain so there's no+// reason to not use it when it is supported.+#ifdef TUKLIB_FAST_UNALIGNED_ACCESS+# define not_equal_16(a, b) (read16ne(a) != read16ne(b))+#else+# define not_equal_16(a, b) \+ ((a)[0] != (b)[0] || (a)[1] != (b)[1])+#endif+++// Optimal - Number of entries in the optimum array.+#define OPTS (1 << 12)+++typedef struct {+ probability choice;+ probability choice2;+ probability low[POS_STATES_MAX][LEN_LOW_SYMBOLS];+ probability mid[POS_STATES_MAX][LEN_MID_SYMBOLS];+ probability high[LEN_HIGH_SYMBOLS];++ uint32_t prices[POS_STATES_MAX][LEN_SYMBOLS];+ uint32_t table_size;+ uint32_t counters[POS_STATES_MAX];++} lzma_length_encoder;+++typedef struct {+ lzma_lzma_state state;++ bool prev_1_is_literal;+ bool prev_2;++ uint32_t pos_prev_2;+ uint32_t back_prev_2;++ uint32_t price;+ uint32_t pos_prev; // pos_next;+ uint32_t back_prev;++ uint32_t backs[REPS];++} lzma_optimal;+++struct lzma_lzma1_encoder_s {+ /// Range encoder+ lzma_range_encoder rc;++ /// Uncompressed size (doesn't include possible preset dictionary)+ uint64_t uncomp_size;++ /// If non-zero, produce at most this much output.+ /// Some input may then be missing from the output.+ uint64_t out_limit;++ /// If the above out_limit is non-zero, *uncomp_size_ptr is set to+ /// the amount of uncompressed data that we were able to fit+ /// in the output buffer.+ uint64_t *uncomp_size_ptr;++ /// State+ lzma_lzma_state state;++ /// The four most recent match distances+ uint32_t reps[REPS];++ /// Array of match candidates+ lzma_match matches[MATCH_LEN_MAX + 1];++ /// Number of match candidates in matches[]+ uint32_t matches_count;++ /// Variable to hold the length of the longest match between calls+ /// to lzma_lzma_optimum_*().+ uint32_t longest_match_length;++ /// True if using getoptimumfast+ bool fast_mode;++ /// True if the encoder has been initialized by encoding the first+ /// byte as a literal.+ bool is_initialized;++ /// True if the range encoder has been flushed, but not all bytes+ /// have been written to the output buffer yet.+ bool is_flushed;++ /// True if end of payload marker will be written.+ bool use_eopm;++ uint32_t pos_mask; ///< (1 << pos_bits) - 1+ uint32_t literal_context_bits;+ uint32_t literal_mask;++ // These are the same as in lzma_decoder.c. See comments there.+ probability literal[LITERAL_CODERS_MAX * LITERAL_CODER_SIZE];+ probability is_match[STATES][POS_STATES_MAX];+ probability is_rep[STATES];+ probability is_rep0[STATES];+ probability is_rep1[STATES];+ probability is_rep2[STATES];+ probability is_rep0_long[STATES][POS_STATES_MAX];+ probability dist_slot[DIST_STATES][DIST_SLOTS];+ probability dist_special[FULL_DISTANCES - DIST_MODEL_END];+ probability dist_align[ALIGN_SIZE];++ // These are the same as in lzma_decoder.c except that the encoders+ // include also price tables.+ lzma_length_encoder match_len_encoder;+ lzma_length_encoder rep_len_encoder;++ // Price tables+ uint32_t dist_slot_prices[DIST_STATES][DIST_SLOTS];+ uint32_t dist_prices[DIST_STATES][FULL_DISTANCES];+ uint32_t dist_table_size;+ uint32_t match_price_count;++ uint32_t align_prices[ALIGN_SIZE];+ uint32_t align_price_count;++ // Optimal+ uint32_t opts_end_index;+ uint32_t opts_current_index;+ lzma_optimal opts[OPTS];+};+++extern void lzma_lzma_optimum_fast(+ lzma_lzma1_encoder *restrict coder, lzma_mf *restrict mf,+ uint32_t *restrict back_res, uint32_t *restrict len_res);++extern void lzma_lzma_optimum_normal(lzma_lzma1_encoder *restrict coder,+ lzma_mf *restrict mf, uint32_t *restrict back_res,+ uint32_t *restrict len_res, uint32_t position);++#endif
+ cbits/liblzma/rangecoder/price.h view
@@ -0,0 +1,92 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file price.h+/// \brief Probability price calculation+//+// Author: Igor Pavlov+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_PRICE_H+#define LZMA_PRICE_H+++#define RC_MOVE_REDUCING_BITS 4+#define RC_BIT_PRICE_SHIFT_BITS 4+#define RC_PRICE_TABLE_SIZE (RC_BIT_MODEL_TOTAL >> RC_MOVE_REDUCING_BITS)++#define RC_INFINITY_PRICE (UINT32_C(1) << 30)+++/// Lookup table for the inline functions defined in this file.+lzma_attr_visibility_hidden+extern const uint8_t lzma_rc_prices[RC_PRICE_TABLE_SIZE];+++static inline uint32_t+rc_bit_price(const probability prob, const uint32_t bit)+{+ return lzma_rc_prices[(prob ^ ((UINT32_C(0) - bit)+ & (RC_BIT_MODEL_TOTAL - 1))) >> RC_MOVE_REDUCING_BITS];+}+++static inline uint32_t+rc_bit_0_price(const probability prob)+{+ return lzma_rc_prices[prob >> RC_MOVE_REDUCING_BITS];+}+++static inline uint32_t+rc_bit_1_price(const probability prob)+{+ return lzma_rc_prices[(prob ^ (RC_BIT_MODEL_TOTAL - 1))+ >> RC_MOVE_REDUCING_BITS];+}+++static inline uint32_t+rc_bittree_price(const probability *const probs,+ const uint32_t bit_levels, uint32_t symbol)+{+ uint32_t price = 0;+ symbol += UINT32_C(1) << bit_levels;++ do {+ const uint32_t bit = symbol & 1;+ symbol >>= 1;+ price += rc_bit_price(probs[symbol], bit);+ } while (symbol != 1);++ return price;+}+++static inline uint32_t+rc_bittree_reverse_price(const probability *const probs,+ uint32_t bit_levels, uint32_t symbol)+{+ uint32_t price = 0;+ uint32_t model_index = 1;++ do {+ const uint32_t bit = symbol & 1;+ symbol >>= 1;+ price += rc_bit_price(probs[model_index], bit);+ model_index = (model_index << 1) + bit;+ } while (--bit_levels != 0);++ return price;+}+++static inline uint32_t+rc_direct_price(const uint32_t bits)+{+ return bits << RC_BIT_PRICE_SHIFT_BITS;+}++#endif
+ cbits/liblzma/rangecoder/price_table.c view
@@ -0,0 +1,24 @@+// SPDX-License-Identifier: 0BSD++// This file has been generated by price_tablegen.c.++#include "range_encoder.h"++const uint8_t lzma_rc_prices[RC_PRICE_TABLE_SIZE] = {+ 128, 103, 91, 84, 78, 73, 69, 66,+ 63, 61, 58, 56, 54, 52, 51, 49,+ 48, 46, 45, 44, 43, 42, 41, 40,+ 39, 38, 37, 36, 35, 34, 34, 33,+ 32, 31, 31, 30, 29, 29, 28, 28,+ 27, 26, 26, 25, 25, 24, 24, 23,+ 23, 22, 22, 22, 21, 21, 20, 20,+ 19, 19, 19, 18, 18, 17, 17, 17,+ 16, 16, 16, 15, 15, 15, 14, 14,+ 14, 13, 13, 13, 12, 12, 12, 11,+ 11, 11, 11, 10, 10, 10, 10, 9,+ 9, 9, 9, 8, 8, 8, 8, 7,+ 7, 7, 7, 6, 6, 6, 6, 5,+ 5, 5, 5, 5, 4, 4, 4, 4,+ 3, 3, 3, 3, 3, 2, 2, 2,+ 2, 2, 2, 1, 1, 1, 1, 1+};
+ cbits/liblzma/rangecoder/price_tablegen.c view
@@ -0,0 +1,93 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file price_tablegen.c+/// \brief Probability price table generator+///+/// Compiling: gcc -std=c99 -o price_tablegen price_tablegen.c+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include <inttypes.h>+#include <stdio.h>++// Make it compile without common.h.+#define BUILDING_PRICE_TABLEGEN+#define lzma_attr_visibility_hidden++#include "range_common.h"+#include "price.h"+++static uint32_t rc_prices[RC_PRICE_TABLE_SIZE];+++static void+init_price_table(void)+{+ for (uint32_t i = (UINT32_C(1) << RC_MOVE_REDUCING_BITS) / 2;+ i < RC_BIT_MODEL_TOTAL;+ i += (UINT32_C(1) << RC_MOVE_REDUCING_BITS)) {+ const uint32_t cycles_bits = RC_BIT_PRICE_SHIFT_BITS;+ uint32_t w = i;+ uint32_t bit_count = 0;++ for (uint32_t j = 0; j < cycles_bits; ++j) {+ w *= w;+ bit_count <<= 1;++ while (w >= (UINT32_C(1) << 16)) {+ w >>= 1;+ ++bit_count;+ }+ }++ rc_prices[i >> RC_MOVE_REDUCING_BITS]+ = (RC_BIT_MODEL_TOTAL_BITS << cycles_bits)+ - 15 - bit_count;+ }++ return;+}+++static void+print_price_table(void)+{+ // Split the SPDX string so that it won't accidentally match+ // when tools search for the string.+ printf("// SPDX" "-License-Identifier" ": 0BSD\n\n"+ "// This file has been generated by price_tablegen.c.\n\n"+ "#include \"range_encoder.h\"\n\n"+ "const uint8_t lzma_rc_prices["+ "RC_PRICE_TABLE_SIZE] = {");++ const size_t array_size = sizeof(lzma_rc_prices)+ / sizeof(lzma_rc_prices[0]);+ for (size_t i = 0; i < array_size; ++i) {+ if (i % 8 == 0)+ printf("\n\t");++ printf("%4" PRIu32, rc_prices[i]);++ if (i != array_size - 1)+ printf(",");+ }++ printf("\n};\n");++ return;+}+++int+main(void)+{+ init_price_table();+ print_price_table();+ return 0;+}
+ cbits/liblzma/rangecoder/range_common.h view
@@ -0,0 +1,77 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file range_common.h+/// \brief Common things for range encoder and decoder+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_RANGE_COMMON_H+#define LZMA_RANGE_COMMON_H++// Skip common.h if building price_tablegen.c.+#ifndef BUILDING_PRICE_TABLEGEN+# include "common.h"+#endif+++///////////////+// Constants //+///////////////++#define RC_SHIFT_BITS 8+#define RC_TOP_BITS 24+#define RC_TOP_VALUE (UINT32_C(1) << RC_TOP_BITS)+#define RC_BIT_MODEL_TOTAL_BITS 11+#define RC_BIT_MODEL_TOTAL (UINT32_C(1) << RC_BIT_MODEL_TOTAL_BITS)+#define RC_MOVE_BITS 5+++////////////+// Macros //+////////////++// Resets the probability so that both 0 and 1 have probability of 50 %+#define bit_reset(prob) \+ prob = RC_BIT_MODEL_TOTAL >> 1++// This does the same for a complete bit tree.+// (A tree represented as an array.)+#define bittree_reset(probs, bit_levels) \+ for (uint32_t bt_i = 0; bt_i < (1 << (bit_levels)); ++bt_i) \+ bit_reset((probs)[bt_i])+++//////////////////////+// Type definitions //+//////////////////////++/// \brief Type of probabilities used with range coder+///+/// This needs to be at least 12-bit integer, so uint16_t is a logical choice.+/// However, on some architecture and compiler combinations, a bigger type+/// may give better speed, because the probability variables are accessed+/// a lot. On the other hand, bigger probability type increases cache+/// footprint, since there are 2 to 14 thousand probability variables in+/// LZMA (assuming the limit of lc + lp <= 4; with lc + lp <= 12 there+/// would be about 1.5 million variables).+///+/// With malicious files, the initialization speed of the LZMA decoder can+/// become important. In that case, smaller probability variables mean that+/// there is less bytes to write to RAM, which makes initialization faster.+/// With big probability type, the initialization can become so slow that it+/// can be a problem e.g. for email servers doing virus scanning.+///+/// I will be sticking to uint16_t unless some specific architectures+/// are *much* faster (20-50 %) with uint32_t.+///+/// Update in 2024: The branchless C and x86-64 assembly was written so that+/// probability is assumed to be uint16_t. (In contrast, LZMA SDK 23.01+/// assembly supports both types.)+typedef uint16_t probability;++#endif
+ cbits/liblzma/rangecoder/range_decoder.h view
@@ -0,0 +1,966 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file range_decoder.h+/// \brief Range Decoder+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_RANGE_DECODER_H+#define LZMA_RANGE_DECODER_H++#include "range_common.h"+++// Choose the range decoder variants to use using a bitmask.+// If no bits are set, only the basic version is used.+// If more than one version is selected for the same feature,+// the last one on the list below is used.+//+// Bitwise-or of the following enable branchless C versions:+// 0x01 normal bittrees+// 0x02 fixed-sized reverse bittrees+// 0x04 variable-sized reverse bittrees (not faster)+// 0x08 matched literal (not faster)+//+// GCC & Clang compatible x86-64 inline assembly:+// 0x010 normal bittrees+// 0x020 fixed-sized reverse bittrees+// 0x040 variable-sized reverse bittrees+// 0x080 matched literal+// 0x100 direct bits+//+// The default can be overridden at build time by defining+// LZMA_RANGE_DECODER_CONFIG to the desired mask.+//+// 2024-02-22: Feedback from benchmarks:+// - Brancless C (0x003) can be better than basic on x86-64 but often it's+// slightly worse on other archs. Since asm is much better on x86-64,+// branchless C is not used at all.+// - With x86-64 asm, there are slight differences between GCC and Clang+// and different processors. Overall 0x1F0 seems to be the best choice.+#ifndef LZMA_RANGE_DECODER_CONFIG+# if defined(__x86_64__) && !defined(__ILP32__) \+ && !defined(__NVCOMPILER) \+ && (defined(__GNUC__) || defined(__clang__))+# define LZMA_RANGE_DECODER_CONFIG 0x1F0+# else+# define LZMA_RANGE_DECODER_CONFIG 0+# endif+#endif+++// Negative RC_BIT_MODEL_TOTAL but the lowest RC_MOVE_BITS are flipped.+// This is useful for updating probability variables in branchless decoding:+//+// uint32_t decoded_bit = ...;+// probability tmp = RC_BIT_MODEL_OFFSET;+// tmp &= decoded_bit - 1;+// prob -= (prob + tmp) >> RC_MOVE_BITS;+#define RC_BIT_MODEL_OFFSET \+ ((UINT32_C(1) << RC_MOVE_BITS) - 1 - RC_BIT_MODEL_TOTAL)+++typedef struct {+ uint32_t range;+ uint32_t code;+ uint32_t init_bytes_left;+} lzma_range_decoder;+++/// Reads the first five bytes to initialize the range decoder.+static inline lzma_ret+rc_read_init(lzma_range_decoder *rc, const uint8_t *restrict in,+ size_t *restrict in_pos, size_t in_size)+{+ while (rc->init_bytes_left > 0) {+ if (*in_pos == in_size)+ return LZMA_OK;++ // The first byte is always 0x00. It could have been omitted+ // in LZMA2 but it wasn't, so one byte is wasted in every+ // LZMA2 chunk.+ if (rc->init_bytes_left == 5 && in[*in_pos] != 0x00)+ return LZMA_DATA_ERROR;++ rc->code = (rc->code << 8) | in[*in_pos];+ ++*in_pos;+ --rc->init_bytes_left;+ }++ return LZMA_STREAM_END;+}+++/// Makes local copies of range decoder and *in_pos variables. Doing this+/// improves speed significantly. The range decoder macros expect also+/// variables 'in' and 'in_size' to be defined.+#define rc_to_local(range_decoder, in_pos, fast_mode_in_required) \+ lzma_range_decoder rc = range_decoder; \+ const uint8_t *rc_in_ptr = in + (in_pos); \+ const uint8_t *rc_in_end = in + in_size; \+ const uint8_t *rc_in_fast_end \+ = (rc_in_end - rc_in_ptr) <= (fast_mode_in_required) \+ ? rc_in_ptr \+ : rc_in_end - (fast_mode_in_required); \+ (void)rc_in_fast_end; /* Silence a warning with HAVE_SMALL. */ \+ uint32_t rc_bound+++/// Evaluates to true if there is enough input remaining to use fast mode.+#define rc_is_fast_allowed() (rc_in_ptr < rc_in_fast_end)+++/// Stores the local copes back to the range decoder structure.+#define rc_from_local(range_decoder, in_pos) \+do { \+ range_decoder = rc; \+ in_pos = (size_t)(rc_in_ptr - in); \+} while (0)+++/// Resets the range decoder structure.+#define rc_reset(range_decoder) \+do { \+ (range_decoder).range = UINT32_MAX; \+ (range_decoder).code = 0; \+ (range_decoder).init_bytes_left = 5; \+} while (0)+++/// When decoding has been properly finished, rc.code is always zero unless+/// the input stream is corrupt. So checking this can catch some corrupt+/// files especially if they don't have any other integrity check.+#define rc_is_finished(range_decoder) \+ ((range_decoder).code == 0)+++// Read the next input byte if needed.+#define rc_normalize() \+do { \+ if (rc.range < RC_TOP_VALUE) { \+ rc.range <<= RC_SHIFT_BITS; \+ rc.code = (rc.code << RC_SHIFT_BITS) | *rc_in_ptr++; \+ } \+} while (0)+++/// If more input is needed but there is+/// no more input available, "goto out" is used to jump out of the main+/// decoder loop. The "_safe" macros are used in the Resumable decoder+/// mode in order to save the sequence to continue decoding from that+/// point later.+#define rc_normalize_safe(seq) \+do { \+ if (rc.range < RC_TOP_VALUE) { \+ if (rc_in_ptr == rc_in_end) { \+ coder->sequence = seq; \+ goto out; \+ } \+ rc.range <<= RC_SHIFT_BITS; \+ rc.code = (rc.code << RC_SHIFT_BITS) | *rc_in_ptr++; \+ } \+} while (0)+++/// Start decoding a bit. This must be used together with rc_update_0()+/// and rc_update_1():+///+/// rc_if_0(prob) {+/// rc_update_0(prob);+/// // Do something+/// } else {+/// rc_update_1(prob);+/// // Do something else+/// }+///+#define rc_if_0(prob) \+ rc_normalize(); \+ rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * (prob); \+ if (rc.code < rc_bound)+++#define rc_if_0_safe(prob, seq) \+ rc_normalize_safe(seq); \+ rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * (prob); \+ if (rc.code < rc_bound)+++/// Update the range decoder state and the used probability variable to+/// match a decoded bit of 0.+///+/// The x86-64 assembly uses the commented method but it seems that,+/// at least on x86-64, the first version is slightly faster as C code.+#define rc_update_0(prob) \+do { \+ rc.range = rc_bound; \+ prob += (RC_BIT_MODEL_TOTAL - (prob)) >> RC_MOVE_BITS; \+ /* prob -= ((prob) + RC_BIT_MODEL_OFFSET) >> RC_MOVE_BITS; */ \+} while (0)+++/// Update the range decoder state and the used probability variable to+/// match a decoded bit of 1.+#define rc_update_1(prob) \+do { \+ rc.range -= rc_bound; \+ rc.code -= rc_bound; \+ prob -= (prob) >> RC_MOVE_BITS; \+} while (0)+++/// Decodes one bit and runs action0 or action1 depending on the decoded bit.+/// This macro is used as the last step in bittree reverse decoders since+/// those don't use "symbol" for anything else than indexing the probability+/// arrays.+#define rc_bit_last(prob, action0, action1) \+do { \+ rc_if_0(prob) { \+ rc_update_0(prob); \+ action0; \+ } else { \+ rc_update_1(prob); \+ action1; \+ } \+} while (0)+++#define rc_bit_last_safe(prob, action0, action1, seq) \+do { \+ rc_if_0_safe(prob, seq) { \+ rc_update_0(prob); \+ action0; \+ } else { \+ rc_update_1(prob); \+ action1; \+ } \+} while (0)+++/// Decodes one bit, updates "symbol", and runs action0 or action1 depending+/// on the decoded bit.+#define rc_bit(prob, action0, action1) \+ rc_bit_last(prob, \+ symbol <<= 1; action0, \+ symbol = (symbol << 1) + 1; action1);+++#define rc_bit_safe(prob, action0, action1, seq) \+ rc_bit_last_safe(prob, \+ symbol <<= 1; action0, \+ symbol = (symbol << 1) + 1; action1, \+ seq);++// Unroll fixed-sized bittree decoding.+//+// A compile-time constant in final_add can be used to get rid of the high bit+// from symbol that is used for the array indexing (1U << bittree_bits).+// final_add may also be used to add offset to the result (LZMA length+// decoder does that).+//+// The reason to have final_add here is that in the asm code the addition+// can be done for free: in x86-64 there is SBB instruction with -1 as+// the immediate value, and final_add is combined with that value.+#define rc_bittree_bit(prob) \+ rc_bit(prob, , )++#define rc_bittree3(probs, final_add) \+do { \+ symbol = 1; \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ symbol += (uint32_t)(final_add); \+} while (0)++#define rc_bittree6(probs, final_add) \+do { \+ symbol = 1; \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ symbol += (uint32_t)(final_add); \+} while (0)++#define rc_bittree8(probs, final_add) \+do { \+ symbol = 1; \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ rc_bittree_bit(probs[symbol]); \+ symbol += (uint32_t)(final_add); \+} while (0)+++// Fixed-sized reverse bittree+#define rc_bittree_rev4(probs) \+do { \+ symbol = 0; \+ rc_bit_last(probs[symbol + 1], , symbol += 1); \+ rc_bit_last(probs[symbol + 2], , symbol += 2); \+ rc_bit_last(probs[symbol + 4], , symbol += 4); \+ rc_bit_last(probs[symbol + 8], , symbol += 8); \+} while (0)+++// Decode one bit from variable-sized reverse bittree. The loop is done+// in the code that uses this macro. This could be changed if the assembly+// version benefited from having the loop done in assembly but it didn't+// seem so in early 2024.+//+// Also, if the loop was done here, the loop counter would likely be local+// to the macro so that it wouldn't modify yet another input variable.+// If a _safe version of a macro with a loop was done then a modifiable+// input variable couldn't be avoided though.+#define rc_bit_add_if_1(probs, dest, value_to_add_if_1) \+ rc_bit(probs[symbol], \+ , \+ dest += value_to_add_if_1);+++// Matched literal+#define decode_with_match_bit \+ t_match_byte <<= 1; \+ t_match_bit = t_match_byte & t_offset; \+ t_subcoder_index = t_offset + t_match_bit + symbol; \+ rc_bit(probs[t_subcoder_index], \+ t_offset &= ~t_match_bit, \+ t_offset &= t_match_bit)++#define rc_matched_literal(probs_base_var, match_byte) \+do { \+ uint32_t t_match_byte = (match_byte); \+ uint32_t t_match_bit; \+ uint32_t t_subcoder_index; \+ uint32_t t_offset = 0x100; \+ symbol = 1; \+ decode_with_match_bit; \+ decode_with_match_bit; \+ decode_with_match_bit; \+ decode_with_match_bit; \+ decode_with_match_bit; \+ decode_with_match_bit; \+ decode_with_match_bit; \+ decode_with_match_bit; \+} while (0)+++/// Decode a bit without using a probability.+//+// NOTE: GCC 13 and Clang/LLVM 16 can, at least on x86-64, optimize the bound+// calculation to use an arithmetic right shift so there's no need to provide+// the alternative code which, according to C99/C11/C23 6.3.1.3-p3 isn't+// perfectly portable: rc_bound = (uint32_t)((int32_t)rc.code >> 31);+#define rc_direct(dest, count_var) \+do { \+ dest = (dest << 1) + 1; \+ rc_normalize(); \+ rc.range >>= 1; \+ rc.code -= rc.range; \+ rc_bound = UINT32_C(0) - (rc.code >> 31); \+ dest += rc_bound; \+ rc.code += rc.range & rc_bound; \+} while (--count_var > 0)++++#define rc_direct_safe(dest, count_var, seq) \+do { \+ rc_normalize_safe(seq); \+ rc.range >>= 1; \+ rc.code -= rc.range; \+ rc_bound = UINT32_C(0) - (rc.code >> 31); \+ rc.code += rc.range & rc_bound; \+ dest = (dest << 1) + (rc_bound + 1); \+} while (--count_var > 0)+++//////////////////+// Branchless C //+//////////////////++/// Decode a bit using a branchless method. This reduces the number of+/// mispredicted branches and thus can improve speed.+#define rc_c_bit(prob, action_bit, action_neg) \+do { \+ probability *p = &(prob); \+ rc_normalize(); \+ rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * *p; \+ uint32_t rc_mask = rc.code >= rc_bound; /* rc_mask = decoded bit */ \+ action_bit; /* action when rc_mask is 0 or 1 */ \+ /* rc_mask becomes 0 if bit is 0 and 0xFFFFFFFF if bit is 1: */ \+ rc_mask = 0U - rc_mask; \+ rc.range &= rc_mask; /* If bit 0: set rc.range = 0 */ \+ rc_bound ^= rc_mask; \+ rc_bound -= rc_mask; /* If bit 1: rc_bound = 0U - rc_bound */ \+ rc.range += rc_bound; \+ rc_bound &= rc_mask; \+ rc.code += rc_bound; \+ action_neg; /* action when rc_mask is 0 or 0xFFFFFFFF */ \+ rc_mask = ~rc_mask; /* If bit 0: all bits are set in rc_mask */ \+ rc_mask &= RC_BIT_MODEL_OFFSET; \+ *p -= (*p + rc_mask) >> RC_MOVE_BITS; \+} while (0)+++// Testing on x86-64 give an impression that only the normal bittrees and+// the fixed-sized reverse bittrees are worth the branchless C code.+// It should be tested on other archs for which there isn't assembly code+// in this file.++// Using addition in "(symbol << 1) + rc_mask" allows use of x86 LEA+// or RISC-V SH1ADD instructions. Compilers might infer it from+// "(symbol << 1) | rc_mask" too if they see that mask is 0 or 1 but+// the use of addition doesn't require such analysis from compilers.+#if LZMA_RANGE_DECODER_CONFIG & 0x01+#undef rc_bittree_bit+#define rc_bittree_bit(prob) \+ rc_c_bit(prob, \+ symbol = (symbol << 1) + rc_mask, \+ )+#endif // LZMA_RANGE_DECODER_CONFIG & 0x01++#if LZMA_RANGE_DECODER_CONFIG & 0x02+#undef rc_bittree_rev4+#define rc_bittree_rev4(probs) \+do { \+ symbol = 0; \+ rc_c_bit(probs[symbol + 1], symbol += rc_mask, ); \+ rc_c_bit(probs[symbol + 2], symbol += rc_mask << 1, ); \+ rc_c_bit(probs[symbol + 4], symbol += rc_mask << 2, ); \+ rc_c_bit(probs[symbol + 8], symbol += rc_mask << 3, ); \+} while (0)+#endif // LZMA_RANGE_DECODER_CONFIG & 0x02++#if LZMA_RANGE_DECODER_CONFIG & 0x04+#undef rc_bit_add_if_1+#define rc_bit_add_if_1(probs, dest, value_to_add_if_1) \+ rc_c_bit(probs[symbol], \+ symbol = (symbol << 1) + rc_mask, \+ dest += (value_to_add_if_1) & rc_mask)+#endif // LZMA_RANGE_DECODER_CONFIG & 0x04+++#if LZMA_RANGE_DECODER_CONFIG & 0x08+#undef decode_with_match_bit+#define decode_with_match_bit \+ t_match_byte <<= 1; \+ t_match_bit = t_match_byte & t_offset; \+ t_subcoder_index = t_offset + t_match_bit + symbol; \+ rc_c_bit(probs[t_subcoder_index], \+ symbol = (symbol << 1) + rc_mask, \+ t_offset &= ~t_match_bit ^ rc_mask)+#endif // LZMA_RANGE_DECODER_CONFIG & 0x08+++////////////+// x86-64 //+////////////++#if LZMA_RANGE_DECODER_CONFIG & 0x1F0++// rc_asm_y and rc_asm_n are used as arguments to macros to control which+// strings to include or omit.+#define rc_asm_y(str) str+#define rc_asm_n(str)++// There are a few possible variations for normalization.+// This is the smallest variant which is also used by LZMA SDK.+//+// - This has partial register write (the MOV from (%[in_ptr])).+//+// - INC saves one byte in code size over ADD. False dependency on+// partial flags from INC shouldn't become a problem on any processor+// because the instructions after normalization don't read the flags+// until SUB which sets all flags.+//+#define rc_asm_normalize \+ "cmp %[top_value], %[range]\n\t" \+ "jae 1f\n\t" \+ "shl %[shift_bits], %[code]\n\t" \+ "mov (%[in_ptr]), %b[code]\n\t" \+ "shl %[shift_bits], %[range]\n\t" \+ "inc %[in_ptr]\n" \+ "1:\n"++// rc_asm_calc(prob) is roughly equivalent to the C version of rc_if_0(prob)...+//+// rc_bound = (rc.range >> RC_BIT_MODEL_TOTAL_BITS) * (prob);+// if (rc.code < rc_bound)+//+// ...but the bound is stored in "range":+//+// t0 = range;+// range = (range >> RC_BIT_MODEL_TOTAL_BITS) * (prob);+// t0 -= range;+// t1 = code;+// code -= range;+//+// The carry flag (CF) from the last subtraction holds the negation of+// the decoded bit (if CF==0 then the decoded bit is 1).+// The values in t0 and t1 are needed for rc_update_0(prob) and+// rc_update_1(prob). If the bit is 0, rc_update_0(prob)...+//+// rc.range = rc_bound;+//+// ...has already been done but the "code -= range" has to be reverted using+// the old value stored in t1. (Also, prob needs to be updated.)+//+// If the bit is 1, rc_update_1(prob)...+//+// rc.range -= rc_bound;+// rc.code -= rc_bound;+//+// ...is already done for "code" but the value for "range" needs to be taken+// from t0. (Also, prob needs to be updated here as well.)+//+// The assignments from t0 and t1 can be done in a branchless manner with CMOV+// after the instructions from this macro. The CF from SUB tells which moves+// are needed.+#define rc_asm_calc(prob) \+ "mov %[range], %[t0]\n\t" \+ "shr %[bit_model_total_bits], %[range]\n\t" \+ "imul %[" prob "], %[range]\n\t" \+ "sub %[range], %[t0]\n\t" \+ "mov %[code], %[t1]\n\t" \+ "sub %[range], %[code]\n\t"++// Also, prob needs to be updated: The update math depends on the decoded bit.+// It can be expressed in a few slightly different ways but this is fairly+// convenient here:+//+// prob -= (prob + (bit ? 0 : RC_BIT_MODEL_OFFSET)) >> RC_MOVE_BITS;+//+// To do it in branchless way when the negation of the decoded bit is in CF,+// both "prob" and "prob + RC_BIT_MODEL_OFFSET" are needed. Then the desired+// value can be picked with CMOV. The addition can be done using LEA without+// affecting CF.+//+// (This prob update method is a tiny bit different from LZMA SDK 23.01.+// In the LZMA SDK a single register is reserved solely for a constant to+// be used with CMOV when updating prob. That is fine since there are enough+// free registers to do so. The method used here uses one fewer register,+// which is valuable with inline assembly.)+//+// * * *+//+// In bittree decoding, each (unrolled) loop iteration decodes one bit+// and needs one prob variable. To make it faster, the prob variable of+// the iteration N+1 is loaded during iteration N. There are two possible+// prob variables to choose from for N+1. Both are loaded from memory and+// the correct one is chosen with CMOV using the same CF as is used for+// other things described above.+//+// This preloading/prefetching requires an extra register. To avoid+// useless moves from "preloaded prob register" to "current prob register",+// the macros swap between the two registers for odd and even iterations.+//+// * * *+//+// Finally, the decoded bit has to be stored in "symbol". Since the negation+// of the bit is in CF, this can be done with SBB: symbol -= CF - 1. That is,+// if the decoded bit is 0 (CF==1) the operation is a no-op "symbol -= 0"+// and when bit is 1 (CF==0) the operation is "symbol -= 0 - 1" which is+// the same as "symbol += 1".+//+// The instructions for all things are intertwined for a few reasons:+// - freeing temporary registers for new use+// - not modifying CF too early+// - instruction scheduling+//+// The first and last iterations can cheat a little. For example,+// on the first iteration "symbol" is known to start from 1 so it+// doesn't need to be read; it can even be immediately initialized+// to 2 to prepare for the second iteration of the loop.+//+// * * *+//+// a = number of the current prob variable (0 or 1)+// b = number of the next prob variable (1 or 0)+// *_only = rc_asm_y or _n to include or exclude code marked with them+#define rc_asm_bittree(a, b, first_only, middle_only, last_only) \+ first_only( \+ "movzwl 2(%[probs_base]), %[prob" #a "]\n\t" \+ "mov $2, %[symbol]\n\t" \+ "movzwl 4(%[probs_base]), %[prob" #b "]\n\t" \+ ) \+ middle_only( \+ /* Note the scaling of 4 instead of 2: */ \+ "movzwl (%[probs_base], %q[symbol], 4), %[prob" #b "]\n\t" \+ ) \+ last_only( \+ "add %[symbol], %[symbol]\n\t" \+ ) \+ \+ rc_asm_normalize \+ rc_asm_calc("prob" #a) \+ \+ "cmovae %[t0], %[range]\n\t" \+ \+ first_only( \+ "movzwl 6(%[probs_base]), %[t0]\n\t" \+ "cmovae %[t0], %[prob" #b "]\n\t" \+ ) \+ middle_only( \+ "movzwl 2(%[probs_base], %q[symbol], 4), %[t0]\n\t" \+ "lea (%q[symbol], %q[symbol]), %[symbol]\n\t" \+ "cmovae %[t0], %[prob" #b "]\n\t" \+ ) \+ \+ "lea %c[bit_model_offset](%q[prob" #a "]), %[t0]\n\t" \+ "cmovb %[t1], %[code]\n\t" \+ "mov %[symbol], %[t1]\n\t" \+ "cmovae %[prob" #a "], %[t0]\n\t" \+ \+ first_only( \+ "sbb $-1, %[symbol]\n\t" \+ ) \+ middle_only( \+ "sbb $-1, %[symbol]\n\t" \+ ) \+ last_only( \+ "sbb %[last_sbb], %[symbol]\n\t" \+ ) \+ \+ "shr %[move_bits], %[t0]\n\t" \+ "sub %[t0], %[prob" #a "]\n\t" \+ /* Scaling of 1 instead of 2 because symbol <<= 1. */ \+ "mov %w[prob" #a "], (%[probs_base], %q[t1], 1)\n\t"++// NOTE: The order of variables in __asm__ can affect speed and code size.+#define rc_asm_bittree_n(probs_base_var, final_add, asm_str) \+do { \+ uint32_t t0; \+ uint32_t t1; \+ uint32_t t_prob0; \+ uint32_t t_prob1; \+ \+ __asm__( \+ asm_str \+ : \+ [range] "+&r"(rc.range), \+ [code] "+&r"(rc.code), \+ [t0] "=&r"(t0), \+ [t1] "=&r"(t1), \+ [prob0] "=&r"(t_prob0), \+ [prob1] "=&r"(t_prob1), \+ [symbol] "=&r"(symbol), \+ [in_ptr] "+&r"(rc_in_ptr) \+ : \+ [probs_base] "r"(probs_base_var), \+ [last_sbb] "n"(-1 - (final_add)), \+ [top_value] "n"(RC_TOP_VALUE), \+ [shift_bits] "n"(RC_SHIFT_BITS), \+ [bit_model_total_bits] "n"(RC_BIT_MODEL_TOTAL_BITS), \+ [bit_model_offset] "n"(RC_BIT_MODEL_OFFSET), \+ [move_bits] "n"(RC_MOVE_BITS) \+ : \+ "cc", "memory"); \+} while (0)+++#if LZMA_RANGE_DECODER_CONFIG & 0x010+#undef rc_bittree3+#define rc_bittree3(probs_base_var, final_add) \+ rc_asm_bittree_n(probs_base_var, final_add, \+ rc_asm_bittree(0, 1, rc_asm_y, rc_asm_n, rc_asm_n) \+ rc_asm_bittree(1, 0, rc_asm_n, rc_asm_y, rc_asm_n) \+ rc_asm_bittree(0, 1, rc_asm_n, rc_asm_n, rc_asm_y) \+ )++#undef rc_bittree6+#define rc_bittree6(probs_base_var, final_add) \+ rc_asm_bittree_n(probs_base_var, final_add, \+ rc_asm_bittree(0, 1, rc_asm_y, rc_asm_n, rc_asm_n) \+ rc_asm_bittree(1, 0, rc_asm_n, rc_asm_y, rc_asm_n) \+ rc_asm_bittree(0, 1, rc_asm_n, rc_asm_y, rc_asm_n) \+ rc_asm_bittree(1, 0, rc_asm_n, rc_asm_y, rc_asm_n) \+ rc_asm_bittree(0, 1, rc_asm_n, rc_asm_y, rc_asm_n) \+ rc_asm_bittree(1, 0, rc_asm_n, rc_asm_n, rc_asm_y) \+ )++#undef rc_bittree8+#define rc_bittree8(probs_base_var, final_add) \+ rc_asm_bittree_n(probs_base_var, final_add, \+ rc_asm_bittree(0, 1, rc_asm_y, rc_asm_n, rc_asm_n) \+ rc_asm_bittree(1, 0, rc_asm_n, rc_asm_y, rc_asm_n) \+ rc_asm_bittree(0, 1, rc_asm_n, rc_asm_y, rc_asm_n) \+ rc_asm_bittree(1, 0, rc_asm_n, rc_asm_y, rc_asm_n) \+ rc_asm_bittree(0, 1, rc_asm_n, rc_asm_y, rc_asm_n) \+ rc_asm_bittree(1, 0, rc_asm_n, rc_asm_y, rc_asm_n) \+ rc_asm_bittree(0, 1, rc_asm_n, rc_asm_y, rc_asm_n) \+ rc_asm_bittree(1, 0, rc_asm_n, rc_asm_n, rc_asm_y) \+ )+#endif // LZMA_RANGE_DECODER_CONFIG & 0x010+++// Fixed-sized reverse bittree+//+// This uses the indexing that constructs the final value in symbol directly.+// add = 1, 2, 4, 8+// dcur = -, 4, 8, 16+// dnext0 = 4, 8, 16, -+// dnext0 = 6, 12, 24, -+#define rc_asm_bittree_rev(a, b, add, dcur, dnext0, dnext1, \+ first_only, middle_only, last_only) \+ first_only( \+ "movzwl 2(%[probs_base]), %[prob" #a "]\n\t" \+ "xor %[symbol], %[symbol]\n\t" \+ "movzwl 4(%[probs_base]), %[prob" #b "]\n\t" \+ ) \+ middle_only( \+ "movzwl " #dnext0 "(%[probs_base], %q[symbol], 2), " \+ "%[prob" #b "]\n\t" \+ ) \+ \+ rc_asm_normalize \+ rc_asm_calc("prob" #a) \+ \+ "cmovae %[t0], %[range]\n\t" \+ \+ first_only( \+ "movzwl 6(%[probs_base]), %[t0]\n\t" \+ "cmovae %[t0], %[prob" #b "]\n\t" \+ ) \+ middle_only( \+ "movzwl " #dnext1 "(%[probs_base], %q[symbol], 2), %[t0]\n\t" \+ "cmovae %[t0], %[prob" #b "]\n\t" \+ ) \+ \+ "lea " #add "(%q[symbol]), %[t0]\n\t" \+ "cmovb %[t1], %[code]\n\t" \+ middle_only( \+ "mov %[symbol], %[t1]\n\t" \+ ) \+ last_only( \+ "mov %[symbol], %[t1]\n\t" \+ ) \+ "cmovae %[t0], %[symbol]\n\t" \+ "lea %c[bit_model_offset](%q[prob" #a "]), %[t0]\n\t" \+ "cmovae %[prob" #a "], %[t0]\n\t" \+ \+ "shr %[move_bits], %[t0]\n\t" \+ "sub %[t0], %[prob" #a "]\n\t" \+ first_only( \+ "mov %w[prob" #a "], 2(%[probs_base])\n\t" \+ ) \+ middle_only( \+ "mov %w[prob" #a "], " \+ #dcur "(%[probs_base], %q[t1], 2)\n\t" \+ ) \+ last_only( \+ "mov %w[prob" #a "], " \+ #dcur "(%[probs_base], %q[t1], 2)\n\t" \+ )++#if LZMA_RANGE_DECODER_CONFIG & 0x020+#undef rc_bittree_rev4+#define rc_bittree_rev4(probs_base_var) \+rc_asm_bittree_n(probs_base_var, 4, \+ rc_asm_bittree_rev(0, 1, 1, -, 4, 6, rc_asm_y, rc_asm_n, rc_asm_n) \+ rc_asm_bittree_rev(1, 0, 2, 4, 8, 12, rc_asm_n, rc_asm_y, rc_asm_n) \+ rc_asm_bittree_rev(0, 1, 4, 8, 16, 24, rc_asm_n, rc_asm_y, rc_asm_n) \+ rc_asm_bittree_rev(1, 0, 8, 16, -, -, rc_asm_n, rc_asm_n, rc_asm_y) \+)+#endif // LZMA_RANGE_DECODER_CONFIG & 0x020+++#if LZMA_RANGE_DECODER_CONFIG & 0x040+#undef rc_bit_add_if_1+#define rc_bit_add_if_1(probs_base_var, dest_var, value_to_add_if_1) \+do { \+ uint32_t t0; \+ uint32_t t1; \+ uint32_t t2 = (value_to_add_if_1); \+ uint32_t t_prob; \+ uint32_t t_index; \+ \+ __asm__( \+ "movzwl (%[probs_base], %q[symbol], 2), %[prob]\n\t" \+ "mov %[symbol], %[index]\n\t" \+ \+ "add %[dest], %[t2]\n\t" \+ "add %[symbol], %[symbol]\n\t" \+ \+ rc_asm_normalize \+ rc_asm_calc("prob") \+ \+ "cmovae %[t0], %[range]\n\t" \+ "lea %c[bit_model_offset](%q[prob]), %[t0]\n\t" \+ "cmovb %[t1], %[code]\n\t" \+ "cmovae %[prob], %[t0]\n\t" \+ \+ "cmovae %[t2], %[dest]\n\t" \+ "sbb $-1, %[symbol]\n\t" \+ \+ "sar %[move_bits], %[t0]\n\t" \+ "sub %[t0], %[prob]\n\t" \+ "mov %w[prob], (%[probs_base], %q[index], 2)" \+ : \+ [range] "+&r"(rc.range), \+ [code] "+&r"(rc.code), \+ [t0] "=&r"(t0), \+ [t1] "=&r"(t1), \+ [prob] "=&r"(t_prob), \+ [index] "=&r"(t_index), \+ [symbol] "+&r"(symbol), \+ [t2] "+&r"(t2), \+ [dest] "+&r"(dest_var), \+ [in_ptr] "+&r"(rc_in_ptr) \+ : \+ [probs_base] "r"(probs_base_var), \+ [top_value] "n"(RC_TOP_VALUE), \+ [shift_bits] "n"(RC_SHIFT_BITS), \+ [bit_model_total_bits] "n"(RC_BIT_MODEL_TOTAL_BITS), \+ [bit_model_offset] "n"(RC_BIT_MODEL_OFFSET), \+ [move_bits] "n"(RC_MOVE_BITS) \+ : \+ "cc", "memory"); \+} while (0)+#endif // LZMA_RANGE_DECODER_CONFIG & 0x040+++// Literal decoding uses a normal 8-bit bittree but literal with match byte+// is more complex in picking the probability variable from the correct+// subtree. This doesn't use preloading/prefetching of the next prob because+// there are four choices instead of two.+//+// FIXME? The first iteration starts with symbol = 1 so it could be optimized+// by a tiny amount.+#define rc_asm_matched_literal(nonlast_only) \+ "add %[offset], %[symbol]\n\t" \+ "and %[offset], %[match_bit]\n\t" \+ "add %[match_bit], %[symbol]\n\t" \+ \+ "movzwl (%[probs_base], %q[symbol], 2), %[prob]\n\t" \+ \+ "add %[symbol], %[symbol]\n\t" \+ \+ nonlast_only( \+ "xor %[match_bit], %[offset]\n\t" \+ "add %[match_byte], %[match_byte]\n\t" \+ ) \+ \+ rc_asm_normalize \+ rc_asm_calc("prob") \+ \+ "cmovae %[t0], %[range]\n\t" \+ "lea %c[bit_model_offset](%q[prob]), %[t0]\n\t" \+ "cmovb %[t1], %[code]\n\t" \+ "mov %[symbol], %[t1]\n\t" \+ "cmovae %[prob], %[t0]\n\t" \+ \+ nonlast_only( \+ "cmovae %[match_bit], %[offset]\n\t" \+ "mov %[match_byte], %[match_bit]\n\t" \+ ) \+ \+ "sbb $-1, %[symbol]\n\t" \+ \+ "shr %[move_bits], %[t0]\n\t" \+ /* Undo symbol += match_bit + offset: */ \+ "and $0x1FF, %[symbol]\n\t" \+ "sub %[t0], %[prob]\n\t" \+ \+ /* Scaling of 1 instead of 2 because symbol <<= 1. */ \+ "mov %w[prob], (%[probs_base], %q[t1], 1)\n\t"+++#if LZMA_RANGE_DECODER_CONFIG & 0x080+#undef rc_matched_literal+#define rc_matched_literal(probs_base_var, match_byte_value) \+do { \+ uint32_t t0; \+ uint32_t t1; \+ uint32_t t_prob; \+ uint32_t t_match_byte = (uint32_t)(match_byte_value) << 1; \+ uint32_t t_match_bit = t_match_byte; \+ uint32_t t_offset = 0x100; \+ symbol = 1; \+ \+ __asm__( \+ rc_asm_matched_literal(rc_asm_y) \+ rc_asm_matched_literal(rc_asm_y) \+ rc_asm_matched_literal(rc_asm_y) \+ rc_asm_matched_literal(rc_asm_y) \+ rc_asm_matched_literal(rc_asm_y) \+ rc_asm_matched_literal(rc_asm_y) \+ rc_asm_matched_literal(rc_asm_y) \+ rc_asm_matched_literal(rc_asm_n) \+ : \+ [range] "+&r"(rc.range), \+ [code] "+&r"(rc.code), \+ [t0] "=&r"(t0), \+ [t1] "=&r"(t1), \+ [prob] "=&r"(t_prob), \+ [match_bit] "+&r"(t_match_bit), \+ [symbol] "+&r"(symbol), \+ [match_byte] "+&r"(t_match_byte), \+ [offset] "+&r"(t_offset), \+ [in_ptr] "+&r"(rc_in_ptr) \+ : \+ [probs_base] "r"(probs_base_var), \+ [top_value] "n"(RC_TOP_VALUE), \+ [shift_bits] "n"(RC_SHIFT_BITS), \+ [bit_model_total_bits] "n"(RC_BIT_MODEL_TOTAL_BITS), \+ [bit_model_offset] "n"(RC_BIT_MODEL_OFFSET), \+ [move_bits] "n"(RC_MOVE_BITS) \+ : \+ "cc", "memory"); \+} while (0)+#endif // LZMA_RANGE_DECODER_CONFIG & 0x080+++// Doing the loop in asm instead of C seems to help a little.+#if LZMA_RANGE_DECODER_CONFIG & 0x100+#undef rc_direct+#define rc_direct(dest_var, count_var) \+do { \+ uint32_t t0; \+ uint32_t t1; \+ \+ __asm__( \+ "2:\n\t" \+ "add %[dest], %[dest]\n\t" \+ "lea 1(%q[dest]), %[t1]\n\t" \+ \+ rc_asm_normalize \+ \+ "shr $1, %[range]\n\t" \+ "mov %[code], %[t0]\n\t" \+ "sub %[range], %[code]\n\t" \+ "cmovns %[t1], %[dest]\n\t" \+ "cmovs %[t0], %[code]\n\t" \+ "dec %[count]\n\t" \+ "jnz 2b\n\t" \+ : \+ [range] "+&r"(rc.range), \+ [code] "+&r"(rc.code), \+ [t0] "=&r"(t0), \+ [t1] "=&r"(t1), \+ [dest] "+&r"(dest_var), \+ [count] "+&r"(count_var), \+ [in_ptr] "+&r"(rc_in_ptr) \+ : \+ [top_value] "n"(RC_TOP_VALUE), \+ [shift_bits] "n"(RC_SHIFT_BITS) \+ : \+ "cc", "memory"); \+} while (0)+#endif // LZMA_RANGE_DECODER_CONFIG & 0x100++#endif // x86_64++#endif
+ cbits/liblzma/rangecoder/range_encoder.h view
@@ -0,0 +1,349 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file range_encoder.h+/// \brief Range Encoder+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_RANGE_ENCODER_H+#define LZMA_RANGE_ENCODER_H++#include "range_common.h"+#include "price.h"+++/// Maximum number of symbols that can be put pending into lzma_range_encoder+/// structure between calls to lzma_rc_encode(). For LZMA, 48+5 is enough+/// (match with big distance and length followed by range encoder flush).+#define RC_SYMBOLS_MAX 53+++typedef struct {+ uint64_t low;+ uint64_t cache_size;+ uint32_t range;+ uint8_t cache;++ /// Number of bytes written out by rc_encode() -> rc_shift_low()+ uint64_t out_total;++ /// Number of symbols in the tables+ size_t count;++ /// rc_encode()'s position in the tables+ size_t pos;++ /// Symbols to encode+ enum {+ RC_BIT_0,+ RC_BIT_1,+ RC_DIRECT_0,+ RC_DIRECT_1,+ RC_FLUSH,+ } symbols[RC_SYMBOLS_MAX];++ /// Probabilities associated with RC_BIT_0 or RC_BIT_1+ probability *probs[RC_SYMBOLS_MAX];++} lzma_range_encoder;+++static inline void+rc_reset(lzma_range_encoder *rc)+{+ rc->low = 0;+ rc->cache_size = 1;+ rc->range = UINT32_MAX;+ rc->cache = 0;+ rc->out_total = 0;+ rc->count = 0;+ rc->pos = 0;+}+++static inline void+rc_forget(lzma_range_encoder *rc)+{+ // This must not be called when rc_encode() is partially done.+ assert(rc->pos == 0);+ rc->count = 0;+}+++static inline void+rc_bit(lzma_range_encoder *rc, probability *prob, uint32_t bit)+{+ rc->symbols[rc->count] = bit;+ rc->probs[rc->count] = prob;+ ++rc->count;+}+++static inline void+rc_bittree(lzma_range_encoder *rc, probability *probs,+ uint32_t bit_count, uint32_t symbol)+{+ uint32_t model_index = 1;++ do {+ const uint32_t bit = (symbol >> --bit_count) & 1;+ rc_bit(rc, &probs[model_index], bit);+ model_index = (model_index << 1) + bit;+ } while (bit_count != 0);+}+++static inline void+rc_bittree_reverse(lzma_range_encoder *rc, probability *probs,+ uint32_t bit_count, uint32_t symbol)+{+ uint32_t model_index = 1;++ do {+ const uint32_t bit = symbol & 1;+ symbol >>= 1;+ rc_bit(rc, &probs[model_index], bit);+ model_index = (model_index << 1) + bit;+ } while (--bit_count != 0);+}+++static inline void+rc_direct(lzma_range_encoder *rc,+ uint32_t value, uint32_t bit_count)+{+ do {+ rc->symbols[rc->count++]+ = RC_DIRECT_0 + ((value >> --bit_count) & 1);+ } while (bit_count != 0);+}+++static inline void+rc_flush(lzma_range_encoder *rc)+{+ for (size_t i = 0; i < 5; ++i)+ rc->symbols[rc->count++] = RC_FLUSH;+}+++static inline bool+rc_shift_low(lzma_range_encoder *rc,+ uint8_t *out, size_t *out_pos, size_t out_size)+{+ if ((uint32_t)(rc->low) < (uint32_t)(0xFF000000)+ || (uint32_t)(rc->low >> 32) != 0) {+ do {+ if (*out_pos == out_size)+ return true;++ out[*out_pos] = rc->cache + (uint8_t)(rc->low >> 32);+ ++*out_pos;+ ++rc->out_total;+ rc->cache = 0xFF;++ } while (--rc->cache_size != 0);++ rc->cache = (rc->low >> 24) & 0xFF;+ }++ ++rc->cache_size;+ rc->low = (rc->low & 0x00FFFFFF) << RC_SHIFT_BITS;++ return false;+}+++// NOTE: The last two arguments are uint64_t instead of size_t because in+// the dummy version these refer to the size of the whole range-encoded+// output stream, not just to the currently available output buffer space.+static inline bool+rc_shift_low_dummy(uint64_t *low, uint64_t *cache_size, uint8_t *cache,+ uint64_t *out_pos, uint64_t out_size)+{+ if ((uint32_t)(*low) < (uint32_t)(0xFF000000)+ || (uint32_t)(*low >> 32) != 0) {+ do {+ if (*out_pos == out_size)+ return true;++ ++*out_pos;+ *cache = 0xFF;++ } while (--*cache_size != 0);++ *cache = (*low >> 24) & 0xFF;+ }++ ++*cache_size;+ *low = (*low & 0x00FFFFFF) << RC_SHIFT_BITS;++ return false;+}+++static inline bool+rc_encode(lzma_range_encoder *rc,+ uint8_t *out, size_t *out_pos, size_t out_size)+{+ assert(rc->count <= RC_SYMBOLS_MAX);++ while (rc->pos < rc->count) {+ // Normalize+ if (rc->range < RC_TOP_VALUE) {+ if (rc_shift_low(rc, out, out_pos, out_size))+ return true;++ rc->range <<= RC_SHIFT_BITS;+ }++ // Encode a bit+ switch (rc->symbols[rc->pos]) {+ case RC_BIT_0: {+ probability prob = *rc->probs[rc->pos];+ rc->range = (rc->range >> RC_BIT_MODEL_TOTAL_BITS)+ * prob;+ prob += (RC_BIT_MODEL_TOTAL - prob) >> RC_MOVE_BITS;+ *rc->probs[rc->pos] = prob;+ break;+ }++ case RC_BIT_1: {+ probability prob = *rc->probs[rc->pos];+ const uint32_t bound = prob * (rc->range+ >> RC_BIT_MODEL_TOTAL_BITS);+ rc->low += bound;+ rc->range -= bound;+ prob -= prob >> RC_MOVE_BITS;+ *rc->probs[rc->pos] = prob;+ break;+ }++ case RC_DIRECT_0:+ rc->range >>= 1;+ break;++ case RC_DIRECT_1:+ rc->range >>= 1;+ rc->low += rc->range;+ break;++ case RC_FLUSH:+ // Prevent further normalizations.+ rc->range = UINT32_MAX;++ // Flush the last five bytes (see rc_flush()).+ do {+ if (rc_shift_low(rc, out, out_pos, out_size))+ return true;+ } while (++rc->pos < rc->count);++ // Reset the range encoder so we are ready to continue+ // encoding if we weren't finishing the stream.+ rc_reset(rc);+ return false;++ default:+ assert(0);+ break;+ }++ ++rc->pos;+ }++ rc->count = 0;+ rc->pos = 0;++ return false;+}+++static inline bool+rc_encode_dummy(const lzma_range_encoder *rc, uint64_t out_limit)+{+ assert(rc->count <= RC_SYMBOLS_MAX);++ uint64_t low = rc->low;+ uint64_t cache_size = rc->cache_size;+ uint32_t range = rc->range;+ uint8_t cache = rc->cache;+ uint64_t out_pos = rc->out_total;++ size_t pos = rc->pos;++ while (true) {+ // Normalize+ if (range < RC_TOP_VALUE) {+ if (rc_shift_low_dummy(&low, &cache_size, &cache,+ &out_pos, out_limit))+ return true;++ range <<= RC_SHIFT_BITS;+ }++ // This check is here because the normalization above must+ // be done before flushing the last bytes.+ if (pos == rc->count)+ break;++ // Encode a bit+ switch (rc->symbols[pos]) {+ case RC_BIT_0: {+ probability prob = *rc->probs[pos];+ range = (range >> RC_BIT_MODEL_TOTAL_BITS)+ * prob;+ break;+ }++ case RC_BIT_1: {+ probability prob = *rc->probs[pos];+ const uint32_t bound = prob * (range+ >> RC_BIT_MODEL_TOTAL_BITS);+ low += bound;+ range -= bound;+ break;+ }++ case RC_DIRECT_0:+ range >>= 1;+ break;++ case RC_DIRECT_1:+ range >>= 1;+ low += range;+ break;++ case RC_FLUSH:+ default:+ assert(0);+ break;+ }++ ++pos;+ }++ // Flush the last bytes. This isn't in rc->symbols[] so we do+ // it after the above loop to take into account the size of+ // the flushing that will be done at the end of the stream.+ for (pos = 0; pos < 5; ++pos) {+ if (rc_shift_low_dummy(&low, &cache_size,+ &cache, &out_pos, out_limit))+ return true;+ }++ return false;+}+++static inline uint64_t+rc_pending(const lzma_range_encoder *rc)+{+ return rc->cache_size + 5 - 1;+}++#endif
+ cbits/liblzma/simple/arm.c view
@@ -0,0 +1,74 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file arm.c+/// \brief Filter for ARM binaries+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "simple_private.h"+++static size_t+arm_code(void *simple lzma_attribute((__unused__)),+ uint32_t now_pos, bool is_encoder,+ uint8_t *buffer, size_t size)+{+ size_t i;+ for (i = 0; i + 4 <= size; i += 4) {+ if (buffer[i + 3] == 0xEB) {+ uint32_t src = ((uint32_t)(buffer[i + 2]) << 16)+ | ((uint32_t)(buffer[i + 1]) << 8)+ | (uint32_t)(buffer[i + 0]);+ src <<= 2;++ uint32_t dest;+ if (is_encoder)+ dest = now_pos + (uint32_t)(i) + 8 + src;+ else+ dest = src - (now_pos + (uint32_t)(i) + 8);++ dest >>= 2;+ buffer[i + 2] = (dest >> 16);+ buffer[i + 1] = (dest >> 8);+ buffer[i + 0] = dest;+ }+ }++ return i;+}+++static lzma_ret+arm_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters, bool is_encoder)+{+ return lzma_simple_coder_init(next, allocator, filters,+ &arm_code, 0, 4, 4, is_encoder);+}+++#ifdef HAVE_ENCODER_ARM+extern lzma_ret+lzma_simple_arm_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return arm_coder_init(next, allocator, filters, true);+}+#endif+++#ifdef HAVE_DECODER_ARM+extern lzma_ret+lzma_simple_arm_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return arm_coder_init(next, allocator, filters, false);+}+#endif
+ cbits/liblzma/simple/arm64.c view
@@ -0,0 +1,136 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file arm64.c+/// \brief Filter for ARM64 binaries+///+/// This converts ARM64 relative addresses in the BL and ADRP immediates+/// to absolute values to increase redundancy of ARM64 code.+///+/// Converting B or ADR instructions was also tested but it's not useful.+/// A majority of the jumps for the B instruction are very small (+/- 0xFF).+/// These are typical for loops and if-statements. Encoding them to their+/// absolute address reduces redundancy since many of the small relative+/// jump values are repeated, but very few of the absolute addresses are.+//+// Authors: Lasse Collin+// Jia Tan+// Igor Pavlov+//+///////////////////////////////////////////////////////////////////////////////++#include "simple_private.h"+++static size_t+arm64_code(void *simple lzma_attribute((__unused__)),+ uint32_t now_pos, bool is_encoder,+ uint8_t *buffer, size_t size)+{+ size_t i;++ // Clang 14.0.6 on x86-64 makes this four times bigger and 40 % slower+ // with auto-vectorization that is enabled by default with -O2.+ // Such vectorization bloat happens with -O2 when targeting ARM64 too+ // but performance hasn't been tested.+#ifdef __clang__+# pragma clang loop vectorize(disable)+#endif+ for (i = 0; i + 4 <= size; i += 4) {+ uint32_t pc = (uint32_t)(now_pos + i);+ uint32_t instr = read32le(buffer + i);++ if ((instr >> 26) == 0x25) {+ // BL instruction:+ // The full 26-bit immediate is converted.+ // The range is +/-128 MiB.+ //+ // Using the full range helps quite a lot with+ // big executables. Smaller range would reduce false+ // positives in non-code sections of the input though+ // so this is a compromise that slightly favors big+ // files. With the full range, only six bits of the 32+ // need to match to trigger a conversion.+ const uint32_t src = instr;+ instr = 0x94000000;++ pc >>= 2;+ if (!is_encoder)+ pc = 0U - pc;++ instr |= (src + pc) & 0x03FFFFFF;+ write32le(buffer + i, instr);++ } else if ((instr & 0x9F000000) == 0x90000000) {+ // ADRP instruction:+ // Only values in the range +/-512 MiB are converted.+ //+ // Using less than the full +/-4 GiB range reduces+ // false positives on non-code sections of the input+ // while being excellent for executables up to 512 MiB.+ // The positive effect of ADRP conversion is smaller+ // than that of BL but it also doesn't hurt so much in+ // non-code sections of input because, with +/-512 MiB+ // range, nine bits of 32 need to match to trigger a+ // conversion (two 10-bit match choices = 9 bits).+ const uint32_t src = ((instr >> 29) & 3)+ | ((instr >> 3) & 0x001FFFFC);++ // With the addition only one branch is needed to+ // check the +/- range. This is usually false when+ // processing ARM64 code so branch prediction will+ // handle it well in terms of performance.+ //+ //if ((src & 0x001E0000) != 0+ // && (src & 0x001E0000) != 0x001E0000)+ if ((src + 0x00020000) & 0x001C0000)+ continue;++ instr &= 0x9000001F;++ pc >>= 12;+ if (!is_encoder)+ pc = 0U - pc;++ const uint32_t dest = src + pc;+ instr |= (dest & 3) << 29;+ instr |= (dest & 0x0003FFFC) << 3;+ instr |= (0U - (dest & 0x00020000)) & 0x00E00000;+ write32le(buffer + i, instr);+ }+ }++ return i;+}+++static lzma_ret+arm64_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters, bool is_encoder)+{+ return lzma_simple_coder_init(next, allocator, filters,+ &arm64_code, 0, 4, 4, is_encoder);+}+++#ifdef HAVE_ENCODER_ARM64+extern lzma_ret+lzma_simple_arm64_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return arm64_coder_init(next, allocator, filters, true);+}+#endif+++#ifdef HAVE_DECODER_ARM64+extern lzma_ret+lzma_simple_arm64_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return arm64_coder_init(next, allocator, filters, false);+}+#endif
+ cbits/liblzma/simple/armthumb.c view
@@ -0,0 +1,79 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file armthumb.c+/// \brief Filter for ARM-Thumb binaries+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "simple_private.h"+++static size_t+armthumb_code(void *simple lzma_attribute((__unused__)),+ uint32_t now_pos, bool is_encoder,+ uint8_t *buffer, size_t size)+{+ size_t i;+ for (i = 0; i + 4 <= size; i += 2) {+ if ((buffer[i + 1] & 0xF8) == 0xF0+ && (buffer[i + 3] & 0xF8) == 0xF8) {+ uint32_t src = (((uint32_t)(buffer[i + 1]) & 7) << 19)+ | ((uint32_t)(buffer[i + 0]) << 11)+ | (((uint32_t)(buffer[i + 3]) & 7) << 8)+ | (uint32_t)(buffer[i + 2]);++ src <<= 1;++ uint32_t dest;+ if (is_encoder)+ dest = now_pos + (uint32_t)(i) + 4 + src;+ else+ dest = src - (now_pos + (uint32_t)(i) + 4);++ dest >>= 1;+ buffer[i + 1] = 0xF0 | ((dest >> 19) & 0x7);+ buffer[i + 0] = (dest >> 11);+ buffer[i + 3] = 0xF8 | ((dest >> 8) & 0x7);+ buffer[i + 2] = (dest);+ i += 2;+ }+ }++ return i;+}+++static lzma_ret+armthumb_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters, bool is_encoder)+{+ return lzma_simple_coder_init(next, allocator, filters,+ &armthumb_code, 0, 4, 2, is_encoder);+}+++#ifdef HAVE_ENCODER_ARMTHUMB+extern lzma_ret+lzma_simple_armthumb_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return armthumb_coder_init(next, allocator, filters, true);+}+#endif+++#ifdef HAVE_DECODER_ARMTHUMB+extern lzma_ret+lzma_simple_armthumb_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return armthumb_coder_init(next, allocator, filters, false);+}+#endif
+ cbits/liblzma/simple/ia64.c view
@@ -0,0 +1,115 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file ia64.c+/// \brief Filter for IA64 (Itanium) binaries+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "simple_private.h"+++static size_t+ia64_code(void *simple lzma_attribute((__unused__)),+ uint32_t now_pos, bool is_encoder,+ uint8_t *buffer, size_t size)+{+ static const uint32_t BRANCH_TABLE[32] = {+ 0, 0, 0, 0, 0, 0, 0, 0,+ 0, 0, 0, 0, 0, 0, 0, 0,+ 4, 4, 6, 6, 0, 0, 7, 7,+ 4, 4, 0, 0, 4, 4, 0, 0+ };++ size_t i;+ for (i = 0; i + 16 <= size; i += 16) {+ const uint32_t instr_template = buffer[i] & 0x1F;+ const uint32_t mask = BRANCH_TABLE[instr_template];+ uint32_t bit_pos = 5;++ for (size_t slot = 0; slot < 3; ++slot, bit_pos += 41) {+ if (((mask >> slot) & 1) == 0)+ continue;++ const size_t byte_pos = (bit_pos >> 3);+ const uint32_t bit_res = bit_pos & 0x7;+ uint64_t instruction = 0;++ for (size_t j = 0; j < 6; ++j)+ instruction += (uint64_t)(+ buffer[i + j + byte_pos])+ << (8 * j);++ uint64_t inst_norm = instruction >> bit_res;++ if (((inst_norm >> 37) & 0xF) == 0x5+ && ((inst_norm >> 9) & 0x7) == 0+ /* && (inst_norm & 0x3F)== 0 */+ ) {+ uint32_t src = (uint32_t)(+ (inst_norm >> 13) & 0xFFFFF);+ src |= ((inst_norm >> 36) & 1) << 20;++ src <<= 4;++ uint32_t dest;+ if (is_encoder)+ dest = now_pos + (uint32_t)(i) + src;+ else+ dest = src - (now_pos + (uint32_t)(i));++ dest >>= 4;++ inst_norm &= ~((uint64_t)(0x8FFFFF) << 13);+ inst_norm |= (uint64_t)(dest & 0xFFFFF) << 13;+ inst_norm |= (uint64_t)(dest & 0x100000)+ << (36 - 20);++ instruction &= (1U << bit_res) - 1;+ instruction |= (inst_norm << bit_res);++ for (size_t j = 0; j < 6; j++)+ buffer[i + j + byte_pos] = (uint8_t)(+ instruction+ >> (8 * j));+ }+ }+ }++ return i;+}+++static lzma_ret+ia64_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters, bool is_encoder)+{+ return lzma_simple_coder_init(next, allocator, filters,+ &ia64_code, 0, 16, 16, is_encoder);+}+++#ifdef HAVE_ENCODER_IA64+extern lzma_ret+lzma_simple_ia64_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return ia64_coder_init(next, allocator, filters, true);+}+#endif+++#ifdef HAVE_DECODER_IA64+extern lzma_ret+lzma_simple_ia64_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return ia64_coder_init(next, allocator, filters, false);+}+#endif
+ cbits/liblzma/simple/powerpc.c view
@@ -0,0 +1,79 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file powerpc.c+/// \brief Filter for PowerPC (big endian) binaries+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "simple_private.h"+++static size_t+powerpc_code(void *simple lzma_attribute((__unused__)),+ uint32_t now_pos, bool is_encoder,+ uint8_t *buffer, size_t size)+{+ size_t i;+ for (i = 0; i + 4 <= size; i += 4) {+ // PowerPC branch 6(48) 24(Offset) 1(Abs) 1(Link)+ if ((buffer[i] >> 2) == 0x12+ && ((buffer[i + 3] & 3) == 1)) {++ const uint32_t src+ = (((uint32_t)(buffer[i + 0]) & 3) << 24)+ | ((uint32_t)(buffer[i + 1]) << 16)+ | ((uint32_t)(buffer[i + 2]) << 8)+ | ((uint32_t)(buffer[i + 3]) & ~UINT32_C(3));++ uint32_t dest;+ if (is_encoder)+ dest = now_pos + (uint32_t)(i) + src;+ else+ dest = src - (now_pos + (uint32_t)(i));++ buffer[i + 0] = 0x48 | ((dest >> 24) & 0x03);+ buffer[i + 1] = (dest >> 16);+ buffer[i + 2] = (dest >> 8);+ buffer[i + 3] &= 0x03;+ buffer[i + 3] |= dest;+ }+ }++ return i;+}+++static lzma_ret+powerpc_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters, bool is_encoder)+{+ return lzma_simple_coder_init(next, allocator, filters,+ &powerpc_code, 0, 4, 4, is_encoder);+}+++#ifdef HAVE_ENCODER_POWERPC+extern lzma_ret+lzma_simple_powerpc_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return powerpc_coder_init(next, allocator, filters, true);+}+#endif+++#ifdef HAVE_DECODER_POWERPC+extern lzma_ret+lzma_simple_powerpc_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return powerpc_coder_init(next, allocator, filters, false);+}+#endif
+ cbits/liblzma/simple/riscv.c view
@@ -0,0 +1,755 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file riscv.c+/// \brief Filter for 32-bit/64-bit little/big endian RISC-V binaries+///+/// This converts program counter relative addresses in function calls+/// (JAL, AUIPC+JALR), address calculation of functions and global+/// variables (AUIPC+ADDI), loads (AUIPC+load), and stores (AUIPC+store).+///+/// For AUIPC+inst2 pairs, the paired instruction checking is fairly relaxed.+/// The paired instruction opcode must only have its lowest two bits set,+/// meaning it will convert any paired instruction that is not a 16-bit+/// compressed instruction. This was shown to be enough to keep the number+/// of false matches low while improving code size and speed.+//+// Authors: Lasse Collin+// Jia Tan+//+// Special thanks:+//+// - Chien Wong <m@xv97.com> provided a few early versions of RISC-V+// filter variants along with test files and benchmark results.+//+// - Igor Pavlov helped a lot in the filter design, getting it both+// faster and smaller. The implementation here is still independently+// written, not based on LZMA SDK.+//+///////////////////////////////////////////////////////////////////////////////++/*++RISC-V filtering+================++ RV32I and RV64I, possibly combined with extensions C, Zfh, F, D,+ and Q, are identical enough that the same filter works for both.++ The instruction encoding is always little endian, even on systems+ with big endian data access. Thus the same filter works for both+ endiannesses.++ The following instructions have program counter relative+ (pc-relative) behavior:++JAL+---++ JAL is used for function calls (including tail calls) and+ unconditional jumps within functions. Jumps within functions+ aren't useful to filter because the absolute addresses often+ appear only once or at most a few times. Tail calls and jumps+ within functions look the same to a simple filter so neither+ are filtered, that is, JAL x0 is ignored (the ABI name of the+ register x0 is "zero").++ Almost all calls store the return address to register x1 (ra)+ or x5 (t0). To reduce false matches when the filter is applied+ to non-code data, only the JAL instructions that use x1 or x5+ are converted. JAL has pc-relative range of +/-1 MiB so longer+ calls and jumps need another method (AUIPC+JALR).++C.J and C.JAL+-------------++ C.J and C.JAL have pc-relative range of +/-2 KiB.++ C.J is for tail calls and jumps within functions and isn't+ filtered for the reasons mentioned for JAL x0.++ C.JAL is an RV32C-only instruction. Its encoding overlaps with+ RV64C-only C.ADDIW which is a common instruction. So if filtering+ C.JAL was useful (it wasn't tested) then a separate filter would+ be needed for RV32 and RV64. Also, false positives would be a+ significant problem when the filter is applied to non-code data+ because C.JAL needs only five bits to match. Thus, this filter+ doesn't modify C.JAL instructions.++BEQ, BNE, BLT, BGE, BLTU, BGEU, C.BEQZ, and C.BNEZ+--------------------------------------------------++ These are conditional branches with pc-relative range+ of +/-4 KiB (+/-256 B for C.*). The absolute addresses often+ appear only once and very short distances are the most common,+ so filtering these instructions would make compression worse.++AUIPC with rd != x0+-------------------++ AUIPC is paired with a second instruction (inst2) to do+ pc-relative jumps, calls, loads, stores, and for taking+ an address of a symbol. AUIPC has a 20-bit immediate and+ the possible inst2 choices have a 12-bit immediate.++ AUIPC stores pc + 20-bit signed immediate to a register.+ The immediate encodes a multiple of 4 KiB so AUIPC itself+ has a pc-relative range of +/-2 GiB. AUIPC does *NOT* set+ the lowest 12 bits of the result to zero! This means that+ the 12-bit immediate in inst2 cannot just include the lowest+ 12 bits of the absolute address as is; the immediate has to+ compensate for the lowest 12 bits that AUIPC copies from the+ program counter. This means that a good filter has to convert+ not only AUIPC but also the paired inst2.++ A strict filter would focus on filtering the following+ AUIPC+inst2 pairs:++ - AUIPC+JALR: Function calls, including tail calls.++ - AUIPC+ADDI: Calculating the address of a function+ or a global variable.++ - AUIPC+load/store from the base instruction sets+ (RV32I, RV64I) or from the floating point extensions+ Zfh, F, D, and Q:+ * RV32I: LB, LH, LW, LBU, LHU, SB, SH, SW+ * RV64I has also: LD, LWU, SD+ * Zfh: FLH, FSH+ * F: FLW, FSW+ * D: FLD, FSD+ * Q: FLQ, FSQ++ NOTE: AUIPC+inst2 can only be a pair if AUIPC's rd specifies+ the same register as inst2's rs1.++ Instead of strictly accepting only the above instructions as inst2,+ this filter uses a much simpler condition: the lowest two bits of+ inst2 must be set, that is, inst2 must not be a 16-bit compressed+ instruction. So this will accept all 32-bit and possible future+ extended instructions as a pair to AUIPC if the bits in AUIPC's+ rd [11:7] match the bits [19:15] in inst2 (the bits that I-type and+ S-type instructions use for rs1). Testing showed that this relaxed+ condition for inst2 did not consistently or significantly affect+ compression ratio but it reduced code size and improved speed.++ Additionally, the paired instruction is always treated as an I-type+ instruction. The S-type instructions used by stores (SB, SH, SW,+ etc.) place the lowest 5 bits of the immediate in a different+ location than I-type instructions. AUIPC+store pairs are less+ common than other pairs, and testing showed that the extra+ code required to handle S-type instructions was not worth the+ compression ratio gained.++ AUIPC+inst2 don't necessarily appear sequentially next to each+ other although very often they do. Especially AUIPC+JALR are+ sequential as that may allow instruction fusion in processors+ (and perhaps help branch prediction as a fused AUIPC+JALR is+ a direct branch while JALR alone is an indirect branch).++ Clang 16 can generate code where AUIPC+inst2 is split:++ - AUIPC is outside a loop and inst2 (load/store) is inside+ the loop. This way the AUIPC instruction needs to be+ executed only once.++ - Load-modify-store may have AUIPC for the load and the same+ AUIPC-result is used for the store too. This may get combined+ with AUIPC being outside the loop.++ - AUIPC is before a conditional branch and inst2 is hundreds+ of bytes away at the branch target.++ - Inner and outer pair:++ auipc a1,0x2f+ auipc a2,0x3d+ ld a2,-500(a2)+ addi a1,a1,-233++ - Many split pairs with an untaken conditional branch between:++ auipc s9,0x1613 # Pair 1+ auipc s4,0x1613 # Pair 2+ auipc s6,0x1613 # Pair 3+ auipc s10,0x1613 # Pair 4+ beqz a5,a3baae+ ld a0,0(a6)+ ld a6,246(s9) # Pair 1+ ld a1,250(s4) # Pair 2+ ld a3,254(s6) # Pair 3+ ld a4,258(s10) # Pair 4++ It's not possible to find all split pairs in a filter like this.+ At least in 2024, simple sequential pairs are 99 % of AUIPC uses+ so filtering only such pairs gives good results and makes the+ filter simpler. However, it's possible that future compilers will+ produce different code where sequential pairs aren't as common.++ This filter doesn't convert AUIPC instructions alone because:++ (1) The conversion would be off-by-one (or off-by-4096) half the+ time because the lowest 12 bits from inst2 (inst2_imm12)+ aren't known. We only know that the absolute address is+ pc + AUIPC_imm20 + [-2048, +2047] but there is no way to+ know the exact 4096-byte multiple (or 4096 * n + 2048):+ there are always two possibilities because AUIPC copies+ the 12 lowest bits from pc instead of zeroing them.++ NOTE: The sign-extension of inst2_imm12 adds a tiny bit+ of extra complexity to AUIPC math in general but it's not+ the reason for this problem. The sign-extension only changes+ the relative position of the pc-relative 4096-byte window.++ (2) Matching AUIPC instruction alone requires only seven bits.+ When the filter is applied to non-code data, that leads+ to many false positives which make compression worse.+ As long as most AUIPC+inst2 pairs appear as two consecutive+ instructions, converting only such pairs gives better results.++ In assembly, AUIPC+inst2 tend to look like this:++ # Call:+ auipc ra, 0x12345+ jalr ra, -42(ra)++ # Tail call:+ auipc t1, 0x12345+ jalr zero, -42(t1)++ # Getting the absolute address:+ auipc a0, 0x12345+ addi a0, a0, -42++ # rd of inst2 isn't necessarily the same as rs1 even+ # in cases where there is no reason to preserve rs1.+ auipc a0, 0x12345+ addi a1, a0, -42++ As of 2024, 16-bit instructions from the C extension don't+ appear as inst2. The RISC-V psABI doesn't list AUIPC+C.* as+ a linker relaxation type explicitly but it's not disallowed+ either. Usefulness is limited as most of the time the lowest+ 12 bits won't fit in a C instruction. This filter doesn't+ support AUIPC+C.* combinations because this makes the filter+ simpler, there are no test files, and it hopefully will never+ be needed anyway.++ (Compare AUIPC to ARM64 where ADRP does set the lowest 12 bits+ to zero. The paired instruction has the lowest 12 bits of the+ absolute address as is in a zero-extended immediate. Thus the+ ARM64 filter doesn't need to care about the instructions that+ are paired with ADRP. An off-by-4096 issue can still occur if+ the code section isn't aligned with the filter's start offset.+ It's not a problem with standalone ELF files but Windows PE+ files need start_offset=3072 for best results. Also, a .tar+ stores files with 512-byte alignment so most of the time it+ won't be the best for ARM64.)++AUIPC with rd == x0+-------------------++ AUIPC instructions with rd=x0 are reserved for HINTs in the base+ instruction set. Such AUIPC instructions are never filtered.++ As of January 2024, it seems likely that AUIPC with rd=x0 will+ be used for landing pads (pseudoinstruction LPAD). LPAD is used+ to mark valid targets for indirect jumps (for JALR), for example,+ beginnings of functions. The 20-bit immediate in LPAD instruction+ is a label, not a pc-relative address. Thus it would be+ counterproductive to convert AUIPC instructions with rd=x0.++ Often the next instruction after LPAD won't have rs1=x0 and thus+ the filtering would be skipped for that reason alone. However,+ it's not good to rely on this. For example, consider a function+ that begins like this:++ int foo(int i)+ {+ if (i <= 234) {+ ...+ }++ A compiler may generate something like this:++ lpad 0x54321+ li a5, 234+ bgt a0, a5, .L2++ Converting the pseudoinstructions to raw instructions:++ auipc x0, 0x54321+ addi x15, x0, 234+ blt x15, x10, .L2++ In this case the filter would undesirably convert the AUIPC+ADDI+ pair if the filter didn't explicitly skip AUIPC instructions+ that have rd=x0.++*/+++#include "simple_private.h"+++// This checks two conditions at once:+// - AUIPC rd == inst2 rs1.+// - inst2 opcode has the lowest two bits set.+//+// The 8 bit left shift aligns the rd of AUIPC with the rs1 of inst2.+// By XORing the registers, any non-zero value in those bits indicates the+// registers are not equal and thus not an AUIPC pair. Subtracting 3 from+// inst2 will zero out the first two opcode bits only when they are set.+// The mask tests if any of the register or opcode bits are set (and thus+// not an AUIPC pair).+//+// Alternative expression: (((((auipc) << 8) ^ (inst2)) & 0xF8003) != 3)+#define NOT_AUIPC_PAIR(auipc, inst2) \+ ((((auipc) << 8) ^ ((inst2) - 3)) & 0xF8003)++// This macro checks multiple conditions:+// (1) AUIPC rd [11:7] == x2 (special rd value).+// (2) AUIPC bits 12 and 13 set (the lowest two opcode bits of packed inst2).+// (3) inst2_rs1 doesn't equal x0 or x2 because the opposite+// conversion is only done when+// auipc_rd != x0 &&+// auipc_rd != x2 &&+// auipc_rd == inst2_rs1.+//+// The left-hand side takes care of (1) and (2).+// (a) The lowest 7 bits are already known to be AUIPC so subtracting 0x17+// makes those bits zeros.+// (b) If AUIPC rd equals x2, subtracting 0x100 makes bits [11:7] zeros.+// If rd doesn't equal x2, then there will be at least one non-zero bit+// and the next step (c) is irrelevant.+// (c) If the lowest two opcode bits of the packed inst2 are set in [13:12],+// then subtracting 0x3000 will make those bits zeros. Otherwise there+// will be at least one non-zero bit.+//+// The shift by 18 removes the high bits from the final '>=' comparison and+// ensures that any non-zero result will be larger than any possible result+// from the right-hand side of the comparison. The cast ensures that the+// left-hand side didn't get promoted to a larger type than uint32_t.+//+// On the right-hand side, inst2_rs1 & 0x1D will be non-zero as long as+// inst2_rs1 is not x0 or x2.+//+// The final '>=' comparison will make the expression true if:+// - The subtraction caused any bits to be set (special AUIPC rd value not+// used or inst2 opcode bits not set). (non-zero >= non-zero or 0)+// - The subtraction did not cause any bits to be set but inst2_rs1 was+// x0 or x2. (0 >= 0)+#define NOT_SPECIAL_AUIPC(auipc, inst2_rs1) \+ ((uint32_t)(((auipc) - 0x3117) << 18) >= ((inst2_rs1) & 0x1D))+++// The encode and decode functions are split for this filter because of the+// AUIPC+inst2 filtering. This filter design allows a decoder-only+// implementation to be smaller than alternative designs.++#ifdef HAVE_ENCODER_RISCV+static size_t+riscv_encode(void *simple lzma_attribute((__unused__)),+ uint32_t now_pos,+ bool is_encoder lzma_attribute((__unused__)),+ uint8_t *buffer, size_t size)+{+ // Avoid using i + 8 <= size in the loop condition.+ //+ // NOTE: If there is a JAL in the last six bytes of the stream, it+ // won't be converted. This is intentional to keep the code simpler.+ if (size < 8)+ return 0;++ size -= 8;++ size_t i;++ // The loop is advanced by 2 bytes every iteration since the+ // instruction stream may include 16-bit instructions (C extension).+ for (i = 0; i <= size; i += 2) {+ uint32_t inst = buffer[i];++ if (inst == 0xEF) {+ // JAL+ const uint32_t b1 = buffer[i + 1];++ // Only filter rd=x1(ra) and rd=x5(t0).+ if ((b1 & 0x0D) != 0)+ continue;++ // The 20-bit immediate is in four pieces.+ // The encoder stores it in big endian form+ // since it improves compression slightly.+ const uint32_t b2 = buffer[i + 2];+ const uint32_t b3 = buffer[i + 3];+ const uint32_t pc = now_pos + (uint32_t)i;++// The following chart shows the highest three bytes of JAL, focusing on+// the 20-bit immediate field [31:12]. The first row of numbers is the+// bit position in a 32-bit little endian instruction. The second row of+// numbers shows the order of the immediate field in a J-type instruction.+// The last row is the bit number in each byte.+//+// To determine the amount to shift each bit, subtract the value in+// the last row from the value in the second last row. If the number+// is positive, shift left. If negative, shift right.+//+// For example, at the rightmost side of the chart, the bit 4 in b1 is+// the bit 12 of the address. Thus that bit needs to be shifted left+// by 12 - 4 = 8 bits to put it in the right place in the addr variable.+//+// NOTE: The immediate of a J-type instruction holds bits [20:1] of+// the address. The bit [0] is always 0 and not part of the immediate.+//+// | b3 | b2 | b1 |+// | 31 30 29 28 27 26 25 24 | 23 22 21 20 19 18 17 16 | 15 14 13 12 x x x x |+// | 20 10 9 8 7 6 5 4 | 3 2 1 11 19 18 17 16 | 15 14 13 12 x x x x |+// | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 | 7 6 5 4 x x x x |++ uint32_t addr = ((b1 & 0xF0) << 8)+ | ((b2 & 0x0F) << 16)+ | ((b2 & 0x10) << 7)+ | ((b2 & 0xE0) >> 4)+ | ((b3 & 0x7F) << 4)+ | ((b3 & 0x80) << 13);++ addr += pc;++ buffer[i + 1] = (uint8_t)((b1 & 0x0F)+ | ((addr >> 13) & 0xF0));++ buffer[i + 2] = (uint8_t)(addr >> 9);+ buffer[i + 3] = (uint8_t)(addr >> 1);++ // The "-2" is included because the for-loop will+ // always increment by 2. In this case, we want to+ // skip an extra 2 bytes since we used 4 bytes+ // of input.+ i += 4 - 2;++ } else if ((inst & 0x7F) == 0x17) {+ // AUIPC+ inst |= (uint32_t)buffer[i + 1] << 8;+ inst |= (uint32_t)buffer[i + 2] << 16;+ inst |= (uint32_t)buffer[i + 3] << 24;++ // Branch based on AUIPC's rd. The bitmask test does+ // the same thing as this:+ //+ // const uint32_t auipc_rd = (inst >> 7) & 0x1F;+ // if (auipc_rd != 0 && auipc_rd != 2) {+ if (inst & 0xE80) {+ // AUIPC's rd doesn't equal x0 or x2.++ // Check if AUIPC+inst2 are a pair.+ uint32_t inst2 = read32le(buffer + i + 4);++ if (NOT_AUIPC_PAIR(inst, inst2)) {+ // The NOT_AUIPC_PAIR macro allows+ // a false AUIPC+AUIPC pair if the+ // bits [19:15] (where rs1 would be)+ // in the second AUIPC match the rd+ // of the first AUIPC.+ //+ // We must skip enough forward so+ // that the first two bytes of the+ // second AUIPC cannot get converted.+ // Such a conversion could make the+ // current pair become a valid pair+ // which would desync the decoder.+ //+ // Skipping six bytes is enough even+ // though the above condition looks+ // at the lowest four bits of the+ // buffer[i + 6] too. This is safe+ // because this filter never changes+ // those bits if a conversion at+ // that position is done.+ i += 6 - 2;+ continue;+ }++ // Convert AUIPC+inst2 to a special format:+ //+ // - The lowest 7 bits [6:0] retain the+ // AUIPC opcode.+ //+ // - The rd [11:7] is set to x2(sp). x2 is+ // used as the stack pointer so AUIPC with+ // rd=x2 should be very rare in real-world+ // executables.+ //+ // - The remaining 20 bits [31:12] (that+ // normally hold the pc-relative immediate)+ // are used to store the lowest 20 bits of+ // inst2. That is, the 12-bit immediate of+ // inst2 is not included.+ //+ // - The location of the original inst2 is+ // used to store the 32-bit absolute+ // address in big endian format. Compared+ // to the 20+12-bit split encoding, this+ // results in a longer uninterrupted+ // sequence of identical common bytes+ // when the same address is referred+ // with different instruction pairs+ // (like AUIPC+LD vs. AUIPC+ADDI) or+ // when the occurrences of the same+ // pair use different registers. When+ // referring to adjacent memory locations+ // (like function calls that go via the+ // ELF PLT), in big endian order only the+ // last 1-2 bytes differ; in little endian+ // the differing 1-2 bytes would be in the+ // middle of the 8-byte sequence.+ //+ // When reversing the transformation, the+ // original rd of AUIPC can be restored+ // from inst2's rs1 as they are required to+ // be the same.++ // Arithmetic right shift makes sign extension+ // trivial but (1) it's implementation-defined+ // behavior (C99/C11/C23 6.5.7-p5) and so is+ // (2) casting unsigned to signed (6.3.1.3-p3).+ //+ // One can check for (1) with+ //+ // if ((-1 >> 1) == -1) ...+ //+ // but (2) has to be checked from the+ // compiler docs. GCC promises that (1)+ // and (2) behave in the common expected+ // way and thus+ //+ // addr += (uint32_t)(+ // (int32_t)inst2 >> 20);+ //+ // does the same as the code below. But since+ // the 100 % portable way is only a few bytes+ // bigger code and there is no real speed+ // difference, let's just use that, especially+ // since the decoder doesn't need this at all.+ uint32_t addr = inst & 0xFFFFF000;+ addr += (inst2 >> 20)+ - ((inst2 >> 19) & 0x1000);++ addr += now_pos + (uint32_t)i;++ // Construct the first 32 bits:+ // [6:0] AUIPC opcode+ // [11:7] Special AUIPC rd = x2+ // [31:12] The lowest 20 bits of inst2+ inst = 0x17 | (2 << 7) | (inst2 << 12);++ write32le(buffer + i, inst);++ // The second 32 bits store the absolute+ // address in big endian order.+ write32be(buffer + i + 4, addr);+ } else {+ // AUIPC's rd equals x0 or x2.+ //+ // x0 indicates a landing pad (LPAD).+ // It's always skipped.+ //+ // AUIPC with rd == x2 is used for the special+ // format as explained above. When the input+ // contains a byte sequence that matches the+ // special format, "fake" decoding must be+ // done to keep the filter bijective (that+ // is, safe to apply on arbitrary data).+ //+ // See the "x0 or x2" section in riscv_decode()+ // for how the "real" decoding is done. The+ // "fake" decoding is a simplified version+ // of "real" decoding with the following+ // differences (these reduce code size of+ // the decoder):+ // (1) The lowest 12 bits aren't sign-extended.+ // (2) No address conversion is done.+ // (3) Big endian format isn't used (the fake+ // address is in little endian order).++ // Check if inst matches the special format.+ const uint32_t fake_rs1 = inst >> 27;++ if (NOT_SPECIAL_AUIPC(inst, fake_rs1)) {+ i += 4 - 2;+ continue;+ }++ const uint32_t fake_addr =+ read32le(buffer + i + 4);++ // Construct the second 32 bits:+ // [19:0] Upper 20 bits from AUIPC+ // [31:20] The lowest 12 bits of fake_addr+ const uint32_t fake_inst2 = (inst >> 12)+ | (fake_addr << 20);++ // Construct new first 32 bits from:+ // [6:0] AUIPC opcode+ // [11:7] Fake AUIPC rd = fake_rs1+ // [31:12] The highest 20 bits of fake_addr+ inst = 0x17 | (fake_rs1 << 7)+ | (fake_addr & 0xFFFFF000);++ write32le(buffer + i, inst);+ write32le(buffer + i + 4, fake_inst2);+ }++ i += 8 - 2;+ }+ }++ return i;+}+++extern lzma_ret+lzma_simple_riscv_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return lzma_simple_coder_init(next, allocator, filters,+ &riscv_encode, 0, 8, 2, true);+}+#endif+++#ifdef HAVE_DECODER_RISCV+static size_t+riscv_decode(void *simple lzma_attribute((__unused__)),+ uint32_t now_pos,+ bool is_encoder lzma_attribute((__unused__)),+ uint8_t *buffer, size_t size)+{+ if (size < 8)+ return 0;++ size -= 8;++ size_t i;+ for (i = 0; i <= size; i += 2) {+ uint32_t inst = buffer[i];++ if (inst == 0xEF) {+ // JAL+ const uint32_t b1 = buffer[i + 1];++ // Only filter rd=x1(ra) and rd=x5(t0).+ if ((b1 & 0x0D) != 0)+ continue;++ const uint32_t b2 = buffer[i + 2];+ const uint32_t b3 = buffer[i + 3];+ const uint32_t pc = now_pos + (uint32_t)i;++// | b3 | b2 | b1 |+// | 31 30 29 28 27 26 25 24 | 23 22 21 20 19 18 17 16 | 15 14 13 12 x x x x |+// | 20 10 9 8 7 6 5 4 | 3 2 1 11 19 18 17 16 | 15 14 13 12 x x x x |+// | 7 6 5 4 3 2 1 0 | 7 6 5 4 3 2 1 0 | 7 6 5 4 x x x x |++ uint32_t addr = ((b1 & 0xF0) << 13)+ | (b2 << 9) | (b3 << 1);++ addr -= pc;++ buffer[i + 1] = (uint8_t)((b1 & 0x0F)+ | ((addr >> 8) & 0xF0));++ buffer[i + 2] = (uint8_t)(((addr >> 16) & 0x0F)+ | ((addr >> 7) & 0x10)+ | ((addr << 4) & 0xE0));++ buffer[i + 3] = (uint8_t)(((addr >> 4) & 0x7F)+ | ((addr >> 13) & 0x80));++ i += 4 - 2;++ } else if ((inst & 0x7F) == 0x17) {+ // AUIPC+ uint32_t inst2;++ inst |= (uint32_t)buffer[i + 1] << 8;+ inst |= (uint32_t)buffer[i + 2] << 16;+ inst |= (uint32_t)buffer[i + 3] << 24;++ if (inst & 0xE80) {+ // AUIPC's rd doesn't equal x0 or x2.++ // Check if it is a "fake" AUIPC+inst2 pair.+ inst2 = read32le(buffer + i + 4);++ if (NOT_AUIPC_PAIR(inst, inst2)) {+ i += 6 - 2;+ continue;+ }++ // Decode (or more like re-encode) the "fake"+ // pair. The "fake" format doesn't do+ // sign-extension, address conversion, or+ // use big endian. (The use of little endian+ // allows sharing the write32le() calls in+ // the decoder to reduce code size when+ // unaligned access isn't supported.)+ uint32_t addr = inst & 0xFFFFF000;+ addr += inst2 >> 20;++ inst = 0x17 | (2 << 7) | (inst2 << 12);+ inst2 = addr;+ } else {+ // AUIPC's rd equals x0 or x2.++ // Check if inst matches the special format+ // used by the encoder.+ const uint32_t inst2_rs1 = inst >> 27;++ if (NOT_SPECIAL_AUIPC(inst, inst2_rs1)) {+ i += 4 - 2;+ continue;+ }++ // Decode the "real" pair.+ uint32_t addr = read32be(buffer + i + 4);++ addr -= now_pos + (uint32_t)i;++ // The second instruction:+ // - Get the lowest 20 bits from inst.+ // - Add the lowest 12 bits of the address+ // as the immediate field.+ inst2 = (inst >> 12) | (addr << 20);++ // AUIPC:+ // - rd is the same as inst2_rs1.+ // - The sign extension of the lowest 12 bits+ // must be taken into account.+ inst = 0x17 | (inst2_rs1 << 7)+ | ((addr + 0x800) & 0xFFFFF000);+ }++ // Both decoder branches write in little endian order.+ write32le(buffer + i, inst);+ write32le(buffer + i + 4, inst2);++ i += 8 - 2;+ }+ }++ return i;+}+++extern lzma_ret+lzma_simple_riscv_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return lzma_simple_coder_init(next, allocator, filters,+ &riscv_decode, 0, 8, 2, false);+}+#endif
+ cbits/liblzma/simple/simple_coder.c view
@@ -0,0 +1,291 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file simple_coder.c+/// \brief Wrapper for simple filters+///+/// Simple filters don't change the size of the data i.e. number of bytes+/// in equals the number of bytes out.+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "simple_private.h"+++/// Copied or encodes/decodes more data to out[].+static lzma_ret+copy_or_code(lzma_simple_coder *coder, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size, lzma_action action)+{+ assert(!coder->end_was_reached);++ if (coder->next.code == NULL) {+ lzma_bufcpy(in, in_pos, in_size, out, out_pos, out_size);++ // Check if end of stream was reached.+ if (coder->is_encoder && action == LZMA_FINISH+ && *in_pos == in_size)+ coder->end_was_reached = true;++ } else {+ // Call the next coder in the chain to provide us some data.+ const lzma_ret ret = coder->next.code(+ coder->next.coder, allocator,+ in, in_pos, in_size,+ out, out_pos, out_size, action);++ if (ret == LZMA_STREAM_END) {+ assert(!coder->is_encoder+ || action == LZMA_FINISH);+ coder->end_was_reached = true;++ } else if (ret != LZMA_OK) {+ return ret;+ }+ }++ return LZMA_OK;+}+++static size_t+call_filter(lzma_simple_coder *coder, uint8_t *buffer, size_t size)+{+ const size_t filtered = coder->filter(coder->simple,+ coder->now_pos, coder->is_encoder,+ buffer, size);+ coder->now_pos += filtered;+ return filtered;+}+++static lzma_ret+simple_code(void *coder_ptr, const lzma_allocator *allocator,+ const uint8_t *restrict in, size_t *restrict in_pos,+ size_t in_size, uint8_t *restrict out,+ size_t *restrict out_pos, size_t out_size, lzma_action action)+{+ lzma_simple_coder *coder = coder_ptr;++ // TODO: Add partial support for LZMA_SYNC_FLUSH. We can support it+ // in cases when the filter is able to filter everything. With most+ // simple filters it can be done at offset that is a multiple of 2,+ // 4, or 16. With x86 filter, it needs good luck, and thus cannot+ // be made to work predictably.+ if (action == LZMA_SYNC_FLUSH)+ return LZMA_OPTIONS_ERROR;++ // Flush already filtered data from coder->buffer[] to out[].+ if (coder->pos < coder->filtered) {+ lzma_bufcpy(coder->buffer, &coder->pos, coder->filtered,+ out, out_pos, out_size);++ // If we couldn't flush all the filtered data, return to+ // application immediately.+ if (coder->pos < coder->filtered)+ return LZMA_OK;++ if (coder->end_was_reached) {+ assert(coder->filtered == coder->size);+ return LZMA_STREAM_END;+ }+ }++ // If we get here, there is no filtered data left in the buffer.+ coder->filtered = 0;++ assert(!coder->end_was_reached);++ // If there is more output space left than there is unfiltered data+ // in coder->buffer[], flush coder->buffer[] to out[], and copy/code+ // more data to out[] hopefully filling it completely. Then filter+ // the data in out[]. This step is where most of the data gets+ // filtered if the buffer sizes used by the application are reasonable.+ const size_t out_avail = out_size - *out_pos;+ const size_t buf_avail = coder->size - coder->pos;+ if (out_avail > buf_avail || buf_avail == 0) {+ // Store the old position so that we know from which byte+ // to start filtering.+ const size_t out_start = *out_pos;++ // Flush data from coder->buffer[] to out[], but don't reset+ // coder->pos and coder->size yet. This way the coder can be+ // restarted if the next filter in the chain returns e.g.+ // LZMA_MEM_ERROR.+ //+ // Do the memcpy() conditionally because out can be NULL+ // (in which case buf_avail is always 0). Calling memcpy()+ // with a null-pointer is undefined even if the third+ // argument is 0.+ if (buf_avail > 0)+ memcpy(out + *out_pos, coder->buffer + coder->pos,+ buf_avail);++ *out_pos += buf_avail;++ // Copy/Encode/Decode more data to out[].+ {+ const lzma_ret ret = copy_or_code(coder, allocator,+ in, in_pos, in_size,+ out, out_pos, out_size, action);+ assert(ret != LZMA_STREAM_END);+ if (ret != LZMA_OK)+ return ret;+ }++ // Filter out[] unless there is nothing to filter.+ // This way we avoid null pointer + 0 (undefined behavior)+ // when out == NULL.+ const size_t size = *out_pos - out_start;+ const size_t filtered = size == 0 ? 0 : call_filter(+ coder, out + out_start, size);++ const size_t unfiltered = size - filtered;+ assert(unfiltered <= coder->allocated / 2);++ // Now we can update coder->pos and coder->size, because+ // the next coder in the chain (if any) was successful.+ coder->pos = 0;+ coder->size = unfiltered;++ if (coder->end_was_reached) {+ // The last byte has been copied to out[] already.+ // They are left as is.+ coder->size = 0;++ } else if (unfiltered > 0) {+ // There is unfiltered data left in out[]. Copy it to+ // coder->buffer[] and rewind *out_pos appropriately.+ *out_pos -= unfiltered;+ memcpy(coder->buffer, out + *out_pos, unfiltered);+ }+ } else if (coder->pos > 0) {+ memmove(coder->buffer, coder->buffer + coder->pos, buf_avail);+ coder->size -= coder->pos;+ coder->pos = 0;+ }++ assert(coder->pos == 0);++ // If coder->buffer[] isn't empty, try to fill it by copying/decoding+ // more data. Then filter coder->buffer[] and copy the successfully+ // filtered data to out[]. It is probable, that some filtered and+ // unfiltered data will be left to coder->buffer[].+ if (coder->size > 0) {+ {+ const lzma_ret ret = copy_or_code(coder, allocator,+ in, in_pos, in_size,+ coder->buffer, &coder->size,+ coder->allocated, action);+ assert(ret != LZMA_STREAM_END);+ if (ret != LZMA_OK)+ return ret;+ }++ coder->filtered = call_filter(+ coder, coder->buffer, coder->size);++ // Everything is considered to be filtered if coder->buffer[]+ // contains the last bytes of the data.+ if (coder->end_was_reached)+ coder->filtered = coder->size;++ // Flush as much as possible.+ lzma_bufcpy(coder->buffer, &coder->pos, coder->filtered,+ out, out_pos, out_size);+ }++ // Check if we got everything done.+ if (coder->end_was_reached && coder->pos == coder->size)+ return LZMA_STREAM_END;++ return LZMA_OK;+}+++static void+simple_coder_end(void *coder_ptr, const lzma_allocator *allocator)+{+ lzma_simple_coder *coder = coder_ptr;+ lzma_next_end(&coder->next, allocator);+ lzma_free(coder->simple, allocator);+ lzma_free(coder, allocator);+ return;+}+++static lzma_ret+simple_coder_update(void *coder_ptr, const lzma_allocator *allocator,+ const lzma_filter *filters_null lzma_attribute((__unused__)),+ const lzma_filter *reversed_filters)+{+ lzma_simple_coder *coder = coder_ptr;++ // No update support, just call the next filter in the chain.+ return lzma_next_filter_update(+ &coder->next, allocator, reversed_filters + 1);+}+++extern lzma_ret+lzma_simple_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters,+ size_t (*filter)(void *simple, uint32_t now_pos,+ bool is_encoder, uint8_t *buffer, size_t size),+ size_t simple_size, size_t unfiltered_max,+ uint32_t alignment, bool is_encoder)+{+ // Allocate memory for the lzma_simple_coder structure if needed.+ lzma_simple_coder *coder = next->coder;+ if (coder == NULL) {+ // Here we allocate space also for the temporary buffer. We+ // need twice the size of unfiltered_max, because then it+ // is always possible to filter at least unfiltered_max bytes+ // more data in coder->buffer[] if it can be filled completely.+ coder = lzma_alloc(sizeof(lzma_simple_coder)+ + 2 * unfiltered_max, allocator);+ if (coder == NULL)+ return LZMA_MEM_ERROR;++ next->coder = coder;+ next->code = &simple_code;+ next->end = &simple_coder_end;+ next->update = &simple_coder_update;++ coder->next = LZMA_NEXT_CODER_INIT;+ coder->filter = filter;+ coder->allocated = 2 * unfiltered_max;++ // Allocate memory for filter-specific data structure.+ if (simple_size > 0) {+ coder->simple = lzma_alloc(simple_size, allocator);+ if (coder->simple == NULL)+ return LZMA_MEM_ERROR;+ } else {+ coder->simple = NULL;+ }+ }++ if (filters[0].options != NULL) {+ const lzma_options_bcj *simple = filters[0].options;+ coder->now_pos = simple->start_offset;+ if (coder->now_pos & (alignment - 1))+ return LZMA_OPTIONS_ERROR;+ } else {+ coder->now_pos = 0;+ }++ // Reset variables.+ coder->is_encoder = is_encoder;+ coder->end_was_reached = false;+ coder->pos = 0;+ coder->filtered = 0;+ coder->size = 0;++ return lzma_next_filter_init(&coder->next, allocator, filters + 1);+}
+ cbits/liblzma/simple/simple_coder.h view
@@ -0,0 +1,89 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file simple_coder.h+/// \brief Wrapper for simple filters+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_SIMPLE_CODER_H+#define LZMA_SIMPLE_CODER_H++#include "common.h"+++extern lzma_ret lzma_simple_x86_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++extern lzma_ret lzma_simple_x86_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);+++extern lzma_ret lzma_simple_powerpc_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++extern lzma_ret lzma_simple_powerpc_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);+++extern lzma_ret lzma_simple_ia64_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++extern lzma_ret lzma_simple_ia64_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);+++extern lzma_ret lzma_simple_arm_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++extern lzma_ret lzma_simple_arm_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);+++extern lzma_ret lzma_simple_armthumb_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++extern lzma_ret lzma_simple_armthumb_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);+++extern lzma_ret lzma_simple_arm64_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++extern lzma_ret lzma_simple_arm64_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);+++extern lzma_ret lzma_simple_sparc_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++extern lzma_ret lzma_simple_sparc_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);+++extern lzma_ret lzma_simple_riscv_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++extern lzma_ret lzma_simple_riscv_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters);++#endif
+ cbits/liblzma/simple/simple_decoder.c view
@@ -0,0 +1,39 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file simple_decoder.c+/// \brief Properties decoder for simple filters+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "simple_decoder.h"+++extern lzma_ret+lzma_simple_props_decode(void **options, const lzma_allocator *allocator,+ const uint8_t *props, size_t props_size)+{+ if (props_size == 0)+ return LZMA_OK;++ if (props_size != 4)+ return LZMA_OPTIONS_ERROR;++ lzma_options_bcj *opt = lzma_alloc(+ sizeof(lzma_options_bcj), allocator);+ if (opt == NULL)+ return LZMA_MEM_ERROR;++ opt->start_offset = read32le(props);++ // Don't leave an options structure allocated if start_offset is zero.+ if (opt->start_offset == 0)+ lzma_free(opt, allocator);+ else+ *options = opt;++ return LZMA_OK;+}
+ cbits/liblzma/simple/simple_decoder.h view
@@ -0,0 +1,21 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file simple_decoder.h+/// \brief Properties decoder for simple filters+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_SIMPLE_DECODER_H+#define LZMA_SIMPLE_DECODER_H++#include "simple_coder.h"++extern lzma_ret lzma_simple_props_decode(+ void **options, const lzma_allocator *allocator,+ const uint8_t *props, size_t props_size);++#endif
+ cbits/liblzma/simple/simple_encoder.c view
@@ -0,0 +1,37 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file simple_encoder.c+/// \brief Properties encoder for simple filters+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "simple_encoder.h"+++extern lzma_ret+lzma_simple_props_size(uint32_t *size, const void *options)+{+ const lzma_options_bcj *const opt = options;+ *size = (opt == NULL || opt->start_offset == 0) ? 0 : 4;+ return LZMA_OK;+}+++extern lzma_ret+lzma_simple_props_encode(const void *options, uint8_t *out)+{+ const lzma_options_bcj *const opt = options;++ // The default start offset is zero, so we don't need to store any+ // options unless the start offset is non-zero.+ if (opt == NULL || opt->start_offset == 0)+ return LZMA_OK;++ write32le(out, opt->start_offset);++ return LZMA_OK;+}
+ cbits/liblzma/simple/simple_encoder.h view
@@ -0,0 +1,22 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file simple_encoder.c+/// \brief Properties encoder for simple filters+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_SIMPLE_ENCODER_H+#define LZMA_SIMPLE_ENCODER_H++#include "simple_coder.h"+++extern lzma_ret lzma_simple_props_size(uint32_t *size, const void *options);++extern lzma_ret lzma_simple_props_encode(const void *options, uint8_t *out);++#endif
+ cbits/liblzma/simple/simple_private.h view
@@ -0,0 +1,73 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file simple_private.h+/// \brief Private definitions for so called simple filters+//+// Author: Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#ifndef LZMA_SIMPLE_PRIVATE_H+#define LZMA_SIMPLE_PRIVATE_H++#include "simple_coder.h"+++typedef struct {+ /// Next filter in the chain+ lzma_next_coder next;++ /// True if the next coder in the chain has returned LZMA_STREAM_END.+ bool end_was_reached;++ /// True if filter() should encode the data; false to decode.+ /// Currently all simple filters use the same function for encoding+ /// and decoding, because the difference between encoders and decoders+ /// is very small.+ bool is_encoder;++ /// Pointer to filter-specific function, which does+ /// the actual filtering.+ size_t (*filter)(void *simple, uint32_t now_pos,+ bool is_encoder, uint8_t *buffer, size_t size);++ /// Pointer to filter-specific data, or NULL if filter doesn't need+ /// any extra data.+ void *simple;++ /// The lowest 32 bits of the current position in the data. Most+ /// filters need this to do conversions between absolute and relative+ /// addresses.+ uint32_t now_pos;++ /// Size of the memory allocated for the buffer.+ size_t allocated;++ /// Flushing position in the temporary buffer. buffer[pos] is the+ /// next byte to be copied to out[].+ size_t pos;++ /// buffer[filtered] is the first unfiltered byte. When pos is smaller+ /// than filtered, there is unflushed filtered data in the buffer.+ size_t filtered;++ /// Total number of bytes (both filtered and unfiltered) currently+ /// in the temporary buffer.+ size_t size;++ /// Temporary buffer+ uint8_t buffer[];+} lzma_simple_coder;+++extern lzma_ret lzma_simple_coder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters,+ size_t (*filter)(void *simple, uint32_t now_pos,+ bool is_encoder, uint8_t *buffer, size_t size),+ size_t simple_size, size_t unfiltered_max,+ uint32_t alignment, bool is_encoder);++#endif
+ cbits/liblzma/simple/sparc.c view
@@ -0,0 +1,86 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file sparc.c+/// \brief Filter for SPARC binaries+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "simple_private.h"+++static size_t+sparc_code(void *simple lzma_attribute((__unused__)),+ uint32_t now_pos, bool is_encoder,+ uint8_t *buffer, size_t size)+{+ size_t i;+ for (i = 0; i + 4 <= size; i += 4) {++ if ((buffer[i] == 0x40 && (buffer[i + 1] & 0xC0) == 0x00)+ || (buffer[i] == 0x7F+ && (buffer[i + 1] & 0xC0) == 0xC0)) {++ uint32_t src = ((uint32_t)buffer[i + 0] << 24)+ | ((uint32_t)buffer[i + 1] << 16)+ | ((uint32_t)buffer[i + 2] << 8)+ | ((uint32_t)buffer[i + 3]);++ src <<= 2;++ uint32_t dest;+ if (is_encoder)+ dest = now_pos + (uint32_t)(i) + src;+ else+ dest = src - (now_pos + (uint32_t)(i));++ dest >>= 2;++ dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF)+ | (dest & 0x3FFFFF)+ | 0x40000000;++ buffer[i + 0] = (uint8_t)(dest >> 24);+ buffer[i + 1] = (uint8_t)(dest >> 16);+ buffer[i + 2] = (uint8_t)(dest >> 8);+ buffer[i + 3] = (uint8_t)(dest);+ }+ }++ return i;+}+++static lzma_ret+sparc_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters, bool is_encoder)+{+ return lzma_simple_coder_init(next, allocator, filters,+ &sparc_code, 0, 4, 4, is_encoder);+}+++#ifdef HAVE_ENCODER_SPARC+extern lzma_ret+lzma_simple_sparc_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return sparc_coder_init(next, allocator, filters, true);+}+#endif+++#ifdef HAVE_DECODER_SPARC+extern lzma_ret+lzma_simple_sparc_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return sparc_coder_init(next, allocator, filters, false);+}+#endif
+ cbits/liblzma/simple/x86.c view
@@ -0,0 +1,157 @@+// SPDX-License-Identifier: 0BSD++///////////////////////////////////////////////////////////////////////////////+//+/// \file x86.c+/// \brief Filter for x86 binaries (BCJ filter)+///+// Authors: Igor Pavlov+// Lasse Collin+//+///////////////////////////////////////////////////////////////////////////////++#include "simple_private.h"+++#define Test86MSByte(b) ((b) == 0 || (b) == 0xFF)+++typedef struct {+ uint32_t prev_mask;+ uint32_t prev_pos;+} lzma_simple_x86;+++static size_t+x86_code(void *simple_ptr, uint32_t now_pos, bool is_encoder,+ uint8_t *buffer, size_t size)+{+ static const uint32_t MASK_TO_BIT_NUMBER[5] = { 0, 1, 2, 2, 3 };++ lzma_simple_x86 *simple = simple_ptr;+ uint32_t prev_mask = simple->prev_mask;+ uint32_t prev_pos = simple->prev_pos;++ if (size < 5)+ return 0;++ if (now_pos - prev_pos > 5)+ prev_pos = now_pos - 5;++ const size_t limit = size - 5;+ size_t buffer_pos = 0;++ while (buffer_pos <= limit) {+ uint8_t b = buffer[buffer_pos];+ if (b != 0xE8 && b != 0xE9) {+ ++buffer_pos;+ continue;+ }++ const uint32_t offset = now_pos + (uint32_t)(buffer_pos)+ - prev_pos;+ prev_pos = now_pos + (uint32_t)(buffer_pos);++ if (offset > 5) {+ prev_mask = 0;+ } else {+ for (uint32_t i = 0; i < offset; ++i) {+ prev_mask &= 0x77;+ prev_mask <<= 1;+ }+ }++ b = buffer[buffer_pos + 4];++ if (Test86MSByte(b) && (prev_mask >> 1) <= 4+ && (prev_mask >> 1) != 3) {++ uint32_t src = ((uint32_t)(b) << 24)+ | ((uint32_t)(buffer[buffer_pos + 3]) << 16)+ | ((uint32_t)(buffer[buffer_pos + 2]) << 8)+ | (buffer[buffer_pos + 1]);++ uint32_t dest;+ while (true) {+ if (is_encoder)+ dest = src + (now_pos + (uint32_t)(+ buffer_pos) + 5);+ else+ dest = src - (now_pos + (uint32_t)(+ buffer_pos) + 5);++ if (prev_mask == 0)+ break;++ const uint32_t i = MASK_TO_BIT_NUMBER[+ prev_mask >> 1];++ b = (uint8_t)(dest >> (24 - i * 8));++ if (!Test86MSByte(b))+ break;++ src = dest ^ ((1U << (32 - i * 8)) - 1);+ }++ buffer[buffer_pos + 4]+ = (uint8_t)(~(((dest >> 24) & 1) - 1));+ buffer[buffer_pos + 3] = (uint8_t)(dest >> 16);+ buffer[buffer_pos + 2] = (uint8_t)(dest >> 8);+ buffer[buffer_pos + 1] = (uint8_t)(dest);+ buffer_pos += 5;+ prev_mask = 0;++ } else {+ ++buffer_pos;+ prev_mask |= 1;+ if (Test86MSByte(b))+ prev_mask |= 0x10;+ }+ }++ simple->prev_mask = prev_mask;+ simple->prev_pos = prev_pos;++ return buffer_pos;+}+++static lzma_ret+x86_coder_init(lzma_next_coder *next, const lzma_allocator *allocator,+ const lzma_filter_info *filters, bool is_encoder)+{+ const lzma_ret ret = lzma_simple_coder_init(next, allocator, filters,+ &x86_code, sizeof(lzma_simple_x86), 5, 1, is_encoder);++ if (ret == LZMA_OK) {+ lzma_simple_coder *coder = next->coder;+ lzma_simple_x86 *simple = coder->simple;+ simple->prev_mask = 0;+ simple->prev_pos = (uint32_t)(-5);+ }++ return ret;+}+++#ifdef HAVE_ENCODER_X86+extern lzma_ret+lzma_simple_x86_encoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return x86_coder_init(next, allocator, filters, true);+}+#endif+++#ifdef HAVE_DECODER_X86+extern lzma_ret+lzma_simple_x86_decoder_init(lzma_next_coder *next,+ const lzma_allocator *allocator,+ const lzma_filter_info *filters)+{+ return x86_coder_init(next, allocator, filters, false);+}+#endif
+ configure view
@@ -0,0 +1,24571 @@+#! /bin/sh+# Guess values for system-dependent variables and create Makefiles.+# Generated by GNU Autoconf 2.72 for XZ Utils 5.6.3.+#+# Report bugs to <lasse.collin@tukaani.org>.+#+#+# Copyright (C) 1992-1996, 1998-2017, 2020-2023 Free Software Foundation,+# Inc.+#+#+# This configure script is free software; the Free Software Foundation+# gives unlimited permission to copy, distribute and modify it.+## -------------------- ##+## M4sh Initialization. ##+## -------------------- ##++# Be more Bourne compatible+DUALCASE=1; export DUALCASE # for MKS sh+if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1+then :+ emulate sh+ NULLCMD=:+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which+ # is contrary to our usage. Disable this feature.+ alias -g '${1+"$@"}'='"$@"'+ setopt NO_GLOB_SUBST+else case e in #(+ e) case `(set -o) 2>/dev/null` in #(+ *posix*) :+ set -o posix ;; #(+ *) :+ ;;+esac ;;+esac+fi++++# Reset variables that may have inherited troublesome values from+# the environment.++# IFS needs to be set, to space, tab, and newline, in precisely that order.+# (If _AS_PATH_WALK were called with IFS unset, it would have the+# side effect of setting IFS to empty, thus disabling word splitting.)+# Quoting is to prevent editors from complaining about space-tab.+as_nl='+'+export as_nl+IFS=" "" $as_nl"++PS1='$ '+PS2='> '+PS4='+ '++# Ensure predictable behavior from utilities with locale-dependent output.+LC_ALL=C+export LC_ALL+LANGUAGE=C+export LANGUAGE++# We cannot yet rely on "unset" to work, but we need these variables+# to be unset--not just set to an empty or harmless value--now, to+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct+# also avoids known problems related to "unset" and subshell syntax+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH+do eval test \${$as_var+y} \+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :+done++# Ensure that fds 0, 1, and 2 are open.+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi+if (exec 3>&2) ; then :; else exec 2>/dev/null; fi++# The user is always right.+if ${PATH_SEPARATOR+false} :; then+ PATH_SEPARATOR=:+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||+ PATH_SEPARATOR=';'+ }+fi+++# Find who we are. Look in the path if we contain no directory separator.+as_myself=+case $0 in #((+ *[\\/]* ) as_myself=$0 ;;+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ test -r "$as_dir$0" && as_myself=$as_dir$0 && break+ done+IFS=$as_save_IFS++ ;;+esac+# We did not find ourselves, most probably we were run as 'sh COMMAND'+# in which case we are not to be found in the path.+if test "x$as_myself" = x; then+ as_myself=$0+fi+if test ! -f "$as_myself"; then+ printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2+ exit 1+fi+++# Use a proper internal environment variable to ensure we don't fall+ # into an infinite loop, continuously re-executing ourselves.+ if test x"${_as_can_reexec}" != xno && test "x$CONFIG_SHELL" != x; then+ _as_can_reexec=no; export _as_can_reexec;+ # We cannot yet assume a decent shell, so we have to provide a+# neutralization value for shells without unset; and this also+# works around shells that cannot unset nonexistent variables.+# Preserve -v and -x to the replacement shell.+BASH_ENV=/dev/null+ENV=/dev/null+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV+case $- in # ((((+ *v*x* | *x*v* ) as_opts=-vx ;;+ *v* ) as_opts=-v ;;+ *x* ) as_opts=-x ;;+ * ) as_opts= ;;+esac+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}+# Admittedly, this is quite paranoid, since all the known shells bail+# out after a failed 'exec'.+printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2+exit 255+ fi+ # We don't want this to propagate to other subprocesses.+ { _as_can_reexec=; unset _as_can_reexec;}+if test "x$CONFIG_SHELL" = x; then+ as_bourne_compatible="if test \${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1+then :+ emulate sh+ NULLCMD=:+ # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which+ # is contrary to our usage. Disable this feature.+ alias -g '\${1+\"\$@\"}'='\"\$@\"'+ setopt NO_GLOB_SUBST+else case e in #(+ e) case \`(set -o) 2>/dev/null\` in #(+ *posix*) :+ set -o posix ;; #(+ *) :+ ;;+esac ;;+esac+fi+"+ as_required="as_fn_return () { (exit \$1); }+as_fn_success () { as_fn_return 0; }+as_fn_failure () { as_fn_return 1; }+as_fn_ret_success () { return 0; }+as_fn_ret_failure () { return 1; }++exitcode=0+as_fn_success || { exitcode=1; echo as_fn_success failed.; }+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }+if ( set x; as_fn_ret_success y && test x = \"\$1\" )+then :++else case e in #(+ e) exitcode=1; echo positional parameters were not saved. ;;+esac+fi+test x\$exitcode = x0 || exit 1+blah=\$(echo \$(echo blah))+test x\"\$blah\" = xblah || exit 1+test -x / || exit 1"+ as_suggested=" as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO+ as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO+ eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&+ test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1+test \$(( 1 + 1 )) = 2 || exit 1++ test -n \"\${ZSH_VERSION+set}\${BASH_VERSION+set}\" || (+ ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'+ ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO+ ECHO=\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO\$ECHO+ PATH=/empty FPATH=/empty; export PATH FPATH+ test \"X\`printf %s \$ECHO\`\" = \"X\$ECHO\" \\+ || test \"X\`print -r -- \$ECHO\`\" = \"X\$ECHO\" ) || exit 1"+ if (eval "$as_required") 2>/dev/null+then :+ as_have_required=yes+else case e in #(+ e) as_have_required=no ;;+esac+fi+ if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null+then :++else case e in #(+ e) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+as_found=false+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ as_found=:+ case $as_dir in #(+ /*)+ for as_base in sh bash ksh sh5; do+ # Try only shells that exist, to save several forks.+ as_shell=$as_dir$as_base+ if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&+ as_run=a "$as_shell" -c "$as_bourne_compatible""$as_required" 2>/dev/null+then :+ CONFIG_SHELL=$as_shell as_have_required=yes+ if as_run=a "$as_shell" -c "$as_bourne_compatible""$as_suggested" 2>/dev/null+then :+ break 2+fi+fi+ done;;+ esac+ as_found=false+done+IFS=$as_save_IFS+if $as_found+then :++else case e in #(+ e) if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&+ as_run=a "$SHELL" -c "$as_bourne_compatible""$as_required" 2>/dev/null+then :+ CONFIG_SHELL=$SHELL as_have_required=yes+fi ;;+esac+fi+++ if test "x$CONFIG_SHELL" != x+then :+ export CONFIG_SHELL+ # We cannot yet assume a decent shell, so we have to provide a+# neutralization value for shells without unset; and this also+# works around shells that cannot unset nonexistent variables.+# Preserve -v and -x to the replacement shell.+BASH_ENV=/dev/null+ENV=/dev/null+(unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV+case $- in # ((((+ *v*x* | *x*v* ) as_opts=-vx ;;+ *v* ) as_opts=-v ;;+ *x* ) as_opts=-x ;;+ * ) as_opts= ;;+esac+exec $CONFIG_SHELL $as_opts "$as_myself" ${1+"$@"}+# Admittedly, this is quite paranoid, since all the known shells bail+# out after a failed 'exec'.+printf "%s\n" "$0: could not re-execute with $CONFIG_SHELL" >&2+exit 255+fi++ if test x$as_have_required = xno+then :+ printf "%s\n" "$0: This script requires a shell more modern than all"+ printf "%s\n" "$0: the shells that I found on your system."+ if test ${ZSH_VERSION+y} ; then+ printf "%s\n" "$0: In particular, zsh $ZSH_VERSION has bugs and should"+ printf "%s\n" "$0: be upgraded to zsh 4.3.4 or later."+ else+ printf "%s\n" "$0: Please tell bug-autoconf@gnu.org and+$0: lasse.collin@tukaani.org about your system, including+$0: any error possibly output before this message. Then+$0: install a modern shell, or manually run the script+$0: under such a shell if you do have one."+ fi+ exit 1+fi ;;+esac+fi+fi+SHELL=${CONFIG_SHELL-/bin/sh}+export SHELL+# Unset more variables known to interfere with behavior of common tools.+CLICOLOR_FORCE= GREP_OPTIONS=+unset CLICOLOR_FORCE GREP_OPTIONS++## --------------------- ##+## M4sh Shell Functions. ##+## --------------------- ##+# as_fn_unset VAR+# ---------------+# Portably unset VAR.+as_fn_unset ()+{+ { eval $1=; unset $1;}+}+as_unset=as_fn_unset+++# as_fn_set_status STATUS+# -----------------------+# Set $? to STATUS, without forking.+as_fn_set_status ()+{+ return $1+} # as_fn_set_status++# as_fn_exit STATUS+# -----------------+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.+as_fn_exit ()+{+ set +e+ as_fn_set_status $1+ exit $1+} # as_fn_exit++# as_fn_mkdir_p+# -------------+# Create "$as_dir" as a directory, including parents if necessary.+as_fn_mkdir_p ()+{++ case $as_dir in #(+ -*) as_dir=./$as_dir;;+ esac+ test -d "$as_dir" || eval $as_mkdir_p || {+ as_dirs=+ while :; do+ case $as_dir in #(+ *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(+ *) as_qdir=$as_dir;;+ esac+ as_dirs="'$as_qdir' $as_dirs"+ as_dir=`$as_dirname -- "$as_dir" ||+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+ X"$as_dir" : 'X\(//\)[^/]' \| \+ X"$as_dir" : 'X\(//\)$' \| \+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X"$as_dir" |+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+ s//\1/+ q+ }+ /^X\(\/\/\)[^/].*/{+ s//\1/+ q+ }+ /^X\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ test -d "$as_dir" && break+ done+ test -z "$as_dirs" || eval "mkdir $as_dirs"+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"+++} # as_fn_mkdir_p++# as_fn_executable_p FILE+# -----------------------+# Test if FILE is an executable regular file.+as_fn_executable_p ()+{+ test -f "$1" && test -x "$1"+} # as_fn_executable_p+# as_fn_append VAR VALUE+# ----------------------+# Append the text in VALUE to the end of the definition contained in VAR. Take+# advantage of any shell optimizations that allow amortized linear growth over+# repeated appends, instead of the typical quadratic growth present in naive+# implementations.+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null+then :+ eval 'as_fn_append ()+ {+ eval $1+=\$2+ }'+else case e in #(+ e) as_fn_append ()+ {+ eval $1=\$$1\$2+ } ;;+esac+fi # as_fn_append++# as_fn_arith ARG...+# ------------------+# Perform arithmetic evaluation on the ARGs, and store the result in the+# global $as_val. Take advantage of shells that can avoid forks. The arguments+# must be portable across $(()) and expr.+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null+then :+ eval 'as_fn_arith ()+ {+ as_val=$(( $* ))+ }'+else case e in #(+ e) as_fn_arith ()+ {+ as_val=`expr "$@" || test $? -eq 1`+ } ;;+esac+fi # as_fn_arith+++# as_fn_error STATUS ERROR [LINENO LOG_FD]+# ----------------------------------------+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the+# script with STATUS, using 1 if that was 0.+as_fn_error ()+{+ as_status=$1; test $as_status -eq 0 && as_status=1+ if test "$4"; then+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4+ fi+ printf "%s\n" "$as_me: error: $2" >&2+ as_fn_exit $as_status+} # as_fn_error++if expr a : '\(a\)' >/dev/null 2>&1 &&+ test "X`expr 00001 : '.*\(...\)'`" = X001; then+ as_expr=expr+else+ as_expr=false+fi++if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then+ as_basename=basename+else+ as_basename=false+fi++if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then+ as_dirname=dirname+else+ as_dirname=false+fi++as_me=`$as_basename -- "$0" ||+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \+ X"$0" : 'X\(//\)$' \| \+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X/"$0" |+ sed '/^.*\/\([^/][^/]*\)\/*$/{+ s//\1/+ q+ }+ /^X\/\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\/\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`++# Avoid depending upon Character Ranges.+as_cr_letters='abcdefghijklmnopqrstuvwxyz'+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'+as_cr_Letters=$as_cr_letters$as_cr_LETTERS+as_cr_digits='0123456789'+as_cr_alnum=$as_cr_Letters$as_cr_digits+++ as_lineno_1=$LINENO as_lineno_1a=$LINENO+ as_lineno_2=$LINENO as_lineno_2a=$LINENO+ eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&+ test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {+ # Blame Lee E. McMahon (1931-1989) for sed's syntax. :-)+ sed -n '+ p+ /[$]LINENO/=+ ' <$as_myself |+ sed '+ t clear+ :clear+ s/[$]LINENO.*/&-/+ t lineno+ b+ :lineno+ N+ :loop+ s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/+ t loop+ s/-\n.*//+ ' >$as_me.lineno &&+ chmod +x "$as_me.lineno" ||+ { printf "%s\n" "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }++ # If we had to re-execute with $CONFIG_SHELL, we're ensured to have+ # already done that, so ensure we don't try to do so again and fall+ # in an infinite loop. This has already happened in practice.+ _as_can_reexec=no; export _as_can_reexec+ # Don't try to exec as it changes $[0], causing all sort of problems+ # (the dirname of $[0] is not the place where we might find the+ # original and so on. Autoconf is especially sensitive to this).+ . "./$as_me.lineno"+ # Exit status is that of the last command.+ exit+}+++# Determine whether it's possible to make 'echo' print without a newline.+# These variables are no longer used directly by Autoconf, but are AC_SUBSTed+# for compatibility with existing Makefiles.+ECHO_C= ECHO_N= ECHO_T=+case `echo -n x` in #(((((+-n*)+ case `echo 'xy\c'` in+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.+ xy) ECHO_C='\c';;+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null+ ECHO_T=' ';;+ esac;;+*)+ ECHO_N='-n';;+esac++# For backward compatibility with old third-party macros, we provide+# the shell variables $as_echo and $as_echo_n. New code should use+# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively.+as_echo='printf %s\n'+as_echo_n='printf %s'++rm -f conf$$ conf$$.exe conf$$.file+if test -d conf$$.dir; then+ rm -f conf$$.dir/conf$$.file+else+ rm -f conf$$.dir+ mkdir conf$$.dir 2>/dev/null+fi+if (echo >conf$$.file) 2>/dev/null; then+ if ln -s conf$$.file conf$$ 2>/dev/null; then+ as_ln_s='ln -s'+ # ... but there are two gotchas:+ # 1) On MSYS, both 'ln -s file dir' and 'ln file dir' fail.+ # 2) DJGPP < 2.04 has no symlinks; 'ln -s' creates a wrapper executable.+ # In both cases, we have to default to 'cp -pR'.+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||+ as_ln_s='cp -pR'+ elif ln conf$$.file conf$$ 2>/dev/null; then+ as_ln_s=ln+ else+ as_ln_s='cp -pR'+ fi+else+ as_ln_s='cp -pR'+fi+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file+rmdir conf$$.dir 2>/dev/null++if mkdir -p . 2>/dev/null; then+ as_mkdir_p='mkdir -p "$as_dir"'+else+ test -d ./-p && rmdir ./-p+ as_mkdir_p=false+fi++as_test_x='test -x'+as_executable_p=as_fn_executable_p++# Sed expression to map a string onto a valid CPP name.+as_sed_cpp="y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"+as_tr_cpp="eval sed '$as_sed_cpp'" # deprecated++# Sed expression to map a string onto a valid variable name.+as_sed_sh="y%*+%pp%;s%[^_$as_cr_alnum]%_%g"+as_tr_sh="eval sed '$as_sed_sh'" # deprecated++SHELL=${CONFIG_SHELL-/bin/sh}+++test -n "$DJDIR" || exec 7<&0 </dev/null+exec 6>&1++# Name of the host.+# hostname on some systems (SVR3.2, old GNU/Linux) returns a bogus exit status,+# so uname gets run too.+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`++#+# Initializations.+#+ac_default_prefix=/usr/local+ac_clean_files=+ac_config_libobj_dir=.+LIBOBJS=+cross_compiling=no+subdirs=+MFLAGS=+MAKEFLAGS=++# Identity of this package.+PACKAGE_NAME='XZ Utils'+PACKAGE_TARNAME='xz'+PACKAGE_VERSION='5.6.3'+PACKAGE_STRING='XZ Utils 5.6.3'+PACKAGE_BUGREPORT='lasse.collin@tukaani.org'+PACKAGE_URL='https://tukaani.org/xz/'++ac_unique_file="cbits/liblzma/common/common.h"+# Factoring default headers for most tests.+ac_includes_default="\+#include <stddef.h>+#ifdef HAVE_STDIO_H+# include <stdio.h>+#endif+#ifdef HAVE_STDLIB_H+# include <stdlib.h>+#endif+#ifdef HAVE_STRING_H+# include <string.h>+#endif+#ifdef HAVE_INTTYPES_H+# include <inttypes.h>+#endif+#ifdef HAVE_STDINT_H+# include <stdint.h>+#endif+#ifdef HAVE_STRINGS_H+# include <strings.h>+#endif+#ifdef HAVE_SYS_TYPES_H+# include <sys/types.h>+#endif+#ifdef HAVE_SYS_STAT_H+# include <sys/stat.h>+#endif+#ifdef HAVE_UNISTD_H+# include <unistd.h>+#endif"++ac_header_c_list=+gt_needs=+enable_year2038=no+ac_subst_vars='LTLIBOBJS+xz+AM_CFLAGS+COND_GNULIB_FALSE+COND_GNULIB_TRUE+HAVE_VISIBILITY+CFLAG_VISIBILITY+COND_INTERNAL_SHA256_FALSE+COND_INTERNAL_SHA256_TRUE+GETOPT_H+LIBOBJS+localedir_c_make+localedir_c+POSUB+LTLIBINTL+LIBINTL+INTLLIBS+LTLIBICONV+LIBICONV+INTL_MACOSX_LIBS+XGETTEXT_EXTRA_OPTIONS+MSGMERGE_FOR_MSGFMT_OPTION+MSGMERGE+XGETTEXT_015+XGETTEXT+GMSGFMT_015+GMSGFMT+MSGFMT+GETTEXT_MACRO_VERSION+USE_NLS+MKDIR_P+INSTALL_DATA+INSTALL_SCRIPT+INSTALL_PROGRAM+SET_MAKE+COND_SYMVERS_GENERIC_FALSE+COND_SYMVERS_GENERIC_TRUE+COND_SYMVERS_LINUX_FALSE+COND_SYMVERS_LINUX_TRUE+COND_SHARED_FALSE+COND_SHARED_TRUE+RC+LT_SYS_LIBRARY_PATH+OTOOL64+OTOOL+LIPO+NMEDIT+DSYMUTIL+MANIFEST_TOOL+AWK+RANLIB+STRIP+ac_ct_AR+AR+FILECMD+NM+ac_ct_DUMPBIN+DUMPBIN+LD+FGREP+EGREP+GREP+LIBTOOL+OBJDUMP+DLLTOOL+AS+COND_THREADS_FALSE+COND_THREADS_TRUE+PTHREAD_CFLAGS+PTHREAD_LIBS+PTHREAD_CXX+PTHREAD_CC+ax_pthread_config+CPP+SED+am__fastdepCCAS_FALSE+am__fastdepCCAS_TRUE+CCASDEPMODE+am__nodep+AMDEPBACKSLASH+AMDEP_FALSE+AMDEP_TRUE+am__include+DEPDIR+am__leading_dot+CCASFLAGS+CCAS+OBJEXT+EXEEXT+ac_ct_CC+CPPFLAGS+LDFLAGS+CFLAGS+CC+LN_S+PREFERABLY_POSIX_SHELL+POSIX_SHELL+enable_path_for_scripts+COND_DOXYGEN_FALSE+COND_DOXYGEN_TRUE+COND_DOC_FALSE+COND_DOC_TRUE+COND_SCRIPTS_FALSE+COND_SCRIPTS_TRUE+COND_LZMALINKS_FALSE+COND_LZMALINKS_TRUE+COND_LZMAINFO_FALSE+COND_LZMAINFO_TRUE+COND_LZMADEC_FALSE+COND_LZMADEC_TRUE+COND_XZDEC_FALSE+COND_XZDEC_TRUE+COND_XZ_FALSE+COND_XZ_TRUE+COND_SMALL_FALSE+COND_SMALL_TRUE+COND_ASM_X86_FALSE+COND_ASM_X86_TRUE+COND_LZIP_DECODER_FALSE+COND_LZIP_DECODER_TRUE+COND_MICROLZMA_FALSE+COND_MICROLZMA_TRUE+COND_CHECK_SHA256_FALSE+COND_CHECK_SHA256_TRUE+COND_CHECK_CRC64_FALSE+COND_CHECK_CRC64_TRUE+COND_CHECK_CRC32_FALSE+COND_CHECK_CRC32_TRUE+COND_DECODER_LZ_FALSE+COND_DECODER_LZ_TRUE+COND_ENCODER_LZ_FALSE+COND_ENCODER_LZ_TRUE+COND_FILTER_LZ_FALSE+COND_FILTER_LZ_TRUE+COND_DECODER_SIMPLE_FALSE+COND_DECODER_SIMPLE_TRUE+COND_ENCODER_SIMPLE_FALSE+COND_ENCODER_SIMPLE_TRUE+COND_FILTER_SIMPLE_FALSE+COND_FILTER_SIMPLE_TRUE+COND_DECODER_RISCV_FALSE+COND_DECODER_RISCV_TRUE+COND_ENCODER_RISCV_FALSE+COND_ENCODER_RISCV_TRUE+COND_FILTER_RISCV_FALSE+COND_FILTER_RISCV_TRUE+COND_DECODER_SPARC_FALSE+COND_DECODER_SPARC_TRUE+COND_ENCODER_SPARC_FALSE+COND_ENCODER_SPARC_TRUE+COND_FILTER_SPARC_FALSE+COND_FILTER_SPARC_TRUE+COND_DECODER_ARM64_FALSE+COND_DECODER_ARM64_TRUE+COND_ENCODER_ARM64_FALSE+COND_ENCODER_ARM64_TRUE+COND_FILTER_ARM64_FALSE+COND_FILTER_ARM64_TRUE+COND_DECODER_ARMTHUMB_FALSE+COND_DECODER_ARMTHUMB_TRUE+COND_ENCODER_ARMTHUMB_FALSE+COND_ENCODER_ARMTHUMB_TRUE+COND_FILTER_ARMTHUMB_FALSE+COND_FILTER_ARMTHUMB_TRUE+COND_DECODER_ARM_FALSE+COND_DECODER_ARM_TRUE+COND_ENCODER_ARM_FALSE+COND_ENCODER_ARM_TRUE+COND_FILTER_ARM_FALSE+COND_FILTER_ARM_TRUE+COND_DECODER_IA64_FALSE+COND_DECODER_IA64_TRUE+COND_ENCODER_IA64_FALSE+COND_ENCODER_IA64_TRUE+COND_FILTER_IA64_FALSE+COND_FILTER_IA64_TRUE+COND_DECODER_POWERPC_FALSE+COND_DECODER_POWERPC_TRUE+COND_ENCODER_POWERPC_FALSE+COND_ENCODER_POWERPC_TRUE+COND_FILTER_POWERPC_FALSE+COND_FILTER_POWERPC_TRUE+COND_DECODER_X86_FALSE+COND_DECODER_X86_TRUE+COND_ENCODER_X86_FALSE+COND_ENCODER_X86_TRUE+COND_FILTER_X86_FALSE+COND_FILTER_X86_TRUE+COND_DECODER_DELTA_FALSE+COND_DECODER_DELTA_TRUE+COND_ENCODER_DELTA_FALSE+COND_ENCODER_DELTA_TRUE+COND_FILTER_DELTA_FALSE+COND_FILTER_DELTA_TRUE+COND_DECODER_LZMA2_FALSE+COND_DECODER_LZMA2_TRUE+COND_ENCODER_LZMA2_FALSE+COND_ENCODER_LZMA2_TRUE+COND_FILTER_LZMA2_FALSE+COND_FILTER_LZMA2_TRUE+COND_DECODER_LZMA1_FALSE+COND_DECODER_LZMA1_TRUE+COND_ENCODER_LZMA1_FALSE+COND_ENCODER_LZMA1_TRUE+COND_FILTER_LZMA1_FALSE+COND_FILTER_LZMA1_TRUE+COND_MAIN_DECODER_FALSE+COND_MAIN_DECODER_TRUE+COND_MAIN_ENCODER_FALSE+COND_MAIN_ENCODER_TRUE+LN_EXEEXT+COND_W32_FALSE+COND_W32_TRUE+host_os+host_vendor+host_cpu+host+build_os+build_vendor+build_cpu+build+target_alias+host_alias+build_alias+LIBS+ECHO_T+ECHO_N+ECHO_C+DEFS+mandir+localedir+libdir+psdir+pdfdir+dvidir+htmldir+infodir+docdir+oldincludedir+includedir+runstatedir+localstatedir+sharedstatedir+sysconfdir+datadir+datarootdir+libexecdir+sbindir+bindir+program_transform_name+prefix+exec_prefix+PACKAGE_URL+PACKAGE_BUGREPORT+PACKAGE_STRING+PACKAGE_VERSION+PACKAGE_TARNAME+PACKAGE_NAME+PATH_SEPARATOR+SHELL+am__quote'+ac_subst_files=''+ac_user_opts='+enable_option_checking+enable_debug+enable_encoders+enable_decoders+enable_match_finders+enable_checks+enable_external_sha256+enable_microlzma+enable_lzip_decoder+enable_assembler+enable_clmul_crc+enable_arm64_crc32+enable_loongarch_crc32+enable_small+enable_threads+enable_assume_ram+enable_xz+enable_xzdec+enable_lzmadec+enable_lzmainfo+enable_lzma_links+enable_scripts+enable_doc+enable_doxygen+enable_sandbox+enable_path_for_scripts+enable_dependency_tracking+enable_shared+enable_static+with_pic+enable_fast_install+with_aix_soname+with_gnu_ld+with_sysroot+enable_libtool_lock+enable_symbol_versions+enable_nls+enable_rpath+with_libiconv_prefix+with_libintl_prefix+enable_largefile+enable_unaligned_access+enable_unsafe_type_punning+enable_werror+enable_year2038+'+ ac_precious_vars='build_alias+host_alias+target_alias+CC+CFLAGS+LDFLAGS+LIBS+CPPFLAGS+CCAS+CCASFLAGS+CPP+LT_SYS_LIBRARY_PATH'+++# Initialize some variables set by options.+ac_init_help=+ac_init_version=false+ac_unrecognized_opts=+ac_unrecognized_sep=+# The variables have the same names as the options, with+# dashes changed to underlines.+cache_file=/dev/null+exec_prefix=NONE+no_create=+no_recursion=+prefix=NONE+program_prefix=NONE+program_suffix=NONE+program_transform_name=s,x,x,+silent=+site=+srcdir=+verbose=+x_includes=NONE+x_libraries=NONE++# Installation directory options.+# These are left unexpanded so users can "make install exec_prefix=/foo"+# and all the variables that are supposed to be based on exec_prefix+# by default will actually change.+# Use braces instead of parens because sh, perl, etc. also accept them.+# (The list follows the same order as the GNU Coding Standards.)+bindir='${exec_prefix}/bin'+sbindir='${exec_prefix}/sbin'+libexecdir='${exec_prefix}/libexec'+datarootdir='${prefix}/share'+datadir='${datarootdir}'+sysconfdir='${prefix}/etc'+sharedstatedir='${prefix}/com'+localstatedir='${prefix}/var'+runstatedir='${localstatedir}/run'+includedir='${prefix}/include'+oldincludedir='/usr/include'+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'+infodir='${datarootdir}/info'+htmldir='${docdir}'+dvidir='${docdir}'+pdfdir='${docdir}'+psdir='${docdir}'+libdir='${exec_prefix}/lib'+localedir='${datarootdir}/locale'+mandir='${datarootdir}/man'++ac_prev=+ac_dashdash=+for ac_option+do+ # If the previous option needs an argument, assign it.+ if test -n "$ac_prev"; then+ eval $ac_prev=\$ac_option+ ac_prev=+ continue+ fi++ case $ac_option in+ *=?*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;+ *=) ac_optarg= ;;+ *) ac_optarg=yes ;;+ esac++ case $ac_dashdash$ac_option in+ --)+ ac_dashdash=yes ;;++ -bindir | --bindir | --bindi | --bind | --bin | --bi)+ ac_prev=bindir ;;+ -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)+ bindir=$ac_optarg ;;++ -build | --build | --buil | --bui | --bu)+ ac_prev=build_alias ;;+ -build=* | --build=* | --buil=* | --bui=* | --bu=*)+ build_alias=$ac_optarg ;;++ -cache-file | --cache-file | --cache-fil | --cache-fi \+ | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)+ ac_prev=cache_file ;;+ -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \+ | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)+ cache_file=$ac_optarg ;;++ --config-cache | -C)+ cache_file=config.cache ;;++ -datadir | --datadir | --datadi | --datad)+ ac_prev=datadir ;;+ -datadir=* | --datadir=* | --datadi=* | --datad=*)+ datadir=$ac_optarg ;;++ -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \+ | --dataroo | --dataro | --datar)+ ac_prev=datarootdir ;;+ -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \+ | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)+ datarootdir=$ac_optarg ;;++ -disable-* | --disable-*)+ ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`+ # Reject names that are not valid shell variable names.+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+ as_fn_error $? "invalid feature name: '$ac_useropt'"+ ac_useropt_orig=$ac_useropt+ ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`+ case $ac_user_opts in+ *"+"enable_$ac_useropt"+"*) ;;+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"+ ac_unrecognized_sep=', ';;+ esac+ eval enable_$ac_useropt=no ;;++ -docdir | --docdir | --docdi | --doc | --do)+ ac_prev=docdir ;;+ -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)+ docdir=$ac_optarg ;;++ -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)+ ac_prev=dvidir ;;+ -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)+ dvidir=$ac_optarg ;;++ -enable-* | --enable-*)+ ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`+ # Reject names that are not valid shell variable names.+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+ as_fn_error $? "invalid feature name: '$ac_useropt'"+ ac_useropt_orig=$ac_useropt+ ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`+ case $ac_user_opts in+ *"+"enable_$ac_useropt"+"*) ;;+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"+ ac_unrecognized_sep=', ';;+ esac+ eval enable_$ac_useropt=\$ac_optarg ;;++ -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \+ | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \+ | --exec | --exe | --ex)+ ac_prev=exec_prefix ;;+ -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \+ | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \+ | --exec=* | --exe=* | --ex=*)+ exec_prefix=$ac_optarg ;;++ -gas | --gas | --ga | --g)+ # Obsolete; use --with-gas.+ with_gas=yes ;;++ -help | --help | --hel | --he | -h)+ ac_init_help=long ;;+ -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)+ ac_init_help=recursive ;;+ -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)+ ac_init_help=short ;;++ -host | --host | --hos | --ho)+ ac_prev=host_alias ;;+ -host=* | --host=* | --hos=* | --ho=*)+ host_alias=$ac_optarg ;;++ -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)+ ac_prev=htmldir ;;+ -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \+ | --ht=*)+ htmldir=$ac_optarg ;;++ -includedir | --includedir | --includedi | --included | --include \+ | --includ | --inclu | --incl | --inc)+ ac_prev=includedir ;;+ -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \+ | --includ=* | --inclu=* | --incl=* | --inc=*)+ includedir=$ac_optarg ;;++ -infodir | --infodir | --infodi | --infod | --info | --inf)+ ac_prev=infodir ;;+ -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)+ infodir=$ac_optarg ;;++ -libdir | --libdir | --libdi | --libd)+ ac_prev=libdir ;;+ -libdir=* | --libdir=* | --libdi=* | --libd=*)+ libdir=$ac_optarg ;;++ -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \+ | --libexe | --libex | --libe)+ ac_prev=libexecdir ;;+ -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \+ | --libexe=* | --libex=* | --libe=*)+ libexecdir=$ac_optarg ;;++ -localedir | --localedir | --localedi | --localed | --locale)+ ac_prev=localedir ;;+ -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)+ localedir=$ac_optarg ;;++ -localstatedir | --localstatedir | --localstatedi | --localstated \+ | --localstate | --localstat | --localsta | --localst | --locals)+ ac_prev=localstatedir ;;+ -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \+ | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)+ localstatedir=$ac_optarg ;;++ -mandir | --mandir | --mandi | --mand | --man | --ma | --m)+ ac_prev=mandir ;;+ -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)+ mandir=$ac_optarg ;;++ -nfp | --nfp | --nf)+ # Obsolete; use --without-fp.+ with_fp=no ;;++ -no-create | --no-create | --no-creat | --no-crea | --no-cre \+ | --no-cr | --no-c | -n)+ no_create=yes ;;++ -no-recursion | --no-recursion | --no-recursio | --no-recursi \+ | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)+ no_recursion=yes ;;++ -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \+ | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \+ | --oldin | --oldi | --old | --ol | --o)+ ac_prev=oldincludedir ;;+ -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \+ | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \+ | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)+ oldincludedir=$ac_optarg ;;++ -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)+ ac_prev=prefix ;;+ -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)+ prefix=$ac_optarg ;;++ -program-prefix | --program-prefix | --program-prefi | --program-pref \+ | --program-pre | --program-pr | --program-p)+ ac_prev=program_prefix ;;+ -program-prefix=* | --program-prefix=* | --program-prefi=* \+ | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)+ program_prefix=$ac_optarg ;;++ -program-suffix | --program-suffix | --program-suffi | --program-suff \+ | --program-suf | --program-su | --program-s)+ ac_prev=program_suffix ;;+ -program-suffix=* | --program-suffix=* | --program-suffi=* \+ | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)+ program_suffix=$ac_optarg ;;++ -program-transform-name | --program-transform-name \+ | --program-transform-nam | --program-transform-na \+ | --program-transform-n | --program-transform- \+ | --program-transform | --program-transfor \+ | --program-transfo | --program-transf \+ | --program-trans | --program-tran \+ | --progr-tra | --program-tr | --program-t)+ ac_prev=program_transform_name ;;+ -program-transform-name=* | --program-transform-name=* \+ | --program-transform-nam=* | --program-transform-na=* \+ | --program-transform-n=* | --program-transform-=* \+ | --program-transform=* | --program-transfor=* \+ | --program-transfo=* | --program-transf=* \+ | --program-trans=* | --program-tran=* \+ | --progr-tra=* | --program-tr=* | --program-t=*)+ program_transform_name=$ac_optarg ;;++ -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)+ ac_prev=pdfdir ;;+ -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)+ pdfdir=$ac_optarg ;;++ -psdir | --psdir | --psdi | --psd | --ps)+ ac_prev=psdir ;;+ -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)+ psdir=$ac_optarg ;;++ -q | -quiet | --quiet | --quie | --qui | --qu | --q \+ | -silent | --silent | --silen | --sile | --sil)+ silent=yes ;;++ -runstatedir | --runstatedir | --runstatedi | --runstated \+ | --runstate | --runstat | --runsta | --runst | --runs \+ | --run | --ru | --r)+ ac_prev=runstatedir ;;+ -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \+ | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \+ | --run=* | --ru=* | --r=*)+ runstatedir=$ac_optarg ;;++ -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)+ ac_prev=sbindir ;;+ -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \+ | --sbi=* | --sb=*)+ sbindir=$ac_optarg ;;++ -sharedstatedir | --sharedstatedir | --sharedstatedi \+ | --sharedstated | --sharedstate | --sharedstat | --sharedsta \+ | --sharedst | --shareds | --shared | --share | --shar \+ | --sha | --sh)+ ac_prev=sharedstatedir ;;+ -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \+ | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \+ | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \+ | --sha=* | --sh=*)+ sharedstatedir=$ac_optarg ;;++ -site | --site | --sit)+ ac_prev=site ;;+ -site=* | --site=* | --sit=*)+ site=$ac_optarg ;;++ -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)+ ac_prev=srcdir ;;+ -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)+ srcdir=$ac_optarg ;;++ -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \+ | --syscon | --sysco | --sysc | --sys | --sy)+ ac_prev=sysconfdir ;;+ -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \+ | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)+ sysconfdir=$ac_optarg ;;++ -target | --target | --targe | --targ | --tar | --ta | --t)+ ac_prev=target_alias ;;+ -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)+ target_alias=$ac_optarg ;;++ -v | -verbose | --verbose | --verbos | --verbo | --verb)+ verbose=yes ;;++ -version | --version | --versio | --versi | --vers | -V)+ ac_init_version=: ;;++ -with-* | --with-*)+ ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`+ # Reject names that are not valid shell variable names.+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+ as_fn_error $? "invalid package name: '$ac_useropt'"+ ac_useropt_orig=$ac_useropt+ ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`+ case $ac_user_opts in+ *"+"with_$ac_useropt"+"*) ;;+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"+ ac_unrecognized_sep=', ';;+ esac+ eval with_$ac_useropt=\$ac_optarg ;;++ -without-* | --without-*)+ ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`+ # Reject names that are not valid shell variable names.+ expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&+ as_fn_error $? "invalid package name: '$ac_useropt'"+ ac_useropt_orig=$ac_useropt+ ac_useropt=`printf "%s\n" "$ac_useropt" | sed 's/[-+.]/_/g'`+ case $ac_user_opts in+ *"+"with_$ac_useropt"+"*) ;;+ *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"+ ac_unrecognized_sep=', ';;+ esac+ eval with_$ac_useropt=no ;;++ --x)+ # Obsolete; use --with-x.+ with_x=yes ;;++ -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \+ | --x-incl | --x-inc | --x-in | --x-i)+ ac_prev=x_includes ;;+ -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \+ | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)+ x_includes=$ac_optarg ;;++ -x-libraries | --x-libraries | --x-librarie | --x-librari \+ | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)+ ac_prev=x_libraries ;;+ -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \+ | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)+ x_libraries=$ac_optarg ;;++ -*) as_fn_error $? "unrecognized option: '$ac_option'+Try '$0 --help' for more information"+ ;;++ *=*)+ ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`+ # Reject names that are not valid shell variable names.+ case $ac_envvar in #(+ '' | [0-9]* | *[!_$as_cr_alnum]* )+ as_fn_error $? "invalid variable name: '$ac_envvar'" ;;+ esac+ eval $ac_envvar=\$ac_optarg+ export $ac_envvar ;;++ *)+ # FIXME: should be removed in autoconf 3.0.+ printf "%s\n" "$as_me: WARNING: you should use --build, --host, --target" >&2+ expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&+ printf "%s\n" "$as_me: WARNING: invalid host type: $ac_option" >&2+ : "${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}"+ ;;++ esac+done++if test -n "$ac_prev"; then+ ac_option=--`echo $ac_prev | sed 's/_/-/g'`+ as_fn_error $? "missing argument to $ac_option"+fi++if test -n "$ac_unrecognized_opts"; then+ case $enable_option_checking in+ no) ;;+ fatal) as_fn_error $? "unrecognized options: $ac_unrecognized_opts" ;;+ *) printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;+ esac+fi++# Check all directory arguments for consistency.+for ac_var in exec_prefix prefix bindir sbindir libexecdir datarootdir \+ datadir sysconfdir sharedstatedir localstatedir includedir \+ oldincludedir docdir infodir htmldir dvidir pdfdir psdir \+ libdir localedir mandir runstatedir+do+ eval ac_val=\$$ac_var+ # Remove trailing slashes.+ case $ac_val in+ */ )+ ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`+ eval $ac_var=\$ac_val;;+ esac+ # Be sure to have absolute directory names.+ case $ac_val in+ [\\/$]* | ?:[\\/]* ) continue;;+ NONE | '' ) case $ac_var in *prefix ) continue;; esac;;+ esac+ as_fn_error $? "expected an absolute directory name for --$ac_var: $ac_val"+done++# There might be people who depend on the old broken behavior: '$host'+# used to hold the argument of --host etc.+# FIXME: To remove some day.+build=$build_alias+host=$host_alias+target=$target_alias++# FIXME: To remove some day.+if test "x$host_alias" != x; then+ if test "x$build_alias" = x; then+ cross_compiling=maybe+ elif test "x$build_alias" != "x$host_alias"; then+ cross_compiling=yes+ fi+fi++ac_tool_prefix=+test -n "$host_alias" && ac_tool_prefix=$host_alias-++test "$silent" = yes && exec 6>/dev/null+++ac_pwd=`pwd` && test -n "$ac_pwd" &&+ac_ls_di=`ls -di .` &&+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||+ as_fn_error $? "working directory cannot be determined"+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||+ as_fn_error $? "pwd does not report name of working directory"+++# Find the source files, if location was not specified.+if test -z "$srcdir"; then+ ac_srcdir_defaulted=yes+ # Try the directory containing this script, then the parent directory.+ ac_confdir=`$as_dirname -- "$as_myself" ||+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+ X"$as_myself" : 'X\(//\)[^/]' \| \+ X"$as_myself" : 'X\(//\)$' \| \+ X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X"$as_myself" |+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+ s//\1/+ q+ }+ /^X\(\/\/\)[^/].*/{+ s//\1/+ q+ }+ /^X\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ srcdir=$ac_confdir+ if test ! -r "$srcdir/$ac_unique_file"; then+ srcdir=..+ fi+else+ ac_srcdir_defaulted=no+fi+if test ! -r "$srcdir/$ac_unique_file"; then+ test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."+ as_fn_error $? "cannot find sources ($ac_unique_file) in $srcdir"+fi+ac_msg="sources are in $srcdir, but 'cd $srcdir' does not work"+ac_abs_confdir=`(+ cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error $? "$ac_msg"+ pwd)`+# When building in place, set srcdir=.+if test "$ac_abs_confdir" = "$ac_pwd"; then+ srcdir=.+fi+# Remove unnecessary trailing slashes from srcdir.+# Double slashes in file names in object file debugging info+# mess up M-x gdb in Emacs.+case $srcdir in+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;+esac+for ac_var in $ac_precious_vars; do+ eval ac_env_${ac_var}_set=\${${ac_var}+set}+ eval ac_env_${ac_var}_value=\$${ac_var}+ eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}+ eval ac_cv_env_${ac_var}_value=\$${ac_var}+done++#+# Report the --help message.+#+if test "$ac_init_help" = "long"; then+ # Omit some internal or obsolete options to make the list less imposing.+ # This message is too long to be a string in the A/UX 3.1 sh.+ cat <<_ACEOF+'configure' configures XZ Utils 5.6.3 to adapt to many kinds of systems.++Usage: $0 [OPTION]... [VAR=VALUE]...++To assign environment variables (e.g., CC, CFLAGS...), specify them as+VAR=VALUE. See below for descriptions of some of the useful variables.++Defaults for the options are specified in brackets.++Configuration:+ -h, --help display this help and exit+ --help=short display options specific to this package+ --help=recursive display the short help of all the included packages+ -V, --version display version information and exit+ -q, --quiet, --silent do not print 'checking ...' messages+ --cache-file=FILE cache test results in FILE [disabled]+ -C, --config-cache alias for '--cache-file=config.cache'+ -n, --no-create do not create output files+ --srcdir=DIR find the sources in DIR [configure dir or '..']++Installation directories:+ --prefix=PREFIX install architecture-independent files in PREFIX+ [$ac_default_prefix]+ --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX+ [PREFIX]++By default, 'make install' will install all the files in+'$ac_default_prefix/bin', '$ac_default_prefix/lib' etc. You can specify+an installation prefix other than '$ac_default_prefix' using '--prefix',+for instance '--prefix=\$HOME'.++For better control, use the options below.++Fine tuning of the installation directories:+ --bindir=DIR user executables [EPREFIX/bin]+ --sbindir=DIR system admin executables [EPREFIX/sbin]+ --libexecdir=DIR program executables [EPREFIX/libexec]+ --sysconfdir=DIR read-only single-machine data [PREFIX/etc]+ --sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]+ --localstatedir=DIR modifiable single-machine data [PREFIX/var]+ --runstatedir=DIR modifiable per-process data [LOCALSTATEDIR/run]+ --libdir=DIR object code libraries [EPREFIX/lib]+ --includedir=DIR C header files [PREFIX/include]+ --oldincludedir=DIR C header files for non-gcc [/usr/include]+ --datarootdir=DIR read-only arch.-independent data root [PREFIX/share]+ --datadir=DIR read-only architecture-independent data [DATAROOTDIR]+ --infodir=DIR info documentation [DATAROOTDIR/info]+ --localedir=DIR locale-dependent data [DATAROOTDIR/locale]+ --mandir=DIR man documentation [DATAROOTDIR/man]+ --docdir=DIR documentation root [DATAROOTDIR/doc/xz]+ --htmldir=DIR html documentation [DOCDIR]+ --dvidir=DIR dvi documentation [DOCDIR]+ --pdfdir=DIR pdf documentation [DOCDIR]+ --psdir=DIR ps documentation [DOCDIR]+_ACEOF++ cat <<\_ACEOF++System types:+ --build=BUILD configure for building on BUILD [guessed]+ --host=HOST cross-compile to build programs to run on HOST [BUILD]+_ACEOF+fi++if test -n "$ac_init_help"; then+ case $ac_init_help in+ short | recursive ) echo "Configuration of XZ Utils 5.6.3:";;+ esac+ cat <<\_ACEOF++Optional Features:+ --disable-option-checking ignore unrecognized --enable/--with options+ --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]+ --enable-debug Enable debugging code.+ --enable-encoders=LIST Comma-separated list of encoders to build.+ Default=all. Available encoders: lzma1 lzma2 delta+ x86 powerpc ia64 arm armthumb arm64 sparc riscv+ --enable-decoders=LIST Comma-separated list of decoders to build.+ Default=all. Available decoders are the same as+ available encoders.+ --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 LZMA1 and LZMA2 filters.+ Available match finders: hc3 hc4 bt2 bt3 bt4+ --enable-checks=LIST Comma-separated list of integrity checks to build.+ Default=all. Available integrity checks: crc32 crc64+ sha256+ --enable-external-sha256+ Use SHA-256 code from the operating system. See+ INSTALL for possible subtle problems.+ --disable-microlzma Do not build MicroLZMA encoder and decoder. It is+ needed by specific applications only, for example,+ erofs-utils.+ --disable-lzip-decoder Disable decompression support for .lz (lzip) files.+ --disable-assembler Do not use assembler optimizations even if such+ exist for the architecture.+ --disable-clmul-crc Do not use carryless multiplication for CRC+ calculation even if support for it is detected.+ --disable-arm64-crc32 Do not use ARM64 CRC32 instructions even if support+ for it is detected.+ --disable-loongarch-crc32+ Do not use LoongArch CRC32 instructions even if+ support for them is detected.+ --enable-small Make liblzma smaller and a little slower. This is+ disabled by default to optimize for speed.+ --enable-threads=METHOD Supported METHODS are 'yes', 'no', 'posix', 'win95',+ and 'vista'. The default is 'yes'. Using 'no'+ together with --enable-small makes liblzma thread+ unsafe.+ --enable-assume-ram=SIZE+ If and only if the real amount of RAM cannot be+ determined, assume SIZE MiB. The default is 128 MiB.+ This affects the default memory usage limit.+ --disable-xz do not build the xz tool+ --disable-xzdec do not build xzdec+ --disable-lzmadec do not build lzmadec (it exists primarily for LZMA+ Utils compatibility)+ --disable-lzmainfo do not build lzmainfo (it exists primarily for LZMA+ Utils compatibility)+ --disable-lzma-links do not create symlinks for LZMA Utils compatibility+ --disable-scripts do not install the scripts xzdiff, xzgrep, xzless,+ xzmore, and their symlinks+ --disable-doc do not install documentation files to docdir (man+ pages are still installed and, if --enable-doxygen+ is used, liblzma API documentation is installed too)+ --enable-doxygen generate HTML version of the liblzma API+ documentation using Doxygen and install the result+ to docdir+ --enable-sandbox=METHOD Sandboxing METHOD can be 'auto', 'no', 'capsicum',+ 'pledge', or 'landlock'. The default is 'auto' which+ enables sandboxing if a supported sandboxing method+ is found.+ --enable-path-for-scripts=PREFIX+ If PREFIX isn't empty, PATH=PREFIX:$PATH will be set+ in the beginning of the scripts (xzgrep and others).+ The default is empty except on Solaris the default+ is /usr/xpg4/bin.+ --enable-dependency-tracking+ do not reject slow dependency extractors+ --disable-dependency-tracking+ speeds up one-time build+ --enable-shared[=PKGS] build shared libraries [default=yes]+ --enable-static[=PKGS] build static libraries [default=yes]+ --enable-fast-install[=PKGS]+ optimize for fast installation [default=yes]+ --disable-libtool-lock avoid locking (might break parallel builds)+ --enable-symbol-versions+ Use symbol versioning for liblzma. Enabled by+ default on GNU/Linux, other GNU-based systems, and+ FreeBSD.+ --disable-nls do not use Native Language Support+ --disable-rpath do not hardcode runtime library paths+ --disable-largefile omit support for large files+ --enable-unaligned-access+ Enable if the system supports *fast* unaligned+ memory access with 16-bit, 32-bit, and 64-bit+ integers. By default, this is enabled on x86,+ x86-64, 32/64-bit big endian PowerPC, 64-bit little+ endian PowerPC, and some ARM, ARM64, and RISC-V+ systems.+ --enable-unsafe-type-punning+ This introduces strict aliasing violations and may+ result in broken code. However, this might improve+ performance in some cases, especially with old+ compilers (e.g. GCC 3 and early 4.x on x86, GCC < 6+ on ARMv6 and ARMv7).+ --enable-werror Enable -Werror to abort compilation on all compiler+ warnings.+ --enable-year2038 support timestamps after 2038++Optional Packages:+ --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]+ --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)+ --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use+ both]+ --with-aix-soname=aix|svr4|both+ shared library versioning (aka "SONAME") variant to+ provide on AIX, [default=aix].+ --with-gnu-ld assume the C compiler uses GNU ld [default=no]+ --with-sysroot[=DIR] Search for dependent libraries within DIR (or the+ compiler's sysroot if not specified).+ --with-gnu-ld assume the C compiler uses GNU ld [default=no]+ --with-libiconv-prefix[=DIR] search for libiconv in DIR/include and DIR/lib+ --without-libiconv-prefix don't search for libiconv in includedir and libdir+ --with-libintl-prefix[=DIR] search for libintl in DIR/include and DIR/lib+ --without-libintl-prefix don't search for libintl in includedir and libdir++Some influential environment variables:+ CC C compiler command+ CFLAGS C compiler flags+ LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a+ nonstandard directory <lib dir>+ LIBS libraries to pass to the linker, e.g. -l<library>+ CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if+ you have headers in a nonstandard directory <include dir>+ CCAS assembler compiler command (defaults to CC)+ CCASFLAGS assembler compiler flags (defaults to CFLAGS)+ CPP C preprocessor+ LT_SYS_LIBRARY_PATH+ User-defined run-time library search path.++Use these variables to override the choices made by 'configure' or to help+it to find libraries and programs with nonstandard names/locations.++Report bugs to <lasse.collin@tukaani.org>.+XZ Utils home page: <https://tukaani.org/xz/>.+_ACEOF+ac_status=$?+fi++if test "$ac_init_help" = "recursive"; then+ # If there are subdirs, report their specific --help.+ for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue+ test -d "$ac_dir" ||+ { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||+ continue+ ac_builddir=.++case "$ac_dir" in+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;+*)+ ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'`+ # A ".." for each directory in $ac_dir_suffix.+ ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`+ case $ac_top_builddir_sub in+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;+ esac ;;+esac+ac_abs_top_builddir=$ac_pwd+ac_abs_builddir=$ac_pwd$ac_dir_suffix+# for backward compatibility:+ac_top_builddir=$ac_top_build_prefix++case $srcdir in+ .) # We are building in place.+ ac_srcdir=.+ ac_top_srcdir=$ac_top_builddir_sub+ ac_abs_top_srcdir=$ac_pwd ;;+ [\\/]* | ?:[\\/]* ) # Absolute name.+ ac_srcdir=$srcdir$ac_dir_suffix;+ ac_top_srcdir=$srcdir+ ac_abs_top_srcdir=$srcdir ;;+ *) # Relative name.+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix+ ac_top_srcdir=$ac_top_build_prefix$srcdir+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;+esac+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix++ cd "$ac_dir" || { ac_status=$?; continue; }+ # Check for configure.gnu first; this name is used for a wrapper for+ # Metaconfig's "Configure" on case-insensitive file systems.+ if test -f "$ac_srcdir/configure.gnu"; then+ echo &&+ $SHELL "$ac_srcdir/configure.gnu" --help=recursive+ elif test -f "$ac_srcdir/configure"; then+ echo &&+ $SHELL "$ac_srcdir/configure" --help=recursive+ else+ printf "%s\n" "$as_me: WARNING: no configuration information is in $ac_dir" >&2+ fi || ac_status=$?+ cd "$ac_pwd" || { ac_status=$?; break; }+ done+fi++test -n "$ac_init_help" && exit $ac_status+if $ac_init_version; then+ cat <<\_ACEOF+XZ Utils configure 5.6.3+generated by GNU Autoconf 2.72++Copyright (C) 2023 Free Software Foundation, Inc.+This configure script is free software; the Free Software Foundation+gives unlimited permission to copy, distribute and modify it.+_ACEOF+ exit+fi++## ------------------------ ##+## Autoconf initialization. ##+## ------------------------ ##++# ac_fn_c_try_compile LINENO+# --------------------------+# Try to compile conftest.$ac_ext, and return whether this succeeded.+ac_fn_c_try_compile ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ rm -f conftest.$ac_objext conftest.beam+ if { { ac_try="$ac_compile"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_compile") 2>conftest.err+ ac_status=$?+ if test -s conftest.err; then+ grep -v '^ *+' conftest.err >conftest.er1+ cat conftest.er1 >&5+ mv -f conftest.er1 conftest.err+ fi+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; } && {+ test -z "$ac_c_werror_flag" ||+ test ! -s conftest.err+ } && test -s conftest.$ac_objext+then :+ ac_retval=0+else case e in #(+ e) printf "%s\n" "$as_me: failed program was:" >&5+sed 's/^/| /' conftest.$ac_ext >&5++ ac_retval=1 ;;+esac+fi+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno+ as_fn_set_status $ac_retval++} # ac_fn_c_try_compile++# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES+# -------------------------------------------------------+# Tests whether HEADER exists and can be compiled using the include files in+# INCLUDES, setting the cache variable VAR accordingly.+ac_fn_c_check_header_compile ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5+printf %s "checking for $2... " >&6; }+if eval test \${$3+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$4+#include <$2>+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ eval "$3=yes"+else case e in #(+ e) eval "$3=no" ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+eval ac_res=\$$3+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno++} # ac_fn_c_check_header_compile++# ac_fn_c_try_link LINENO+# -----------------------+# Try to link conftest.$ac_ext, and return whether this succeeded.+ac_fn_c_try_link ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ rm -f conftest.$ac_objext conftest.beam conftest$ac_exeext+ if { { ac_try="$ac_link"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_link") 2>conftest.err+ ac_status=$?+ if test -s conftest.err; then+ grep -v '^ *+' conftest.err >conftest.er1+ cat conftest.er1 >&5+ mv -f conftest.er1 conftest.err+ fi+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; } && {+ test -z "$ac_c_werror_flag" ||+ test ! -s conftest.err+ } && test -s conftest$ac_exeext && {+ test "$cross_compiling" = yes ||+ test -x conftest$ac_exeext+ }+then :+ ac_retval=0+else case e in #(+ e) printf "%s\n" "$as_me: failed program was:" >&5+sed 's/^/| /' conftest.$ac_ext >&5++ ac_retval=1 ;;+esac+fi+ # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information+ # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would+ # interfere with the next link command; also delete a directory that is+ # left behind by Apple's compiler. We do this before executing the actions.+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno+ as_fn_set_status $ac_retval++} # ac_fn_c_try_link++# ac_fn_c_try_cpp LINENO+# ----------------------+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.+ac_fn_c_try_cpp ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ if { { ac_try="$ac_cpp conftest.$ac_ext"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err+ ac_status=$?+ if test -s conftest.err; then+ grep -v '^ *+' conftest.err >conftest.er1+ cat conftest.er1 >&5+ mv -f conftest.er1 conftest.err+ fi+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; } > conftest.i && {+ test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||+ test ! -s conftest.err+ }+then :+ ac_retval=0+else case e in #(+ e) printf "%s\n" "$as_me: failed program was:" >&5+sed 's/^/| /' conftest.$ac_ext >&5++ ac_retval=1 ;;+esac+fi+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno+ as_fn_set_status $ac_retval++} # ac_fn_c_try_cpp++# ac_fn_c_check_func LINENO FUNC VAR+# ----------------------------------+# Tests whether FUNC exists, setting the cache variable VAR accordingly+ac_fn_c_check_func ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5+printf %s "checking for $2... " >&6; }+if eval test \${$3+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.+ For example, HP-UX 11i <limits.h> declares gettimeofday. */+#define $2 innocuous_$2++/* System header to define __stub macros and hopefully few prototypes,+ which can conflict with char $2 (void); below. */++#include <limits.h>+#undef $2++/* Override any GCC internal prototype to avoid an error.+ Use char because int might match the return type of a GCC+ builtin and then its argument prototype would still apply. */+#ifdef __cplusplus+extern "C"+#endif+char $2 (void);+/* The GNU C library defines this for functions which it implements+ to always fail with ENOSYS. Some functions are actually named+ something starting with __ and the normal name is an alias. */+#if defined __stub_$2 || defined __stub___$2+choke me+#endif++int+main (void)+{+return $2 ();+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ eval "$3=yes"+else case e in #(+ e) eval "$3=no" ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext ;;+esac+fi+eval ac_res=\$$3+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno++} # ac_fn_c_check_func++# ac_fn_c_try_run LINENO+# ----------------------+# Try to run conftest.$ac_ext, and return whether this succeeded. Assumes that+# executables *can* be run.+ac_fn_c_try_run ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ if { { ac_try="$ac_link"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_link") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'+ { { case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_try") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }; }+then :+ ac_retval=0+else case e in #(+ e) printf "%s\n" "$as_me: program exited with status $ac_status" >&5+ printf "%s\n" "$as_me: failed program was:" >&5+sed 's/^/| /' conftest.$ac_ext >&5++ ac_retval=$ac_status ;;+esac+fi+ rm -rf conftest.dSYM conftest_ipa8_conftest.oo+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno+ as_fn_set_status $ac_retval++} # ac_fn_c_try_run++# ac_fn_c_check_type LINENO TYPE VAR INCLUDES+# -------------------------------------------+# Tests whether TYPE exists after having included INCLUDES, setting cache+# variable VAR accordingly.+ac_fn_c_check_type ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2" >&5+printf %s "checking for $2... " >&6; }+if eval test \${$3+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) eval "$3=no"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$4+int+main (void)+{+if (sizeof ($2))+ return 0;+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$4+int+main (void)+{+if (sizeof (($2)))+ return 0;+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++else case e in #(+ e) eval "$3=yes" ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+eval ac_res=\$$3+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno++} # ac_fn_c_check_type++# ac_fn_c_find_uintX_t LINENO BITS VAR+# ------------------------------------+# Finds an unsigned integer type with width BITS, setting cache variable VAR+# accordingly.+ac_fn_c_find_uintX_t ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for uint$2_t" >&5+printf %s "checking for uint$2_t... " >&6; }+if eval test \${$3+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) eval "$3=no"+ # Order is important - never check a type that is potentially smaller+ # than half of the expected target width.+ for ac_type in uint$2_t 'unsigned int' 'unsigned long int' \+ 'unsigned long long int' 'unsigned short int' 'unsigned char'; do+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_includes_default+int+main (void)+{+static int test_array [1 - 2 * !((($ac_type) -1 >> ($2 / 2 - 1)) >> ($2 / 2 - 1) == 3)];+test_array [0] = 0;+return test_array [0];++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ case $ac_type in #(+ uint$2_t) :+ eval "$3=yes" ;; #(+ *) :+ eval "$3=\$ac_type" ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ if eval test \"x\$"$3"\" = x"no"+then :++else case e in #(+ e) break ;;+esac+fi+ done ;;+esac+fi+eval ac_res=\$$3+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno++} # ac_fn_c_find_uintX_t++# ac_fn_c_find_intX_t LINENO BITS VAR+# -----------------------------------+# Finds a signed integer type with width BITS, setting cache variable VAR+# accordingly.+ac_fn_c_find_intX_t ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for int$2_t" >&5+printf %s "checking for int$2_t... " >&6; }+if eval test \${$3+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) eval "$3=no"+ # Order is important - never check a type that is potentially smaller+ # than half of the expected target width.+ for ac_type in int$2_t 'int' 'long int' \+ 'long long int' 'short int' 'signed char'; do+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_includes_default+ enum { N = $2 / 2 - 1 };+int+main (void)+{+static int test_array [1 - 2 * !(0 < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1))];+test_array [0] = 0;+return test_array [0];++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_includes_default+ enum { N = $2 / 2 - 1 };+int+main (void)+{+static int test_array [1 - 2 * !(($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 1)+ < ($ac_type) ((((($ac_type) 1 << N) << N) - 1) * 2 + 2))];+test_array [0] = 0;+return test_array [0];++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++else case e in #(+ e) case $ac_type in #(+ int$2_t) :+ eval "$3=yes" ;; #(+ *) :+ eval "$3=\$ac_type" ;;+esac ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ if eval test \"x\$"$3"\" = x"no"+then :++else case e in #(+ e) break ;;+esac+fi+ done ;;+esac+fi+eval ac_res=\$$3+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno++} # ac_fn_c_find_intX_t++# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES+# --------------------------------------------+# Tries to find the compile-time value of EXPR in a program that includes+# INCLUDES, setting VAR accordingly. Returns whether the value could be+# computed+ac_fn_c_compute_int ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ if test "$cross_compiling" = yes; then+ # Depending upon the size, compute the lo and hi bounds.+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$4+int+main (void)+{+static int test_array [1 - 2 * !(($2) >= 0)];+test_array [0] = 0;+return test_array [0];++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_lo=0 ac_mid=0+ while :; do+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$4+int+main (void)+{+static int test_array [1 - 2 * !(($2) <= $ac_mid)];+test_array [0] = 0;+return test_array [0];++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_hi=$ac_mid; break+else case e in #(+ e) as_fn_arith $ac_mid + 1 && ac_lo=$as_val+ if test $ac_lo -le $ac_mid; then+ ac_lo= ac_hi=+ break+ fi+ as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ done+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$4+int+main (void)+{+static int test_array [1 - 2 * !(($2) < 0)];+test_array [0] = 0;+return test_array [0];++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_hi=-1 ac_mid=-1+ while :; do+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$4+int+main (void)+{+static int test_array [1 - 2 * !(($2) >= $ac_mid)];+test_array [0] = 0;+return test_array [0];++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_lo=$ac_mid; break+else case e in #(+ e) as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val+ if test $ac_mid -le $ac_hi; then+ ac_lo= ac_hi=+ break+ fi+ as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ done+else case e in #(+ e) ac_lo= ac_hi= ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+# Binary search between lo and hi bounds.+while test "x$ac_lo" != "x$ac_hi"; do+ as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$4+int+main (void)+{+static int test_array [1 - 2 * !(($2) <= $ac_mid)];+test_array [0] = 0;+return test_array [0];++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_hi=$ac_mid+else case e in #(+ e) as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+done+case $ac_lo in #((+?*) eval "$3=\$ac_lo"; ac_retval=0 ;;+'') ac_retval=1 ;;+esac+ else+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$4+static long int longval (void) { return $2; }+static unsigned long int ulongval (void) { return $2; }+#include <stdio.h>+#include <stdlib.h>+int+main (void)+{++ FILE *f = fopen ("conftest.val", "w");+ if (! f)+ return 1;+ if (($2) < 0)+ {+ long int i = longval ();+ if (i != ($2))+ return 1;+ fprintf (f, "%ld", i);+ }+ else+ {+ unsigned long int i = ulongval ();+ if (i != ($2))+ return 1;+ fprintf (f, "%lu", i);+ }+ /* Do not output a trailing newline, as this causes \r\n confusion+ on some platforms. */+ return ferror (f) || fclose (f) != 0;++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_run "$LINENO"+then :+ echo >>conftest.val; read $3 <conftest.val; ac_retval=0+else case e in #(+ e) ac_retval=1 ;;+esac+fi+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \+ conftest.$ac_objext conftest.beam conftest.$ac_ext+rm -f conftest.val++ fi+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno+ as_fn_set_status $ac_retval++} # ac_fn_c_compute_int++# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES+# ----------------------------------------------------+# Tries to find if the field MEMBER exists in type AGGR, after including+# INCLUDES, setting cache variable VAR accordingly.+ac_fn_c_check_member ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5+printf %s "checking for $2.$3... " >&6; }+if eval test \${$4+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$5+int+main (void)+{+static $2 ac_aggr;+if (ac_aggr.$3)+return 0;+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ eval "$4=yes"+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$5+int+main (void)+{+static $2 ac_aggr;+if (sizeof ac_aggr.$3)+return 0;+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ eval "$4=yes"+else case e in #(+ e) eval "$4=no" ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+eval ac_res=\$$4+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno++} # ac_fn_c_check_member++# ac_fn_check_decl LINENO SYMBOL VAR INCLUDES EXTRA-OPTIONS FLAG-VAR+# ------------------------------------------------------------------+# Tests whether SYMBOL is declared in INCLUDES, setting cache variable VAR+# accordingly. Pass EXTRA-OPTIONS to the compiler, using FLAG-VAR.+ac_fn_check_decl ()+{+ as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ as_decl_name=`echo $2|sed 's/ *(.*//'`+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $as_decl_name is declared" >&5+printf %s "checking whether $as_decl_name is declared... " >&6; }+if eval test \${$3+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) as_decl_use=`echo $2|sed -e 's/(/((/' -e 's/)/) 0&/' -e 's/,/) 0& (/g'`+ eval ac_save_FLAGS=\$$6+ as_fn_append $6 " $5"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$4+int+main (void)+{+#ifndef $as_decl_name+#ifdef __cplusplus+ (void) $as_decl_use;+#else+ (void) $as_decl_name;+#endif+#endif++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ eval "$3=yes"+else case e in #(+ e) eval "$3=no" ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ eval $6=\$ac_save_FLAGS+ ;;+esac+fi+eval ac_res=\$$3+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }+ eval $as_lineno_stack; ${as_lineno_stack:+:} unset as_lineno++} # ac_fn_check_decl+ac_configure_args_raw=+for ac_arg+do+ case $ac_arg in+ *\'*)+ ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;+ esac+ as_fn_append ac_configure_args_raw " '$ac_arg'"+done++case $ac_configure_args_raw in+ *$as_nl*)+ ac_safe_unquote= ;;+ *)+ ac_unsafe_z='|&;<>()$`\\"*?[ '' ' # This string ends in space, tab.+ ac_unsafe_a="$ac_unsafe_z#~"+ ac_safe_unquote="s/ '\\([^$ac_unsafe_a][^$ac_unsafe_z]*\\)'/ \\1/g"+ ac_configure_args_raw=` printf "%s\n" "$ac_configure_args_raw" | sed "$ac_safe_unquote"`;;+esac++cat >config.log <<_ACEOF+This file contains any messages produced by compilers while+running configure, to aid debugging if configure makes a mistake.++It was created by XZ Utils $as_me 5.6.3, which was+generated by GNU Autoconf 2.72. Invocation command line was++ $ $0$ac_configure_args_raw++_ACEOF+exec 5>>config.log+{+cat <<_ASUNAME+## --------- ##+## Platform. ##+## --------- ##++hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`+uname -m = `(uname -m) 2>/dev/null || echo unknown`+uname -r = `(uname -r) 2>/dev/null || echo unknown`+uname -s = `(uname -s) 2>/dev/null || echo unknown`+uname -v = `(uname -v) 2>/dev/null || echo unknown`++/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`+/bin/uname -X = `(/bin/uname -X) 2>/dev/null || echo unknown`++/bin/arch = `(/bin/arch) 2>/dev/null || echo unknown`+/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null || echo unknown`+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`+/usr/bin/hostinfo = `(/usr/bin/hostinfo) 2>/dev/null || echo unknown`+/bin/machine = `(/bin/machine) 2>/dev/null || echo unknown`+/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null || echo unknown`+/bin/universe = `(/bin/universe) 2>/dev/null || echo unknown`++_ASUNAME++as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ printf "%s\n" "PATH: $as_dir"+ done+IFS=$as_save_IFS++} >&5++cat >&5 <<_ACEOF+++## ----------- ##+## Core tests. ##+## ----------- ##++_ACEOF+++# Keep a trace of the command line.+# Strip out --no-create and --no-recursion so they do not pile up.+# Strip out --silent because we don't want to record it for future runs.+# Also quote any args containing shell meta-characters.+# Make two passes to allow for proper duplicate-argument suppression.+ac_configure_args=+ac_configure_args0=+ac_configure_args1=+ac_must_keep_next=false+for ac_pass in 1 2+do+ for ac_arg+ do+ case $ac_arg in+ -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \+ | -silent | --silent | --silen | --sile | --sil)+ continue ;;+ *\'*)+ ac_arg=`printf "%s\n" "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;+ esac+ case $ac_pass in+ 1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;+ 2)+ as_fn_append ac_configure_args1 " '$ac_arg'"+ if test $ac_must_keep_next = true; then+ ac_must_keep_next=false # Got value, back to normal.+ else+ case $ac_arg in+ *=* | --config-cache | -C | -disable-* | --disable-* \+ | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \+ | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \+ | -with-* | --with-* | -without-* | --without-* | --x)+ case "$ac_configure_args0 " in+ "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;+ esac+ ;;+ -* ) ac_must_keep_next=true ;;+ esac+ fi+ as_fn_append ac_configure_args " '$ac_arg'"+ ;;+ esac+ done+done+{ ac_configure_args0=; unset ac_configure_args0;}+{ ac_configure_args1=; unset ac_configure_args1;}++# When interrupted or exit'd, cleanup temporary files, and complete+# config.log. We remove comments because anyway the quotes in there+# would cause problems or look ugly.+# WARNING: Use '\'' to represent an apostrophe within the trap.+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.+trap 'exit_status=$?+ # Sanitize IFS.+ IFS=" "" $as_nl"+ # Save into config.log some information that might help in debugging.+ {+ echo++ printf "%s\n" "## ---------------- ##+## Cache variables. ##+## ---------------- ##"+ echo+ # The following way of writing the cache mishandles newlines in values,+(+ for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do+ eval ac_val=\$$ac_var+ case $ac_val in #(+ *${as_nl}*)+ case $ac_var in #(+ *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5+printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;+ esac+ case $ac_var in #(+ _ | IFS | as_nl) ;; #(+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(+ *) { eval $ac_var=; unset $ac_var;} ;;+ esac ;;+ esac+ done+ (set) 2>&1 |+ case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(+ *${as_nl}ac_space=\ *)+ sed -n \+ "s/'\''/'\''\\\\'\'''\''/g;+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"+ ;; #(+ *)+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"+ ;;+ esac |+ sort+)+ echo++ printf "%s\n" "## ----------------- ##+## Output variables. ##+## ----------------- ##"+ echo+ for ac_var in $ac_subst_vars+ do+ eval ac_val=\$$ac_var+ case $ac_val in+ *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;+ esac+ printf "%s\n" "$ac_var='\''$ac_val'\''"+ done | sort+ echo++ if test -n "$ac_subst_files"; then+ printf "%s\n" "## ------------------- ##+## File substitutions. ##+## ------------------- ##"+ echo+ for ac_var in $ac_subst_files+ do+ eval ac_val=\$$ac_var+ case $ac_val in+ *\'\''*) ac_val=`printf "%s\n" "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;+ esac+ printf "%s\n" "$ac_var='\''$ac_val'\''"+ done | sort+ echo+ fi++ if test -s confdefs.h; then+ printf "%s\n" "## ----------- ##+## confdefs.h. ##+## ----------- ##"+ echo+ cat confdefs.h+ echo+ fi+ test "$ac_signal" != 0 &&+ printf "%s\n" "$as_me: caught signal $ac_signal"+ printf "%s\n" "$as_me: exit $exit_status"+ } >&5+ rm -f core *.core core.conftest.* &&+ rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&+ exit $exit_status+' 0+for ac_signal in 1 2 13 15; do+ trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal+done+ac_signal=0++# confdefs.h avoids OS command line length limits that DEFS can exceed.+rm -f -r conftest* confdefs.h++printf "%s\n" "/* confdefs.h */" > confdefs.h++# Predefined preprocessor variables.++printf "%s\n" "#define PACKAGE_NAME \"$PACKAGE_NAME\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_TARNAME \"$PACKAGE_TARNAME\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_VERSION \"$PACKAGE_VERSION\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_STRING \"$PACKAGE_STRING\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_BUGREPORT \"$PACKAGE_BUGREPORT\"" >>confdefs.h++printf "%s\n" "#define PACKAGE_URL \"$PACKAGE_URL\"" >>confdefs.h+++# Let the site file select an alternate cache file if it wants to.+# Prefer an explicitly selected file to automatically selected ones.+if test -n "$CONFIG_SITE"; then+ ac_site_files="$CONFIG_SITE"+elif test "x$prefix" != xNONE; then+ ac_site_files="$prefix/share/config.site $prefix/etc/config.site"+else+ ac_site_files="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site"+fi++for ac_site_file in $ac_site_files+do+ case $ac_site_file in #(+ */*) :+ ;; #(+ *) :+ ac_site_file=./$ac_site_file ;;+esac+ if test -f "$ac_site_file" && test -r "$ac_site_file"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5+printf "%s\n" "$as_me: loading site script $ac_site_file" >&6;}+ sed 's/^/| /' "$ac_site_file" >&5+ . "$ac_site_file" \+ || { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}+as_fn_error $? "failed to load site script $ac_site_file+See 'config.log' for more details" "$LINENO" 5; }+ fi+done++if test -r "$cache_file"; then+ # Some versions of bash will fail to source /dev/null (special files+ # actually), so we avoid doing that. DJGPP emulates it as a regular file.+ if test /dev/null != "$cache_file" && test -f "$cache_file"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5+printf "%s\n" "$as_me: loading cache $cache_file" >&6;}+ case $cache_file in+ [\\/]* | ?:[\\/]* ) . "$cache_file";;+ *) . "./$cache_file";;+ esac+ fi+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5+printf "%s\n" "$as_me: creating cache $cache_file" >&6;}+ >$cache_file+fi++# Test code for whether the C compiler supports C89 (global declarations)+ac_c_conftest_c89_globals='+/* Does the compiler advertise C89 conformance?+ Do not test the value of __STDC__, because some compilers set it to 0+ while being otherwise adequately conformant. */+#if !defined __STDC__+# error "Compiler does not advertise C89 conformance"+#endif++#include <stddef.h>+#include <stdarg.h>+struct stat;+/* Most of the following tests are stolen from RCS 5.7 src/conf.sh. */+struct buf { int x; };+struct buf * (*rcsopen) (struct buf *, struct stat *, int);+static char *e (char **p, int i)+{+ return p[i];+}+static char *f (char * (*g) (char **, int), char **p, ...)+{+ char *s;+ va_list v;+ va_start (v,p);+ s = g (p, va_arg (v,int));+ va_end (v);+ return s;+}++/* C89 style stringification. */+#define noexpand_stringify(a) #a+const char *stringified = noexpand_stringify(arbitrary+token=sequence);++/* C89 style token pasting. Exercises some of the corner cases that+ e.g. old MSVC gets wrong, but not very hard. */+#define noexpand_concat(a,b) a##b+#define expand_concat(a,b) noexpand_concat(a,b)+extern int vA;+extern int vbee;+#define aye A+#define bee B+int *pvA = &expand_concat(v,aye);+int *pvbee = &noexpand_concat(v,bee);++/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default. It has+ function prototypes and stuff, but not \xHH hex character constants.+ These do not provoke an error unfortunately, instead are silently treated+ as an "x". The following induces an error, until -std is added to get+ proper ANSI mode. Curiously \x00 != x always comes out true, for an+ array size at least. It is necessary to write \x00 == 0 to get something+ that is true only with -std. */+int osf4_cc_array ['\''\x00'\'' == 0 ? 1 : -1];++/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters+ inside strings and character constants. */+#define FOO(x) '\''x'\''+int xlc6_cc_array[FOO(a) == '\''x'\'' ? 1 : -1];++int test (int i, double x);+struct s1 {int (*f) (int a);};+struct s2 {int (*f) (double a);};+int pairnames (int, char **, int *(*)(struct buf *, struct stat *, int),+ int, int);'++# Test code for whether the C compiler supports C89 (body of main).+ac_c_conftest_c89_main='+ok |= (argc == 0 || f (e, argv, 0) != argv[0] || f (e, argv, 1) != argv[1]);+'++# Test code for whether the C compiler supports C99 (global declarations)+ac_c_conftest_c99_globals='+/* Does the compiler advertise C99 conformance? */+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 199901L+# error "Compiler does not advertise C99 conformance"+#endif++// See if C++-style comments work.++#include <stdbool.h>+extern int puts (const char *);+extern int printf (const char *, ...);+extern int dprintf (int, const char *, ...);+extern void *malloc (size_t);+extern void free (void *);++// Check varargs macros. These examples are taken from C99 6.10.3.5.+// dprintf is used instead of fprintf to avoid needing to declare+// FILE and stderr.+#define debug(...) dprintf (2, __VA_ARGS__)+#define showlist(...) puts (#__VA_ARGS__)+#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))+static void+test_varargs_macros (void)+{+ int x = 1234;+ int y = 5678;+ debug ("Flag");+ debug ("X = %d\n", x);+ showlist (The first, second, and third items.);+ report (x>y, "x is %d but y is %d", x, y);+}++// Check long long types.+#define BIG64 18446744073709551615ull+#define BIG32 4294967295ul+#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)+#if !BIG_OK+ #error "your preprocessor is broken"+#endif+#if BIG_OK+#else+ #error "your preprocessor is broken"+#endif+static long long int bignum = -9223372036854775807LL;+static unsigned long long int ubignum = BIG64;++struct incomplete_array+{+ int datasize;+ double data[];+};++struct named_init {+ int number;+ const wchar_t *name;+ double average;+};++typedef const char *ccp;++static inline int+test_restrict (ccp restrict text)+{+ // Iterate through items via the restricted pointer.+ // Also check for declarations in for loops.+ for (unsigned int i = 0; *(text+i) != '\''\0'\''; ++i)+ continue;+ return 0;+}++// Check varargs and va_copy.+static bool+test_varargs (const char *format, ...)+{+ va_list args;+ va_start (args, format);+ va_list args_copy;+ va_copy (args_copy, args);++ const char *str = "";+ int number = 0;+ float fnumber = 0;++ while (*format)+ {+ switch (*format++)+ {+ case '\''s'\'': // string+ str = va_arg (args_copy, const char *);+ break;+ case '\''d'\'': // int+ number = va_arg (args_copy, int);+ break;+ case '\''f'\'': // float+ fnumber = va_arg (args_copy, double);+ break;+ default:+ break;+ }+ }+ va_end (args_copy);+ va_end (args);++ return *str && number && fnumber;+}+'++# Test code for whether the C compiler supports C99 (body of main).+ac_c_conftest_c99_main='+ // Check bool.+ _Bool success = false;+ success |= (argc != 0);++ // Check restrict.+ if (test_restrict ("String literal") == 0)+ success = true;+ char *restrict newvar = "Another string";++ // Check varargs.+ success &= test_varargs ("s, d'\'' f .", "string", 65, 34.234);+ test_varargs_macros ();++ // Check flexible array members.+ struct incomplete_array *ia =+ malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));+ ia->datasize = 10;+ for (int i = 0; i < ia->datasize; ++i)+ ia->data[i] = i * 1.234;+ // Work around memory leak warnings.+ free (ia);++ // Check named initializers.+ struct named_init ni = {+ .number = 34,+ .name = L"Test wide string",+ .average = 543.34343,+ };++ ni.number = 58;++ int dynamic_array[ni.number];+ dynamic_array[0] = argv[0][0];+ dynamic_array[ni.number - 1] = 543;++ // work around unused variable warnings+ ok |= (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == '\''x'\''+ || dynamic_array[ni.number - 1] != 543);+'++# Test code for whether the C compiler supports C11 (global declarations)+ac_c_conftest_c11_globals='+/* Does the compiler advertise C11 conformance? */+#if !defined __STDC_VERSION__ || __STDC_VERSION__ < 201112L+# error "Compiler does not advertise C11 conformance"+#endif++// Check _Alignas.+char _Alignas (double) aligned_as_double;+char _Alignas (0) no_special_alignment;+extern char aligned_as_int;+char _Alignas (0) _Alignas (int) aligned_as_int;++// Check _Alignof.+enum+{+ int_alignment = _Alignof (int),+ int_array_alignment = _Alignof (int[100]),+ char_alignment = _Alignof (char)+};+_Static_assert (0 < -_Alignof (int), "_Alignof is signed");++// Check _Noreturn.+int _Noreturn does_not_return (void) { for (;;) continue; }++// Check _Static_assert.+struct test_static_assert+{+ int x;+ _Static_assert (sizeof (int) <= sizeof (long int),+ "_Static_assert does not work in struct");+ long int y;+};++// Check UTF-8 literals.+#define u8 syntax error!+char const utf8_literal[] = u8"happens to be ASCII" "another string";++// Check duplicate typedefs.+typedef long *long_ptr;+typedef long int *long_ptr;+typedef long_ptr long_ptr;++// Anonymous structures and unions -- taken from C11 6.7.2.1 Example 1.+struct anonymous+{+ union {+ struct { int i; int j; };+ struct { int k; long int l; } w;+ };+ int m;+} v1;+'++# Test code for whether the C compiler supports C11 (body of main).+ac_c_conftest_c11_main='+ _Static_assert ((offsetof (struct anonymous, i)+ == offsetof (struct anonymous, w.k)),+ "Anonymous union alignment botch");+ v1.i = 2;+ v1.w.k = 5;+ ok |= v1.i != 5;+'++# Test code for whether the C compiler supports C11 (complete).+ac_c_conftest_c11_program="${ac_c_conftest_c89_globals}+${ac_c_conftest_c99_globals}+${ac_c_conftest_c11_globals}++int+main (int argc, char **argv)+{+ int ok = 0;+ ${ac_c_conftest_c89_main}+ ${ac_c_conftest_c99_main}+ ${ac_c_conftest_c11_main}+ return ok;+}+"++# Test code for whether the C compiler supports C99 (complete).+ac_c_conftest_c99_program="${ac_c_conftest_c89_globals}+${ac_c_conftest_c99_globals}++int+main (int argc, char **argv)+{+ int ok = 0;+ ${ac_c_conftest_c89_main}+ ${ac_c_conftest_c99_main}+ return ok;+}+"++# Test code for whether the C compiler supports C89 (complete).+ac_c_conftest_c89_program="${ac_c_conftest_c89_globals}++int+main (int argc, char **argv)+{+ int ok = 0;+ ${ac_c_conftest_c89_main}+ return ok;+}+"++as_fn_append ac_header_c_list " stdio.h stdio_h HAVE_STDIO_H"+as_fn_append ac_header_c_list " stdlib.h stdlib_h HAVE_STDLIB_H"+as_fn_append ac_header_c_list " string.h string_h HAVE_STRING_H"+as_fn_append ac_header_c_list " inttypes.h inttypes_h HAVE_INTTYPES_H"+as_fn_append ac_header_c_list " stdint.h stdint_h HAVE_STDINT_H"+as_fn_append ac_header_c_list " strings.h strings_h HAVE_STRINGS_H"+as_fn_append ac_header_c_list " sys/stat.h sys_stat_h HAVE_SYS_STAT_H"+as_fn_append ac_header_c_list " sys/types.h sys_types_h HAVE_SYS_TYPES_H"+as_fn_append ac_header_c_list " unistd.h unistd_h HAVE_UNISTD_H"+as_fn_append ac_header_c_list " wchar.h wchar_h HAVE_WCHAR_H"+as_fn_append ac_header_c_list " minix/config.h minix_config_h HAVE_MINIX_CONFIG_H"+gt_needs="$gt_needs "+as_fn_append ac_header_c_list " sys/cdefs.h sys_cdefs_h HAVE_SYS_CDEFS_H"++# Auxiliary files required by this configure script.+ac_aux_files="config.rpath install-sh ltmain.sh config.guess config.sub"++# Locations in which to look for auxiliary files.+ac_aux_dir_candidates="${srcdir}/build/autoconf"++# Search for a directory containing all of the required auxiliary files,+# $ac_aux_files, from the $PATH-style list $ac_aux_dir_candidates.+# If we don't find one directory that contains all the files we need,+# we report the set of missing files from the *first* directory in+# $ac_aux_dir_candidates and give up.+ac_missing_aux_files=""+ac_first_candidate=:+printf "%s\n" "$as_me:${as_lineno-$LINENO}: looking for aux files: $ac_aux_files" >&5+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+as_found=false+for as_dir in $ac_aux_dir_candidates+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ as_found=:++ printf "%s\n" "$as_me:${as_lineno-$LINENO}: trying $as_dir" >&5+ ac_aux_dir_found=yes+ ac_install_sh=+ for ac_aux in $ac_aux_files+ do+ # As a special case, if "install-sh" is required, that requirement+ # can be satisfied by any of "install-sh", "install.sh", or "shtool",+ # and $ac_install_sh is set appropriately for whichever one is found.+ if test x"$ac_aux" = x"install-sh"+ then+ if test -f "${as_dir}install-sh"; then+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install-sh found" >&5+ ac_install_sh="${as_dir}install-sh -c"+ elif test -f "${as_dir}install.sh"; then+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}install.sh found" >&5+ ac_install_sh="${as_dir}install.sh -c"+ elif test -f "${as_dir}shtool"; then+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}shtool found" >&5+ ac_install_sh="${as_dir}shtool install -c"+ else+ ac_aux_dir_found=no+ if $ac_first_candidate; then+ ac_missing_aux_files="${ac_missing_aux_files} install-sh"+ else+ break+ fi+ fi+ else+ if test -f "${as_dir}${ac_aux}"; then+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: ${as_dir}${ac_aux} found" >&5+ else+ ac_aux_dir_found=no+ if $ac_first_candidate; then+ ac_missing_aux_files="${ac_missing_aux_files} ${ac_aux}"+ else+ break+ fi+ fi+ fi+ done+ if test "$ac_aux_dir_found" = yes; then+ ac_aux_dir="$as_dir"+ break+ fi+ ac_first_candidate=false++ as_found=false+done+IFS=$as_save_IFS+if $as_found+then :++else case e in #(+ e) as_fn_error $? "cannot find required auxiliary files:$ac_missing_aux_files" "$LINENO" 5 ;;+esac+fi+++# These three variables are undocumented and unsupported,+# and are intended to be withdrawn in a future Autoconf release.+# They can cause serious problems if a builder's source tree is in a directory+# whose full name contains unusual characters.+if test -f "${ac_aux_dir}config.guess"; then+ ac_config_guess="$SHELL ${ac_aux_dir}config.guess"+fi+if test -f "${ac_aux_dir}config.sub"; then+ ac_config_sub="$SHELL ${ac_aux_dir}config.sub"+fi+if test -f "$ac_aux_dir/configure"; then+ ac_configure="$SHELL ${ac_aux_dir}configure"+fi++# Check that the precious variables saved in the cache have kept the same+# value.+ac_cache_corrupted=false+for ac_var in $ac_precious_vars; do+ eval ac_old_set=\$ac_cv_env_${ac_var}_set+ eval ac_new_set=\$ac_env_${ac_var}_set+ eval ac_old_val=\$ac_cv_env_${ac_var}_value+ eval ac_new_val=\$ac_env_${ac_var}_value+ case $ac_old_set,$ac_new_set in+ set,)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: '$ac_var' was set to '$ac_old_val' in the previous run" >&5+printf "%s\n" "$as_me: error: '$ac_var' was set to '$ac_old_val' in the previous run" >&2;}+ ac_cache_corrupted=: ;;+ ,set)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: '$ac_var' was not set in the previous run" >&5+printf "%s\n" "$as_me: error: '$ac_var' was not set in the previous run" >&2;}+ ac_cache_corrupted=: ;;+ ,);;+ *)+ if test "x$ac_old_val" != "x$ac_new_val"; then+ # differences in whitespace do not lead to failure.+ ac_old_val_w=`echo x $ac_old_val`+ ac_new_val_w=`echo x $ac_new_val`+ if test "$ac_old_val_w" != "$ac_new_val_w"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: '$ac_var' has changed since the previous run:" >&5+printf "%s\n" "$as_me: error: '$ac_var' has changed since the previous run:" >&2;}+ ac_cache_corrupted=:+ else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in '$ac_var' since the previous run:" >&5+printf "%s\n" "$as_me: warning: ignoring whitespace changes in '$ac_var' since the previous run:" >&2;}+ eval $ac_var=\$ac_old_val+ fi+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: former value: '$ac_old_val'" >&5+printf "%s\n" "$as_me: former value: '$ac_old_val'" >&2;}+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: current value: '$ac_new_val'" >&5+printf "%s\n" "$as_me: current value: '$ac_new_val'" >&2;}+ fi;;+ esac+ # Pass precious variables to config.status.+ if test "$ac_new_set" = set; then+ case $ac_new_val in+ *\'*) ac_arg=$ac_var=`printf "%s\n" "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;+ *) ac_arg=$ac_var=$ac_new_val ;;+ esac+ case " $ac_configure_args " in+ *" '$ac_arg' "*) ;; # Avoid dups. Use of quotes ensures accuracy.+ *) as_fn_append ac_configure_args " '$ac_arg'" ;;+ esac+ fi+done+if $ac_cache_corrupted; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5+printf "%s\n" "$as_me: error: changes in the environment can compromise the build" >&2;}+ as_fn_error $? "run '${MAKE-make} distclean' and/or 'rm $cache_file'+ and start over" "$LINENO" 5+fi+## -------------------- ##+## Main body of script. ##+## -------------------- ##++ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu++++++ac_config_headers="$ac_config_headers cbits/config.h"+++echo+echo "$PACKAGE_STRING"++echo+echo "System type:"+# This is needed to know if assembler optimizations can be used.++++ # Make sure we can run config.sub.+$SHELL "${ac_aux_dir}config.sub" sun4 >/dev/null 2>&1 ||+ as_fn_error $? "cannot run $SHELL ${ac_aux_dir}config.sub" "$LINENO" 5++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking build system type" >&5+printf %s "checking build system type... " >&6; }+if test ${ac_cv_build+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_build_alias=$build_alias+test "x$ac_build_alias" = x &&+ ac_build_alias=`$SHELL "${ac_aux_dir}config.guess"`+test "x$ac_build_alias" = x &&+ as_fn_error $? "cannot guess build type; you must specify one" "$LINENO" 5+ac_cv_build=`$SHELL "${ac_aux_dir}config.sub" $ac_build_alias` ||+ as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $ac_build_alias failed" "$LINENO" 5+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5+printf "%s\n" "$ac_cv_build" >&6; }+case $ac_cv_build in+*-*-*) ;;+*) as_fn_error $? "invalid value of canonical build" "$LINENO" 5;;+esac+build=$ac_cv_build+ac_save_IFS=$IFS; IFS='-'+set x $ac_cv_build+shift+build_cpu=$1+build_vendor=$2+shift; shift+# Remember, the first character of IFS is used to create $*,+# except with old shells:+build_os=$*+IFS=$ac_save_IFS+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac+++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking host system type" >&5+printf %s "checking host system type... " >&6; }+if test ${ac_cv_host+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test "x$host_alias" = x; then+ ac_cv_host=$ac_cv_build+else+ ac_cv_host=`$SHELL "${ac_aux_dir}config.sub" $host_alias` ||+ as_fn_error $? "$SHELL ${ac_aux_dir}config.sub $host_alias failed" "$LINENO" 5+fi+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5+printf "%s\n" "$ac_cv_host" >&6; }+case $ac_cv_host in+*-*-*) ;;+*) as_fn_error $? "invalid value of canonical host" "$LINENO" 5;;+esac+host=$ac_cv_host+ac_save_IFS=$IFS; IFS='-'+set x $ac_cv_host+shift+host_cpu=$1+host_vendor=$2+shift; shift+# Remember, the first character of IFS is used to create $*,+# except with old shells:+host_os=$*+IFS=$ac_save_IFS+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac++++# We do some special things on Windows (32-bit or 64-bit) builds.+case $host_os in+ mingw* | cygwin | msys) is_w32=yes ;;+ *) is_w32=no ;;+esac+ if test "$is_w32" = yes; then+ COND_W32_TRUE=+ COND_W32_FALSE='#'+else+ COND_W32_TRUE='#'+ COND_W32_FALSE=+fi+++# We need to use $EXEEXT with $(LN_S) when creating symlinks to+# executables. Cygwin is an exception to this, since it is recommended+# that symlinks don't have the .exe suffix. To make this work, we+# define LN_EXEEXT.+#+# MSYS2 is treated the same way as Cygwin. It uses plain "msys" like+# the original MSYS when building MSYS/MSYS2-binaries. Hopefully this+# doesn't break things for the original MSYS developers. Note that this+# doesn't affect normal MSYS/MSYS2 users building non-MSYS/MSYS2 binaries+# since in that case the $host_os is usually mingw32.+case $host_os in+ cygwin | msys) LN_EXEEXT= ;;+ *) LN_EXEEXT='$(EXEEXT)' ;;+esac+++echo+echo "Configure options:"+AM_CFLAGS=+++#############+# Debugging #+#############++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if debugging code should be compiled" >&5+printf %s "checking if debugging code should be compiled... " >&6; }+# Check whether --enable-debug was given.+if test ${enable_debug+y}+then :+ enableval=$enable_debug;+else case e in #(+ e) enable_debug=no ;;+esac+fi++if test "x$enable_debug" = xyes; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }+else++printf "%s\n" "#define NDEBUG 1" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++###########+# Filters #+###########+++++enable_filter_lzma1=no+enable_encoder_lzma1=no+enable_decoder_lzma1=no+enable_filter_lzma2=no+enable_encoder_lzma2=no+enable_decoder_lzma2=no+enable_filter_delta=no+enable_encoder_delta=no+enable_decoder_delta=no+enable_filter_x86=no+enable_encoder_x86=no+enable_decoder_x86=no+enable_filter_powerpc=no+enable_encoder_powerpc=no+enable_decoder_powerpc=no+enable_filter_ia64=no+enable_encoder_ia64=no+enable_decoder_ia64=no+enable_filter_arm=no+enable_encoder_arm=no+enable_decoder_arm=no+enable_filter_armthumb=no+enable_encoder_armthumb=no+enable_decoder_armthumb=no+enable_filter_arm64=no+enable_encoder_arm64=no+enable_decoder_arm64=no+enable_filter_sparc=no+enable_encoder_sparc=no+enable_decoder_sparc=no+enable_filter_riscv=no+enable_encoder_riscv=no+enable_decoder_riscv=no++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which encoders to build" >&5+printf %s "checking which encoders to build... " >&6; }+# Check whether --enable-encoders was given.+if test ${enable_encoders+y}+then :+ enableval=$enable_encoders;+else case e in #(+ e) enable_encoders=lzma1,lzma2,delta,x86,powerpc,ia64,arm,armthumb,arm64,sparc,riscv ;;+esac+fi++enable_encoders=`echo "$enable_encoders" | sed 's/,/ /g'`+if test "x$enable_encoders" = xno || test "x$enable_encoders" = x; then+ enable_encoders=no+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: (none)" >&5+printf "%s\n" "(none)" >&6; }+else+ for arg in $enable_encoders+ do+ case $arg in+ lzma1)+ enable_filter_lzma1=yes+ enable_encoder_lzma1=yes++printf "%s\n" "#define HAVE_ENCODER_LZMA1 1" >>confdefs.h++ ;;+ lzma2)+ enable_filter_lzma2=yes+ enable_encoder_lzma2=yes++printf "%s\n" "#define HAVE_ENCODER_LZMA2 1" >>confdefs.h++ ;;+ delta)+ enable_filter_delta=yes+ enable_encoder_delta=yes++printf "%s\n" "#define HAVE_ENCODER_DELTA 1" >>confdefs.h++ ;;+ x86)+ enable_filter_x86=yes+ enable_encoder_x86=yes++printf "%s\n" "#define HAVE_ENCODER_X86 1" >>confdefs.h++ ;;+ powerpc)+ enable_filter_powerpc=yes+ enable_encoder_powerpc=yes++printf "%s\n" "#define HAVE_ENCODER_POWERPC 1" >>confdefs.h++ ;;+ ia64)+ enable_filter_ia64=yes+ enable_encoder_ia64=yes++printf "%s\n" "#define HAVE_ENCODER_IA64 1" >>confdefs.h++ ;;+ arm)+ enable_filter_arm=yes+ enable_encoder_arm=yes++printf "%s\n" "#define HAVE_ENCODER_ARM 1" >>confdefs.h++ ;;+ armthumb)+ enable_filter_armthumb=yes+ enable_encoder_armthumb=yes++printf "%s\n" "#define HAVE_ENCODER_ARMTHUMB 1" >>confdefs.h++ ;;+ arm64)+ enable_filter_arm64=yes+ enable_encoder_arm64=yes++printf "%s\n" "#define HAVE_ENCODER_ARM64 1" >>confdefs.h++ ;;+ sparc)+ enable_filter_sparc=yes+ enable_encoder_sparc=yes++printf "%s\n" "#define HAVE_ENCODER_SPARC 1" >>confdefs.h++ ;;+ riscv)+ enable_filter_riscv=yes+ enable_encoder_riscv=yes++printf "%s\n" "#define HAVE_ENCODER_RISCV 1" >>confdefs.h++ ;;+ *)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5+printf "%s\n" "" >&6; }+ as_fn_error $? "unknown filter: $arg" "$LINENO" 5+ ;;+ esac+ done++printf "%s\n" "#define HAVE_ENCODERS 1" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_encoders" >&5+printf "%s\n" "$enable_encoders" >&6; }+fi++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which decoders to build" >&5+printf %s "checking which decoders to build... " >&6; }+# Check whether --enable-decoders was given.+if test ${enable_decoders+y}+then :+ enableval=$enable_decoders;+else case e in #(+ e) enable_decoders=lzma1,lzma2,delta,x86,powerpc,ia64,arm,armthumb,arm64,sparc,riscv ;;+esac+fi++enable_decoders=`echo "$enable_decoders" | sed 's/,/ /g'`+if test "x$enable_decoders" = xno || test "x$enable_decoders" = x; then+ enable_decoders=no+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: (none)" >&5+printf "%s\n" "(none)" >&6; }+else+ for arg in $enable_decoders+ do+ case $arg in+ lzma1)+ enable_filter_lzma1=yes+ enable_decoder_lzma1=yes++printf "%s\n" "#define HAVE_DECODER_LZMA1 1" >>confdefs.h++ ;;+ lzma2)+ enable_filter_lzma2=yes+ enable_decoder_lzma2=yes++printf "%s\n" "#define HAVE_DECODER_LZMA2 1" >>confdefs.h++ ;;+ delta)+ enable_filter_delta=yes+ enable_decoder_delta=yes++printf "%s\n" "#define HAVE_DECODER_DELTA 1" >>confdefs.h++ ;;+ x86)+ enable_filter_x86=yes+ enable_decoder_x86=yes++printf "%s\n" "#define HAVE_DECODER_X86 1" >>confdefs.h++ ;;+ powerpc)+ enable_filter_powerpc=yes+ enable_decoder_powerpc=yes++printf "%s\n" "#define HAVE_DECODER_POWERPC 1" >>confdefs.h++ ;;+ ia64)+ enable_filter_ia64=yes+ enable_decoder_ia64=yes++printf "%s\n" "#define HAVE_DECODER_IA64 1" >>confdefs.h++ ;;+ arm)+ enable_filter_arm=yes+ enable_decoder_arm=yes++printf "%s\n" "#define HAVE_DECODER_ARM 1" >>confdefs.h++ ;;+ armthumb)+ enable_filter_armthumb=yes+ enable_decoder_armthumb=yes++printf "%s\n" "#define HAVE_DECODER_ARMTHUMB 1" >>confdefs.h++ ;;+ arm64)+ enable_filter_arm64=yes+ enable_decoder_arm64=yes++printf "%s\n" "#define HAVE_DECODER_ARM64 1" >>confdefs.h++ ;;+ sparc)+ enable_filter_sparc=yes+ enable_decoder_sparc=yes++printf "%s\n" "#define HAVE_DECODER_SPARC 1" >>confdefs.h++ ;;+ riscv)+ enable_filter_riscv=yes+ enable_decoder_riscv=yes++printf "%s\n" "#define HAVE_DECODER_RISCV 1" >>confdefs.h++ ;;+ *)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5+printf "%s\n" "" >&6; }+ as_fn_error $? "unknown filter: $arg" "$LINENO" 5+ ;;+ esac+ done++printf "%s\n" "#define HAVE_DECODERS 1" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_decoders" >&5+printf "%s\n" "$enable_decoders" >&6; }+fi++if test "x$enable_encoder_lzma2$enable_encoder_lzma1" = xyesno \+ || test "x$enable_decoder_lzma2$enable_decoder_lzma1" = xyesno; then+ as_fn_error $? "LZMA2 requires that LZMA1 is also enabled." "$LINENO" 5+fi++ if test "x$enable_encoders" != xno; then+ COND_MAIN_ENCODER_TRUE=+ COND_MAIN_ENCODER_FALSE='#'+else+ COND_MAIN_ENCODER_TRUE='#'+ COND_MAIN_ENCODER_FALSE=+fi++ if test "x$enable_decoders" != xno; then+ COND_MAIN_DECODER_TRUE=+ COND_MAIN_DECODER_FALSE='#'+else+ COND_MAIN_DECODER_TRUE='#'+ COND_MAIN_DECODER_FALSE=+fi+++ if test "x$enable_filter_lzma1" = xyes; then+ COND_FILTER_LZMA1_TRUE=+ COND_FILTER_LZMA1_FALSE='#'+else+ COND_FILTER_LZMA1_TRUE='#'+ COND_FILTER_LZMA1_FALSE=+fi++ if test "x$enable_encoder_lzma1" = xyes; then+ COND_ENCODER_LZMA1_TRUE=+ COND_ENCODER_LZMA1_FALSE='#'+else+ COND_ENCODER_LZMA1_TRUE='#'+ COND_ENCODER_LZMA1_FALSE=+fi++ if test "x$enable_decoder_lzma1" = xyes; then+ COND_DECODER_LZMA1_TRUE=+ COND_DECODER_LZMA1_FALSE='#'+else+ COND_DECODER_LZMA1_TRUE='#'+ COND_DECODER_LZMA1_FALSE=+fi++ if test "x$enable_filter_lzma2" = xyes; then+ COND_FILTER_LZMA2_TRUE=+ COND_FILTER_LZMA2_FALSE='#'+else+ COND_FILTER_LZMA2_TRUE='#'+ COND_FILTER_LZMA2_FALSE=+fi++ if test "x$enable_encoder_lzma2" = xyes; then+ COND_ENCODER_LZMA2_TRUE=+ COND_ENCODER_LZMA2_FALSE='#'+else+ COND_ENCODER_LZMA2_TRUE='#'+ COND_ENCODER_LZMA2_FALSE=+fi++ if test "x$enable_decoder_lzma2" = xyes; then+ COND_DECODER_LZMA2_TRUE=+ COND_DECODER_LZMA2_FALSE='#'+else+ COND_DECODER_LZMA2_TRUE='#'+ COND_DECODER_LZMA2_FALSE=+fi++ if test "x$enable_filter_delta" = xyes; then+ COND_FILTER_DELTA_TRUE=+ COND_FILTER_DELTA_FALSE='#'+else+ COND_FILTER_DELTA_TRUE='#'+ COND_FILTER_DELTA_FALSE=+fi++ if test "x$enable_encoder_delta" = xyes; then+ COND_ENCODER_DELTA_TRUE=+ COND_ENCODER_DELTA_FALSE='#'+else+ COND_ENCODER_DELTA_TRUE='#'+ COND_ENCODER_DELTA_FALSE=+fi++ if test "x$enable_decoder_delta" = xyes; then+ COND_DECODER_DELTA_TRUE=+ COND_DECODER_DELTA_FALSE='#'+else+ COND_DECODER_DELTA_TRUE='#'+ COND_DECODER_DELTA_FALSE=+fi++ if test "x$enable_filter_x86" = xyes; then+ COND_FILTER_X86_TRUE=+ COND_FILTER_X86_FALSE='#'+else+ COND_FILTER_X86_TRUE='#'+ COND_FILTER_X86_FALSE=+fi++ if test "x$enable_encoder_x86" = xyes; then+ COND_ENCODER_X86_TRUE=+ COND_ENCODER_X86_FALSE='#'+else+ COND_ENCODER_X86_TRUE='#'+ COND_ENCODER_X86_FALSE=+fi++ if test "x$enable_decoder_x86" = xyes; then+ COND_DECODER_X86_TRUE=+ COND_DECODER_X86_FALSE='#'+else+ COND_DECODER_X86_TRUE='#'+ COND_DECODER_X86_FALSE=+fi++ if test "x$enable_filter_powerpc" = xyes; then+ COND_FILTER_POWERPC_TRUE=+ COND_FILTER_POWERPC_FALSE='#'+else+ COND_FILTER_POWERPC_TRUE='#'+ COND_FILTER_POWERPC_FALSE=+fi++ if test "x$enable_encoder_powerpc" = xyes; then+ COND_ENCODER_POWERPC_TRUE=+ COND_ENCODER_POWERPC_FALSE='#'+else+ COND_ENCODER_POWERPC_TRUE='#'+ COND_ENCODER_POWERPC_FALSE=+fi++ if test "x$enable_decoder_powerpc" = xyes; then+ COND_DECODER_POWERPC_TRUE=+ COND_DECODER_POWERPC_FALSE='#'+else+ COND_DECODER_POWERPC_TRUE='#'+ COND_DECODER_POWERPC_FALSE=+fi++ if test "x$enable_filter_ia64" = xyes; then+ COND_FILTER_IA64_TRUE=+ COND_FILTER_IA64_FALSE='#'+else+ COND_FILTER_IA64_TRUE='#'+ COND_FILTER_IA64_FALSE=+fi++ if test "x$enable_encoder_ia64" = xyes; then+ COND_ENCODER_IA64_TRUE=+ COND_ENCODER_IA64_FALSE='#'+else+ COND_ENCODER_IA64_TRUE='#'+ COND_ENCODER_IA64_FALSE=+fi++ if test "x$enable_decoder_ia64" = xyes; then+ COND_DECODER_IA64_TRUE=+ COND_DECODER_IA64_FALSE='#'+else+ COND_DECODER_IA64_TRUE='#'+ COND_DECODER_IA64_FALSE=+fi++ if test "x$enable_filter_arm" = xyes; then+ COND_FILTER_ARM_TRUE=+ COND_FILTER_ARM_FALSE='#'+else+ COND_FILTER_ARM_TRUE='#'+ COND_FILTER_ARM_FALSE=+fi++ if test "x$enable_encoder_arm" = xyes; then+ COND_ENCODER_ARM_TRUE=+ COND_ENCODER_ARM_FALSE='#'+else+ COND_ENCODER_ARM_TRUE='#'+ COND_ENCODER_ARM_FALSE=+fi++ if test "x$enable_decoder_arm" = xyes; then+ COND_DECODER_ARM_TRUE=+ COND_DECODER_ARM_FALSE='#'+else+ COND_DECODER_ARM_TRUE='#'+ COND_DECODER_ARM_FALSE=+fi++ if test "x$enable_filter_armthumb" = xyes; then+ COND_FILTER_ARMTHUMB_TRUE=+ COND_FILTER_ARMTHUMB_FALSE='#'+else+ COND_FILTER_ARMTHUMB_TRUE='#'+ COND_FILTER_ARMTHUMB_FALSE=+fi++ if test "x$enable_encoder_armthumb" = xyes; then+ COND_ENCODER_ARMTHUMB_TRUE=+ COND_ENCODER_ARMTHUMB_FALSE='#'+else+ COND_ENCODER_ARMTHUMB_TRUE='#'+ COND_ENCODER_ARMTHUMB_FALSE=+fi++ if test "x$enable_decoder_armthumb" = xyes; then+ COND_DECODER_ARMTHUMB_TRUE=+ COND_DECODER_ARMTHUMB_FALSE='#'+else+ COND_DECODER_ARMTHUMB_TRUE='#'+ COND_DECODER_ARMTHUMB_FALSE=+fi++ if test "x$enable_filter_arm64" = xyes; then+ COND_FILTER_ARM64_TRUE=+ COND_FILTER_ARM64_FALSE='#'+else+ COND_FILTER_ARM64_TRUE='#'+ COND_FILTER_ARM64_FALSE=+fi++ if test "x$enable_encoder_arm64" = xyes; then+ COND_ENCODER_ARM64_TRUE=+ COND_ENCODER_ARM64_FALSE='#'+else+ COND_ENCODER_ARM64_TRUE='#'+ COND_ENCODER_ARM64_FALSE=+fi++ if test "x$enable_decoder_arm64" = xyes; then+ COND_DECODER_ARM64_TRUE=+ COND_DECODER_ARM64_FALSE='#'+else+ COND_DECODER_ARM64_TRUE='#'+ COND_DECODER_ARM64_FALSE=+fi++ if test "x$enable_filter_sparc" = xyes; then+ COND_FILTER_SPARC_TRUE=+ COND_FILTER_SPARC_FALSE='#'+else+ COND_FILTER_SPARC_TRUE='#'+ COND_FILTER_SPARC_FALSE=+fi++ if test "x$enable_encoder_sparc" = xyes; then+ COND_ENCODER_SPARC_TRUE=+ COND_ENCODER_SPARC_FALSE='#'+else+ COND_ENCODER_SPARC_TRUE='#'+ COND_ENCODER_SPARC_FALSE=+fi++ if test "x$enable_decoder_sparc" = xyes; then+ COND_DECODER_SPARC_TRUE=+ COND_DECODER_SPARC_FALSE='#'+else+ COND_DECODER_SPARC_TRUE='#'+ COND_DECODER_SPARC_FALSE=+fi++ if test "x$enable_filter_riscv" = xyes; then+ COND_FILTER_RISCV_TRUE=+ COND_FILTER_RISCV_FALSE='#'+else+ COND_FILTER_RISCV_TRUE='#'+ COND_FILTER_RISCV_FALSE=+fi++ if test "x$enable_encoder_riscv" = xyes; then+ COND_ENCODER_RISCV_TRUE=+ COND_ENCODER_RISCV_FALSE='#'+else+ COND_ENCODER_RISCV_TRUE='#'+ COND_ENCODER_RISCV_FALSE=+fi++ if test "x$enable_decoder_riscv" = xyes; then+ COND_DECODER_RISCV_TRUE=+ COND_DECODER_RISCV_FALSE='#'+else+ COND_DECODER_RISCV_TRUE='#'+ COND_DECODER_RISCV_FALSE=+fi+++# The so called "simple filters" share common code.+enable_filter_simple=no+enable_encoder_simple=no+enable_decoder_simple=no+test "x$enable_filter_x86" = xyes && enable_filter_simple=yes+test "x$enable_encoder_x86" = xyes && enable_encoder_simple=yes+test "x$enable_decoder_x86" = xyes && enable_decoder_simple=yes+test "x$enable_filter_powerpc" = xyes && enable_filter_simple=yes+test "x$enable_encoder_powerpc" = xyes && enable_encoder_simple=yes+test "x$enable_decoder_powerpc" = xyes && enable_decoder_simple=yes+test "x$enable_filter_ia64" = xyes && enable_filter_simple=yes+test "x$enable_encoder_ia64" = xyes && enable_encoder_simple=yes+test "x$enable_decoder_ia64" = xyes && enable_decoder_simple=yes+test "x$enable_filter_arm" = xyes && enable_filter_simple=yes+test "x$enable_encoder_arm" = xyes && enable_encoder_simple=yes+test "x$enable_decoder_arm" = xyes && enable_decoder_simple=yes+test "x$enable_filter_armthumb" = xyes && enable_filter_simple=yes+test "x$enable_encoder_armthumb" = xyes && enable_encoder_simple=yes+test "x$enable_decoder_armthumb" = xyes && enable_decoder_simple=yes+test "x$enable_filter_arm64" = xyes && enable_filter_simple=yes+test "x$enable_encoder_arm64" = xyes && enable_encoder_simple=yes+test "x$enable_decoder_arm64" = xyes && enable_decoder_simple=yes+test "x$enable_filter_sparc" = xyes && enable_filter_simple=yes+test "x$enable_encoder_sparc" = xyes && enable_encoder_simple=yes+test "x$enable_decoder_sparc" = xyes && enable_decoder_simple=yes+test "x$enable_filter_riscv" = xyes && enable_filter_simple=yes+test "x$enable_encoder_riscv" = xyes && enable_encoder_simple=yes+test "x$enable_decoder_riscv" = xyes && enable_decoder_simple=yes+ if test "x$enable_filter_simple" = xyes; then+ COND_FILTER_SIMPLE_TRUE=+ COND_FILTER_SIMPLE_FALSE='#'+else+ COND_FILTER_SIMPLE_TRUE='#'+ COND_FILTER_SIMPLE_FALSE=+fi++ if test "x$enable_encoder_simple" = xyes; then+ COND_ENCODER_SIMPLE_TRUE=+ COND_ENCODER_SIMPLE_FALSE='#'+else+ COND_ENCODER_SIMPLE_TRUE='#'+ COND_ENCODER_SIMPLE_FALSE=+fi++ if test "x$enable_decoder_simple" = xyes; then+ COND_DECODER_SIMPLE_TRUE=+ COND_DECODER_SIMPLE_FALSE='#'+else+ COND_DECODER_SIMPLE_TRUE='#'+ COND_DECODER_SIMPLE_FALSE=+fi+++# LZ-based filters share common code.+enable_filter_lz=no+enable_encoder_lz=no+enable_decoder_lz=no+test "x$enable_filter_lzma1" = xyes && enable_filter_lz=yes+test "x$enable_encoder_lzma1" = xyes && enable_encoder_lz=yes+test "x$enable_decoder_lzma1" = xyes && enable_decoder_lz=yes+test "x$enable_filter_lzma2" = xyes && enable_filter_lz=yes+test "x$enable_encoder_lzma2" = xyes && enable_encoder_lz=yes+test "x$enable_decoder_lzma2" = xyes && enable_decoder_lz=yes+ if test "x$enable_filter_lz" = xyes; then+ COND_FILTER_LZ_TRUE=+ COND_FILTER_LZ_FALSE='#'+else+ COND_FILTER_LZ_TRUE='#'+ COND_FILTER_LZ_FALSE=+fi++ if test "x$enable_encoder_lz" = xyes; then+ COND_ENCODER_LZ_TRUE=+ COND_ENCODER_LZ_FALSE='#'+else+ COND_ENCODER_LZ_TRUE='#'+ COND_ENCODER_LZ_FALSE=+fi++ if test "x$enable_decoder_lz" = xyes; then+ COND_DECODER_LZ_TRUE=+ COND_DECODER_LZ_FALSE='#'+else+ COND_DECODER_LZ_TRUE='#'+ COND_DECODER_LZ_FALSE=+fi++++#################+# Match finders #+#################++++enable_match_finder_hc3=no+enable_match_finder_hc4=no+enable_match_finder_bt2=no+enable_match_finder_bt3=no+enable_match_finder_bt4=no+++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which match finders to build" >&5+printf %s "checking which match finders to build... " >&6; }+# Check whether --enable-match-finders was given.+if test ${enable_match_finders+y}+then :+ enableval=$enable_match_finders;+else case e in #(+ e) enable_match_finders=hc3,hc4,bt2,bt3,bt4 ;;+esac+fi++enable_match_finders=`echo "$enable_match_finders" | sed 's/,/ /g'`+if test "x$enable_encoder_lz" = xyes ; then+ if test -z "$enable_match_finders"; then+ as_fn_error $? "At least one match finder is required for an LZ-based encoder." "$LINENO" 5+ fi++ for arg in $enable_match_finders+ do+ case $arg in+ hc3)+ enable_match_finder_hc3=yes++printf "%s\n" "#define HAVE_MF_HC3 1" >>confdefs.h++ ;;+ hc4)+ enable_match_finder_hc4=yes++printf "%s\n" "#define HAVE_MF_HC4 1" >>confdefs.h++ ;;+ bt2)+ enable_match_finder_bt2=yes++printf "%s\n" "#define HAVE_MF_BT2 1" >>confdefs.h++ ;;+ bt3)+ enable_match_finder_bt3=yes++printf "%s\n" "#define HAVE_MF_BT3 1" >>confdefs.h++ ;;+ bt4)+ enable_match_finder_bt4=yes++printf "%s\n" "#define HAVE_MF_BT4 1" >>confdefs.h++ ;;+ *)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5+printf "%s\n" "" >&6; }+ as_fn_error $? "unknown match finder: $arg" "$LINENO" 5+ ;;+ esac+ done+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_match_finders" >&5+printf "%s\n" "$enable_match_finders" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: (none because not building any LZ-based encoder)" >&5+printf "%s\n" "(none because not building any LZ-based encoder)" >&6; }+fi+++####################+# Integrity checks #+####################++++enable_check_crc32=no+enable_check_crc64=no+enable_check_sha256=no++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which integrity checks to build" >&5+printf %s "checking which integrity checks to build... " >&6; }+# Check whether --enable-checks was given.+if test ${enable_checks+y}+then :+ enableval=$enable_checks;+else case e in #(+ e) enable_checks=crc32,crc64,sha256 ;;+esac+fi++enable_checks=`echo "$enable_checks" | sed 's/,/ /g'`+if test "x$enable_checks" = xno || test "x$enable_checks" = x; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: (none)" >&5+printf "%s\n" "(none)" >&6; }+else+ for arg in $enable_checks+ do+ case $arg in+ crc32)+ enable_check_crc32=yes++printf "%s\n" "#define HAVE_CHECK_CRC32 1" >>confdefs.h++ ;;+ crc64)+ enable_check_crc64=yes++printf "%s\n" "#define HAVE_CHECK_CRC64 1" >>confdefs.h++ ;;+ sha256)+ enable_check_sha256=yes++printf "%s\n" "#define HAVE_CHECK_SHA256 1" >>confdefs.h++ ;;+ *)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5+printf "%s\n" "" >&6; }+ as_fn_error $? "unknown integrity check: $arg" "$LINENO" 5+ ;;+ esac+ done+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_checks" >&5+printf "%s\n" "$enable_checks" >&6; }+fi+if test "x$enable_check_crc32" = xno ; then+ as_fn_error $? "For now, the CRC32 check must always be enabled." "$LINENO" 5+fi++ if test "x$enable_check_crc32" = xyes; then+ COND_CHECK_CRC32_TRUE=+ COND_CHECK_CRC32_FALSE='#'+else+ COND_CHECK_CRC32_TRUE='#'+ COND_CHECK_CRC32_FALSE=+fi++ if test "x$enable_check_crc64" = xyes; then+ COND_CHECK_CRC64_TRUE=+ COND_CHECK_CRC64_FALSE='#'+else+ COND_CHECK_CRC64_TRUE='#'+ COND_CHECK_CRC64_FALSE=+fi++ if test "x$enable_check_sha256" = xyes; then+ COND_CHECK_SHA256_TRUE=+ COND_CHECK_SHA256_FALSE='#'+else+ COND_CHECK_SHA256_TRUE='#'+ COND_CHECK_SHA256_FALSE=+fi+++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if external SHA-256 should be used" >&5+printf %s "checking if external SHA-256 should be used... " >&6; }+# Check whether --enable-external-sha256 was given.+if test ${enable_external_sha256+y}+then :+ enableval=$enable_external_sha256;+else case e in #(+ e) enable_external_sha256=no ;;+esac+fi++if test "x$enable_check_sha256" != "xyes"; then+ enable_external_sha256=no+fi+if test "x$enable_external_sha256" = xyes; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++#############+# MicroLZMA #+#############++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if MicroLZMA support should be built" >&5+printf %s "checking if MicroLZMA support should be built... " >&6; }+# Check whether --enable-microlzma was given.+if test ${enable_microlzma+y}+then :+ enableval=$enable_microlzma;+else case e in #(+ e) enable_microlzma=yes ;;+esac+fi++case $enable_microlzma in+ yes | no)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_microlzma" >&5+printf "%s\n" "$enable_microlzma" >&6; }+ ;;+ *)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5+printf "%s\n" "" >&6; }+ as_fn_error $? "--enable-microlzma accepts only 'yes' or 'no'." "$LINENO" 5+ ;;+esac+ if test "x$enable_microlzma" = xyes; then+ COND_MICROLZMA_TRUE=+ COND_MICROLZMA_FALSE='#'+else+ COND_MICROLZMA_TRUE='#'+ COND_MICROLZMA_FALSE=+fi++++#############################+# .lz (lzip) format support #+#############################++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if .lz (lzip) decompression support should be built" >&5+printf %s "checking if .lz (lzip) decompression support should be built... " >&6; }+# Check whether --enable-lzip-decoder was given.+if test ${enable_lzip_decoder+y}+then :+ enableval=$enable_lzip_decoder;+else case e in #(+ e) enable_lzip_decoder=yes ;;+esac+fi++if test "x$enable_decoder_lzma1" != xyes; then+ enable_lzip_decoder=no+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no because LZMA1 decoder is disabled" >&5+printf "%s\n" "no because LZMA1 decoder is disabled" >&6; }+elif test "x$enable_lzip_decoder" = xyes; then++printf "%s\n" "#define HAVE_LZIP_DECODER 1" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+ if test "x$enable_lzip_decoder" = xyes; then+ COND_LZIP_DECODER_TRUE=+ COND_LZIP_DECODER_FALSE='#'+else+ COND_LZIP_DECODER_TRUE='#'+ COND_LZIP_DECODER_FALSE=+fi++++###########################+# Assembler optimizations #+###########################++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if assembler optimizations should be used" >&5+printf %s "checking if assembler optimizations should be used... " >&6; }+# Check whether --enable-assembler was given.+if test ${enable_assembler+y}+then :+ enableval=$enable_assembler;+else case e in #(+ e) enable_assembler=yes ;;+esac+fi++if test "x$enable_assembler" = xyes; then+ enable_assembler=no+ case $host_os in+ # Darwin should work too but only if not creating universal+ # binaries. Solaris x86 could work too but I cannot test.+ linux* | *bsd* | mingw* | cygwin | msys | *djgpp*)+ case $host_cpu in+ i?86) enable_assembler=x86 ;;+ esac+ ;;+ esac+fi+case $enable_assembler in+ x86)++printf "%s\n" "#define HAVE_CRC_X86_ASM 1" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: x86" >&5+printf "%s\n" "x86" >&6; }+ ;;+ no)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+ ;;+ *)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5+printf "%s\n" "" >&6; }+ as_fn_error $? "--enable-assembler accepts only 'yes', 'no', or 'x86' (32-bit)." "$LINENO" 5+ ;;+esac+ if test "x$enable_assembler" = xx86; then+ COND_ASM_X86_TRUE=+ COND_ASM_X86_FALSE='#'+else+ COND_ASM_X86_TRUE='#'+ COND_ASM_X86_FALSE=+fi++++#############+# CLMUL CRC #+#############++# Check whether --enable-clmul-crc was given.+if test ${enable_clmul_crc+y}+then :+ enableval=$enable_clmul_crc;+else case e in #(+ e) enable_clmul_crc=yes ;;+esac+fi++++############################+# ARM64 CRC32 Instructions #+############################++# Check whether --enable-arm64-crc32 was given.+if test ${enable_arm64_crc32+y}+then :+ enableval=$enable_arm64_crc32;+else case e in #(+ e) enable_arm64_crc32=yes ;;+esac+fi++++################################+# LoongArch CRC32 instructions #+################################++# Check whether --enable-loongarch-crc32 was given.+if test ${enable_loongarch_crc32+y}+then :+ enableval=$enable_loongarch_crc32;+else case e in #(+ e) enable_loongarch_crc32=yes ;;+esac+fi++++#####################+# Size optimization #+#####################++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if small size is preferred over speed" >&5+printf %s "checking if small size is preferred over speed... " >&6; }+# Check whether --enable-small was given.+if test ${enable_small+y}+then :+ enableval=$enable_small;+else case e in #(+ e) enable_small=no ;;+esac+fi++if test "x$enable_small" = xyes; then++printf "%s\n" "#define HAVE_SMALL 1" >>confdefs.h++elif test "x$enable_small" != xno; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5+printf "%s\n" "" >&6; }+ as_fn_error $? "--enable-small accepts only 'yes' or 'no'" "$LINENO" 5+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_small" >&5+printf "%s\n" "$enable_small" >&6; }+ if test "x$enable_small" = xyes; then+ COND_SMALL_TRUE=+ COND_SMALL_FALSE='#'+else+ COND_SMALL_TRUE='#'+ COND_SMALL_FALSE=+fi++++#############+# Threading #+#############++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if threading support is wanted" >&5+printf %s "checking if threading support is wanted... " >&6; }+# Check whether --enable-threads was given.+if test ${enable_threads+y}+then :+ enableval=$enable_threads;+else case e in #(+ e) enable_threads=yes ;;+esac+fi+++if test "x$enable_threads" = xyes; then+ case $host_os in+ mingw*)+ case $host_cpu in+ i?86) enable_threads=win95 ;;+ *) enable_threads=vista ;;+ esac+ ;;+ *)+ enable_threads=posix+ ;;+ esac+fi++case $enable_threads in+ posix | win95 | vista)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes, $enable_threads" >&5+printf "%s\n" "yes, $enable_threads" >&6; }+ ;;+ no)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+ ;;+ *)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5+printf "%s\n" "" >&6; }+ as_fn_error $? "--enable-threads only accepts 'yes', 'no', 'posix', 'win95', or 'vista'" "$LINENO" 5+ ;;+esac++# We use the actual result a little later.+++#########################+# Assumed amount of RAM #+#########################++# We use 128 MiB as default, because it will allow decompressing files+# created with "xz -9". It would be slightly safer to guess a lower value,+# but most systems, on which we don't have any way to determine the amount+# of RAM, will probably have at least 128 MiB of RAM.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how much RAM to assume if the real amount is unknown" >&5+printf %s "checking how much RAM to assume if the real amount is unknown... " >&6; }+# Check whether --enable-assume-ram was given.+if test ${enable_assume_ram+y}+then :+ enableval=$enable_assume_ram;+else case e in #(+ e) enable_assume_ram=128 ;;+esac+fi++assume_ram_check=`echo "$enable_assume_ram" | tr -d 0123456789`+if test -z "$enable_assume_ram" || test -n "$assume_ram_check"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5+printf "%s\n" "" >&6; }+ as_fn_error $? "--enable-assume-ram accepts only an integer argument" "$LINENO" 5+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_assume_ram MiB" >&5+printf "%s\n" "$enable_assume_ram MiB" >&6; }++printf "%s\n" "#define ASSUME_RAM $enable_assume_ram" >>confdefs.h++++#########################+# Components to install #+#########################++# Check whether --enable-xz was given.+if test ${enable_xz+y}+then :+ enableval=$enable_xz;+else case e in #(+ e) enable_xz=yes ;;+esac+fi++ if test x$enable_xz != xno; then+ COND_XZ_TRUE=+ COND_XZ_FALSE='#'+else+ COND_XZ_TRUE='#'+ COND_XZ_FALSE=+fi+++# Check whether --enable-xzdec was given.+if test ${enable_xzdec+y}+then :+ enableval=$enable_xzdec;+else case e in #(+ e) enable_xzdec=yes ;;+esac+fi++test "x$enable_decoders" = xno && enable_xzdec=no+ if test x$enable_xzdec != xno; then+ COND_XZDEC_TRUE=+ COND_XZDEC_FALSE='#'+else+ COND_XZDEC_TRUE='#'+ COND_XZDEC_FALSE=+fi+++# Check whether --enable-lzmadec was given.+if test ${enable_lzmadec+y}+then :+ enableval=$enable_lzmadec;+else case e in #(+ e) enable_lzmadec=yes ;;+esac+fi++test "x$enable_decoder_lzma1" = xno && enable_lzmadec=no+ if test x$enable_lzmadec != xno; then+ COND_LZMADEC_TRUE=+ COND_LZMADEC_FALSE='#'+else+ COND_LZMADEC_TRUE='#'+ COND_LZMADEC_FALSE=+fi+++# Check whether --enable-lzmainfo was given.+if test ${enable_lzmainfo+y}+then :+ enableval=$enable_lzmainfo;+else case e in #(+ e) enable_lzmainfo=yes ;;+esac+fi++test "x$enable_decoder_lzma1" = xno && enable_lzmainfo=no+ if test x$enable_lzmainfo != xno; then+ COND_LZMAINFO_TRUE=+ COND_LZMAINFO_FALSE='#'+else+ COND_LZMAINFO_TRUE='#'+ COND_LZMAINFO_FALSE=+fi+++# Check whether --enable-lzma-links was given.+if test ${enable_lzma_links+y}+then :+ enableval=$enable_lzma_links;+else case e in #(+ e) enable_lzma_links=yes ;;+esac+fi++ if test x$enable_lzma_links != xno; then+ COND_LZMALINKS_TRUE=+ COND_LZMALINKS_FALSE='#'+else+ COND_LZMALINKS_TRUE='#'+ COND_LZMALINKS_FALSE=+fi+++# Check whether --enable-scripts was given.+if test ${enable_scripts+y}+then :+ enableval=$enable_scripts;+else case e in #(+ e) enable_scripts=yes ;;+esac+fi++ if test x$enable_scripts != xno; then+ COND_SCRIPTS_TRUE=+ COND_SCRIPTS_FALSE='#'+else+ COND_SCRIPTS_TRUE='#'+ COND_SCRIPTS_FALSE=+fi+++# Check whether --enable-doc was given.+if test ${enable_doc+y}+then :+ enableval=$enable_doc;+else case e in #(+ e) enable_doc=yes ;;+esac+fi++ if test x$enable_doc != xno; then+ COND_DOC_TRUE=+ COND_DOC_FALSE='#'+else+ COND_DOC_TRUE='#'+ COND_DOC_FALSE=+fi+++# Check whether --enable-doxygen was given.+if test ${enable_doxygen+y}+then :+ enableval=$enable_doxygen;+else case e in #(+ e) enable_doxygen=no ;;+esac+fi++ if test x$enable_doxygen != xno; then+ COND_DOXYGEN_TRUE=+ COND_DOXYGEN_FALSE='#'+else+ COND_DOXYGEN_TRUE='#'+ COND_DOXYGEN_FALSE=+fi++++##############+# Sandboxing #+##############++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if sandboxing should be used" >&5+printf %s "checking if sandboxing should be used... " >&6; }+# Check whether --enable-sandbox was given.+if test ${enable_sandbox+y}+then :+ enableval=$enable_sandbox;+else case e in #(+ e) enable_sandbox=auto ;;+esac+fi++case $enable_xzdec-$enable_xz-$enable_sandbox in+ no-no-*)+ enable_sandbox=no+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, --disable-xz and --disable-xzdec was used" >&5+printf "%s\n" "no, --disable-xz and --disable-xzdec was used" >&6; }+ ;;+ *-*-auto)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: maybe (autodetect)" >&5+printf "%s\n" "maybe (autodetect)" >&6; }+ ;;+ *-*-no | *-*-capsicum | *-*-pledge | *-*-landlock)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_sandbox" >&5+printf "%s\n" "$enable_sandbox" >&6; }+ ;;+ *)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5+printf "%s\n" "" >&6; }+ as_fn_error $? "--enable-sandbox only accepts 'auto', 'no', 'capsicum', 'pledge', or 'landlock'." "$LINENO" 5+ ;;+esac+++###########################+# PATH prefix for scripts #+###########################++# The scripts can add a prefix to the search PATH so that POSIX tools+# or the xz binary is always in the PATH.+# Check whether --enable-path-for-scripts was given.+if test ${enable_path_for_scripts+y}+then :+ enableval=$enable_path_for_scripts;+else case e in #(+ e)+ case $host_os in+ solaris*) enable_path_for_scripts=/usr/xpg4/bin ;;+ *) enable_path_for_scripts= ;;+ esac+ ;;+esac+fi++if test -n "$enable_path_for_scripts" && test "x$enable_path_for_scripts" != xno ; then+ enable_path_for_scripts="PATH=$enable_path_for_scripts:\$PATH"+else+ enable_path_for_scripts=+fi++++###############################################################################+# Checks for programs.+###############################################################################++echo+case $host_os in+ solaris*)+ # The gnulib POSIX shell macro below may pick a shell that+ # doesn't work with xzgrep. Workaround by picking a shell+ # that is known to work.+ if test -z "$gl_cv_posix_shell" && test -x /usr/xpg4/bin/sh; then+ gl_cv_posix_shell=/usr/xpg4/bin/sh+ fi+ ;;+esac++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a shell that conforms to POSIX" >&5+printf %s "checking for a shell that conforms to POSIX... " >&6; }+if test ${gl_cv_posix_shell+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) gl_test_posix_shell_script='+ func_return () {+ (exit $1)+ }+ func_success () {+ func_return 0+ }+ func_failure () {+ func_return 1+ }+ func_ret_success () {+ return 0+ }+ func_ret_failure () {+ return 1+ }+ subshell_umask_sanity () {+ (umask 22; (umask 0); test $(umask) -eq 22)+ }+ test "$(echo foo)" = foo &&+ func_success &&+ ! func_failure &&+ func_ret_success &&+ ! func_ret_failure &&+ (set x && func_ret_success y && test x = "$1") &&+ subshell_umask_sanity+ '+ for gl_cv_posix_shell in \+ "$CONFIG_SHELL" "$SHELL" /bin/sh /bin/bash /bin/ksh /bin/sh5 no; do+ case $gl_cv_posix_shell in+ /*)+ "$gl_cv_posix_shell" -c "$gl_test_posix_shell_script" 2>/dev/null \+ && break;;+ esac+ done ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_posix_shell" >&5+printf "%s\n" "$gl_cv_posix_shell" >&6; }++ if test "$gl_cv_posix_shell" != no; then+ POSIX_SHELL=$gl_cv_posix_shell+ PREFERABLY_POSIX_SHELL=$POSIX_SHELL+ else+ POSIX_SHELL=+ PREFERABLY_POSIX_SHELL=/bin/sh+ fi++++if test -z "$POSIX_SHELL" && test "x$enable_scripts" = xyes ; then+ as_fn_error $? "No POSIX conforming shell (sh) was found." "$LINENO" 5+fi+++# We don't use "subdir-objects" yet because it breaks "make distclean" when+# dependencies are enabled (as of Automake 1.14.1) due to this bug:+# https://debbugs.gnu.org/cgi/bugreport.cgi?bug=17354+# The -Wno-unsupported is used to silence warnings about missing+# "subdir-objects".+#AM_INIT_AUTOMAKE([1.12 foreign tar-v7 filename-length-max=99 -Wno-unsupported])+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5+printf %s "checking whether ln -s works... " >&6; }+LN_S=$as_ln_s+if test "$LN_S" = "ln -s"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5+printf "%s\n" "no, using $LN_S" >&6; }+fi++++++++++++ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu+if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.+set dummy ${ac_tool_prefix}gcc; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_CC="${ac_tool_prefix}gcc"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_CC"; then+ ac_ct_CC=$CC+ # Extract the first word of "gcc", so it can be a program name with args.+set dummy gcc; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_CC+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_CC"; then+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_CC="gcc"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_CC=$ac_cv_prog_ac_ct_CC+if test -n "$ac_ct_CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5+printf "%s\n" "$ac_ct_CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_CC" = x; then+ CC=""+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ CC=$ac_ct_CC+ fi+else+ CC="$ac_cv_prog_CC"+fi++if test -z "$CC"; then+ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.+set dummy ${ac_tool_prefix}cc; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_CC="${ac_tool_prefix}cc"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ fi+fi+if test -z "$CC"; then+ # Extract the first word of "cc", so it can be a program name with args.+set dummy cc; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+ ac_prog_rejected=no+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ if test "$as_dir$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then+ ac_prog_rejected=yes+ continue+ fi+ ac_cv_prog_CC="cc"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++if test $ac_prog_rejected = yes; then+ # We found a bogon in the path, so make sure we never use it.+ set dummy $ac_cv_prog_CC+ shift+ if test $# != 0; then+ # We chose a different compiler from the bogus one.+ # However, it has the same basename, so the bogon will be chosen+ # first if we set CC to just the basename; use the full file name.+ shift+ ac_cv_prog_CC="$as_dir$ac_word${1+' '}$@"+ fi+fi+fi ;;+esac+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$CC"; then+ if test -n "$ac_tool_prefix"; then+ for ac_prog in cl.exe+ do+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.+set dummy $ac_tool_prefix$ac_prog; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_CC="$ac_tool_prefix$ac_prog"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ test -n "$CC" && break+ done+fi+if test -z "$CC"; then+ ac_ct_CC=$CC+ for ac_prog in cl.exe+do+ # Extract the first word of "$ac_prog", so it can be a program name with args.+set dummy $ac_prog; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_CC+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_CC"; then+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_CC="$ac_prog"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_CC=$ac_cv_prog_ac_ct_CC+if test -n "$ac_ct_CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5+printf "%s\n" "$ac_ct_CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ test -n "$ac_ct_CC" && break+done++ if test "x$ac_ct_CC" = x; then+ CC=""+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ CC=$ac_ct_CC+ fi+fi++fi+if test -z "$CC"; then+ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}clang", so it can be a program name with args.+set dummy ${ac_tool_prefix}clang; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_CC+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$CC"; then+ ac_cv_prog_CC="$CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_CC="${ac_tool_prefix}clang"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+CC=$ac_cv_prog_CC+if test -n "$CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CC" >&5+printf "%s\n" "$CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_CC"; then+ ac_ct_CC=$CC+ # Extract the first word of "clang", so it can be a program name with args.+set dummy clang; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_CC+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_CC"; then+ ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_CC="clang"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_CC=$ac_cv_prog_ac_ct_CC+if test -n "$ac_ct_CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5+printf "%s\n" "$ac_ct_CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_CC" = x; then+ CC=""+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ CC=$ac_ct_CC+ fi+else+ CC="$ac_cv_prog_CC"+fi++fi+++test -z "$CC" && { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}+as_fn_error $? "no acceptable C compiler found in \$PATH+See 'config.log' for more details" "$LINENO" 5; }++# Provide some information about the compiler.+printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5+set X $ac_compile+ac_compiler=$2+for ac_option in --version -v -V -qversion -version; do+ { { ac_try="$ac_compiler $ac_option >&5"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_compiler $ac_option >&5") 2>conftest.err+ ac_status=$?+ if test -s conftest.err; then+ sed '10a\+... rest of stderr output deleted ...+ 10q' conftest.err >conftest.er1+ cat conftest.er1 >&5+ fi+ rm -f conftest.er1 conftest.err+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+done++cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+ac_clean_files_save=$ac_clean_files+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"+# Try to create an executable without -o first, disregard a.out.+# It will help us diagnose broken compilers, and finding out an intuition+# of exeext.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5+printf %s "checking whether the C compiler works... " >&6; }+ac_link_default=`printf "%s\n" "$ac_link" | sed 's/ -o *conftest[^ ]*//'`++# The possible output files:+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"++ac_rmfiles=+for ac_file in $ac_files+do+ case $ac_file in+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;+ * ) ac_rmfiles="$ac_rmfiles $ac_file";;+ esac+done+rm -f $ac_rmfiles++if { { ac_try="$ac_link_default"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_link_default") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+then :+ # Autoconf-2.13 could set the ac_cv_exeext variable to 'no'.+# So ignore a value of 'no', otherwise this would lead to 'EXEEXT = no'+# in a Makefile. We should not override ac_cv_exeext if it was cached,+# so that the user can short-circuit this test for compilers unknown to+# Autoconf.+for ac_file in $ac_files ''+do+ test -f "$ac_file" || continue+ case $ac_file in+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )+ ;;+ [ab].out )+ # We found the default executable, but exeext='' is most+ # certainly right.+ break;;+ *.* )+ if test ${ac_cv_exeext+y} && test "$ac_cv_exeext" != no;+ then :; else+ ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`+ fi+ # We set ac_cv_exeext here because the later test for it is not+ # safe: cross compilers may not add the suffix if given an '-o'+ # argument, so we may need to know it at that point already.+ # Even if this section looks crufty: it has the advantage of+ # actually working.+ break;;+ * )+ break;;+ esac+done+test "$ac_cv_exeext" = no && ac_cv_exeext=++else case e in #(+ e) ac_file='' ;;+esac+fi+if test -z "$ac_file"+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+printf "%s\n" "$as_me: failed program was:" >&5+sed 's/^/| /' conftest.$ac_ext >&5++{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}+as_fn_error 77 "C compiler cannot create executables+See 'config.log' for more details" "$LINENO" 5; }+else case e in #(+ e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; } ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5+printf %s "checking for C compiler default output file name... " >&6; }+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5+printf "%s\n" "$ac_file" >&6; }+ac_exeext=$ac_cv_exeext++rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out+ac_clean_files=$ac_clean_files_save+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5+printf %s "checking for suffix of executables... " >&6; }+if { { ac_try="$ac_link"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_link") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+then :+ # If both 'conftest.exe' and 'conftest' are 'present' (well, observable)+# catch 'conftest.exe'. For instance with Cygwin, 'ls conftest' will+# work properly (i.e., refer to 'conftest.exe'), while it won't with+# 'rm'.+for ac_file in conftest.exe conftest conftest.*; do+ test -f "$ac_file" || continue+ case $ac_file in+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;+ *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`+ break;;+ * ) break;;+ esac+done+else case e in #(+ e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}+as_fn_error $? "cannot compute suffix of executables: cannot compile and link+See 'config.log' for more details" "$LINENO" 5; } ;;+esac+fi+rm -f conftest conftest$ac_cv_exeext+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5+printf "%s\n" "$ac_cv_exeext" >&6; }++rm -f conftest.$ac_ext+EXEEXT=$ac_cv_exeext+ac_exeext=$EXEEXT+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <stdio.h>+int+main (void)+{+FILE *f = fopen ("conftest.out", "w");+ if (!f)+ return 1;+ return ferror (f) || fclose (f) != 0;++ ;+ return 0;+}+_ACEOF+ac_clean_files="$ac_clean_files conftest.out"+# Check that the compiler produces executables we can run. If not, either+# the compiler is broken, or we cross compile.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5+printf %s "checking whether we are cross compiling... " >&6; }+if test "$cross_compiling" != yes; then+ { { ac_try="$ac_link"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_link") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+ if { ac_try='./conftest$ac_cv_exeext'+ { { case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_try") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }; }; then+ cross_compiling=no+ else+ if test "$cross_compiling" = maybe; then+ cross_compiling=yes+ else+ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}+as_fn_error 77 "cannot run C compiled programs.+If you meant to cross compile, use '--host'.+See 'config.log' for more details" "$LINENO" 5; }+ fi+ fi+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5+printf "%s\n" "$cross_compiling" >&6; }++rm -f conftest.$ac_ext conftest$ac_cv_exeext \+ conftest.o conftest.obj conftest.out+ac_clean_files=$ac_clean_files_save+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5+printf %s "checking for suffix of object files... " >&6; }+if test ${ac_cv_objext+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+rm -f conftest.o conftest.obj+if { { ac_try="$ac_compile"+case "(($ac_try" in+ *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;+ *) ac_try_echo=$ac_try;;+esac+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""+printf "%s\n" "$ac_try_echo"; } >&5+ (eval "$ac_compile") 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+then :+ for ac_file in conftest.o conftest.obj conftest.*; do+ test -f "$ac_file" || continue;+ case $ac_file in+ *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;+ *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`+ break;;+ esac+done+else case e in #(+ e) printf "%s\n" "$as_me: failed program was:" >&5+sed 's/^/| /' conftest.$ac_ext >&5++{ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}+as_fn_error $? "cannot compute suffix of object files: cannot compile+See 'config.log' for more details" "$LINENO" 5; } ;;+esac+fi+rm -f conftest.$ac_cv_objext conftest.$ac_ext ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5+printf "%s\n" "$ac_cv_objext" >&6; }+OBJEXT=$ac_cv_objext+ac_objext=$OBJEXT+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports GNU C" >&5+printf %s "checking whether the compiler supports GNU C... " >&6; }+if test ${ac_cv_c_compiler_gnu+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{+#ifndef __GNUC__+ choke me+#endif++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_compiler_gnu=yes+else case e in #(+ e) ac_compiler_gnu=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ac_cv_c_compiler_gnu=$ac_compiler_gnu+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5+printf "%s\n" "$ac_cv_c_compiler_gnu" >&6; }+ac_compiler_gnu=$ac_cv_c_compiler_gnu++if test $ac_compiler_gnu = yes; then+ GCC=yes+else+ GCC=+fi+ac_test_CFLAGS=${CFLAGS+y}+ac_save_CFLAGS=$CFLAGS+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5+printf %s "checking whether $CC accepts -g... " >&6; }+if test ${ac_cv_prog_cc_g+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_save_c_werror_flag=$ac_c_werror_flag+ ac_c_werror_flag=yes+ ac_cv_prog_cc_g=no+ CFLAGS="-g"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_g=yes+else case e in #(+ e) CFLAGS=""+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++else case e in #(+ e) ac_c_werror_flag=$ac_save_c_werror_flag+ CFLAGS="-g"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_g=yes+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ ac_c_werror_flag=$ac_save_c_werror_flag ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5+printf "%s\n" "$ac_cv_prog_cc_g" >&6; }+if test $ac_test_CFLAGS; then+ CFLAGS=$ac_save_CFLAGS+elif test $ac_cv_prog_cc_g = yes; then+ if test "$GCC" = yes; then+ CFLAGS="-g -O2"+ else+ CFLAGS="-g"+ fi+else+ if test "$GCC" = yes; then+ CFLAGS="-O2"+ else+ CFLAGS=+ fi+fi+ac_prog_cc_stdc=no+if test x$ac_prog_cc_stdc = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C11 features" >&5+printf %s "checking for $CC option to enable C11 features... " >&6; }+if test ${ac_cv_prog_cc_c11+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_cv_prog_cc_c11=no+ac_save_CC=$CC+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_c_conftest_c11_program+_ACEOF+for ac_arg in '' -std=gnu11+do+ CC="$ac_save_CC $ac_arg"+ if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_c11=$ac_arg+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam+ test "x$ac_cv_prog_cc_c11" != "xno" && break+done+rm -f conftest.$ac_ext+CC=$ac_save_CC ;;+esac+fi++if test "x$ac_cv_prog_cc_c11" = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5+printf "%s\n" "unsupported" >&6; }+else case e in #(+ e) if test "x$ac_cv_prog_cc_c11" = x+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5+printf "%s\n" "none needed" >&6; }+else case e in #(+ e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c11" >&5+printf "%s\n" "$ac_cv_prog_cc_c11" >&6; }+ CC="$CC $ac_cv_prog_cc_c11" ;;+esac+fi+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c11+ ac_prog_cc_stdc=c11 ;;+esac+fi+fi+if test x$ac_prog_cc_stdc = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C99 features" >&5+printf %s "checking for $CC option to enable C99 features... " >&6; }+if test ${ac_cv_prog_cc_c99+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_cv_prog_cc_c99=no+ac_save_CC=$CC+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_c_conftest_c99_program+_ACEOF+for ac_arg in '' -std=gnu99 -std=c99 -c99 -qlanglvl=extc1x -qlanglvl=extc99 -AC99 -D_STDC_C99=+do+ CC="$ac_save_CC $ac_arg"+ if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_c99=$ac_arg+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam+ test "x$ac_cv_prog_cc_c99" != "xno" && break+done+rm -f conftest.$ac_ext+CC=$ac_save_CC ;;+esac+fi++if test "x$ac_cv_prog_cc_c99" = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5+printf "%s\n" "unsupported" >&6; }+else case e in #(+ e) if test "x$ac_cv_prog_cc_c99" = x+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5+printf "%s\n" "none needed" >&6; }+else case e in #(+ e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5+printf "%s\n" "$ac_cv_prog_cc_c99" >&6; }+ CC="$CC $ac_cv_prog_cc_c99" ;;+esac+fi+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99+ ac_prog_cc_stdc=c99 ;;+esac+fi+fi+if test x$ac_prog_cc_stdc = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC option to enable C89 features" >&5+printf %s "checking for $CC option to enable C89 features... " >&6; }+if test ${ac_cv_prog_cc_c89+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_cv_prog_cc_c89=no+ac_save_CC=$CC+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_c_conftest_c89_program+_ACEOF+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"+do+ CC="$ac_save_CC $ac_arg"+ if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_prog_cc_c89=$ac_arg+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam+ test "x$ac_cv_prog_cc_c89" != "xno" && break+done+rm -f conftest.$ac_ext+CC=$ac_save_CC ;;+esac+fi++if test "x$ac_cv_prog_cc_c89" = xno+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5+printf "%s\n" "unsupported" >&6; }+else case e in #(+ e) if test "x$ac_cv_prog_cc_c89" = x+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none needed" >&5+printf "%s\n" "none needed" >&6; }+else case e in #(+ e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5+printf "%s\n" "$ac_cv_prog_cc_c89" >&6; }+ CC="$CC $ac_cv_prog_cc_c89" ;;+esac+fi+ ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89+ ac_prog_cc_stdc=c89 ;;+esac+fi+fi++ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu+++if test x$ac_cv_prog_cc_c99 = xno ; then+ as_fn_error $? "No C99 compiler was found." "$LINENO" 5+fi++#AM_PROG_CC_C_O+rm -rf .tst 2>/dev/null+mkdir .tst 2>/dev/null+if test -d .tst; then+ am__leading_dot=.+else+ am__leading_dot=_+fi+rmdir .tst 2>/dev/null++DEPDIR="${am__leading_dot}deps"++ac_config_commands="$ac_config_commands depfiles"++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} supports the include directive" >&5+printf %s "checking whether ${MAKE-make} supports the include directive... " >&6; }+cat > confinc.mk << 'END'+am__doit:+ @echo this is the am__doit target >confinc.out+.PHONY: am__doit+END+am__include="#"+am__quote=+# BSD make does it like this.+echo '.include "confinc.mk" # ignored' > confmf.BSD+# Other make implementations (GNU, Solaris 10, AIX) do it like this.+echo 'include confinc.mk # ignored' > confmf.GNU+_am_result=no+for s in GNU BSD; do+ { echo "$as_me:$LINENO: ${MAKE-make} -f confmf.$s && cat confinc.out" >&5+ (${MAKE-make} -f confmf.$s && cat confinc.out) >&5 2>&5+ ac_status=$?+ echo "$as_me:$LINENO: \$? = $ac_status" >&5+ (exit $ac_status); }+ case $?:`cat confinc.out 2>/dev/null` in #(+ '0:this is the am__doit target') :+ case $s in #(+ BSD) :+ am__include='.include' am__quote='"' ;; #(+ *) :+ am__include='include' am__quote='' ;;+esac ;; #(+ *) :+ ;;+esac+ if test "$am__include" != "#"; then+ _am_result="yes ($s style)"+ break+ fi+done+rm -f confinc.* confmf.*+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${_am_result}" >&5+printf "%s\n" "${_am_result}" >&6; }++# Check whether --enable-dependency-tracking was given.+if test ${enable_dependency_tracking+y}+then :+ enableval=$enable_dependency_tracking;+fi++if test "x$enable_dependency_tracking" != xno; then+ am_depcomp="$ac_aux_dir/depcomp"+ AMDEPBACKSLASH='\'+ am__nodep='_no'+fi+ if test "x$enable_dependency_tracking" != xno; then+ AMDEP_TRUE=+ AMDEP_FALSE='#'+else+ AMDEP_TRUE='#'+ AMDEP_FALSE=+fi+++# By default we simply use the C compiler to build assembly code.++test "${CCAS+set}" = set || CCAS=$CC+test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS++++depcc="$CCAS" am_compiler_list=++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5+printf %s "checking dependency style of $depcc... " >&6; }+if test ${am_cv_CCAS_dependencies_compiler_type+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then+ # We make a subdir and do the tests there. Otherwise we can end up+ # making bogus files that we don't know about and never remove. For+ # instance it was reported that on HP-UX the gcc test will end up+ # making a dummy file named 'D' -- because '-MD' means "put the output+ # in D".+ rm -rf conftest.dir+ mkdir conftest.dir+ # Copy depcomp to subdir because otherwise we won't find it if we're+ # using a relative directory.+ cp "$am_depcomp" conftest.dir+ cd conftest.dir+ # We will build objects and dependencies in a subdirectory because+ # it helps to detect inapplicable dependency modes. For instance+ # both Tru64's cc and ICC support -MD to output dependencies as a+ # side effect of compilation, but ICC will put the dependencies in+ # the current directory while Tru64 will put them in the object+ # directory.+ mkdir sub++ am_cv_CCAS_dependencies_compiler_type=none+ if test "$am_compiler_list" = ""; then+ am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`+ fi+ am__universal=false+++ for depmode in $am_compiler_list; do+ # Setup a source with many dependencies, because some compilers+ # like to wrap large dependency lists on column 80 (with \), and+ # we should not choose a depcomp mode which is confused by this.+ #+ # We need to recreate these files for each test, as the compiler may+ # overwrite some of them when testing with obscure command lines.+ # This happens at least with the AIX C compiler.+ : > sub/conftest.c+ for i in 1 2 3 4 5 6; do+ echo '#include "conftst'$i'.h"' >> sub/conftest.c+ # Using ": > sub/conftst$i.h" creates only sub/conftst1.h with+ # Solaris 10 /bin/sh.+ echo '/* dummy */' > sub/conftst$i.h+ done+ echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf++ # We check with '-c' and '-o' for the sake of the "dashmstdout"+ # mode. It turns out that the SunPro C++ compiler does not properly+ # handle '-M -o', and we need to detect this. Also, some Intel+ # versions had trouble with output in subdirs.+ am__obj=sub/conftest.${OBJEXT-o}+ am__minus_obj="-o $am__obj"+ case $depmode in+ gcc)+ # This depmode causes a compiler race in universal mode.+ test "$am__universal" = false || continue+ ;;+ nosideeffect)+ # After this tag, mechanisms are not by side-effect, so they'll+ # only be used when explicitly requested.+ if test "x$enable_dependency_tracking" = xyes; then+ continue+ else+ break+ fi+ ;;+ msvc7 | msvc7msys | msvisualcpp | msvcmsys)+ # This compiler won't grok '-c -o', but also, the minuso test has+ # not run yet. These depmodes are late enough in the game, and+ # so weak that their functioning should not be impacted.+ am__obj=conftest.${OBJEXT-o}+ am__minus_obj=+ ;;+ none) break ;;+ esac+ if depmode=$depmode \+ source=sub/conftest.c object=$am__obj \+ depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \+ $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \+ >/dev/null 2>conftest.err &&+ grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&+ grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&+ grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&+ ${MAKE-make} -s -f confmf > /dev/null 2>&1; then+ # icc doesn't choke on unknown options, it will just issue warnings+ # or remarks (even with -Werror). So we grep stderr for any message+ # that says an option was ignored or not supported.+ # When given -MP, icc 7.0 and 7.1 complain thus:+ # icc: Command line warning: ignoring option '-M'; no argument required+ # The diagnosis changed in icc 8.0:+ # icc: Command line remark: option '-MP' not supported+ if (grep 'ignoring option' conftest.err ||+ grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else+ am_cv_CCAS_dependencies_compiler_type=$depmode+ break+ fi+ fi+ done++ cd ..+ rm -rf conftest.dir+else+ am_cv_CCAS_dependencies_compiler_type=none+fi+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_CCAS_dependencies_compiler_type" >&5+printf "%s\n" "$am_cv_CCAS_dependencies_compiler_type" >&6; }+CCASDEPMODE=depmode=$am_cv_CCAS_dependencies_compiler_type++ if+ test "x$enable_dependency_tracking" != xno \+ && test "$am_cv_CCAS_dependencies_compiler_type" = gcc3; then+ am__fastdepCCAS_TRUE=+ am__fastdepCCAS_FALSE='#'+else+ am__fastdepCCAS_TRUE='#'+ am__fastdepCCAS_FALSE=+fi++++ac_header= ac_cache=+for ac_item in $ac_header_c_list+do+ if test $ac_cache; then+ ac_fn_c_check_header_compile "$LINENO" $ac_header ac_cv_header_$ac_cache "$ac_includes_default"+ if eval test \"x\$ac_cv_header_$ac_cache\" = xyes; then+ printf "%s\n" "#define $ac_item 1" >> confdefs.h+ fi+ ac_header= ac_cache=+ elif test $ac_header; then+ ac_cache=$ac_item+ else+ ac_header=$ac_item+ fi+done+++++++++if test $ac_cv_header_stdlib_h = yes && test $ac_cv_header_string_h = yes+then :++printf "%s\n" "#define STDC_HEADERS 1" >>confdefs.h++fi+++++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5+printf %s "checking whether it is safe to define __EXTENSIONS__... " >&6; }+if test ${ac_cv_safe_to_define___extensions__+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++# define __EXTENSIONS__ 1+ $ac_includes_default+int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_safe_to_define___extensions__=yes+else case e in #(+ e) ac_cv_safe_to_define___extensions__=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5+printf "%s\n" "$ac_cv_safe_to_define___extensions__" >&6; }++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether _XOPEN_SOURCE should be defined" >&5+printf %s "checking whether _XOPEN_SOURCE should be defined... " >&6; }+if test ${ac_cv_should_define__xopen_source+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_cv_should_define__xopen_source=no+ if test $ac_cv_header_wchar_h = yes+then :+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++ #include <wchar.h>+ mbstate_t x;+int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++ #define _XOPEN_SOURCE 500+ #include <wchar.h>+ mbstate_t x;+int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_should_define__xopen_source=yes+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_should_define__xopen_source" >&5+printf "%s\n" "$ac_cv_should_define__xopen_source" >&6; }++ printf "%s\n" "#define _ALL_SOURCE 1" >>confdefs.h++ printf "%s\n" "#define _DARWIN_C_SOURCE 1" >>confdefs.h++ printf "%s\n" "#define _GNU_SOURCE 1" >>confdefs.h++ printf "%s\n" "#define _HPUX_ALT_XOPEN_SOCKET_API 1" >>confdefs.h++ printf "%s\n" "#define _NETBSD_SOURCE 1" >>confdefs.h++ printf "%s\n" "#define _OPENBSD_SOURCE 1" >>confdefs.h++ printf "%s\n" "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_IEC_60559_ATTRIBS_EXT__ 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_IEC_60559_BFP_EXT__ 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_IEC_60559_DFP_EXT__ 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_IEC_60559_EXT__ 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_IEC_60559_FUNCS_EXT__ 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_IEC_60559_TYPES_EXT__ 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_LIB_EXT2__ 1" >>confdefs.h++ printf "%s\n" "#define __STDC_WANT_MATH_SPEC_FUNCS__ 1" >>confdefs.h++ printf "%s\n" "#define _TANDEM_SOURCE 1" >>confdefs.h++ if test $ac_cv_header_minix_config_h = yes+then :+ MINIX=yes+ printf "%s\n" "#define _MINIX 1" >>confdefs.h++ printf "%s\n" "#define _POSIX_SOURCE 1" >>confdefs.h++ printf "%s\n" "#define _POSIX_1_SOURCE 2" >>confdefs.h++else case e in #(+ e) MINIX= ;;+esac+fi+ if test $ac_cv_safe_to_define___extensions__ = yes+then :+ printf "%s\n" "#define __EXTENSIONS__ 1" >>confdefs.h++fi+ if test $ac_cv_should_define__xopen_source = yes+then :+ printf "%s\n" "#define _XOPEN_SOURCE 500" >>confdefs.h++fi+++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5+printf %s "checking for a sed that does not truncate output... " >&6; }+if test ${ac_cv_path_SED+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/+ for ac_i in 1 2 3 4 5 6 7; do+ ac_script="$ac_script$as_nl$ac_script"+ done+ echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed+ { ac_script=; unset ac_script;}+ if test -z "$SED"; then+ ac_path_SED_found=false+ # Loop through the user's path and test for each of PROGNAME-LIST+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_prog in sed gsed+ do+ for ac_exec_ext in '' $ac_executable_extensions; do+ ac_path_SED="$as_dir$ac_prog$ac_exec_ext"+ as_fn_executable_p "$ac_path_SED" || continue+# Check for GNU ac_path_SED and select it if it is found.+ # Check for GNU $ac_path_SED+case `"$ac_path_SED" --version 2>&1` in #(+*GNU*)+ ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;+#(+*)+ ac_count=0+ printf %s 0123456789 >"conftest.in"+ while :+ do+ cat "conftest.in" "conftest.in" >"conftest.tmp"+ mv "conftest.tmp" "conftest.in"+ cp "conftest.in" "conftest.nl"+ printf "%s\n" '' >> "conftest.nl"+ "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break+ as_fn_arith $ac_count + 1 && ac_count=$as_val+ if test $ac_count -gt ${ac_path_SED_max-0}; then+ # Best one so far, save it but keep looking for a better one+ ac_cv_path_SED="$ac_path_SED"+ ac_path_SED_max=$ac_count+ fi+ # 10*(2^10) chars as input seems more than enough+ test $ac_count -gt 10 && break+ done+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;+esac++ $ac_path_SED_found && break 3+ done+ done+ done+IFS=$as_save_IFS+ if test -z "$ac_cv_path_SED"; then+ as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5+ fi+else+ ac_cv_path_SED=$SED+fi+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5+printf "%s\n" "$ac_cv_path_SED" >&6; }+ SED="$ac_cv_path_SED"+ rm -f conftest.sed++ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5+printf %s "checking how to run the C preprocessor... " >&6; }+# On Suns, sometimes $CPP names a directory.+if test -n "$CPP" && test -d "$CPP"; then+ CPP=+fi+if test -z "$CPP"; then+ if test ${ac_cv_prog_CPP+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) # Double quotes because $CC needs to be expanded+ for CPP in "$CC -E" "$CC -E -traditional-cpp" cpp /lib/cpp+ do+ ac_preproc_ok=false+for ac_c_preproc_warn_flag in '' yes+do+ # Use a header file that comes with gcc, so configuring glibc+ # with a fresh cross-compiler works.+ # On the NeXT, cc -E runs the code through the compiler's parser,+ # not just through cpp. "Syntax error" is here to catch this case.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <limits.h>+ Syntax error+_ACEOF+if ac_fn_c_try_cpp "$LINENO"+then :++else case e in #(+ e) # Broken: fails on valid input.+continue ;;+esac+fi+rm -f conftest.err conftest.i conftest.$ac_ext++ # OK, works on sane cases. Now check whether nonexistent headers+ # can be detected and how.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <ac_nonexistent.h>+_ACEOF+if ac_fn_c_try_cpp "$LINENO"+then :+ # Broken: success on invalid input.+continue+else case e in #(+ e) # Passes both tests.+ac_preproc_ok=:+break ;;+esac+fi+rm -f conftest.err conftest.i conftest.$ac_ext++done+# Because of 'break', _AC_PREPROC_IFELSE's cleaning code was skipped.+rm -f conftest.i conftest.err conftest.$ac_ext+if $ac_preproc_ok+then :+ break+fi++ done+ ac_cv_prog_CPP=$CPP+ ;;+esac+fi+ CPP=$ac_cv_prog_CPP+else+ ac_cv_prog_CPP=$CPP+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5+printf "%s\n" "$CPP" >&6; }+ac_preproc_ok=false+for ac_c_preproc_warn_flag in '' yes+do+ # Use a header file that comes with gcc, so configuring glibc+ # with a fresh cross-compiler works.+ # On the NeXT, cc -E runs the code through the compiler's parser,+ # not just through cpp. "Syntax error" is here to catch this case.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <limits.h>+ Syntax error+_ACEOF+if ac_fn_c_try_cpp "$LINENO"+then :++else case e in #(+ e) # Broken: fails on valid input.+continue ;;+esac+fi+rm -f conftest.err conftest.i conftest.$ac_ext++ # OK, works on sane cases. Now check whether nonexistent headers+ # can be detected and how.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <ac_nonexistent.h>+_ACEOF+if ac_fn_c_try_cpp "$LINENO"+then :+ # Broken: success on invalid input.+continue+else case e in #(+ e) # Passes both tests.+ac_preproc_ok=:+break ;;+esac+fi+rm -f conftest.err conftest.i conftest.$ac_ext++done+# Because of 'break', _AC_PREPROC_IFELSE's cleaning code was skipped.+rm -f conftest.i conftest.err conftest.$ac_ext+if $ac_preproc_ok+then :++else case e in #(+ e) { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}+as_fn_error $? "C preprocessor \"$CPP\" fails sanity check+See 'config.log' for more details" "$LINENO" 5; } ;;+esac+fi++ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu+++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep -e" >&5+printf %s "checking for egrep -e... " >&6; }+if test ${ac_cv_path_EGREP_TRADITIONAL+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -z "$EGREP_TRADITIONAL"; then+ ac_path_EGREP_TRADITIONAL_found=false+ # Loop through the user's path and test for each of PROGNAME-LIST+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_prog in grep ggrep+ do+ for ac_exec_ext in '' $ac_executable_extensions; do+ ac_path_EGREP_TRADITIONAL="$as_dir$ac_prog$ac_exec_ext"+ as_fn_executable_p "$ac_path_EGREP_TRADITIONAL" || continue+# Check for GNU ac_path_EGREP_TRADITIONAL and select it if it is found.+ # Check for GNU $ac_path_EGREP_TRADITIONAL+case `"$ac_path_EGREP_TRADITIONAL" --version 2>&1` in #(+*GNU*)+ ac_cv_path_EGREP_TRADITIONAL="$ac_path_EGREP_TRADITIONAL" ac_path_EGREP_TRADITIONAL_found=:;;+#(+*)+ ac_count=0+ printf %s 0123456789 >"conftest.in"+ while :+ do+ cat "conftest.in" "conftest.in" >"conftest.tmp"+ mv "conftest.tmp" "conftest.in"+ cp "conftest.in" "conftest.nl"+ printf "%s\n" 'EGREP_TRADITIONAL' >> "conftest.nl"+ "$ac_path_EGREP_TRADITIONAL" -E 'EGR(EP|AC)_TRADITIONAL$' < "conftest.nl" >"conftest.out" 2>/dev/null || break+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break+ as_fn_arith $ac_count + 1 && ac_count=$as_val+ if test $ac_count -gt ${ac_path_EGREP_TRADITIONAL_max-0}; then+ # Best one so far, save it but keep looking for a better one+ ac_cv_path_EGREP_TRADITIONAL="$ac_path_EGREP_TRADITIONAL"+ ac_path_EGREP_TRADITIONAL_max=$ac_count+ fi+ # 10*(2^10) chars as input seems more than enough+ test $ac_count -gt 10 && break+ done+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;+esac++ $ac_path_EGREP_TRADITIONAL_found && break 3+ done+ done+ done+IFS=$as_save_IFS+ if test -z "$ac_cv_path_EGREP_TRADITIONAL"; then+ :+ fi+else+ ac_cv_path_EGREP_TRADITIONAL=$EGREP_TRADITIONAL+fi++ if test "$ac_cv_path_EGREP_TRADITIONAL"+then :+ ac_cv_path_EGREP_TRADITIONAL="$ac_cv_path_EGREP_TRADITIONAL -E"+else case e in #(+ e) if test -z "$EGREP_TRADITIONAL"; then+ ac_path_EGREP_TRADITIONAL_found=false+ # Loop through the user's path and test for each of PROGNAME-LIST+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_prog in egrep+ do+ for ac_exec_ext in '' $ac_executable_extensions; do+ ac_path_EGREP_TRADITIONAL="$as_dir$ac_prog$ac_exec_ext"+ as_fn_executable_p "$ac_path_EGREP_TRADITIONAL" || continue+# Check for GNU ac_path_EGREP_TRADITIONAL and select it if it is found.+ # Check for GNU $ac_path_EGREP_TRADITIONAL+case `"$ac_path_EGREP_TRADITIONAL" --version 2>&1` in #(+*GNU*)+ ac_cv_path_EGREP_TRADITIONAL="$ac_path_EGREP_TRADITIONAL" ac_path_EGREP_TRADITIONAL_found=:;;+#(+*)+ ac_count=0+ printf %s 0123456789 >"conftest.in"+ while :+ do+ cat "conftest.in" "conftest.in" >"conftest.tmp"+ mv "conftest.tmp" "conftest.in"+ cp "conftest.in" "conftest.nl"+ printf "%s\n" 'EGREP_TRADITIONAL' >> "conftest.nl"+ "$ac_path_EGREP_TRADITIONAL" 'EGR(EP|AC)_TRADITIONAL$' < "conftest.nl" >"conftest.out" 2>/dev/null || break+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break+ as_fn_arith $ac_count + 1 && ac_count=$as_val+ if test $ac_count -gt ${ac_path_EGREP_TRADITIONAL_max-0}; then+ # Best one so far, save it but keep looking for a better one+ ac_cv_path_EGREP_TRADITIONAL="$ac_path_EGREP_TRADITIONAL"+ ac_path_EGREP_TRADITIONAL_max=$ac_count+ fi+ # 10*(2^10) chars as input seems more than enough+ test $ac_count -gt 10 && break+ done+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;+esac++ $ac_path_EGREP_TRADITIONAL_found && break 3+ done+ done+ done+IFS=$as_save_IFS+ if test -z "$ac_cv_path_EGREP_TRADITIONAL"; then+ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5+ fi+else+ ac_cv_path_EGREP_TRADITIONAL=$EGREP_TRADITIONAL+fi+ ;;+esac+fi ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP_TRADITIONAL" >&5+printf "%s\n" "$ac_cv_path_EGREP_TRADITIONAL" >&6; }+ EGREP_TRADITIONAL=$ac_cv_path_EGREP_TRADITIONAL++case $enable_threads in #(+ posix) :++ echo+ echo "POSIX threading support:"+++++ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu++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"+ if test "x$PTHREAD_CC" != "x"+then :+ CC="$PTHREAD_CC"+fi+ if test "x$PTHREAD_CXX" != "x"+then :+ CXX="$PTHREAD_CXX"+fi+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"+ LIBS="$PTHREAD_LIBS $LIBS"+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS" >&5+printf %s "checking for pthread_join using $CC $PTHREAD_CFLAGS $PTHREAD_LIBS... " >&6; }+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++/* Override any GCC internal prototype to avoid an error.+ Use char because int might match the return type of a GCC+ builtin and then its argument prototype would still apply.+ The 'extern "C"' is for builds by C++ compilers;+ although this is not generally supported in C code supporting it here+ has little cost and some practical benefit (sr 110532). */+#ifdef __cplusplus+extern "C"+#endif+char pthread_join (void);+int+main (void)+{+return pthread_join ();+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ ax_pthread_ok=yes+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5+printf "%s\n" "$ax_pthread_ok" >&6; }+ 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 with a "," contain both+# C compiler flags (before ",") and linker flags (after ","). Other items+# starting with a "-" are C compiler flags, and remaining 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.)++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++# if !defined(_OPEN_THREADS) && !defined(_UNIX03_THREADS)+ AX_PTHREAD_ZOS_MISSING+# endif++_ACEOF+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |+ $EGREP_TRADITIONAL "AX_PTHREAD_ZOS_MISSING" >/dev/null 2>&1+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support." >&5+printf "%s\n" "$as_me: WARNING: IBM z/OS requires -D_OPEN_THREADS or -D_UNIX03_THREADS to enable pthreads support." >&2;}+fi+rm -rf conftest*++ ;;++ 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,-lpthread pthread $ax_pthread_flags"+ ;;+esac++# Are we compiling with Clang?++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC is Clang" >&5+printf %s "checking whether $CC is Clang... " >&6; }+if test ${ax_cv_PTHREAD_CLANG+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ax_cv_PTHREAD_CLANG=no+ # Note that Autoconf sets GCC=yes for Clang as well as GCC+ if test "x$GCC" = "xyes"; then+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+/* Note: Clang 2.7 lacks __clang_[a-z]+__ */+# if defined(__clang__) && defined(__llvm__)+ AX_PTHREAD_CC_IS_CLANG+# endif++_ACEOF+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |+ $EGREP_TRADITIONAL "AX_PTHREAD_CC_IS_CLANG" >/dev/null 2>&1+then :+ ax_cv_PTHREAD_CLANG=yes+fi+rm -rf conftest*++ fi+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_CLANG" >&5+printf "%s\n" "$ax_cv_PTHREAD_CLANG" >&6; }+ax_pthread_clang="$ax_cv_PTHREAD_CLANG"+++# GCC generally uses -pthread, or -pthreads on some platforms (e.g. SPARC)++# Note that for GCC and Clang -pthread generally implies -lpthread,+# except when -nostdlib is passed.+# This is problematic using libtool to build C++ shared libraries with pthread:+# [1] https://gcc.gnu.org/bugzilla/show_bug.cgi?id=25460+# [2] https://bugzilla.redhat.com/show_bug.cgi?id=661333+# [3] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=468555+# To solve this, first try -pthread together with -lpthread for GCC++if test "x$GCC" = "xyes"+then :+ ax_pthread_flags="-pthread,-lpthread -pthread -pthreads $ax_pthread_flags"+fi++# Clang takes -pthread (never supported any other flag), but we'll try with -lpthread first++if test "x$ax_pthread_clang" = "xyes"+then :+ ax_pthread_flags="-pthread,-lpthread -pthread"+fi+++# 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+if test "x$ax_pthread_check_macro" = "x--"+then :+ ax_pthread_check_cond=0+else case e in #(+ e) ax_pthread_check_cond="!defined($ax_pthread_check_macro)" ;;+esac+fi+++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)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pthreads work without any flags" >&5+printf %s "checking whether pthreads work without any flags... " >&6; }+ ;;++ *,*)+ PTHREAD_CFLAGS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\1/"`+ PTHREAD_LIBS=`echo $ax_pthread_try_flag | sed "s/^\(.*\),\(.*\)$/\2/"`+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with \"$PTHREAD_CFLAGS\" and \"$PTHREAD_LIBS\"" >&5+printf %s "checking whether pthreads work with \"$PTHREAD_CFLAGS\" and \"$PTHREAD_LIBS\"... " >&6; }+ ;;++ -*)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether pthreads work with $ax_pthread_try_flag" >&5+printf %s "checking whether pthreads work with $ax_pthread_try_flag... " >&6; }+ PTHREAD_CFLAGS="$ax_pthread_try_flag"+ ;;++ pthread-config)+ # Extract the first word of "pthread-config", so it can be a program name with args.+set dummy pthread-config; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ax_pthread_config+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ax_pthread_config"; then+ ac_cv_prog_ax_pthread_config="$ax_pthread_config" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ax_pthread_config="yes"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++ test -z "$ac_cv_prog_ax_pthread_config" && ac_cv_prog_ax_pthread_config="no"+fi ;;+esac+fi+ax_pthread_config=$ac_cv_prog_ax_pthread_config+if test -n "$ax_pthread_config"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_config" >&5+printf "%s\n" "$ax_pthread_config" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ if test "x$ax_pthread_config" = "xno"+then :+ continue+fi+ PTHREAD_CFLAGS="`pthread-config --cflags`"+ PTHREAD_LIBS="`pthread-config --ldflags` `pthread-config --libs`"+ ;;++ *)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the pthreads library -l$ax_pthread_try_flag" >&5+printf %s "checking for the pthreads library -l$ax_pthread_try_flag... " >&6; }+ 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.++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <pthread.h>+# if $ax_pthread_check_cond+# error "$ax_pthread_check_macro must be defined"+# endif+ static void *some_global = NULL;+ static void routine(void *a)+ {+ /* To avoid any unused-parameter or+ unused-but-set-parameter warning. */+ some_global = a;+ }+ static void *start_routine(void *a) { return a; }+int+main (void)+{+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) /* ; */+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ ax_pthread_ok=yes+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext++ CFLAGS="$ax_pthread_save_CFLAGS"+ LIBS="$ax_pthread_save_LIBS"++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_pthread_ok" >&5+printf "%s\n" "$ax_pthread_ok" >&6; }+ if test "x$ax_pthread_ok" = "xyes"+then :+ break+fi++ PTHREAD_LIBS=""+ PTHREAD_CFLAGS=""+done+fi+++# 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.)++ # 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.++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether Clang needs flag to prevent \"argument unused\" warning when linking with -pthread" >&5+printf %s "checking whether Clang needs flag to prevent \"argument unused\" warning when linking with -pthread... " >&6; }+if test ${ax_cv_PTHREAD_CLANG_NO_WARN_FLAG+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) 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=`printf "%s\n" "$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+ if test "x$ax_pthread_try" = "xunknown"+then :+ break+fi+ CFLAGS="-Werror -Wunknown-warning-option $ax_pthread_try -pthread $ax_pthread_save_CFLAGS"+ ac_link="$ax_pthread_save_ac_link"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+int main(void){return 0;}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ ac_link="$ax_pthread_2step_ac_link"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+int main(void){return 0;}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ break+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext++fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ done+ ac_link="$ax_pthread_save_ac_link"+ CFLAGS="$ax_pthread_save_CFLAGS"+ if test "x$ax_pthread_try" = "x"+then :+ ax_pthread_try=no+fi+ ax_cv_PTHREAD_CLANG_NO_WARN_FLAG="$ax_pthread_try"+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" >&5+printf "%s\n" "$ax_cv_PTHREAD_CLANG_NO_WARN_FLAG" >&6; }++ 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++++# 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.+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for joinable pthread attribute" >&5+printf %s "checking for joinable pthread attribute... " >&6; }+if test ${ax_cv_PTHREAD_JOINABLE_ATTR+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ax_cv_PTHREAD_JOINABLE_ATTR=unknown+ for ax_pthread_attr in PTHREAD_CREATE_JOINABLE PTHREAD_CREATE_UNDETACHED; do+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <pthread.h>+int+main (void)+{+int attr = $ax_pthread_attr; return attr /* ; */+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ ax_cv_PTHREAD_JOINABLE_ATTR=$ax_pthread_attr; break+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ done+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_JOINABLE_ATTR" >&5+printf "%s\n" "$ax_cv_PTHREAD_JOINABLE_ATTR" >&6; }+ 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"+then :++printf "%s\n" "#define PTHREAD_CREATE_JOINABLE $ax_cv_PTHREAD_JOINABLE_ATTR" >>confdefs.h++ ax_pthread_joinable_attr_defined=yes++fi++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether more special flags are required for pthreads" >&5+printf %s "checking whether more special flags are required for pthreads... " >&6; }+if test ${ax_cv_PTHREAD_SPECIAL_FLAGS+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ax_cv_PTHREAD_SPECIAL_FLAGS=no+ case $host_os in+ solaris*)+ ax_cv_PTHREAD_SPECIAL_FLAGS="-D_POSIX_PTHREAD_SEMANTICS"+ ;;+ esac+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_SPECIAL_FLAGS" >&5+printf "%s\n" "$ax_cv_PTHREAD_SPECIAL_FLAGS" >&6; }+ if test "x$ax_cv_PTHREAD_SPECIAL_FLAGS" != "xno" && \+ test "x$ax_pthread_special_flags_added" != "xyes"+then :+ PTHREAD_CFLAGS="$ax_cv_PTHREAD_SPECIAL_FLAGS $PTHREAD_CFLAGS"+ ax_pthread_special_flags_added=yes+fi++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for PTHREAD_PRIO_INHERIT" >&5+printf %s "checking for PTHREAD_PRIO_INHERIT... " >&6; }+if test ${ax_cv_PTHREAD_PRIO_INHERIT+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <pthread.h>+int+main (void)+{+int i = PTHREAD_PRIO_INHERIT;+ return i;+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ ax_cv_PTHREAD_PRIO_INHERIT=yes+else case e in #(+ e) ax_cv_PTHREAD_PRIO_INHERIT=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ax_cv_PTHREAD_PRIO_INHERIT" >&5+printf "%s\n" "$ax_cv_PTHREAD_PRIO_INHERIT" >&6; }+ if test "x$ax_cv_PTHREAD_PRIO_INHERIT" = "xyes" && \+ test "x$ax_pthread_prio_inherit_defined" != "xyes"+then :++printf "%s\n" "#define HAVE_PTHREAD_PRIO_INHERIT 1" >>confdefs.h++ ax_pthread_prio_inherit_defined=yes++fi++ 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*)+ case "x/$CC" in #(+ 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+ case "x$CC" in #(+ x/*) :++ if as_fn_executable_p ${CC}_r+then :+ PTHREAD_CC="${CC}_r"+fi+ if test "x${CXX}" != "x"+then :+ if as_fn_executable_p ${CXX}_r+then :+ PTHREAD_CXX="${CXX}_r"+fi+fi+ ;; #(+ *) :++ for ac_prog in ${CC}_r+do+ # Extract the first word of "$ac_prog", so it can be a program name with args.+set dummy $ac_prog; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_PTHREAD_CC+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$PTHREAD_CC"; then+ ac_cv_prog_PTHREAD_CC="$PTHREAD_CC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_PTHREAD_CC="$ac_prog"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+PTHREAD_CC=$ac_cv_prog_PTHREAD_CC+if test -n "$PTHREAD_CC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CC" >&5+printf "%s\n" "$PTHREAD_CC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ test -n "$PTHREAD_CC" && break+done+test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"++ if test "x${CXX}" != "x"+then :+ for ac_prog in ${CXX}_r+do+ # Extract the first word of "$ac_prog", so it can be a program name with args.+set dummy $ac_prog; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_PTHREAD_CXX+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$PTHREAD_CXX"; then+ ac_cv_prog_PTHREAD_CXX="$PTHREAD_CXX" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_PTHREAD_CXX="$ac_prog"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+PTHREAD_CXX=$ac_cv_prog_PTHREAD_CXX+if test -n "$PTHREAD_CXX"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $PTHREAD_CXX" >&5+printf "%s\n" "$PTHREAD_CXX" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ test -n "$PTHREAD_CXX" && break+done+test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX"++fi++ ;;+esac+ ;; #(+ *) :+ ;;+esac+ ;;+ esac+ fi+fi++test -n "$PTHREAD_CC" || PTHREAD_CC="$CC"+test -n "$PTHREAD_CXX" || PTHREAD_CXX="$CXX"+++++++# Finally, execute ACTION-IF-FOUND/ACTION-IF-NOT-FOUND:+if test "x$ax_pthread_ok" = "xyes"; then+ :+ :+else+ ax_pthread_ok=no++fi+ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu++ LIBS="$PTHREAD_LIBS $LIBS"+ AM_CFLAGS="$AM_CFLAGS $PTHREAD_CFLAGS"++++printf "%s\n" "#define MYTHREAD_POSIX 1" >>confdefs.h+++ # This is nice to have but not mandatory.+ OLD_CFLAGS=$CFLAGS+ CFLAGS="$CFLAGS $PTHREAD_CFLAGS"+ ac_fn_c_check_func "$LINENO" "pthread_condattr_setclock" "ac_cv_func_pthread_condattr_setclock"+if test "x$ac_cv_func_pthread_condattr_setclock" = xyes+then :+ printf "%s\n" "#define HAVE_PTHREAD_CONDATTR_SETCLOCK 1" >>confdefs.h++fi++ CFLAGS=$OLD_CFLAGS+ ;; #(+ win95) :+++printf "%s\n" "#define MYTHREAD_WIN95 1" >>confdefs.h++ ;; #(+ vista) :+++printf "%s\n" "#define MYTHREAD_VISTA 1" >>confdefs.h+++ ;; #(+ *) :+ ;;+esac+ if test "x$enable_threads" != xno; then+ COND_THREADS_TRUE=+ COND_THREADS_FALSE='#'+else+ COND_THREADS_TRUE='#'+ COND_THREADS_FALSE=+fi+++echo+echo "Initializing Libtool:"+++case `pwd` in+ *\ * | *\ *)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&5+printf "%s\n" "$as_me: WARNING: Libtool does not cope well with whitespace in \`pwd\`" >&2;} ;;+esac++++macro_version='2.4.7'+macro_revision='2.4.7'+++++++++++++++ltmain=$ac_aux_dir/ltmain.sh++# Backslashify metacharacters that are still active within+# double-quoted strings.+sed_quote_subst='s/\(["`$\\]\)/\\\1/g'++# Same as above, but do not quote variable references.+double_quote_subst='s/\(["`\\]\)/\\\1/g'++# Sed substitution to delay expansion of an escaped shell variable in a+# double_quote_subst'ed string.+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'++# Sed substitution to delay expansion of an escaped single quote.+delay_single_quote_subst='s/'\''/'\'\\\\\\\'\''/g'++# Sed substitution to avoid accidental globbing in evaled expressions+no_glob_subst='s/\*/\\\*/g'++ECHO='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO+ECHO=$ECHO$ECHO$ECHO$ECHO$ECHO$ECHO++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to print strings" >&5+printf %s "checking how to print strings... " >&6; }+# Test print first, because it will be a builtin if present.+if test "X`( print -r -- -n ) 2>/dev/null`" = X-n && \+ test "X`print -r -- $ECHO 2>/dev/null`" = "X$ECHO"; then+ ECHO='print -r --'+elif test "X`printf %s $ECHO 2>/dev/null`" = "X$ECHO"; then+ ECHO='printf %s\n'+else+ # Use this function as a fallback that always works.+ func_fallback_echo ()+ {+ eval 'cat <<_LTECHO_EOF+$1+_LTECHO_EOF'+ }+ ECHO='func_fallback_echo'+fi++# func_echo_all arg...+# Invoke $ECHO with all args, space-separated.+func_echo_all ()+{+ $ECHO ""+}++case $ECHO in+ printf*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: printf" >&5+printf "%s\n" "printf" >&6; } ;;+ print*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: print -r" >&5+printf "%s\n" "print -r" >&6; } ;;+ *) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: cat" >&5+printf "%s\n" "cat" >&6; } ;;+esac+++++++++++++++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5+printf %s "checking for a sed that does not truncate output... " >&6; }+if test ${ac_cv_path_SED+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/+ for ac_i in 1 2 3 4 5 6 7; do+ ac_script="$ac_script$as_nl$ac_script"+ done+ echo "$ac_script" 2>/dev/null | sed 99q >conftest.sed+ { ac_script=; unset ac_script;}+ if test -z "$SED"; then+ ac_path_SED_found=false+ # Loop through the user's path and test for each of PROGNAME-LIST+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_prog in sed gsed+ do+ for ac_exec_ext in '' $ac_executable_extensions; do+ ac_path_SED="$as_dir$ac_prog$ac_exec_ext"+ as_fn_executable_p "$ac_path_SED" || continue+# Check for GNU ac_path_SED and select it if it is found.+ # Check for GNU $ac_path_SED+case `"$ac_path_SED" --version 2>&1` in #(+*GNU*)+ ac_cv_path_SED="$ac_path_SED" ac_path_SED_found=:;;+#(+*)+ ac_count=0+ printf %s 0123456789 >"conftest.in"+ while :+ do+ cat "conftest.in" "conftest.in" >"conftest.tmp"+ mv "conftest.tmp" "conftest.in"+ cp "conftest.in" "conftest.nl"+ printf "%s\n" '' >> "conftest.nl"+ "$ac_path_SED" -f conftest.sed < "conftest.nl" >"conftest.out" 2>/dev/null || break+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break+ as_fn_arith $ac_count + 1 && ac_count=$as_val+ if test $ac_count -gt ${ac_path_SED_max-0}; then+ # Best one so far, save it but keep looking for a better one+ ac_cv_path_SED="$ac_path_SED"+ ac_path_SED_max=$ac_count+ fi+ # 10*(2^10) chars as input seems more than enough+ test $ac_count -gt 10 && break+ done+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;+esac++ $ac_path_SED_found && break 3+ done+ done+ done+IFS=$as_save_IFS+ if test -z "$ac_cv_path_SED"; then+ as_fn_error $? "no acceptable sed could be found in \$PATH" "$LINENO" 5+ fi+else+ ac_cv_path_SED=$SED+fi+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_SED" >&5+printf "%s\n" "$ac_cv_path_SED" >&6; }+ SED="$ac_cv_path_SED"+ rm -f conftest.sed++test -z "$SED" && SED=sed+Xsed="$SED -e 1s/^X//"++++++++++++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5+printf %s "checking for grep that handles long lines and -e... " >&6; }+if test ${ac_cv_path_GREP+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -z "$GREP"; then+ ac_path_GREP_found=false+ # Loop through the user's path and test for each of PROGNAME-LIST+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_prog in grep ggrep+ do+ for ac_exec_ext in '' $ac_executable_extensions; do+ ac_path_GREP="$as_dir$ac_prog$ac_exec_ext"+ as_fn_executable_p "$ac_path_GREP" || continue+# Check for GNU ac_path_GREP and select it if it is found.+ # Check for GNU $ac_path_GREP+case `"$ac_path_GREP" --version 2>&1` in #(+*GNU*)+ ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;+#(+*)+ ac_count=0+ printf %s 0123456789 >"conftest.in"+ while :+ do+ cat "conftest.in" "conftest.in" >"conftest.tmp"+ mv "conftest.tmp" "conftest.in"+ cp "conftest.in" "conftest.nl"+ printf "%s\n" 'GREP' >> "conftest.nl"+ "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break+ as_fn_arith $ac_count + 1 && ac_count=$as_val+ if test $ac_count -gt ${ac_path_GREP_max-0}; then+ # Best one so far, save it but keep looking for a better one+ ac_cv_path_GREP="$ac_path_GREP"+ ac_path_GREP_max=$ac_count+ fi+ # 10*(2^10) chars as input seems more than enough+ test $ac_count -gt 10 && break+ done+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;+esac++ $ac_path_GREP_found && break 3+ done+ done+ done+IFS=$as_save_IFS+ if test -z "$ac_cv_path_GREP"; then+ as_fn_error $? "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5+ fi+else+ ac_cv_path_GREP=$GREP+fi+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5+printf "%s\n" "$ac_cv_path_GREP" >&6; }+ GREP="$ac_cv_path_GREP"+++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5+printf %s "checking for egrep... " >&6; }+if test ${ac_cv_path_EGREP+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if echo a | $GREP -E '(a|b)' >/dev/null 2>&1+ then ac_cv_path_EGREP="$GREP -E"+ else+ if test -z "$EGREP"; then+ ac_path_EGREP_found=false+ # Loop through the user's path and test for each of PROGNAME-LIST+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_prog in egrep+ do+ for ac_exec_ext in '' $ac_executable_extensions; do+ ac_path_EGREP="$as_dir$ac_prog$ac_exec_ext"+ as_fn_executable_p "$ac_path_EGREP" || continue+# Check for GNU ac_path_EGREP and select it if it is found.+ # Check for GNU $ac_path_EGREP+case `"$ac_path_EGREP" --version 2>&1` in #(+*GNU*)+ ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;+#(+*)+ ac_count=0+ printf %s 0123456789 >"conftest.in"+ while :+ do+ cat "conftest.in" "conftest.in" >"conftest.tmp"+ mv "conftest.tmp" "conftest.in"+ cp "conftest.in" "conftest.nl"+ printf "%s\n" 'EGREP' >> "conftest.nl"+ "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break+ as_fn_arith $ac_count + 1 && ac_count=$as_val+ if test $ac_count -gt ${ac_path_EGREP_max-0}; then+ # Best one so far, save it but keep looking for a better one+ ac_cv_path_EGREP="$ac_path_EGREP"+ ac_path_EGREP_max=$ac_count+ fi+ # 10*(2^10) chars as input seems more than enough+ test $ac_count -gt 10 && break+ done+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;+esac++ $ac_path_EGREP_found && break 3+ done+ done+ done+IFS=$as_save_IFS+ if test -z "$ac_cv_path_EGREP"; then+ as_fn_error $? "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5+ fi+else+ ac_cv_path_EGREP=$EGREP+fi++ fi ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5+printf "%s\n" "$ac_cv_path_EGREP" >&6; }+ EGREP="$ac_cv_path_EGREP"++ EGREP_TRADITIONAL=$EGREP+ ac_cv_path_EGREP_TRADITIONAL=$EGREP++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for fgrep" >&5+printf %s "checking for fgrep... " >&6; }+if test ${ac_cv_path_FGREP+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if echo 'ab*c' | $GREP -F 'ab*c' >/dev/null 2>&1+ then ac_cv_path_FGREP="$GREP -F"+ else+ if test -z "$FGREP"; then+ ac_path_FGREP_found=false+ # Loop through the user's path and test for each of PROGNAME-LIST+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_prog in fgrep+ do+ for ac_exec_ext in '' $ac_executable_extensions; do+ ac_path_FGREP="$as_dir$ac_prog$ac_exec_ext"+ as_fn_executable_p "$ac_path_FGREP" || continue+# Check for GNU ac_path_FGREP and select it if it is found.+ # Check for GNU $ac_path_FGREP+case `"$ac_path_FGREP" --version 2>&1` in #(+*GNU*)+ ac_cv_path_FGREP="$ac_path_FGREP" ac_path_FGREP_found=:;;+#(+*)+ ac_count=0+ printf %s 0123456789 >"conftest.in"+ while :+ do+ cat "conftest.in" "conftest.in" >"conftest.tmp"+ mv "conftest.tmp" "conftest.in"+ cp "conftest.in" "conftest.nl"+ printf "%s\n" 'FGREP' >> "conftest.nl"+ "$ac_path_FGREP" FGREP < "conftest.nl" >"conftest.out" 2>/dev/null || break+ diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break+ as_fn_arith $ac_count + 1 && ac_count=$as_val+ if test $ac_count -gt ${ac_path_FGREP_max-0}; then+ # Best one so far, save it but keep looking for a better one+ ac_cv_path_FGREP="$ac_path_FGREP"+ ac_path_FGREP_max=$ac_count+ fi+ # 10*(2^10) chars as input seems more than enough+ test $ac_count -gt 10 && break+ done+ rm -f conftest.in conftest.tmp conftest.nl conftest.out;;+esac++ $ac_path_FGREP_found && break 3+ done+ done+ done+IFS=$as_save_IFS+ if test -z "$ac_cv_path_FGREP"; then+ as_fn_error $? "no acceptable fgrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5+ fi+else+ ac_cv_path_FGREP=$FGREP+fi++ fi ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_FGREP" >&5+printf "%s\n" "$ac_cv_path_FGREP" >&6; }+ FGREP="$ac_cv_path_FGREP"+++test -z "$GREP" && GREP=grep++++++++++++++++++++# Check whether --with-gnu-ld was given.+if test ${with_gnu_ld+y}+then :+ withval=$with_gnu_ld; test no = "$withval" || with_gnu_ld=yes+else case e in #(+ e) with_gnu_ld=no ;;+esac+fi++ac_prog=ld+if test yes = "$GCC"; then+ # Check if gcc -print-prog-name=ld gives a path.+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5+printf %s "checking for ld used by $CC... " >&6; }+ case $host in+ *-*-mingw*)+ # gcc leaves a trailing carriage return, which upsets mingw+ ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;+ *)+ ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;+ esac+ case $ac_prog in+ # Accept absolute paths.+ [\\/]* | ?:[\\/]*)+ re_direlt='/[^/][^/]*/\.\./'+ # Canonicalize the pathname of ld+ ac_prog=`$ECHO "$ac_prog"| $SED 's%\\\\%/%g'`+ while $ECHO "$ac_prog" | $GREP "$re_direlt" > /dev/null 2>&1; do+ ac_prog=`$ECHO $ac_prog| $SED "s%$re_direlt%/%"`+ done+ test -z "$LD" && LD=$ac_prog+ ;;+ "")+ # If it fails, then pretend we aren't using GCC.+ ac_prog=ld+ ;;+ *)+ # If it is relative, then search for the first ld in PATH.+ with_gnu_ld=unknown+ ;;+ esac+elif test yes = "$with_gnu_ld"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5+printf %s "checking for GNU ld... " >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5+printf %s "checking for non-GNU ld... " >&6; }+fi+if test ${lt_cv_path_LD+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -z "$LD"; then+ lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR+ for ac_dir in $PATH; do+ IFS=$lt_save_ifs+ test -z "$ac_dir" && ac_dir=.+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then+ lt_cv_path_LD=$ac_dir/$ac_prog+ # Check to see if the program is GNU ld. I'd rather use --version,+ # but apparently some variants of GNU ld only accept -v.+ # Break only if it was the GNU/non-GNU ld that we prefer.+ case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in+ *GNU* | *'with BFD'*)+ test no != "$with_gnu_ld" && break+ ;;+ *)+ test yes != "$with_gnu_ld" && break+ ;;+ esac+ fi+ done+ IFS=$lt_save_ifs+else+ lt_cv_path_LD=$LD # Let the user override the test with a path.+fi ;;+esac+fi++LD=$lt_cv_path_LD+if test -n "$LD"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LD" >&5+printf "%s\n" "$LD" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+test -z "$LD" && as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5+printf %s "checking if the linker ($LD) is GNU ld... " >&6; }+if test ${lt_cv_prog_gnu_ld+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) # I'd rather use --version here, but apparently some GNU lds only accept -v.+case `$LD -v 2>&1 </dev/null` in+*GNU* | *'with BFD'*)+ lt_cv_prog_gnu_ld=yes+ ;;+*)+ lt_cv_prog_gnu_ld=no+ ;;+esac ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5+printf "%s\n" "$lt_cv_prog_gnu_ld" >&6; }+with_gnu_ld=$lt_cv_prog_gnu_ld++++++++++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for BSD- or MS-compatible name lister (nm)" >&5+printf %s "checking for BSD- or MS-compatible name lister (nm)... " >&6; }+if test ${lt_cv_path_NM+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$NM"; then+ # Let the user override the test.+ lt_cv_path_NM=$NM+else+ lt_nm_to_check=${ac_tool_prefix}nm+ if test -n "$ac_tool_prefix" && test "$build" = "$host"; then+ lt_nm_to_check="$lt_nm_to_check nm"+ fi+ for lt_tmp_nm in $lt_nm_to_check; do+ lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR+ for ac_dir in $PATH /usr/ccs/bin/elf /usr/ccs/bin /usr/ucb /bin; do+ IFS=$lt_save_ifs+ test -z "$ac_dir" && ac_dir=.+ tmp_nm=$ac_dir/$lt_tmp_nm+ if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext"; then+ # Check to see if the nm accepts a BSD-compat flag.+ # Adding the 'sed 1q' prevents false positives on HP-UX, which says:+ # nm: unknown option "B" ignored+ # Tru64's nm complains that /dev/null is an invalid object file+ # MSYS converts /dev/null to NUL, MinGW nm treats NUL as empty+ case $build_os in+ mingw*) lt_bad_file=conftest.nm/nofile ;;+ *) lt_bad_file=/dev/null ;;+ esac+ case `"$tmp_nm" -B $lt_bad_file 2>&1 | $SED '1q'` in+ *$lt_bad_file* | *'Invalid file or object type'*)+ lt_cv_path_NM="$tmp_nm -B"+ break 2+ ;;+ *)+ case `"$tmp_nm" -p /dev/null 2>&1 | $SED '1q'` in+ */dev/null*)+ lt_cv_path_NM="$tmp_nm -p"+ break 2+ ;;+ *)+ lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but+ continue # so that we can try to find one that supports BSD flags+ ;;+ esac+ ;;+ esac+ fi+ done+ IFS=$lt_save_ifs+ done+ : ${lt_cv_path_NM=no}+fi ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5+printf "%s\n" "$lt_cv_path_NM" >&6; }+if test no != "$lt_cv_path_NM"; then+ NM=$lt_cv_path_NM+else+ # Didn't find any BSD compatible name lister, look for dumpbin.+ if test -n "$DUMPBIN"; then :+ # Let the user override the test.+ else+ if test -n "$ac_tool_prefix"; then+ for ac_prog in dumpbin "link -dump"+ do+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.+set dummy $ac_tool_prefix$ac_prog; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_DUMPBIN+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$DUMPBIN"; then+ ac_cv_prog_DUMPBIN="$DUMPBIN" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_DUMPBIN="$ac_tool_prefix$ac_prog"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+DUMPBIN=$ac_cv_prog_DUMPBIN+if test -n "$DUMPBIN"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DUMPBIN" >&5+printf "%s\n" "$DUMPBIN" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ test -n "$DUMPBIN" && break+ done+fi+if test -z "$DUMPBIN"; then+ ac_ct_DUMPBIN=$DUMPBIN+ for ac_prog in dumpbin "link -dump"+do+ # Extract the first word of "$ac_prog", so it can be a program name with args.+set dummy $ac_prog; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_DUMPBIN+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_DUMPBIN"; then+ ac_cv_prog_ac_ct_DUMPBIN="$ac_ct_DUMPBIN" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_DUMPBIN="$ac_prog"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_DUMPBIN=$ac_cv_prog_ac_ct_DUMPBIN+if test -n "$ac_ct_DUMPBIN"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DUMPBIN" >&5+printf "%s\n" "$ac_ct_DUMPBIN" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ test -n "$ac_ct_DUMPBIN" && break+done++ if test "x$ac_ct_DUMPBIN" = x; then+ DUMPBIN=":"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ DUMPBIN=$ac_ct_DUMPBIN+ fi+fi++ case `$DUMPBIN -symbols -headers /dev/null 2>&1 | $SED '1q'` in+ *COFF*)+ DUMPBIN="$DUMPBIN -symbols -headers"+ ;;+ *)+ DUMPBIN=:+ ;;+ esac+ fi++ if test : != "$DUMPBIN"; then+ NM=$DUMPBIN+ fi+fi+test -z "$NM" && NM=nm+++++++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the name lister ($NM) interface" >&5+printf %s "checking the name lister ($NM) interface... " >&6; }+if test ${lt_cv_nm_interface+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_nm_interface="BSD nm"+ echo "int some_variable = 0;" > conftest.$ac_ext+ (eval echo "\"\$as_me:$LINENO: $ac_compile\"" >&5)+ (eval "$ac_compile" 2>conftest.err)+ cat conftest.err >&5+ (eval echo "\"\$as_me:$LINENO: $NM \\\"conftest.$ac_objext\\\"\"" >&5)+ (eval "$NM \"conftest.$ac_objext\"" 2>conftest.err > conftest.out)+ cat conftest.err >&5+ (eval echo "\"\$as_me:$LINENO: output\"" >&5)+ cat conftest.out >&5+ if $GREP 'External.*some_variable' conftest.out > /dev/null; then+ lt_cv_nm_interface="MS dumpbin"+ fi+ rm -f conftest* ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_nm_interface" >&5+printf "%s\n" "$lt_cv_nm_interface" >&6; }++# find the maximum length of command line arguments+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5+printf %s "checking the maximum length of command line arguments... " >&6; }+if test ${lt_cv_sys_max_cmd_len+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) i=0+ teststring=ABCD++ case $build_os in+ msdosdjgpp*)+ # On DJGPP, this test can blow up pretty badly due to problems in libc+ # (any single argument exceeding 2000 bytes causes a buffer overrun+ # during glob expansion). Even if it were fixed, the result of this+ # check would be larger than it should be.+ lt_cv_sys_max_cmd_len=12288; # 12K is about right+ ;;++ gnu*)+ # Under GNU Hurd, this test is not required because there is+ # no limit to the length of command line arguments.+ # Libtool will interpret -1 as no limit whatsoever+ lt_cv_sys_max_cmd_len=-1;+ ;;++ cygwin* | mingw* | cegcc*)+ # On Win9x/ME, this test blows up -- it succeeds, but takes+ # about 5 minutes as the teststring grows exponentially.+ # Worse, since 9x/ME are not pre-emptively multitasking,+ # you end up with a "frozen" computer, even though with patience+ # the test eventually succeeds (with a max line length of 256k).+ # Instead, let's just punt: use the minimum linelength reported by+ # all of the supported platforms: 8192 (on NT/2K/XP).+ lt_cv_sys_max_cmd_len=8192;+ ;;++ mint*)+ # On MiNT this can take a long time and run out of memory.+ lt_cv_sys_max_cmd_len=8192;+ ;;++ amigaos*)+ # On AmigaOS with pdksh, this test takes hours, literally.+ # So we just punt and use a minimum line length of 8192.+ lt_cv_sys_max_cmd_len=8192;+ ;;++ bitrig* | darwin* | dragonfly* | freebsd* | midnightbsd* | netbsd* | openbsd*)+ # This has been around since 386BSD, at least. Likely further.+ if test -x /sbin/sysctl; then+ lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`+ elif test -x /usr/sbin/sysctl; then+ lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`+ else+ lt_cv_sys_max_cmd_len=65536 # usable default for all BSDs+ fi+ # And add a safety zone+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`+ ;;++ interix*)+ # We know the value 262144 and hardcode it with a safety zone (like BSD)+ lt_cv_sys_max_cmd_len=196608+ ;;++ os2*)+ # The test takes a long time on OS/2.+ lt_cv_sys_max_cmd_len=8192+ ;;++ osf*)+ # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure+ # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not+ # nice to cause kernel panics so lets avoid the loop below.+ # First set a reasonable default.+ lt_cv_sys_max_cmd_len=16384+ #+ if test -x /sbin/sysconfig; then+ case `/sbin/sysconfig -q proc exec_disable_arg_limit` in+ *1*) lt_cv_sys_max_cmd_len=-1 ;;+ esac+ fi+ ;;+ sco3.2v5*)+ lt_cv_sys_max_cmd_len=102400+ ;;+ sysv5* | sco5v6* | sysv4.2uw2*)+ kargmax=`grep ARG_MAX /etc/conf/cf.d/stune 2>/dev/null`+ if test -n "$kargmax"; then+ lt_cv_sys_max_cmd_len=`echo $kargmax | $SED 's/.*[ ]//'`+ else+ lt_cv_sys_max_cmd_len=32768+ fi+ ;;+ *)+ lt_cv_sys_max_cmd_len=`(getconf ARG_MAX) 2> /dev/null`+ if test -n "$lt_cv_sys_max_cmd_len" && \+ test undefined != "$lt_cv_sys_max_cmd_len"; then+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`+ else+ # Make teststring a little bigger before we do anything with it.+ # a 1K string should be a reasonable start.+ for i in 1 2 3 4 5 6 7 8; do+ teststring=$teststring$teststring+ done+ SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}+ # If test is not a shell built-in, we'll probably end up computing a+ # maximum length that is only half of the actual maximum length, but+ # we can't tell.+ while { test X`env echo "$teststring$teststring" 2>/dev/null` \+ = "X$teststring$teststring"; } >/dev/null 2>&1 &&+ test 17 != "$i" # 1/2 MB should be enough+ do+ i=`expr $i + 1`+ teststring=$teststring$teststring+ done+ # Only check the string length outside the loop.+ lt_cv_sys_max_cmd_len=`expr "X$teststring" : ".*" 2>&1`+ teststring=+ # Add a significant safety factor because C++ compilers can tack on+ # massive amounts of additional arguments before passing them to the+ # linker. It appears as though 1/2 is a usable value.+ lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`+ fi+ ;;+ esac+ ;;+esac+fi++if test -n "$lt_cv_sys_max_cmd_len"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5+printf "%s\n" "$lt_cv_sys_max_cmd_len" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: none" >&5+printf "%s\n" "none" >&6; }+fi+max_cmd_len=$lt_cv_sys_max_cmd_len+++++++: ${CP="cp -f"}+: ${MV="mv -f"}+: ${RM="rm -f"}++if ( (MAIL=60; unset MAIL) || exit) >/dev/null 2>&1; then+ lt_unset=unset+else+ lt_unset=false+fi++++++# test EBCDIC or ASCII+case `echo X|tr X '\101'` in+ A) # ASCII based system+ # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr+ lt_SP2NL='tr \040 \012'+ lt_NL2SP='tr \015\012 \040\040'+ ;;+ *) # EBCDIC based system+ lt_SP2NL='tr \100 \n'+ lt_NL2SP='tr \r\n \100\100'+ ;;+esac++++++++++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to $host format" >&5+printf %s "checking how to convert $build file names to $host format... " >&6; }+if test ${lt_cv_to_host_file_cmd+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) case $host in+ *-*-mingw* )+ case $build in+ *-*-mingw* ) # actually msys+ lt_cv_to_host_file_cmd=func_convert_file_msys_to_w32+ ;;+ *-*-cygwin* )+ lt_cv_to_host_file_cmd=func_convert_file_cygwin_to_w32+ ;;+ * ) # otherwise, assume *nix+ lt_cv_to_host_file_cmd=func_convert_file_nix_to_w32+ ;;+ esac+ ;;+ *-*-cygwin* )+ case $build in+ *-*-mingw* ) # actually msys+ lt_cv_to_host_file_cmd=func_convert_file_msys_to_cygwin+ ;;+ *-*-cygwin* )+ lt_cv_to_host_file_cmd=func_convert_file_noop+ ;;+ * ) # otherwise, assume *nix+ lt_cv_to_host_file_cmd=func_convert_file_nix_to_cygwin+ ;;+ esac+ ;;+ * ) # unhandled hosts (and "normal" native builds)+ lt_cv_to_host_file_cmd=func_convert_file_noop+ ;;+esac+ ;;+esac+fi++to_host_file_cmd=$lt_cv_to_host_file_cmd+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_host_file_cmd" >&5+printf "%s\n" "$lt_cv_to_host_file_cmd" >&6; }++++++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to convert $build file names to toolchain format" >&5+printf %s "checking how to convert $build file names to toolchain format... " >&6; }+if test ${lt_cv_to_tool_file_cmd+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) #assume ordinary cross tools, or native build.+lt_cv_to_tool_file_cmd=func_convert_file_noop+case $host in+ *-*-mingw* )+ case $build in+ *-*-mingw* ) # actually msys+ lt_cv_to_tool_file_cmd=func_convert_file_msys_to_w32+ ;;+ esac+ ;;+esac+ ;;+esac+fi++to_tool_file_cmd=$lt_cv_to_tool_file_cmd+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_to_tool_file_cmd" >&5+printf "%s\n" "$lt_cv_to_tool_file_cmd" >&6; }++++++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5+printf %s "checking for $LD option to reload object files... " >&6; }+if test ${lt_cv_ld_reload_flag+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_ld_reload_flag='-r' ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5+printf "%s\n" "$lt_cv_ld_reload_flag" >&6; }+reload_flag=$lt_cv_ld_reload_flag+case $reload_flag in+"" | " "*) ;;+*) reload_flag=" $reload_flag" ;;+esac+reload_cmds='$LD$reload_flag -o $output$reload_objs'+case $host_os in+ cygwin* | mingw* | pw32* | cegcc*)+ if test yes != "$GCC"; then+ reload_cmds=false+ fi+ ;;+ darwin*)+ if test yes = "$GCC"; then+ reload_cmds='$LTCC $LTCFLAGS -nostdlib $wl-r -o $output$reload_objs'+ else+ reload_cmds='$LD$reload_flag -o $output$reload_objs'+ fi+ ;;+esac++++++++++if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}file", so it can be a program name with args.+set dummy ${ac_tool_prefix}file; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_FILECMD+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$FILECMD"; then+ ac_cv_prog_FILECMD="$FILECMD" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_FILECMD="${ac_tool_prefix}file"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+FILECMD=$ac_cv_prog_FILECMD+if test -n "$FILECMD"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $FILECMD" >&5+printf "%s\n" "$FILECMD" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_FILECMD"; then+ ac_ct_FILECMD=$FILECMD+ # Extract the first word of "file", so it can be a program name with args.+set dummy file; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_FILECMD+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_FILECMD"; then+ ac_cv_prog_ac_ct_FILECMD="$ac_ct_FILECMD" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_FILECMD="file"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_FILECMD=$ac_cv_prog_ac_ct_FILECMD+if test -n "$ac_ct_FILECMD"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_FILECMD" >&5+printf "%s\n" "$ac_ct_FILECMD" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_FILECMD" = x; then+ FILECMD=":"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ FILECMD=$ac_ct_FILECMD+ fi+else+ FILECMD="$ac_cv_prog_FILECMD"+fi++++++++if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.+set dummy ${ac_tool_prefix}objdump; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_OBJDUMP+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$OBJDUMP"; then+ ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+OBJDUMP=$ac_cv_prog_OBJDUMP+if test -n "$OBJDUMP"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5+printf "%s\n" "$OBJDUMP" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_OBJDUMP"; then+ ac_ct_OBJDUMP=$OBJDUMP+ # Extract the first word of "objdump", so it can be a program name with args.+set dummy objdump; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_OBJDUMP+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_OBJDUMP"; then+ ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_OBJDUMP="objdump"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP+if test -n "$ac_ct_OBJDUMP"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5+printf "%s\n" "$ac_ct_OBJDUMP" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_OBJDUMP" = x; then+ OBJDUMP="false"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ OBJDUMP=$ac_ct_OBJDUMP+ fi+else+ OBJDUMP="$ac_cv_prog_OBJDUMP"+fi++test -z "$OBJDUMP" && OBJDUMP=objdump+++++++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to recognize dependent libraries" >&5+printf %s "checking how to recognize dependent libraries... " >&6; }+if test ${lt_cv_deplibs_check_method+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_file_magic_cmd='$MAGIC_CMD'+lt_cv_file_magic_test_file=+lt_cv_deplibs_check_method='unknown'+# Need to set the preceding variable on all platforms that support+# interlibrary dependencies.+# 'none' -- dependencies not supported.+# 'unknown' -- same as none, but documents that we really don't know.+# 'pass_all' -- all dependencies passed with no checks.+# 'test_compile' -- check by making test program.+# 'file_magic [[regex]]' -- check by looking for files in library path+# that responds to the $file_magic_cmd with a given extended regex.+# If you have 'file' or equivalent on your system and you're not sure+# whether 'pass_all' will *always* work, you probably want this one.++case $host_os in+aix[4-9]*)+ lt_cv_deplibs_check_method=pass_all+ ;;++beos*)+ lt_cv_deplibs_check_method=pass_all+ ;;++bsdi[45]*)+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'+ lt_cv_file_magic_cmd='$FILECMD -L'+ lt_cv_file_magic_test_file=/shlib/libc.so+ ;;++cygwin*)+ # func_win32_libid is a shell function defined in ltmain.sh+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'+ lt_cv_file_magic_cmd='func_win32_libid'+ ;;++mingw* | pw32*)+ # Base MSYS/MinGW do not provide the 'file' command needed by+ # func_win32_libid shell function, so use a weaker test based on 'objdump',+ # unless we find 'file', for example because we are cross-compiling.+ if ( file / ) >/dev/null 2>&1; then+ lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'+ lt_cv_file_magic_cmd='func_win32_libid'+ else+ # Keep this pattern in sync with the one in func_win32_libid.+ lt_cv_deplibs_check_method='file_magic file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)'+ lt_cv_file_magic_cmd='$OBJDUMP -f'+ fi+ ;;++cegcc*)+ # use the weaker test based on 'objdump'. See mingw*.+ lt_cv_deplibs_check_method='file_magic file format pe-arm-.*little(.*architecture: arm)?'+ lt_cv_file_magic_cmd='$OBJDUMP -f'+ ;;++darwin* | rhapsody*)+ lt_cv_deplibs_check_method=pass_all+ ;;++freebsd* | dragonfly* | midnightbsd*)+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then+ case $host_cpu in+ i*86 )+ # Not sure whether the presence of OpenBSD here was a mistake.+ # Let's accept both of them until this is cleared up.+ lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'+ lt_cv_file_magic_cmd=$FILECMD+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`+ ;;+ esac+ else+ lt_cv_deplibs_check_method=pass_all+ fi+ ;;++haiku*)+ lt_cv_deplibs_check_method=pass_all+ ;;++hpux10.20* | hpux11*)+ lt_cv_file_magic_cmd=$FILECMD+ case $host_cpu in+ ia64*)+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'+ lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so+ ;;+ hppa*64*)+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF[ -][0-9][0-9])(-bit)?( [LM]SB)? shared object( file)?[, -]* PA-RISC [0-9]\.[0-9]'+ lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl+ ;;+ *)+ lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9]\.[0-9]) shared library'+ lt_cv_file_magic_test_file=/usr/lib/libc.sl+ ;;+ esac+ ;;++interix[3-9]*)+ # PIC code is broken on Interix 3.x, that's why |\.a not |_pic\.a here+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|\.a)$'+ ;;++irix5* | irix6* | nonstopux*)+ case $LD in+ *-32|*"-32 ") libmagic=32-bit;;+ *-n32|*"-n32 ") libmagic=N32;;+ *-64|*"-64 ") libmagic=64-bit;;+ *) libmagic=never-match;;+ esac+ lt_cv_deplibs_check_method=pass_all+ ;;++# This must be glibc/ELF.+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)+ lt_cv_deplibs_check_method=pass_all+ ;;++netbsd*)+ if echo __ELF__ | $CC -E - | $GREP __ELF__ > /dev/null; then+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'+ else+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'+ fi+ ;;++newos6*)+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'+ lt_cv_file_magic_cmd=$FILECMD+ lt_cv_file_magic_test_file=/usr/lib/libnls.so+ ;;++*nto* | *qnx*)+ lt_cv_deplibs_check_method=pass_all+ ;;++openbsd* | bitrig*)+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'+ else+ lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'+ fi+ ;;++osf3* | osf4* | osf5*)+ lt_cv_deplibs_check_method=pass_all+ ;;++rdos*)+ lt_cv_deplibs_check_method=pass_all+ ;;++solaris*)+ lt_cv_deplibs_check_method=pass_all+ ;;++sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)+ lt_cv_deplibs_check_method=pass_all+ ;;++sysv4 | sysv4.3*)+ case $host_vendor in+ motorola)+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'+ lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`+ ;;+ ncr)+ lt_cv_deplibs_check_method=pass_all+ ;;+ sequent)+ lt_cv_file_magic_cmd='/bin/file'+ lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'+ ;;+ sni)+ lt_cv_file_magic_cmd='/bin/file'+ lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"+ lt_cv_file_magic_test_file=/lib/libc.so+ ;;+ siemens)+ lt_cv_deplibs_check_method=pass_all+ ;;+ pc)+ lt_cv_deplibs_check_method=pass_all+ ;;+ esac+ ;;++tpf*)+ lt_cv_deplibs_check_method=pass_all+ ;;+os2*)+ lt_cv_deplibs_check_method=pass_all+ ;;+esac+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5+printf "%s\n" "$lt_cv_deplibs_check_method" >&6; }++file_magic_glob=+want_nocaseglob=no+if test "$build" = "$host"; then+ case $host_os in+ mingw* | pw32*)+ if ( shopt | grep nocaseglob ) >/dev/null 2>&1; then+ want_nocaseglob=yes+ else+ file_magic_glob=`echo aAbBcCdDeEfFgGhHiIjJkKlLmMnNoOpPqQrRsStTuUvVwWxXyYzZ | $SED -e "s/\(..\)/s\/[\1]\/[\1]\/g;/g"`+ fi+ ;;+ esac+fi++file_magic_cmd=$lt_cv_file_magic_cmd+deplibs_check_method=$lt_cv_deplibs_check_method+test -z "$deplibs_check_method" && deplibs_check_method=unknown+++++++++++++++++++++++if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.+set dummy ${ac_tool_prefix}dlltool; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_DLLTOOL+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$DLLTOOL"; then+ ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+DLLTOOL=$ac_cv_prog_DLLTOOL+if test -n "$DLLTOOL"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5+printf "%s\n" "$DLLTOOL" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_DLLTOOL"; then+ ac_ct_DLLTOOL=$DLLTOOL+ # Extract the first word of "dlltool", so it can be a program name with args.+set dummy dlltool; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_DLLTOOL+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_DLLTOOL"; then+ ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_DLLTOOL="dlltool"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL+if test -n "$ac_ct_DLLTOOL"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5+printf "%s\n" "$ac_ct_DLLTOOL" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_DLLTOOL" = x; then+ DLLTOOL="false"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ DLLTOOL=$ac_ct_DLLTOOL+ fi+else+ DLLTOOL="$ac_cv_prog_DLLTOOL"+fi++test -z "$DLLTOOL" && DLLTOOL=dlltool++++++++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to associate runtime and link libraries" >&5+printf %s "checking how to associate runtime and link libraries... " >&6; }+if test ${lt_cv_sharedlib_from_linklib_cmd+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_sharedlib_from_linklib_cmd='unknown'++case $host_os in+cygwin* | mingw* | pw32* | cegcc*)+ # two different shell functions defined in ltmain.sh;+ # decide which one to use based on capabilities of $DLLTOOL+ case `$DLLTOOL --help 2>&1` in+ *--identify-strict*)+ lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib+ ;;+ *)+ lt_cv_sharedlib_from_linklib_cmd=func_cygming_dll_for_implib_fallback+ ;;+ esac+ ;;+*)+ # fallback: assume linklib IS sharedlib+ lt_cv_sharedlib_from_linklib_cmd=$ECHO+ ;;+esac+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sharedlib_from_linklib_cmd" >&5+printf "%s\n" "$lt_cv_sharedlib_from_linklib_cmd" >&6; }+sharedlib_from_linklib_cmd=$lt_cv_sharedlib_from_linklib_cmd+test -z "$sharedlib_from_linklib_cmd" && sharedlib_from_linklib_cmd=$ECHO++++++++if test -n "$ac_tool_prefix"; then+ for ac_prog in ar+ do+ # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.+set dummy $ac_tool_prefix$ac_prog; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_AR+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$AR"; then+ ac_cv_prog_AR="$AR" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_AR="$ac_tool_prefix$ac_prog"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+AR=$ac_cv_prog_AR+if test -n "$AR"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AR" >&5+printf "%s\n" "$AR" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ test -n "$AR" && break+ done+fi+if test -z "$AR"; then+ ac_ct_AR=$AR+ for ac_prog in ar+do+ # Extract the first word of "$ac_prog", so it can be a program name with args.+set dummy $ac_prog; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_AR+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_AR"; then+ ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_AR="$ac_prog"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_AR=$ac_cv_prog_ac_ct_AR+if test -n "$ac_ct_AR"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5+printf "%s\n" "$ac_ct_AR" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ test -n "$ac_ct_AR" && break+done++ if test "x$ac_ct_AR" = x; then+ AR="false"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ AR=$ac_ct_AR+ fi+fi++: ${AR=ar}+++++++# Use ARFLAGS variable as AR's operation code to sync the variable naming with+# Automake. If both AR_FLAGS and ARFLAGS are specified, AR_FLAGS should have+# higher priority because thats what people were doing historically (setting+# ARFLAGS for automake and AR_FLAGS for libtool). FIXME: Make the AR_FLAGS+# variable obsoleted/removed.++test ${AR_FLAGS+y} || AR_FLAGS=${ARFLAGS-cr}+lt_ar_flags=$AR_FLAGS+++++++# Make AR_FLAGS overridable by 'make ARFLAGS='. Don't try to run-time override+# by AR_FLAGS because that was never working and AR_FLAGS is about to die.+++++++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for archiver @FILE support" >&5+printf %s "checking for archiver @FILE support... " >&6; }+if test ${lt_cv_ar_at_file+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_ar_at_file=no+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ echo conftest.$ac_objext > conftest.lst+ lt_ar_try='$AR $AR_FLAGS libconftest.a @conftest.lst >&5'+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5+ (eval $lt_ar_try) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+ if test 0 -eq "$ac_status"; then+ # Ensure the archiver fails upon bogus file names.+ rm -f conftest.$ac_objext libconftest.a+ { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$lt_ar_try\""; } >&5+ (eval $lt_ar_try) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+ if test 0 -ne "$ac_status"; then+ lt_cv_ar_at_file=@+ fi+ fi+ rm -f conftest.* libconftest.a++fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ar_at_file" >&5+printf "%s\n" "$lt_cv_ar_at_file" >&6; }++if test no = "$lt_cv_ar_at_file"; then+ archiver_list_spec=+else+ archiver_list_spec=$lt_cv_ar_at_file+fi++++++++if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.+set dummy ${ac_tool_prefix}strip; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_STRIP+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$STRIP"; then+ ac_cv_prog_STRIP="$STRIP" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_STRIP="${ac_tool_prefix}strip"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+STRIP=$ac_cv_prog_STRIP+if test -n "$STRIP"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5+printf "%s\n" "$STRIP" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_STRIP"; then+ ac_ct_STRIP=$STRIP+ # Extract the first word of "strip", so it can be a program name with args.+set dummy strip; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_STRIP+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_STRIP"; then+ ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_STRIP="strip"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP+if test -n "$ac_ct_STRIP"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5+printf "%s\n" "$ac_ct_STRIP" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_STRIP" = x; then+ STRIP=":"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ STRIP=$ac_ct_STRIP+ fi+else+ STRIP="$ac_cv_prog_STRIP"+fi++test -z "$STRIP" && STRIP=:+++++++if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.+set dummy ${ac_tool_prefix}ranlib; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_RANLIB+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$RANLIB"; then+ ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+RANLIB=$ac_cv_prog_RANLIB+if test -n "$RANLIB"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5+printf "%s\n" "$RANLIB" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_RANLIB"; then+ ac_ct_RANLIB=$RANLIB+ # Extract the first word of "ranlib", so it can be a program name with args.+set dummy ranlib; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_RANLIB+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_RANLIB"; then+ ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_RANLIB="ranlib"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB+if test -n "$ac_ct_RANLIB"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5+printf "%s\n" "$ac_ct_RANLIB" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_RANLIB" = x; then+ RANLIB=":"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ RANLIB=$ac_ct_RANLIB+ fi+else+ RANLIB="$ac_cv_prog_RANLIB"+fi++test -z "$RANLIB" && RANLIB=:+++++++# Determine commands to create old-style static archives.+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs'+old_postinstall_cmds='chmod 644 $oldlib'+old_postuninstall_cmds=++if test -n "$RANLIB"; then+ case $host_os in+ bitrig* | openbsd*)+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB -t \$tool_oldlib"+ ;;+ *)+ old_postinstall_cmds="$old_postinstall_cmds~\$RANLIB \$tool_oldlib"+ ;;+ esac+ old_archive_cmds="$old_archive_cmds~\$RANLIB \$tool_oldlib"+fi++case $host_os in+ darwin*)+ lock_old_archive_extraction=yes ;;+ *)+ lock_old_archive_extraction=no ;;+esac++++++++++++++++++++++for ac_prog in gawk mawk nawk awk+do+ # Extract the first word of "$ac_prog", so it can be a program name with args.+set dummy $ac_prog; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_AWK+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$AWK"; then+ ac_cv_prog_AWK="$AWK" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_AWK="$ac_prog"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+AWK=$ac_cv_prog_AWK+if test -n "$AWK"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5+printf "%s\n" "$AWK" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ test -n "$AWK" && break+done++++++++++++++++++++# If no C compiler was specified, use CC.+LTCC=${LTCC-"$CC"}++# If no C compiler flags were specified, use CFLAGS.+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}++# Allow CC to be a program name with arguments.+compiler=$CC+++# Check for command to grab the raw symbol name followed by C symbol from nm.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5+printf %s "checking command to parse $NM output from $compiler object... " >&6; }+if test ${lt_cv_sys_global_symbol_pipe+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e)+# These are sane defaults that work on at least a few old systems.+# [They come from Ultrix. What could be older than Ultrix?!! ;)]++# Character class describing NM global symbol codes.+symcode='[BCDEGRST]'++# Regexp to match symbols that can be accessed directly from C.+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'++# Define system-specific variables.+case $host_os in+aix*)+ symcode='[BCDT]'+ ;;+cygwin* | mingw* | pw32* | cegcc*)+ symcode='[ABCDGISTW]'+ ;;+hpux*)+ if test ia64 = "$host_cpu"; then+ symcode='[ABCDEGRST]'+ fi+ ;;+irix* | nonstopux*)+ symcode='[BCDEGRST]'+ ;;+osf*)+ symcode='[BCDEGQRST]'+ ;;+solaris*)+ symcode='[BDRT]'+ ;;+sco3.2v5*)+ symcode='[DT]'+ ;;+sysv4.2uw2*)+ symcode='[DT]'+ ;;+sysv5* | sco5v6* | unixware* | OpenUNIX*)+ symcode='[ABDT]'+ ;;+sysv4)+ symcode='[DFNSTU]'+ ;;+esac++# If we're using GNU nm, then use its standard symbol codes.+case `$NM -V 2>&1` in+*GNU* | *'with BFD'*)+ symcode='[ABCDGIRSTW]' ;;+esac++if test "$lt_cv_nm_interface" = "MS dumpbin"; then+ # Gets list of data symbols to import.+ lt_cv_sys_global_symbol_to_import="$SED -n -e 's/^I .* \(.*\)$/\1/p'"+ # Adjust the below global symbol transforms to fixup imported variables.+ lt_cdecl_hook=" -e 's/^I .* \(.*\)$/extern __declspec(dllimport) char \1;/p'"+ lt_c_name_hook=" -e 's/^I .* \(.*\)$/ {\"\1\", (void *) 0},/p'"+ lt_c_name_lib_hook="\+ -e 's/^I .* \(lib.*\)$/ {\"\1\", (void *) 0},/p'\+ -e 's/^I .* \(.*\)$/ {\"lib\1\", (void *) 0},/p'"+else+ # Disable hooks by default.+ lt_cv_sys_global_symbol_to_import=+ lt_cdecl_hook=+ lt_c_name_hook=+ lt_c_name_lib_hook=+fi++# Transform an extracted symbol line into a proper C declaration.+# Some systems (esp. on ia64) link data and code symbols differently,+# so use this general approach.+lt_cv_sys_global_symbol_to_cdecl="$SED -n"\+$lt_cdecl_hook\+" -e 's/^T .* \(.*\)$/extern int \1();/p'"\+" -e 's/^$symcode$symcode* .* \(.*\)$/extern char \1;/p'"++# Transform an extracted symbol line into symbol name and symbol address+lt_cv_sys_global_symbol_to_c_name_address="$SED -n"\+$lt_c_name_hook\+" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\+" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/p'"++# Transform an extracted symbol line into symbol name with lib prefix and+# symbol address.+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix="$SED -n"\+$lt_c_name_lib_hook\+" -e 's/^: \(.*\) .*$/ {\"\1\", (void *) 0},/p'"\+" -e 's/^$symcode$symcode* .* \(lib.*\)$/ {\"\1\", (void *) \&\1},/p'"\+" -e 's/^$symcode$symcode* .* \(.*\)$/ {\"lib\1\", (void *) \&\1},/p'"++# Handle CRLF in mingw tool chain+opt_cr=+case $build_os in+mingw*)+ opt_cr=`$ECHO 'x\{0,1\}' | tr x '\015'` # option cr in regexp+ ;;+esac++# Try without a prefix underscore, then with it.+for ac_symprfx in "" "_"; do++ # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.+ symxfrm="\\1 $ac_symprfx\\2 \\2"++ # Write the raw and C identifiers.+ if test "$lt_cv_nm_interface" = "MS dumpbin"; then+ # Fake it for dumpbin and say T for any non-static function,+ # D for any global variable and I for any imported variable.+ # Also find C++ and __fastcall symbols from MSVC++ or ICC,+ # which start with @ or ?.+ lt_cv_sys_global_symbol_pipe="$AWK '"\+" {last_section=section; section=\$ 3};"\+" /^COFF SYMBOL TABLE/{for(i in hide) delete hide[i]};"\+" /Section length .*#relocs.*(pick any)/{hide[last_section]=1};"\+" /^ *Symbol name *: /{split(\$ 0,sn,\":\"); si=substr(sn[2],2)};"\+" /^ *Type *: code/{print \"T\",si,substr(si,length(prfx))};"\+" /^ *Type *: data/{print \"I\",si,substr(si,length(prfx))};"\+" \$ 0!~/External *\|/{next};"\+" / 0+ UNDEF /{next}; / UNDEF \([^|]\)*()/{next};"\+" {if(hide[section]) next};"\+" {f=\"D\"}; \$ 0~/\(\).*\|/{f=\"T\"};"\+" {split(\$ 0,a,/\||\r/); split(a[2],s)};"\+" s[1]~/^[@?]/{print f,s[1],s[1]; next};"\+" s[1]~prfx {split(s[1],t,\"@\"); print f,t[1],substr(t[1],length(prfx))}"\+" ' prfx=^$ac_symprfx"+ else+ lt_cv_sys_global_symbol_pipe="$SED -n -e 's/^.*[ ]\($symcode$symcode*\)[ ][ ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"+ fi+ lt_cv_sys_global_symbol_pipe="$lt_cv_sys_global_symbol_pipe | $SED '/ __gnu_lto/d'"++ # Check to see that the pipe works correctly.+ pipe_works=no++ rm -f conftest*+ cat > conftest.$ac_ext <<_LT_EOF+#ifdef __cplusplus+extern "C" {+#endif+char nm_test_var;+void nm_test_func(void);+void nm_test_func(void){}+#ifdef __cplusplus+}+#endif+int main(){nm_test_var='a';nm_test_func();return(0);}+_LT_EOF++ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5+ (eval $ac_compile) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }; then+ # Now try to grab the symbols.+ nlist=conftest.nm+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist\""; } >&5+ (eval $NM conftest.$ac_objext \| "$lt_cv_sys_global_symbol_pipe" \> $nlist) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; } && test -s "$nlist"; then+ # Try sorting and uniquifying the output.+ if sort "$nlist" | uniq > "$nlist"T; then+ mv -f "$nlist"T "$nlist"+ else+ rm -f "$nlist"T+ fi++ # Make sure that we snagged all the symbols we need.+ if $GREP ' nm_test_var$' "$nlist" >/dev/null; then+ if $GREP ' nm_test_func$' "$nlist" >/dev/null; then+ cat <<_LT_EOF > conftest.$ac_ext+/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */+#if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE+/* DATA imports from DLLs on WIN32 can't be const, because runtime+ relocations are performed -- see ld's documentation on pseudo-relocs. */+# define LT_DLSYM_CONST+#elif defined __osf__+/* This system does not cope well with relocations in const data. */+# define LT_DLSYM_CONST+#else+# define LT_DLSYM_CONST const+#endif++#ifdef __cplusplus+extern "C" {+#endif++_LT_EOF+ # Now generate the symbol file.+ eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | $GREP -v main >> conftest.$ac_ext'++ cat <<_LT_EOF >> conftest.$ac_ext++/* The mapping between symbol names and symbols. */+LT_DLSYM_CONST struct {+ const char *name;+ void *address;+}+lt__PROGRAM__LTX_preloaded_symbols[] =+{+ { "@PROGRAM@", (void *) 0 },+_LT_EOF+ $SED "s/^$symcode$symcode* .* \(.*\)$/ {\"\1\", (void *) \&\1},/" < "$nlist" | $GREP -v main >> conftest.$ac_ext+ cat <<\_LT_EOF >> conftest.$ac_ext+ {0, (void *) 0}+};++/* This works around a problem in FreeBSD linker */+#ifdef FREEBSD_WORKAROUND+static const void *lt_preloaded_setup() {+ return lt__PROGRAM__LTX_preloaded_symbols;+}+#endif++#ifdef __cplusplus+}+#endif+_LT_EOF+ # Now try linking the two files.+ mv conftest.$ac_objext conftstm.$ac_objext+ lt_globsym_save_LIBS=$LIBS+ lt_globsym_save_CFLAGS=$CFLAGS+ LIBS=conftstm.$ac_objext+ CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5+ (eval $ac_link) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; } && test -s conftest$ac_exeext; then+ pipe_works=yes+ fi+ LIBS=$lt_globsym_save_LIBS+ CFLAGS=$lt_globsym_save_CFLAGS+ else+ echo "cannot find nm_test_func in $nlist" >&5+ fi+ else+ echo "cannot find nm_test_var in $nlist" >&5+ fi+ else+ echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5+ fi+ else+ echo "$progname: failed program was:" >&5+ cat conftest.$ac_ext >&5+ fi+ rm -rf conftest* conftst*++ # Do not use the global_symbol_pipe unless it works.+ if test yes = "$pipe_works"; then+ break+ else+ lt_cv_sys_global_symbol_pipe=+ fi+done+ ;;+esac+fi++if test -z "$lt_cv_sys_global_symbol_pipe"; then+ lt_cv_sys_global_symbol_to_cdecl=+fi+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: failed" >&5+printf "%s\n" "failed" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ok" >&5+printf "%s\n" "ok" >&6; }+fi++# Response file support.+if test "$lt_cv_nm_interface" = "MS dumpbin"; then+ nm_file_list_spec='@'+elif $NM --help 2>/dev/null | grep '[@]FILE' >/dev/null; then+ nm_file_list_spec='@'+fi++++++++++++++++++++++++++++++++++++++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for sysroot" >&5+printf %s "checking for sysroot... " >&6; }++# Check whether --with-sysroot was given.+if test ${with_sysroot+y}+then :+ withval=$with_sysroot;+else case e in #(+ e) with_sysroot=no ;;+esac+fi+++lt_sysroot=+case $with_sysroot in #(+ yes)+ if test yes = "$GCC"; then+ lt_sysroot=`$CC --print-sysroot 2>/dev/null`+ fi+ ;; #(+ /*)+ lt_sysroot=`echo "$with_sysroot" | $SED -e "$sed_quote_subst"`+ ;; #(+ no|'')+ ;; #(+ *)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_sysroot" >&5+printf "%s\n" "$with_sysroot" >&6; }+ as_fn_error $? "The sysroot must be an absolute path." "$LINENO" 5+ ;;+esac++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: ${lt_sysroot:-no}" >&5+printf "%s\n" "${lt_sysroot:-no}" >&6; }++++++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a working dd" >&5+printf %s "checking for a working dd... " >&6; }+if test ${ac_cv_path_lt_DD+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) printf 0123456789abcdef0123456789abcdef >conftest.i+cat conftest.i conftest.i >conftest2.i+: ${lt_DD:=$DD}+if test -z "$lt_DD"; then+ ac_path_lt_DD_found=false+ # Loop through the user's path and test for each of PROGNAME-LIST+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_prog in dd+ do+ for ac_exec_ext in '' $ac_executable_extensions; do+ ac_path_lt_DD="$as_dir$ac_prog$ac_exec_ext"+ as_fn_executable_p "$ac_path_lt_DD" || continue+if "$ac_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then+ cmp -s conftest.i conftest.out \+ && ac_cv_path_lt_DD="$ac_path_lt_DD" ac_path_lt_DD_found=:+fi+ $ac_path_lt_DD_found && break 3+ done+ done+ done+IFS=$as_save_IFS+ if test -z "$ac_cv_path_lt_DD"; then+ :+ fi+else+ ac_cv_path_lt_DD=$lt_DD+fi++rm -f conftest.i conftest2.i conftest.out ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_lt_DD" >&5+printf "%s\n" "$ac_cv_path_lt_DD" >&6; }+++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to truncate binary pipes" >&5+printf %s "checking how to truncate binary pipes... " >&6; }+if test ${lt_cv_truncate_bin+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) printf 0123456789abcdef0123456789abcdef >conftest.i+cat conftest.i conftest.i >conftest2.i+lt_cv_truncate_bin=+if "$ac_cv_path_lt_DD" bs=32 count=1 <conftest2.i >conftest.out 2>/dev/null; then+ cmp -s conftest.i conftest.out \+ && lt_cv_truncate_bin="$ac_cv_path_lt_DD bs=4096 count=1"+fi+rm -f conftest.i conftest2.i conftest.out+test -z "$lt_cv_truncate_bin" && lt_cv_truncate_bin="$SED -e 4q" ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_truncate_bin" >&5+printf "%s\n" "$lt_cv_truncate_bin" >&6; }++++++++# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.+func_cc_basename ()+{+ for cc_temp in $*""; do+ case $cc_temp in+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;+ \-*) ;;+ *) break;;+ esac+ done+ func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`+}++# Check whether --enable-libtool-lock was given.+if test ${enable_libtool_lock+y}+then :+ enableval=$enable_libtool_lock;+fi++test no = "$enable_libtool_lock" || enable_libtool_lock=yes++# Some flags need to be propagated to the compiler or linker for good+# libtool support.+case $host in+ia64-*-hpux*)+ # Find out what ABI is being produced by ac_compile, and set mode+ # options accordingly.+ echo 'int i;' > conftest.$ac_ext+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5+ (eval $ac_compile) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }; then+ case `$FILECMD conftest.$ac_objext` in+ *ELF-32*)+ HPUX_IA64_MODE=32+ ;;+ *ELF-64*)+ HPUX_IA64_MODE=64+ ;;+ esac+ fi+ rm -rf conftest*+ ;;+*-*-irix6*)+ # Find out what ABI is being produced by ac_compile, and set linker+ # options accordingly.+ echo '#line '$LINENO' "configure"' > conftest.$ac_ext+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5+ (eval $ac_compile) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }; then+ if test yes = "$lt_cv_prog_gnu_ld"; then+ case `$FILECMD conftest.$ac_objext` in+ *32-bit*)+ LD="${LD-ld} -melf32bsmip"+ ;;+ *N32*)+ LD="${LD-ld} -melf32bmipn32"+ ;;+ *64-bit*)+ LD="${LD-ld} -melf64bmip"+ ;;+ esac+ else+ case `$FILECMD conftest.$ac_objext` in+ *32-bit*)+ LD="${LD-ld} -32"+ ;;+ *N32*)+ LD="${LD-ld} -n32"+ ;;+ *64-bit*)+ LD="${LD-ld} -64"+ ;;+ esac+ fi+ fi+ rm -rf conftest*+ ;;++mips64*-*linux*)+ # Find out what ABI is being produced by ac_compile, and set linker+ # options accordingly.+ echo '#line '$LINENO' "configure"' > conftest.$ac_ext+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5+ (eval $ac_compile) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }; then+ emul=elf+ case `$FILECMD conftest.$ac_objext` in+ *32-bit*)+ emul="${emul}32"+ ;;+ *64-bit*)+ emul="${emul}64"+ ;;+ esac+ case `$FILECMD conftest.$ac_objext` in+ *MSB*)+ emul="${emul}btsmip"+ ;;+ *LSB*)+ emul="${emul}ltsmip"+ ;;+ esac+ case `$FILECMD conftest.$ac_objext` in+ *N32*)+ emul="${emul}n32"+ ;;+ esac+ LD="${LD-ld} -m $emul"+ fi+ rm -rf conftest*+ ;;++x86_64-*kfreebsd*-gnu|x86_64-*linux*|powerpc*-*linux*| \+s390*-*linux*|s390*-*tpf*|sparc*-*linux*)+ # Find out what ABI is being produced by ac_compile, and set linker+ # options accordingly. Note that the listed cases only cover the+ # situations where additional linker options are needed (such as when+ # doing 32-bit compilation for a host where ld defaults to 64-bit, or+ # vice versa); the common cases where no linker options are needed do+ # not appear in the list.+ echo 'int i;' > conftest.$ac_ext+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5+ (eval $ac_compile) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }; then+ case `$FILECMD conftest.o` in+ *32-bit*)+ case $host in+ x86_64-*kfreebsd*-gnu)+ LD="${LD-ld} -m elf_i386_fbsd"+ ;;+ x86_64-*linux*)+ case `$FILECMD conftest.o` in+ *x86-64*)+ LD="${LD-ld} -m elf32_x86_64"+ ;;+ *)+ LD="${LD-ld} -m elf_i386"+ ;;+ esac+ ;;+ powerpc64le-*linux*)+ LD="${LD-ld} -m elf32lppclinux"+ ;;+ powerpc64-*linux*)+ LD="${LD-ld} -m elf32ppclinux"+ ;;+ s390x-*linux*)+ LD="${LD-ld} -m elf_s390"+ ;;+ sparc64-*linux*)+ LD="${LD-ld} -m elf32_sparc"+ ;;+ esac+ ;;+ *64-bit*)+ case $host in+ x86_64-*kfreebsd*-gnu)+ LD="${LD-ld} -m elf_x86_64_fbsd"+ ;;+ x86_64-*linux*)+ LD="${LD-ld} -m elf_x86_64"+ ;;+ powerpcle-*linux*)+ LD="${LD-ld} -m elf64lppc"+ ;;+ powerpc-*linux*)+ LD="${LD-ld} -m elf64ppc"+ ;;+ s390*-*linux*|s390*-*tpf*)+ LD="${LD-ld} -m elf64_s390"+ ;;+ sparc*-*linux*)+ LD="${LD-ld} -m elf64_sparc"+ ;;+ esac+ ;;+ esac+ fi+ rm -rf conftest*+ ;;++*-*-sco3.2v5*)+ # On SCO OpenServer 5, we need -belf to get full-featured binaries.+ SAVE_CFLAGS=$CFLAGS+ CFLAGS="$CFLAGS -belf"+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5+printf %s "checking whether the C compiler needs -belf... " >&6; }+if test ${lt_cv_cc_needs_belf+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu++ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ lt_cv_cc_needs_belf=yes+else case e in #(+ e) lt_cv_cc_needs_belf=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5+printf "%s\n" "$lt_cv_cc_needs_belf" >&6; }+ if test yes != "$lt_cv_cc_needs_belf"; then+ # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf+ CFLAGS=$SAVE_CFLAGS+ fi+ ;;+*-*solaris*)+ # Find out what ABI is being produced by ac_compile, and set linker+ # options accordingly.+ echo 'int i;' > conftest.$ac_ext+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5+ (eval $ac_compile) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }; then+ case `$FILECMD conftest.o` in+ *64-bit*)+ case $lt_cv_prog_gnu_ld in+ yes*)+ case $host in+ i?86-*-solaris*|x86_64-*-solaris*)+ LD="${LD-ld} -m elf_x86_64"+ ;;+ sparc*-*-solaris*)+ LD="${LD-ld} -m elf64_sparc"+ ;;+ esac+ # GNU ld 2.21 introduced _sol2 emulations. Use them if available.+ if ${LD-ld} -V | grep _sol2 >/dev/null 2>&1; then+ LD=${LD-ld}_sol2+ fi+ ;;+ *)+ if ${LD-ld} -64 -r -o conftest2.o conftest.o >/dev/null 2>&1; then+ LD="${LD-ld} -64"+ fi+ ;;+ esac+ ;;+ esac+ fi+ rm -rf conftest*+ ;;+esac++need_locks=$enable_libtool_lock++if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}mt", so it can be a program name with args.+set dummy ${ac_tool_prefix}mt; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_MANIFEST_TOOL+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$MANIFEST_TOOL"; then+ ac_cv_prog_MANIFEST_TOOL="$MANIFEST_TOOL" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_MANIFEST_TOOL="${ac_tool_prefix}mt"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+MANIFEST_TOOL=$ac_cv_prog_MANIFEST_TOOL+if test -n "$MANIFEST_TOOL"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MANIFEST_TOOL" >&5+printf "%s\n" "$MANIFEST_TOOL" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_MANIFEST_TOOL"; then+ ac_ct_MANIFEST_TOOL=$MANIFEST_TOOL+ # Extract the first word of "mt", so it can be a program name with args.+set dummy mt; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_MANIFEST_TOOL+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_MANIFEST_TOOL"; then+ ac_cv_prog_ac_ct_MANIFEST_TOOL="$ac_ct_MANIFEST_TOOL" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_MANIFEST_TOOL="mt"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_MANIFEST_TOOL=$ac_cv_prog_ac_ct_MANIFEST_TOOL+if test -n "$ac_ct_MANIFEST_TOOL"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_MANIFEST_TOOL" >&5+printf "%s\n" "$ac_ct_MANIFEST_TOOL" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_MANIFEST_TOOL" = x; then+ MANIFEST_TOOL=":"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ MANIFEST_TOOL=$ac_ct_MANIFEST_TOOL+ fi+else+ MANIFEST_TOOL="$ac_cv_prog_MANIFEST_TOOL"+fi++test -z "$MANIFEST_TOOL" && MANIFEST_TOOL=mt+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $MANIFEST_TOOL is a manifest tool" >&5+printf %s "checking if $MANIFEST_TOOL is a manifest tool... " >&6; }+if test ${lt_cv_path_mainfest_tool+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_path_mainfest_tool=no+ echo "$as_me:$LINENO: $MANIFEST_TOOL '-?'" >&5+ $MANIFEST_TOOL '-?' 2>conftest.err > conftest.out+ cat conftest.err >&5+ if $GREP 'Manifest Tool' conftest.out > /dev/null; then+ lt_cv_path_mainfest_tool=yes+ fi+ rm -f conftest* ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_mainfest_tool" >&5+printf "%s\n" "$lt_cv_path_mainfest_tool" >&6; }+if test yes != "$lt_cv_path_mainfest_tool"; then+ MANIFEST_TOOL=:+fi+++++++ case $host_os in+ rhapsody* | darwin*)+ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}dsymutil", so it can be a program name with args.+set dummy ${ac_tool_prefix}dsymutil; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_DSYMUTIL+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$DSYMUTIL"; then+ ac_cv_prog_DSYMUTIL="$DSYMUTIL" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_DSYMUTIL="${ac_tool_prefix}dsymutil"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+DSYMUTIL=$ac_cv_prog_DSYMUTIL+if test -n "$DSYMUTIL"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DSYMUTIL" >&5+printf "%s\n" "$DSYMUTIL" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_DSYMUTIL"; then+ ac_ct_DSYMUTIL=$DSYMUTIL+ # Extract the first word of "dsymutil", so it can be a program name with args.+set dummy dsymutil; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_DSYMUTIL+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_DSYMUTIL"; then+ ac_cv_prog_ac_ct_DSYMUTIL="$ac_ct_DSYMUTIL" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_DSYMUTIL="dsymutil"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_DSYMUTIL=$ac_cv_prog_ac_ct_DSYMUTIL+if test -n "$ac_ct_DSYMUTIL"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DSYMUTIL" >&5+printf "%s\n" "$ac_ct_DSYMUTIL" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_DSYMUTIL" = x; then+ DSYMUTIL=":"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ DSYMUTIL=$ac_ct_DSYMUTIL+ fi+else+ DSYMUTIL="$ac_cv_prog_DSYMUTIL"+fi++ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}nmedit", so it can be a program name with args.+set dummy ${ac_tool_prefix}nmedit; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_NMEDIT+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$NMEDIT"; then+ ac_cv_prog_NMEDIT="$NMEDIT" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_NMEDIT="${ac_tool_prefix}nmedit"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+NMEDIT=$ac_cv_prog_NMEDIT+if test -n "$NMEDIT"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $NMEDIT" >&5+printf "%s\n" "$NMEDIT" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_NMEDIT"; then+ ac_ct_NMEDIT=$NMEDIT+ # Extract the first word of "nmedit", so it can be a program name with args.+set dummy nmedit; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_NMEDIT+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_NMEDIT"; then+ ac_cv_prog_ac_ct_NMEDIT="$ac_ct_NMEDIT" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_NMEDIT="nmedit"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_NMEDIT=$ac_cv_prog_ac_ct_NMEDIT+if test -n "$ac_ct_NMEDIT"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_NMEDIT" >&5+printf "%s\n" "$ac_ct_NMEDIT" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_NMEDIT" = x; then+ NMEDIT=":"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ NMEDIT=$ac_ct_NMEDIT+ fi+else+ NMEDIT="$ac_cv_prog_NMEDIT"+fi++ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}lipo", so it can be a program name with args.+set dummy ${ac_tool_prefix}lipo; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_LIPO+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$LIPO"; then+ ac_cv_prog_LIPO="$LIPO" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_LIPO="${ac_tool_prefix}lipo"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+LIPO=$ac_cv_prog_LIPO+if test -n "$LIPO"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIPO" >&5+printf "%s\n" "$LIPO" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_LIPO"; then+ ac_ct_LIPO=$LIPO+ # Extract the first word of "lipo", so it can be a program name with args.+set dummy lipo; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_LIPO+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_LIPO"; then+ ac_cv_prog_ac_ct_LIPO="$ac_ct_LIPO" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_LIPO="lipo"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_LIPO=$ac_cv_prog_ac_ct_LIPO+if test -n "$ac_ct_LIPO"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_LIPO" >&5+printf "%s\n" "$ac_ct_LIPO" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_LIPO" = x; then+ LIPO=":"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ LIPO=$ac_ct_LIPO+ fi+else+ LIPO="$ac_cv_prog_LIPO"+fi++ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}otool", so it can be a program name with args.+set dummy ${ac_tool_prefix}otool; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_OTOOL+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$OTOOL"; then+ ac_cv_prog_OTOOL="$OTOOL" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_OTOOL="${ac_tool_prefix}otool"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+OTOOL=$ac_cv_prog_OTOOL+if test -n "$OTOOL"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL" >&5+printf "%s\n" "$OTOOL" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_OTOOL"; then+ ac_ct_OTOOL=$OTOOL+ # Extract the first word of "otool", so it can be a program name with args.+set dummy otool; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_OTOOL+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_OTOOL"; then+ ac_cv_prog_ac_ct_OTOOL="$ac_ct_OTOOL" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_OTOOL="otool"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_OTOOL=$ac_cv_prog_ac_ct_OTOOL+if test -n "$ac_ct_OTOOL"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL" >&5+printf "%s\n" "$ac_ct_OTOOL" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_OTOOL" = x; then+ OTOOL=":"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ OTOOL=$ac_ct_OTOOL+ fi+else+ OTOOL="$ac_cv_prog_OTOOL"+fi++ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}otool64", so it can be a program name with args.+set dummy ${ac_tool_prefix}otool64; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_OTOOL64+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$OTOOL64"; then+ ac_cv_prog_OTOOL64="$OTOOL64" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_OTOOL64="${ac_tool_prefix}otool64"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+OTOOL64=$ac_cv_prog_OTOOL64+if test -n "$OTOOL64"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OTOOL64" >&5+printf "%s\n" "$OTOOL64" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_OTOOL64"; then+ ac_ct_OTOOL64=$OTOOL64+ # Extract the first word of "otool64", so it can be a program name with args.+set dummy otool64; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_OTOOL64+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_OTOOL64"; then+ ac_cv_prog_ac_ct_OTOOL64="$ac_ct_OTOOL64" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_OTOOL64="otool64"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_OTOOL64=$ac_cv_prog_ac_ct_OTOOL64+if test -n "$ac_ct_OTOOL64"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OTOOL64" >&5+printf "%s\n" "$ac_ct_OTOOL64" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_OTOOL64" = x; then+ OTOOL64=":"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ OTOOL64=$ac_ct_OTOOL64+ fi+else+ OTOOL64="$ac_cv_prog_OTOOL64"+fi++++++++++++++++++++++++++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -single_module linker flag" >&5+printf %s "checking for -single_module linker flag... " >&6; }+if test ${lt_cv_apple_cc_single_mod+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_apple_cc_single_mod=no+ if test -z "$LT_MULTI_MODULE"; then+ # By default we will add the -single_module flag. You can override+ # by either setting the environment variable LT_MULTI_MODULE+ # non-empty at configure time, or by adding -multi_module to the+ # link flags.+ rm -rf libconftest.dylib*+ echo "int foo(void){return 1;}" > conftest.c+ echo "$LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \+-dynamiclib -Wl,-single_module conftest.c" >&5+ $LTCC $LTCFLAGS $LDFLAGS -o libconftest.dylib \+ -dynamiclib -Wl,-single_module conftest.c 2>conftest.err+ _lt_result=$?+ # If there is a non-empty error log, and "single_module"+ # appears in it, assume the flag caused a linker warning+ if test -s conftest.err && $GREP single_module conftest.err; then+ cat conftest.err >&5+ # Otherwise, if the output was created with a 0 exit code from+ # the compiler, it worked.+ elif test -f libconftest.dylib && test 0 = "$_lt_result"; then+ lt_cv_apple_cc_single_mod=yes+ else+ cat conftest.err >&5+ fi+ rm -rf libconftest.dylib*+ rm -f conftest.*+ fi ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_apple_cc_single_mod" >&5+printf "%s\n" "$lt_cv_apple_cc_single_mod" >&6; }++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -exported_symbols_list linker flag" >&5+printf %s "checking for -exported_symbols_list linker flag... " >&6; }+if test ${lt_cv_ld_exported_symbols_list+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_ld_exported_symbols_list=no+ save_LDFLAGS=$LDFLAGS+ echo "_main" > conftest.sym+ LDFLAGS="$LDFLAGS -Wl,-exported_symbols_list,conftest.sym"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ lt_cv_ld_exported_symbols_list=yes+else case e in #(+ e) lt_cv_ld_exported_symbols_list=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ LDFLAGS=$save_LDFLAGS+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_exported_symbols_list" >&5+printf "%s\n" "$lt_cv_ld_exported_symbols_list" >&6; }++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for -force_load linker flag" >&5+printf %s "checking for -force_load linker flag... " >&6; }+if test ${lt_cv_ld_force_load+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_ld_force_load=no+ cat > conftest.c << _LT_EOF+int forced_loaded() { return 2;}+_LT_EOF+ echo "$LTCC $LTCFLAGS -c -o conftest.o conftest.c" >&5+ $LTCC $LTCFLAGS -c -o conftest.o conftest.c 2>&5+ echo "$AR $AR_FLAGS libconftest.a conftest.o" >&5+ $AR $AR_FLAGS libconftest.a conftest.o 2>&5+ echo "$RANLIB libconftest.a" >&5+ $RANLIB libconftest.a 2>&5+ cat > conftest.c << _LT_EOF+int main() { return 0;}+_LT_EOF+ echo "$LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a" >&5+ $LTCC $LTCFLAGS $LDFLAGS -o conftest conftest.c -Wl,-force_load,./libconftest.a 2>conftest.err+ _lt_result=$?+ if test -s conftest.err && $GREP force_load conftest.err; then+ cat conftest.err >&5+ elif test -f conftest && test 0 = "$_lt_result" && $GREP forced_load conftest >/dev/null 2>&1; then+ lt_cv_ld_force_load=yes+ else+ cat conftest.err >&5+ fi+ rm -f conftest.err libconftest.a conftest conftest.c+ rm -rf conftest.dSYM+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_force_load" >&5+printf "%s\n" "$lt_cv_ld_force_load" >&6; }+ case $host_os in+ rhapsody* | darwin1.[012])+ _lt_dar_allow_undefined='$wl-undefined ${wl}suppress' ;;+ darwin1.*)+ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;+ darwin*)+ case $MACOSX_DEPLOYMENT_TARGET,$host in+ 10.[012],*|,*powerpc*-darwin[5-8]*)+ _lt_dar_allow_undefined='$wl-flat_namespace $wl-undefined ${wl}suppress' ;;+ *)+ _lt_dar_allow_undefined='$wl-undefined ${wl}dynamic_lookup' ;;+ esac+ ;;+ esac+ if test yes = "$lt_cv_apple_cc_single_mod"; then+ _lt_dar_single_mod='$single_module'+ fi+ if test yes = "$lt_cv_ld_exported_symbols_list"; then+ _lt_dar_export_syms=' $wl-exported_symbols_list,$output_objdir/$libname-symbols.expsym'+ else+ _lt_dar_export_syms='~$NMEDIT -s $output_objdir/$libname-symbols.expsym $lib'+ fi+ if test : != "$DSYMUTIL" && test no = "$lt_cv_ld_force_load"; then+ _lt_dsymutil='~$DSYMUTIL $lib || :'+ else+ _lt_dsymutil=+ fi+ ;;+ esac++# func_munge_path_list VARIABLE PATH+# -----------------------------------+# VARIABLE is name of variable containing _space_ separated list of+# directories to be munged by the contents of PATH, which is string+# having a format:+# "DIR[:DIR]:"+# string "DIR[ DIR]" will be prepended to VARIABLE+# ":DIR[:DIR]"+# string "DIR[ DIR]" will be appended to VARIABLE+# "DIRP[:DIRP]::[DIRA:]DIRA"+# string "DIRP[ DIRP]" will be prepended to VARIABLE and string+# "DIRA[ DIRA]" will be appended to VARIABLE+# "DIR[:DIR]"+# VARIABLE will be replaced by "DIR[ DIR]"+func_munge_path_list ()+{+ case x$2 in+ x)+ ;;+ *:)+ eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"+ ;;+ x:*)+ eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"+ ;;+ *::*)+ eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"+ eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"+ ;;+ *)+ eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"+ ;;+ esac+}++ac_fn_c_check_header_compile "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default+"+if test "x$ac_cv_header_dlfcn_h" = xyes+then :+ printf "%s\n" "#define HAVE_DLFCN_H 1" >>confdefs.h++fi++++++# Set options+enable_win32_dll=yes++case $host in+*-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-cegcc*)+ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args.+set dummy ${ac_tool_prefix}as; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_AS+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$AS"; then+ ac_cv_prog_AS="$AS" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_AS="${ac_tool_prefix}as"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+AS=$ac_cv_prog_AS+if test -n "$AS"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $AS" >&5+printf "%s\n" "$AS" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_AS"; then+ ac_ct_AS=$AS+ # Extract the first word of "as", so it can be a program name with args.+set dummy as; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_AS+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_AS"; then+ ac_cv_prog_ac_ct_AS="$ac_ct_AS" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_AS="as"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_AS=$ac_cv_prog_ac_ct_AS+if test -n "$ac_ct_AS"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AS" >&5+printf "%s\n" "$ac_ct_AS" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_AS" = x; then+ AS="false"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ AS=$ac_ct_AS+ fi+else+ AS="$ac_cv_prog_AS"+fi++ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args.+set dummy ${ac_tool_prefix}dlltool; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_DLLTOOL+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$DLLTOOL"; then+ ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+DLLTOOL=$ac_cv_prog_DLLTOOL+if test -n "$DLLTOOL"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $DLLTOOL" >&5+printf "%s\n" "$DLLTOOL" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_DLLTOOL"; then+ ac_ct_DLLTOOL=$DLLTOOL+ # Extract the first word of "dlltool", so it can be a program name with args.+set dummy dlltool; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_DLLTOOL+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_DLLTOOL"; then+ ac_cv_prog_ac_ct_DLLTOOL="$ac_ct_DLLTOOL" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_DLLTOOL="dlltool"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_DLLTOOL=$ac_cv_prog_ac_ct_DLLTOOL+if test -n "$ac_ct_DLLTOOL"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_DLLTOOL" >&5+printf "%s\n" "$ac_ct_DLLTOOL" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_DLLTOOL" = x; then+ DLLTOOL="false"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ DLLTOOL=$ac_ct_DLLTOOL+ fi+else+ DLLTOOL="$ac_cv_prog_DLLTOOL"+fi++ if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}objdump", so it can be a program name with args.+set dummy ${ac_tool_prefix}objdump; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_OBJDUMP+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$OBJDUMP"; then+ ac_cv_prog_OBJDUMP="$OBJDUMP" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_OBJDUMP="${ac_tool_prefix}objdump"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+OBJDUMP=$ac_cv_prog_OBJDUMP+if test -n "$OBJDUMP"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $OBJDUMP" >&5+printf "%s\n" "$OBJDUMP" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_OBJDUMP"; then+ ac_ct_OBJDUMP=$OBJDUMP+ # Extract the first word of "objdump", so it can be a program name with args.+set dummy objdump; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_OBJDUMP+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_OBJDUMP"; then+ ac_cv_prog_ac_ct_OBJDUMP="$ac_ct_OBJDUMP" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_OBJDUMP="objdump"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_OBJDUMP=$ac_cv_prog_ac_ct_OBJDUMP+if test -n "$ac_ct_OBJDUMP"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_OBJDUMP" >&5+printf "%s\n" "$ac_ct_OBJDUMP" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_OBJDUMP" = x; then+ OBJDUMP="false"+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ OBJDUMP=$ac_ct_OBJDUMP+ fi+else+ OBJDUMP="$ac_cv_prog_OBJDUMP"+fi++ ;;+esac++test -z "$AS" && AS=as++++++test -z "$DLLTOOL" && DLLTOOL=dlltool++++++test -z "$OBJDUMP" && OBJDUMP=objdump++++++++ enable_dlopen=no++++ # Check whether --enable-shared was given.+if test ${enable_shared+y}+then :+ enableval=$enable_shared; p=${PACKAGE-default}+ case $enableval in+ yes) enable_shared=yes ;;+ no) enable_shared=no ;;+ *)+ enable_shared=no+ # Look at the argument we got. We use all the common list separators.+ lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,+ for pkg in $enableval; do+ IFS=$lt_save_ifs+ if test "X$pkg" = "X$p"; then+ enable_shared=yes+ fi+ done+ IFS=$lt_save_ifs+ ;;+ esac+else case e in #(+ e) enable_shared=yes ;;+esac+fi++++++++++ # Check whether --enable-static was given.+if test ${enable_static+y}+then :+ enableval=$enable_static; p=${PACKAGE-default}+ case $enableval in+ yes) enable_static=yes ;;+ no) enable_static=no ;;+ *)+ enable_static=no+ # Look at the argument we got. We use all the common list separators.+ lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,+ for pkg in $enableval; do+ IFS=$lt_save_ifs+ if test "X$pkg" = "X$p"; then+ enable_static=yes+ fi+ done+ IFS=$lt_save_ifs+ ;;+ esac+else case e in #(+ e) enable_static=yes ;;+esac+fi+++++++++++# Check whether --with-pic was given.+if test ${with_pic+y}+then :+ withval=$with_pic; lt_p=${PACKAGE-default}+ case $withval in+ yes|no) pic_mode=$withval ;;+ *)+ pic_mode=default+ # Look at the argument we got. We use all the common list separators.+ lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,+ for lt_pkg in $withval; do+ IFS=$lt_save_ifs+ if test "X$lt_pkg" = "X$lt_p"; then+ pic_mode=yes+ fi+ done+ IFS=$lt_save_ifs+ ;;+ esac+else case e in #(+ e) pic_mode=default ;;+esac+fi+++++++++ # Check whether --enable-fast-install was given.+if test ${enable_fast_install+y}+then :+ enableval=$enable_fast_install; p=${PACKAGE-default}+ case $enableval in+ yes) enable_fast_install=yes ;;+ no) enable_fast_install=no ;;+ *)+ enable_fast_install=no+ # Look at the argument we got. We use all the common list separators.+ lt_save_ifs=$IFS; IFS=$IFS$PATH_SEPARATOR,+ for pkg in $enableval; do+ IFS=$lt_save_ifs+ if test "X$pkg" = "X$p"; then+ enable_fast_install=yes+ fi+ done+ IFS=$lt_save_ifs+ ;;+ esac+else case e in #(+ e) enable_fast_install=yes ;;+esac+fi+++++++++ shared_archive_member_spec=+case $host,$enable_shared in+power*-*-aix[5-9]*,yes)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking which variant of shared library versioning to provide" >&5+printf %s "checking which variant of shared library versioning to provide... " >&6; }++# Check whether --with-aix-soname was given.+if test ${with_aix_soname+y}+then :+ withval=$with_aix_soname; case $withval in+ aix|svr4|both)+ ;;+ *)+ as_fn_error $? "Unknown argument to --with-aix-soname" "$LINENO" 5+ ;;+ esac+ lt_cv_with_aix_soname=$with_aix_soname+else case e in #(+ e) if test ${lt_cv_with_aix_soname+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_with_aix_soname=aix ;;+esac+fi++ with_aix_soname=$lt_cv_with_aix_soname ;;+esac+fi++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $with_aix_soname" >&5+printf "%s\n" "$with_aix_soname" >&6; }+ if test aix != "$with_aix_soname"; then+ # For the AIX way of multilib, we name the shared archive member+ # based on the bitwidth used, traditionally 'shr.o' or 'shr_64.o',+ # and 'shr.imp' or 'shr_64.imp', respectively, for the Import File.+ # Even when GNU compilers ignore OBJECT_MODE but need '-maix64' flag,+ # the AIX toolchain works better with OBJECT_MODE set (default 32).+ if test 64 = "${OBJECT_MODE-32}"; then+ shared_archive_member_spec=shr_64+ else+ shared_archive_member_spec=shr+ fi+ fi+ ;;+*)+ with_aix_soname=aix+ ;;+esac+++++++++++# This can be used to rebuild libtool when needed+LIBTOOL_DEPS=$ltmain++# Always use our own libtool.+LIBTOOL='$(SHELL) $(top_builddir)/libtool'+++++++++++++++++++++++++++++++test -z "$LN_S" && LN_S="ln -s"+++++++++++++++if test -n "${ZSH_VERSION+set}"; then+ setopt NO_GLOB_SUBST+fi++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5+printf %s "checking for objdir... " >&6; }+if test ${lt_cv_objdir+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) rm -f .libs 2>/dev/null+mkdir .libs 2>/dev/null+if test -d .libs; then+ lt_cv_objdir=.libs+else+ # MS-DOS does not allow filenames that begin with a dot.+ lt_cv_objdir=_libs+fi+rmdir .libs 2>/dev/null ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5+printf "%s\n" "$lt_cv_objdir" >&6; }+objdir=$lt_cv_objdir++++++printf "%s\n" "#define LT_OBJDIR \"$lt_cv_objdir/\"" >>confdefs.h+++++case $host_os in+aix3*)+ # AIX sometimes has problems with the GCC collect2 program. For some+ # reason, if we set the COLLECT_NAMES environment variable, the problems+ # vanish in a puff of smoke.+ if test set != "${COLLECT_NAMES+set}"; then+ COLLECT_NAMES=+ export COLLECT_NAMES+ fi+ ;;+esac++# Global variables:+ofile=libtool+can_build_shared=yes++# All known linkers require a '.a' archive for static linking (except MSVC and+# ICC, which need '.lib').+libext=a++with_gnu_ld=$lt_cv_prog_gnu_ld++old_CC=$CC+old_CFLAGS=$CFLAGS++# Set sane defaults for various variables+test -z "$CC" && CC=cc+test -z "$LTCC" && LTCC=$CC+test -z "$LTCFLAGS" && LTCFLAGS=$CFLAGS+test -z "$LD" && LD=ld+test -z "$ac_objext" && ac_objext=o++func_cc_basename $compiler+cc_basename=$func_cc_basename_result+++# Only perform the check for file, if the check method requires it+test -z "$MAGIC_CMD" && MAGIC_CMD=file+case $deplibs_check_method in+file_magic*)+ if test "$file_magic_cmd" = '$MAGIC_CMD'; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5+printf %s "checking for ${ac_tool_prefix}file... " >&6; }+if test ${lt_cv_path_MAGIC_CMD+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) case $MAGIC_CMD in+[\\/*] | ?:[\\/]*)+ lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.+ ;;+*)+ lt_save_MAGIC_CMD=$MAGIC_CMD+ lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"+ for ac_dir in $ac_dummy; do+ IFS=$lt_save_ifs+ test -z "$ac_dir" && ac_dir=.+ if test -f "$ac_dir/${ac_tool_prefix}file"; then+ lt_cv_path_MAGIC_CMD=$ac_dir/"${ac_tool_prefix}file"+ if test -n "$file_magic_test_file"; then+ case $deplibs_check_method in+ "file_magic "*)+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`+ MAGIC_CMD=$lt_cv_path_MAGIC_CMD+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |+ $EGREP "$file_magic_regex" > /dev/null; then+ :+ else+ cat <<_LT_EOF 1>&2++*** Warning: the command libtool uses to detect shared libraries,+*** $file_magic_cmd, produces output that libtool cannot recognize.+*** The result is that libtool may fail to recognize shared libraries+*** as such. This will affect the creation of libtool libraries that+*** depend on shared libraries, but programs linked with such libtool+*** libraries will work regardless of this problem. Nevertheless, you+*** may want to report the problem to your system manager and/or to+*** bug-libtool@gnu.org++_LT_EOF+ fi ;;+ esac+ fi+ break+ fi+ done+ IFS=$lt_save_ifs+ MAGIC_CMD=$lt_save_MAGIC_CMD+ ;;+esac ;;+esac+fi++MAGIC_CMD=$lt_cv_path_MAGIC_CMD+if test -n "$MAGIC_CMD"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5+printf "%s\n" "$MAGIC_CMD" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++++++if test -z "$lt_cv_path_MAGIC_CMD"; then+ if test -n "$ac_tool_prefix"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for file" >&5+printf %s "checking for file... " >&6; }+if test ${lt_cv_path_MAGIC_CMD+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) case $MAGIC_CMD in+[\\/*] | ?:[\\/]*)+ lt_cv_path_MAGIC_CMD=$MAGIC_CMD # Let the user override the test with a path.+ ;;+*)+ lt_save_MAGIC_CMD=$MAGIC_CMD+ lt_save_ifs=$IFS; IFS=$PATH_SEPARATOR+ ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"+ for ac_dir in $ac_dummy; do+ IFS=$lt_save_ifs+ test -z "$ac_dir" && ac_dir=.+ if test -f "$ac_dir/file"; then+ lt_cv_path_MAGIC_CMD=$ac_dir/"file"+ if test -n "$file_magic_test_file"; then+ case $deplibs_check_method in+ "file_magic "*)+ file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`+ MAGIC_CMD=$lt_cv_path_MAGIC_CMD+ if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |+ $EGREP "$file_magic_regex" > /dev/null; then+ :+ else+ cat <<_LT_EOF 1>&2++*** Warning: the command libtool uses to detect shared libraries,+*** $file_magic_cmd, produces output that libtool cannot recognize.+*** The result is that libtool may fail to recognize shared libraries+*** as such. This will affect the creation of libtool libraries that+*** depend on shared libraries, but programs linked with such libtool+*** libraries will work regardless of this problem. Nevertheless, you+*** may want to report the problem to your system manager and/or to+*** bug-libtool@gnu.org++_LT_EOF+ fi ;;+ esac+ fi+ break+ fi+ done+ IFS=$lt_save_ifs+ MAGIC_CMD=$lt_save_MAGIC_CMD+ ;;+esac ;;+esac+fi++MAGIC_CMD=$lt_cv_path_MAGIC_CMD+if test -n "$MAGIC_CMD"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5+printf "%s\n" "$MAGIC_CMD" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ else+ MAGIC_CMD=:+ fi+fi++ fi+ ;;+esac++# Use C for the default configuration in the libtool script++lt_save_CC=$CC+ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu+++# Source file extension for C test sources.+ac_ext=c++# Object file extension for compiled C test sources.+objext=o+objext=$objext++# Code to be used in simple compile tests+lt_simple_compile_test_code="int some_variable = 0;"++# Code to be used in simple link tests+lt_simple_link_test_code='int main(){return(0);}'++++++++# If no C compiler was specified, use CC.+LTCC=${LTCC-"$CC"}++# If no C compiler flags were specified, use CFLAGS.+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}++# Allow CC to be a program name with arguments.+compiler=$CC++# Save the default compiler, since it gets overwritten when the other+# tags are being tested, and _LT_TAGVAR(compiler, []) is a NOP.+compiler_DEFAULT=$CC++# save warnings/boilerplate of simple test code+ac_outfile=conftest.$ac_objext+echo "$lt_simple_compile_test_code" >conftest.$ac_ext+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err+_lt_compiler_boilerplate=`cat conftest.err`+$RM conftest*++ac_outfile=conftest.$ac_objext+echo "$lt_simple_link_test_code" >conftest.$ac_ext+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err+_lt_linker_boilerplate=`cat conftest.err`+$RM -r conftest*+++## CAVEAT EMPTOR:+## There is no encapsulation within the following macros, do not change+## the running order or otherwise move them around unless you know exactly+## what you are doing...+if test -n "$compiler"; then++lt_prog_compiler_no_builtin_flag=++if test yes = "$GCC"; then+ case $cc_basename in+ nvcc*)+ lt_prog_compiler_no_builtin_flag=' -Xcompiler -fno-builtin' ;;+ *)+ lt_prog_compiler_no_builtin_flag=' -fno-builtin' ;;+ esac++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5+printf %s "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }+if test ${lt_cv_prog_compiler_rtti_exceptions+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_prog_compiler_rtti_exceptions=no+ ac_outfile=conftest.$ac_objext+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext+ lt_compiler_flag="-fno-rtti -fno-exceptions" ## exclude from sc_useless_quotes_in_assignment+ # Insert the option either (1) after the last *FLAGS variable, or+ # (2) before a word containing "conftest.", or (3) at the end.+ # Note that $ac_compile itself does not contain backslashes and begins+ # with a dollar sign (not a hyphen), so the echo should work correctly.+ # The option is referenced via a variable to avoid confusing sed.+ lt_compile=`echo "$ac_compile" | $SED \+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \+ -e 's:$: $lt_compiler_flag:'`+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)+ (eval "$lt_compile" 2>conftest.err)+ ac_status=$?+ cat conftest.err >&5+ echo "$as_me:$LINENO: \$? = $ac_status" >&5+ if (exit $ac_status) && test -s "$ac_outfile"; then+ # The compiler can only warn and ignore the option if not recognized+ # So say no if there are warnings other than the usual output.+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then+ lt_cv_prog_compiler_rtti_exceptions=yes+ fi+ fi+ $RM conftest*+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5+printf "%s\n" "$lt_cv_prog_compiler_rtti_exceptions" >&6; }++if test yes = "$lt_cv_prog_compiler_rtti_exceptions"; then+ lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"+else+ :+fi++fi+++++++ lt_prog_compiler_wl=+lt_prog_compiler_pic=+lt_prog_compiler_static=+++ if test yes = "$GCC"; then+ lt_prog_compiler_wl='-Wl,'+ lt_prog_compiler_static='-static'++ case $host_os in+ aix*)+ # All AIX code is PIC.+ if test ia64 = "$host_cpu"; then+ # AIX 5 now supports IA64 processor+ lt_prog_compiler_static='-Bstatic'+ fi+ lt_prog_compiler_pic='-fPIC'+ ;;++ amigaos*)+ case $host_cpu in+ powerpc)+ # see comment about AmigaOS4 .so support+ lt_prog_compiler_pic='-fPIC'+ ;;+ m68k)+ # FIXME: we need at least 68020 code to build shared libraries, but+ # adding the '-m68020' flag to GCC prevents building anything better,+ # like '-m68040'.+ lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'+ ;;+ esac+ ;;++ beos* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)+ # PIC is the default for these OSes.+ ;;++ mingw* | cygwin* | pw32* | os2* | cegcc*)+ # This hack is so that the source file can tell whether it is being+ # built for inclusion in a dll (and should export symbols for example).+ # Although the cygwin gcc ignores -fPIC, still need this for old-style+ # (--disable-auto-import) libraries+ lt_prog_compiler_pic='-DDLL_EXPORT'+ case $host_os in+ os2*)+ lt_prog_compiler_static='$wl-static'+ ;;+ esac+ ;;++ darwin* | rhapsody*)+ # PIC is the default on this platform+ # Common symbols not allowed in MH_DYLIB files+ lt_prog_compiler_pic='-fno-common'+ ;;++ haiku*)+ # PIC is the default for Haiku.+ # The "-static" flag exists, but is broken.+ lt_prog_compiler_static=+ ;;++ hpux*)+ # PIC is the default for 64-bit PA HP-UX, but not for 32-bit+ # PA HP-UX. On IA64 HP-UX, PIC is the default but the pic flag+ # sets the default TLS model and affects inlining.+ case $host_cpu in+ hppa*64*)+ # +Z the default+ ;;+ *)+ lt_prog_compiler_pic='-fPIC'+ ;;+ esac+ ;;++ interix[3-9]*)+ # Interix 3.x gcc -fpic/-fPIC options generate broken code.+ # Instead, we relocate shared libraries at runtime.+ ;;++ msdosdjgpp*)+ # Just because we use GCC doesn't mean we suddenly get shared libraries+ # on systems that don't support them.+ lt_prog_compiler_can_build_shared=no+ enable_shared=no+ ;;++ *nto* | *qnx*)+ # QNX uses GNU C++, but need to define -shared option too, otherwise+ # it will coredump.+ lt_prog_compiler_pic='-fPIC -shared'+ ;;++ sysv4*MP*)+ if test -d /usr/nec; then+ lt_prog_compiler_pic=-Kconform_pic+ fi+ ;;++ *)+ lt_prog_compiler_pic='-fPIC'+ ;;+ esac++ case $cc_basename in+ nvcc*) # Cuda Compiler Driver 2.2+ lt_prog_compiler_wl='-Xlinker '+ if test -n "$lt_prog_compiler_pic"; then+ lt_prog_compiler_pic="-Xcompiler $lt_prog_compiler_pic"+ fi+ ;;+ esac+ else+ # PORTME Check for flag to pass linker flags through the system compiler.+ case $host_os in+ aix*)+ lt_prog_compiler_wl='-Wl,'+ if test ia64 = "$host_cpu"; then+ # AIX 5 now supports IA64 processor+ lt_prog_compiler_static='-Bstatic'+ else+ lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'+ fi+ ;;++ darwin* | rhapsody*)+ # PIC is the default on this platform+ # Common symbols not allowed in MH_DYLIB files+ lt_prog_compiler_pic='-fno-common'+ case $cc_basename in+ nagfor*)+ # NAG Fortran compiler+ lt_prog_compiler_wl='-Wl,-Wl,,'+ lt_prog_compiler_pic='-PIC'+ lt_prog_compiler_static='-Bstatic'+ ;;+ esac+ ;;++ mingw* | cygwin* | pw32* | os2* | cegcc*)+ # This hack is so that the source file can tell whether it is being+ # built for inclusion in a dll (and should export symbols for example).+ lt_prog_compiler_pic='-DDLL_EXPORT'+ case $host_os in+ os2*)+ lt_prog_compiler_static='$wl-static'+ ;;+ esac+ ;;++ hpux9* | hpux10* | hpux11*)+ lt_prog_compiler_wl='-Wl,'+ # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but+ # not for PA HP-UX.+ case $host_cpu in+ hppa*64*|ia64*)+ # +Z the default+ ;;+ *)+ lt_prog_compiler_pic='+Z'+ ;;+ esac+ # Is there a better lt_prog_compiler_static that works with the bundled CC?+ lt_prog_compiler_static='$wl-a ${wl}archive'+ ;;++ irix5* | irix6* | nonstopux*)+ lt_prog_compiler_wl='-Wl,'+ # PIC (with -KPIC) is the default.+ lt_prog_compiler_static='-non_shared'+ ;;++ linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)+ case $cc_basename in+ # old Intel for x86_64, which still supported -KPIC.+ ecc*)+ lt_prog_compiler_wl='-Wl,'+ lt_prog_compiler_pic='-KPIC'+ lt_prog_compiler_static='-static'+ ;;+ # icc used to be incompatible with GCC.+ # ICC 10 doesn't accept -KPIC any more.+ icc* | ifort*)+ lt_prog_compiler_wl='-Wl,'+ lt_prog_compiler_pic='-fPIC'+ lt_prog_compiler_static='-static'+ ;;+ # Lahey Fortran 8.1.+ lf95*)+ lt_prog_compiler_wl='-Wl,'+ lt_prog_compiler_pic='--shared'+ lt_prog_compiler_static='--static'+ ;;+ nagfor*)+ # NAG Fortran compiler+ lt_prog_compiler_wl='-Wl,-Wl,,'+ lt_prog_compiler_pic='-PIC'+ lt_prog_compiler_static='-Bstatic'+ ;;+ tcc*)+ # Fabrice Bellard et al's Tiny C Compiler+ lt_prog_compiler_wl='-Wl,'+ lt_prog_compiler_pic='-fPIC'+ lt_prog_compiler_static='-static'+ ;;+ pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)+ # Portland Group compilers (*not* the Pentium gcc compiler,+ # which looks to be a dead project)+ lt_prog_compiler_wl='-Wl,'+ lt_prog_compiler_pic='-fpic'+ lt_prog_compiler_static='-Bstatic'+ ;;+ ccc*)+ lt_prog_compiler_wl='-Wl,'+ # All Alpha code is PIC.+ lt_prog_compiler_static='-non_shared'+ ;;+ xl* | bgxl* | bgf* | mpixl*)+ # IBM XL C 8.0/Fortran 10.1, 11.1 on PPC and BlueGene+ lt_prog_compiler_wl='-Wl,'+ lt_prog_compiler_pic='-qpic'+ lt_prog_compiler_static='-qstaticlink'+ ;;+ *)+ case `$CC -V 2>&1 | $SED 5q` in+ *Sun\ Ceres\ Fortran* | *Sun*Fortran*\ [1-7].* | *Sun*Fortran*\ 8.[0-3]*)+ # Sun Fortran 8.3 passes all unrecognized flags to the linker+ lt_prog_compiler_pic='-KPIC'+ lt_prog_compiler_static='-Bstatic'+ lt_prog_compiler_wl=''+ ;;+ *Sun\ F* | *Sun*Fortran*)+ lt_prog_compiler_pic='-KPIC'+ lt_prog_compiler_static='-Bstatic'+ lt_prog_compiler_wl='-Qoption ld '+ ;;+ *Sun\ C*)+ # Sun C 5.9+ lt_prog_compiler_pic='-KPIC'+ lt_prog_compiler_static='-Bstatic'+ lt_prog_compiler_wl='-Wl,'+ ;;+ *Intel*\ [CF]*Compiler*)+ lt_prog_compiler_wl='-Wl,'+ lt_prog_compiler_pic='-fPIC'+ lt_prog_compiler_static='-static'+ ;;+ *Portland\ Group*)+ lt_prog_compiler_wl='-Wl,'+ lt_prog_compiler_pic='-fpic'+ lt_prog_compiler_static='-Bstatic'+ ;;+ esac+ ;;+ esac+ ;;++ newsos6)+ lt_prog_compiler_pic='-KPIC'+ lt_prog_compiler_static='-Bstatic'+ ;;++ *nto* | *qnx*)+ # QNX uses GNU C++, but need to define -shared option too, otherwise+ # it will coredump.+ lt_prog_compiler_pic='-fPIC -shared'+ ;;++ osf3* | osf4* | osf5*)+ lt_prog_compiler_wl='-Wl,'+ # All OSF/1 code is PIC.+ lt_prog_compiler_static='-non_shared'+ ;;++ rdos*)+ lt_prog_compiler_static='-non_shared'+ ;;++ solaris*)+ lt_prog_compiler_pic='-KPIC'+ lt_prog_compiler_static='-Bstatic'+ case $cc_basename in+ f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)+ lt_prog_compiler_wl='-Qoption ld ';;+ *)+ lt_prog_compiler_wl='-Wl,';;+ esac+ ;;++ sunos4*)+ lt_prog_compiler_wl='-Qoption ld '+ lt_prog_compiler_pic='-PIC'+ lt_prog_compiler_static='-Bstatic'+ ;;++ sysv4 | sysv4.2uw2* | sysv4.3*)+ lt_prog_compiler_wl='-Wl,'+ lt_prog_compiler_pic='-KPIC'+ lt_prog_compiler_static='-Bstatic'+ ;;++ sysv4*MP*)+ if test -d /usr/nec; then+ lt_prog_compiler_pic='-Kconform_pic'+ lt_prog_compiler_static='-Bstatic'+ fi+ ;;++ sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)+ lt_prog_compiler_wl='-Wl,'+ lt_prog_compiler_pic='-KPIC'+ lt_prog_compiler_static='-Bstatic'+ ;;++ unicos*)+ lt_prog_compiler_wl='-Wl,'+ lt_prog_compiler_can_build_shared=no+ ;;++ uts4*)+ lt_prog_compiler_pic='-pic'+ lt_prog_compiler_static='-Bstatic'+ ;;++ *)+ lt_prog_compiler_can_build_shared=no+ ;;+ esac+ fi++case $host_os in+ # For platforms that do not support PIC, -DPIC is meaningless:+ *djgpp*)+ lt_prog_compiler_pic=+ ;;+ *)+ lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"+ ;;+esac++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5+printf %s "checking for $compiler option to produce PIC... " >&6; }+if test ${lt_cv_prog_compiler_pic+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_prog_compiler_pic=$lt_prog_compiler_pic ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic" >&5+printf "%s\n" "$lt_cv_prog_compiler_pic" >&6; }+lt_prog_compiler_pic=$lt_cv_prog_compiler_pic++#+# Check to make sure the PIC flag actually works.+#+if test -n "$lt_prog_compiler_pic"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5+printf %s "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }+if test ${lt_cv_prog_compiler_pic_works+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_prog_compiler_pic_works=no+ ac_outfile=conftest.$ac_objext+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext+ lt_compiler_flag="$lt_prog_compiler_pic -DPIC" ## exclude from sc_useless_quotes_in_assignment+ # Insert the option either (1) after the last *FLAGS variable, or+ # (2) before a word containing "conftest.", or (3) at the end.+ # Note that $ac_compile itself does not contain backslashes and begins+ # with a dollar sign (not a hyphen), so the echo should work correctly.+ # The option is referenced via a variable to avoid confusing sed.+ lt_compile=`echo "$ac_compile" | $SED \+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \+ -e 's:$: $lt_compiler_flag:'`+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)+ (eval "$lt_compile" 2>conftest.err)+ ac_status=$?+ cat conftest.err >&5+ echo "$as_me:$LINENO: \$? = $ac_status" >&5+ if (exit $ac_status) && test -s "$ac_outfile"; then+ # The compiler can only warn and ignore the option if not recognized+ # So say no if there are warnings other than the usual output.+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' >conftest.exp+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2+ if test ! -s conftest.er2 || diff conftest.exp conftest.er2 >/dev/null; then+ lt_cv_prog_compiler_pic_works=yes+ fi+ fi+ $RM conftest*+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_pic_works" >&5+printf "%s\n" "$lt_cv_prog_compiler_pic_works" >&6; }++if test yes = "$lt_cv_prog_compiler_pic_works"; then+ case $lt_prog_compiler_pic in+ "" | " "*) ;;+ *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;+ esac+else+ lt_prog_compiler_pic=+ lt_prog_compiler_can_build_shared=no+fi++fi++++++++++++#+# Check to make sure the static flag actually works.+#+wl=$lt_prog_compiler_wl eval lt_tmp_static_flag=\"$lt_prog_compiler_static\"+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_tmp_static_flag works" >&5+printf %s "checking if $compiler static flag $lt_tmp_static_flag works... " >&6; }+if test ${lt_cv_prog_compiler_static_works+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_prog_compiler_static_works=no+ save_LDFLAGS=$LDFLAGS+ LDFLAGS="$LDFLAGS $lt_tmp_static_flag"+ echo "$lt_simple_link_test_code" > conftest.$ac_ext+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then+ # The linker can only warn and ignore the option if not recognized+ # So say no if there are warnings+ if test -s conftest.err; then+ # Append any errors to the config.log.+ cat conftest.err 1>&5+ $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2+ if diff conftest.exp conftest.er2 >/dev/null; then+ lt_cv_prog_compiler_static_works=yes+ fi+ else+ lt_cv_prog_compiler_static_works=yes+ fi+ fi+ $RM -r conftest*+ LDFLAGS=$save_LDFLAGS+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_static_works" >&5+printf "%s\n" "$lt_cv_prog_compiler_static_works" >&6; }++if test yes = "$lt_cv_prog_compiler_static_works"; then+ :+else+ lt_prog_compiler_static=+fi++++++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5+printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; }+if test ${lt_cv_prog_compiler_c_o+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_prog_compiler_c_o=no+ $RM -r conftest 2>/dev/null+ mkdir conftest+ cd conftest+ mkdir out+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext++ lt_compiler_flag="-o out/conftest2.$ac_objext"+ # Insert the option either (1) after the last *FLAGS variable, or+ # (2) before a word containing "conftest.", or (3) at the end.+ # Note that $ac_compile itself does not contain backslashes and begins+ # with a dollar sign (not a hyphen), so the echo should work correctly.+ lt_compile=`echo "$ac_compile" | $SED \+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \+ -e 's:$: $lt_compiler_flag:'`+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)+ (eval "$lt_compile" 2>out/conftest.err)+ ac_status=$?+ cat out/conftest.err >&5+ echo "$as_me:$LINENO: \$? = $ac_status" >&5+ if (exit $ac_status) && test -s out/conftest2.$ac_objext+ then+ # The compiler can only warn and ignore the option if not recognized+ # So say no if there are warnings+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then+ lt_cv_prog_compiler_c_o=yes+ fi+ fi+ chmod u+w . 2>&5+ $RM conftest*+ # SGI C++ compiler will create directory out/ii_files/ for+ # template instantiation+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files+ $RM out/* && rmdir out+ cd ..+ $RM -r conftest+ $RM conftest*+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5+printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; }+++++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5+printf %s "checking if $compiler supports -c -o file.$ac_objext... " >&6; }+if test ${lt_cv_prog_compiler_c_o+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_prog_compiler_c_o=no+ $RM -r conftest 2>/dev/null+ mkdir conftest+ cd conftest+ mkdir out+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext++ lt_compiler_flag="-o out/conftest2.$ac_objext"+ # Insert the option either (1) after the last *FLAGS variable, or+ # (2) before a word containing "conftest.", or (3) at the end.+ # Note that $ac_compile itself does not contain backslashes and begins+ # with a dollar sign (not a hyphen), so the echo should work correctly.+ lt_compile=`echo "$ac_compile" | $SED \+ -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \+ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \+ -e 's:$: $lt_compiler_flag:'`+ (eval echo "\"\$as_me:$LINENO: $lt_compile\"" >&5)+ (eval "$lt_compile" 2>out/conftest.err)+ ac_status=$?+ cat out/conftest.err >&5+ echo "$as_me:$LINENO: \$? = $ac_status" >&5+ if (exit $ac_status) && test -s out/conftest2.$ac_objext+ then+ # The compiler can only warn and ignore the option if not recognized+ # So say no if there are warnings+ $ECHO "$_lt_compiler_boilerplate" | $SED '/^$/d' > out/conftest.exp+ $SED '/^$/d; /^ *+/d' out/conftest.err >out/conftest.er2+ if test ! -s out/conftest.er2 || diff out/conftest.exp out/conftest.er2 >/dev/null; then+ lt_cv_prog_compiler_c_o=yes+ fi+ fi+ chmod u+w . 2>&5+ $RM conftest*+ # SGI C++ compiler will create directory out/ii_files/ for+ # template instantiation+ test -d out/ii_files && $RM out/ii_files/* && rmdir out/ii_files+ $RM out/* && rmdir out+ cd ..+ $RM -r conftest+ $RM conftest*+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5+printf "%s\n" "$lt_cv_prog_compiler_c_o" >&6; }+++++hard_links=nottested+if test no = "$lt_cv_prog_compiler_c_o" && test no != "$need_locks"; then+ # do not overwrite the value of need_locks provided by the user+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5+printf %s "checking if we can lock with hard links... " >&6; }+ hard_links=yes+ $RM conftest*+ ln conftest.a conftest.b 2>/dev/null && hard_links=no+ touch conftest.a+ ln conftest.a conftest.b 2>&5 || hard_links=no+ ln conftest.a conftest.b 2>/dev/null && hard_links=no+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5+printf "%s\n" "$hard_links" >&6; }+ if test no = "$hard_links"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&5+printf "%s\n" "$as_me: WARNING: '$CC' does not support '-c -o', so 'make -j' may be unsafe" >&2;}+ need_locks=warn+ fi+else+ need_locks=no+fi+++++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5+printf %s "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }++ runpath_var=+ allow_undefined_flag=+ always_export_symbols=no+ archive_cmds=+ archive_expsym_cmds=+ compiler_needs_object=no+ enable_shared_with_static_runtimes=no+ export_dynamic_flag_spec=+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'+ hardcode_automatic=no+ hardcode_direct=no+ hardcode_direct_absolute=no+ hardcode_libdir_flag_spec=+ hardcode_libdir_separator=+ hardcode_minus_L=no+ hardcode_shlibpath_var=unsupported+ inherit_rpath=no+ link_all_deplibs=unknown+ module_cmds=+ module_expsym_cmds=+ old_archive_from_new_cmds=+ old_archive_from_expsyms_cmds=+ thread_safe_flag_spec=+ whole_archive_flag_spec=+ # include_expsyms should be a list of space-separated symbols to be *always*+ # included in the symbol list+ include_expsyms=+ # exclude_expsyms can be an extended regexp of symbols to exclude+ # it will be wrapped by ' (' and ')$', so one must not match beginning or+ # end of line. Example: 'a|bc|.*d.*' will exclude the symbols 'a' and 'bc',+ # as well as any symbol that contains 'd'.+ exclude_expsyms='_GLOBAL_OFFSET_TABLE_|_GLOBAL__F[ID]_.*'+ # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out+ # platforms (ab)use it in PIC code, but their linkers get confused if+ # the symbol is explicitly referenced. Since portable code cannot+ # rely on this symbol name, it's probably fine to never include it in+ # preloaded symbol tables.+ # Exclude shared library initialization/finalization symbols.+ extract_expsyms_cmds=++ case $host_os in+ cygwin* | mingw* | pw32* | cegcc*)+ # FIXME: the MSVC++ and ICC port hasn't been tested in a loooong time+ # When not using gcc, we currently assume that we are using+ # Microsoft Visual C++ or Intel C++ Compiler.+ if test yes != "$GCC"; then+ with_gnu_ld=no+ fi+ ;;+ interix*)+ # we just hope/assume this is gcc and not c89 (= MSVC++ or ICC)+ with_gnu_ld=yes+ ;;+ openbsd* | bitrig*)+ with_gnu_ld=no+ ;;+ esac++ ld_shlibs=yes++ # On some targets, GNU ld is compatible enough with the native linker+ # that we're better off using the native interface for both.+ lt_use_gnu_ld_interface=no+ if test yes = "$with_gnu_ld"; then+ case $host_os in+ aix*)+ # The AIX port of GNU ld has always aspired to compatibility+ # with the native linker. However, as the warning in the GNU ld+ # block says, versions before 2.19.5* couldn't really create working+ # shared libraries, regardless of the interface used.+ case `$LD -v 2>&1` in+ *\ \(GNU\ Binutils\)\ 2.19.5*) ;;+ *\ \(GNU\ Binutils\)\ 2.[2-9]*) ;;+ *\ \(GNU\ Binutils\)\ [3-9]*) ;;+ *)+ lt_use_gnu_ld_interface=yes+ ;;+ esac+ ;;+ *)+ lt_use_gnu_ld_interface=yes+ ;;+ esac+ fi++ if test yes = "$lt_use_gnu_ld_interface"; then+ # If archive_cmds runs LD, not CC, wlarc should be empty+ wlarc='$wl'++ # Set some defaults for GNU ld with shared library support. These+ # are reset later if shared libraries are not supported. Putting them+ # here allows them to be overridden if necessary.+ runpath_var=LD_RUN_PATH+ hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'+ export_dynamic_flag_spec='$wl--export-dynamic'+ # ancient GNU ld didn't support --whole-archive et. al.+ if $LD --help 2>&1 | $GREP 'no-whole-archive' > /dev/null; then+ whole_archive_flag_spec=$wlarc'--whole-archive$convenience '$wlarc'--no-whole-archive'+ else+ whole_archive_flag_spec=+ fi+ supports_anon_versioning=no+ case `$LD -v | $SED -e 's/([^)]\+)\s\+//' 2>&1` in+ *GNU\ gold*) supports_anon_versioning=yes ;;+ *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11+ *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...+ *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...+ *\ 2.11.*) ;; # other 2.11 versions+ *) supports_anon_versioning=yes ;;+ esac++ # See if GNU ld supports shared libraries.+ case $host_os in+ aix[3-9]*)+ # On AIX/PPC, the GNU linker is very broken+ if test ia64 != "$host_cpu"; then+ ld_shlibs=no+ cat <<_LT_EOF 1>&2++*** Warning: the GNU linker, at least up to release 2.19, is reported+*** to be unable to reliably create shared libraries on AIX.+*** Therefore, libtool is disabling shared libraries support. If you+*** really care for shared libraries, you may want to install binutils+*** 2.20 or above, or modify your PATH so that a non-GNU linker is found.+*** You will then need to restart the configuration process.++_LT_EOF+ fi+ ;;++ amigaos*)+ case $host_cpu in+ powerpc)+ # see comment about AmigaOS4 .so support+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'+ archive_expsym_cmds=''+ ;;+ m68k)+ archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'+ hardcode_libdir_flag_spec='-L$libdir'+ hardcode_minus_L=yes+ ;;+ esac+ ;;++ beos*)+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then+ allow_undefined_flag=unsupported+ # Joseph Beckenbach <jrb3@best.com> says some releases of gcc+ # support --undefined. This deserves some investigation. FIXME+ archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'+ else+ ld_shlibs=no+ fi+ ;;++ cygwin* | mingw* | pw32* | cegcc*)+ # _LT_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,+ # as there is no search path for DLLs.+ hardcode_libdir_flag_spec='-L$libdir'+ export_dynamic_flag_spec='$wl--export-all-symbols'+ allow_undefined_flag=unsupported+ always_export_symbols=no+ enable_shared_with_static_runtimes=yes+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1 DATA/;s/^.*[ ]__nm__\([^ ]*\)[ ][^ ]*/\1 DATA/;/^I[ ]/d;/^[AITW][ ]/s/.* //'\'' | sort | uniq > $export_symbols'+ exclude_expsyms='[_]+GLOBAL_OFFSET_TABLE_|[_]+GLOBAL__[FID]_.*|[_]+head_[A-Za-z0-9_]+_dll|[A-Za-z0-9_]+_dll_iname'++ if $LD --help 2>&1 | $GREP 'auto-import' > /dev/null; then+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'+ # If the export-symbols file already is a .def file, use it as+ # is; otherwise, prepend EXPORTS...+ archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then+ cp $export_symbols $output_objdir/$soname.def;+ else+ echo EXPORTS > $output_objdir/$soname.def;+ cat $export_symbols >> $output_objdir/$soname.def;+ fi~+ $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname $wl--enable-auto-image-base -Xlinker --out-implib -Xlinker $lib'+ else+ ld_shlibs=no+ fi+ ;;++ haiku*)+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'+ link_all_deplibs=yes+ ;;++ os2*)+ hardcode_libdir_flag_spec='-L$libdir'+ hardcode_minus_L=yes+ allow_undefined_flag=unsupported+ shrext_cmds=.dll+ archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~+ $ECHO EXPORTS >> $output_objdir/$libname.def~+ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~+ emximp -o $lib $output_objdir/$libname.def'+ archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~+ $ECHO EXPORTS >> $output_objdir/$libname.def~+ prefix_cmds="$SED"~+ if test EXPORTS = "`$SED 1q $export_symbols`"; then+ prefix_cmds="$prefix_cmds -e 1d";+ fi~+ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~+ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~+ emximp -o $lib $output_objdir/$libname.def'+ old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'+ enable_shared_with_static_runtimes=yes+ file_list_spec='@'+ ;;++ interix[3-9]*)+ hardcode_direct=no+ hardcode_shlibpath_var=no+ hardcode_libdir_flag_spec='$wl-rpath,$libdir'+ export_dynamic_flag_spec='$wl-E'+ # Hack: On Interix 3.x, we cannot compile PIC because of a broken gcc.+ # Instead, shared libraries are loaded at an image base (0x10000000 by+ # default) and relocated if they conflict, which is a slow very memory+ # consuming and fragmenting process. To avoid this, we pick a random,+ # 256 KiB-aligned image base between 0x50000000 and 0x6FFC0000 at link+ # time. Moving up from 0x10000000 also allows more sbrk(2) space.+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'+ archive_expsym_cmds='$SED "s|^|_|" $export_symbols >$output_objdir/$soname.expsym~$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-h,$soname $wl--retain-symbols-file,$output_objdir/$soname.expsym $wl--image-base,`expr ${RANDOM-$$} % 4096 / 2 \* 262144 + 1342177280` -o $lib'+ ;;++ gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)+ tmp_diet=no+ if test linux-dietlibc = "$host_os"; then+ case $cc_basename in+ diet\ *) tmp_diet=yes;; # linux-dietlibc with static linking (!diet-dyn)+ esac+ fi+ if $LD --help 2>&1 | $EGREP ': supported targets:.* elf' > /dev/null \+ && test no = "$tmp_diet"+ then+ tmp_addflag=' $pic_flag'+ tmp_sharedflag='-shared'+ case $cc_basename,$host_cpu in+ pgcc*) # Portland Group C compiler+ whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'+ tmp_addflag=' $pic_flag'+ ;;+ pgf77* | pgf90* | pgf95* | pgfortran*)+ # Portland Group f77 and f90 compilers+ whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'+ tmp_addflag=' $pic_flag -Mnomain' ;;+ ecc*,ia64* | icc*,ia64*) # Intel C compiler on ia64+ tmp_addflag=' -i_dynamic' ;;+ efc*,ia64* | ifort*,ia64*) # Intel Fortran compiler on ia64+ tmp_addflag=' -i_dynamic -nofor_main' ;;+ ifc* | ifort*) # Intel Fortran compiler+ tmp_addflag=' -nofor_main' ;;+ lf95*) # Lahey Fortran 8.1+ whole_archive_flag_spec=+ tmp_sharedflag='--shared' ;;+ nagfor*) # NAGFOR 5.3+ tmp_sharedflag='-Wl,-shared' ;;+ xl[cC]* | bgxl[cC]* | mpixl[cC]*) # IBM XL C 8.0 on PPC (deal with xlf below)+ tmp_sharedflag='-qmkshrobj'+ tmp_addflag= ;;+ nvcc*) # Cuda Compiler Driver 2.2+ whole_archive_flag_spec='$wl--whole-archive`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'+ compiler_needs_object=yes+ ;;+ esac+ case `$CC -V 2>&1 | $SED 5q` in+ *Sun\ C*) # Sun C 5.9+ whole_archive_flag_spec='$wl--whole-archive`new_convenience=; for conv in $convenience\"\"; do test -z \"$conv\" || new_convenience=\"$new_convenience,$conv\"; done; func_echo_all \"$new_convenience\"` $wl--no-whole-archive'+ compiler_needs_object=yes+ tmp_sharedflag='-G' ;;+ *Sun\ F*) # Sun Fortran 8.3+ tmp_sharedflag='-G' ;;+ esac+ archive_cmds='$CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'++ if test yes = "$supports_anon_versioning"; then+ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~+ cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~+ echo "local: *; };" >> $output_objdir/$libname.ver~+ $CC '"$tmp_sharedflag""$tmp_addflag"' $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-version-script $wl$output_objdir/$libname.ver -o $lib'+ fi++ case $cc_basename in+ tcc*)+ export_dynamic_flag_spec='-rdynamic'+ ;;+ xlf* | bgf* | bgxlf* | mpixlf*)+ # IBM XL Fortran 10.1 on PPC cannot create shared libs itself+ whole_archive_flag_spec='--whole-archive$convenience --no-whole-archive'+ hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'+ archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname -o $lib'+ if test yes = "$supports_anon_versioning"; then+ archive_expsym_cmds='echo "{ global:" > $output_objdir/$libname.ver~+ cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~+ echo "local: *; };" >> $output_objdir/$libname.ver~+ $LD -shared $libobjs $deplibs $linker_flags -soname $soname -version-script $output_objdir/$libname.ver -o $lib'+ fi+ ;;+ esac+ else+ ld_shlibs=no+ fi+ ;;++ netbsd*)+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then+ archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'+ wlarc=+ else+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'+ archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'+ fi+ ;;++ solaris*)+ if $LD -v 2>&1 | $GREP 'BFD 2\.8' > /dev/null; then+ ld_shlibs=no+ cat <<_LT_EOF 1>&2++*** Warning: The releases 2.8.* of the GNU linker cannot reliably+*** create shared libraries on Solaris systems. Therefore, libtool+*** is disabling shared libraries support. We urge you to upgrade GNU+*** binutils to release 2.9.1 or newer. Another option is to modify+*** your PATH or compiler configuration so that the native linker is+*** used, and then restart.++_LT_EOF+ elif $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'+ archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'+ else+ ld_shlibs=no+ fi+ ;;++ sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)+ case `$LD -v 2>&1` in+ *\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)+ ld_shlibs=no+ cat <<_LT_EOF 1>&2++*** Warning: Releases of the GNU linker prior to 2.16.91.0.3 cannot+*** reliably create shared libraries on SCO systems. Therefore, libtool+*** is disabling shared libraries support. We urge you to upgrade GNU+*** binutils to release 2.16.91.0.3 or newer. Another option is to modify+*** your PATH or compiler configuration so that the native linker is+*** used, and then restart.++_LT_EOF+ ;;+ *)+ # For security reasons, it is highly recommended that you always+ # use absolute paths for naming shared libraries, and exclude the+ # DT_RUNPATH tag from executables and libraries. But doing so+ # requires that you compile everything twice, which is a pain.+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then+ hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'+ else+ ld_shlibs=no+ fi+ ;;+ esac+ ;;++ sunos4*)+ archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'+ wlarc=+ hardcode_direct=yes+ hardcode_shlibpath_var=no+ ;;++ *)+ if $LD --help 2>&1 | $GREP ': supported targets:.* elf' > /dev/null; then+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'+ archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname $wl-retain-symbols-file $wl$export_symbols -o $lib'+ else+ ld_shlibs=no+ fi+ ;;+ esac++ if test no = "$ld_shlibs"; then+ runpath_var=+ hardcode_libdir_flag_spec=+ export_dynamic_flag_spec=+ whole_archive_flag_spec=+ fi+ else+ # PORTME fill in a description of your system's linker (not GNU ld)+ case $host_os in+ aix3*)+ allow_undefined_flag=unsupported+ always_export_symbols=yes+ archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'+ # Note: this linker hardcodes the directories in LIBPATH if there+ # are no directories specified by -L.+ hardcode_minus_L=yes+ if test yes = "$GCC" && test -z "$lt_prog_compiler_static"; then+ # Neither direct hardcoding nor static linking is supported with a+ # broken collect2.+ hardcode_direct=unsupported+ fi+ ;;++ aix[4-9]*)+ if test ia64 = "$host_cpu"; then+ # On IA64, the linker does run time linking by default, so we don't+ # have to do anything special.+ aix_use_runtimelinking=no+ exp_sym_flag='-Bexport'+ no_entry_flag=+ else+ # If we're using GNU nm, then we don't want the "-C" option.+ # -C means demangle to GNU nm, but means don't demangle to AIX nm.+ # Without the "-l" option, or with the "-B" option, AIX nm treats+ # weak defined symbols like other global defined symbols, whereas+ # GNU nm marks them as "W".+ # While the 'weak' keyword is ignored in the Export File, we need+ # it in the Import File for the 'aix-soname' feature, so we have+ # to replace the "-B" option with "-P" for AIX nm.+ if $NM -V 2>&1 | $GREP 'GNU' > /dev/null; then+ export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "W")) && (substr(\$ 3,1,1) != ".")) { if (\$ 2 == "W") { print \$ 3 " weak" } else { print \$ 3 } } }'\'' | sort -u > $export_symbols'+ else+ export_symbols_cmds='`func_echo_all $NM | $SED -e '\''s/B\([^B]*\)$/P\1/'\''` -PCpgl $libobjs $convenience | awk '\''{ if (((\$ 2 == "T") || (\$ 2 == "D") || (\$ 2 == "B") || (\$ 2 == "L") || (\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) && (substr(\$ 1,1,1) != ".")) { if ((\$ 2 == "W") || (\$ 2 == "V") || (\$ 2 == "Z")) { print \$ 1 " weak" } else { print \$ 1 } } }'\'' | sort -u > $export_symbols'+ fi+ aix_use_runtimelinking=no++ # Test if we are trying to use run time linking or normal+ # AIX style linking. If -brtl is somewhere in LDFLAGS, we+ # have runtime linking enabled, and use it for executables.+ # For shared libraries, we enable/disable runtime linking+ # depending on the kind of the shared library created -+ # when "with_aix_soname,aix_use_runtimelinking" is:+ # "aix,no" lib.a(lib.so.V) shared, rtl:no, for executables+ # "aix,yes" lib.so shared, rtl:yes, for executables+ # lib.a static archive+ # "both,no" lib.so.V(shr.o) shared, rtl:yes+ # lib.a(lib.so.V) shared, rtl:no, for executables+ # "both,yes" lib.so.V(shr.o) shared, rtl:yes, for executables+ # lib.a(lib.so.V) shared, rtl:no+ # "svr4,*" lib.so.V(shr.o) shared, rtl:yes, for executables+ # lib.a static archive+ case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)+ for ld_flag in $LDFLAGS; do+ if (test x-brtl = "x$ld_flag" || test x-Wl,-brtl = "x$ld_flag"); then+ aix_use_runtimelinking=yes+ break+ fi+ done+ if test svr4,no = "$with_aix_soname,$aix_use_runtimelinking"; then+ # With aix-soname=svr4, we create the lib.so.V shared archives only,+ # so we don't have lib.a shared libs to link our executables.+ # We have to force runtime linking in this case.+ aix_use_runtimelinking=yes+ LDFLAGS="$LDFLAGS -Wl,-brtl"+ fi+ ;;+ esac++ exp_sym_flag='-bexport'+ no_entry_flag='-bnoentry'+ fi++ # When large executables or shared objects are built, AIX ld can+ # have problems creating the table of contents. If linking a library+ # or program results in "error TOC overflow" add -mminimal-toc to+ # CXXFLAGS/CFLAGS for g++/gcc. In the cases where that is not+ # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.++ archive_cmds=''+ hardcode_direct=yes+ hardcode_direct_absolute=yes+ hardcode_libdir_separator=':'+ link_all_deplibs=yes+ file_list_spec='$wl-f,'+ case $with_aix_soname,$aix_use_runtimelinking in+ aix,*) ;; # traditional, no import file+ svr4,* | *,yes) # use import file+ # The Import File defines what to hardcode.+ hardcode_direct=no+ hardcode_direct_absolute=no+ ;;+ esac++ if test yes = "$GCC"; then+ case $host_os in aix4.[012]|aix4.[012].*)+ # We only want to do this on AIX 4.2 and lower, the check+ # below for broken collect2 doesn't work under 4.3++ collect2name=`$CC -print-prog-name=collect2`+ if test -f "$collect2name" &&+ strings "$collect2name" | $GREP resolve_lib_name >/dev/null+ then+ # We have reworked collect2+ :+ else+ # We have old collect2+ hardcode_direct=unsupported+ # It fails to find uninstalled libraries when the uninstalled+ # path is not listed in the libpath. Setting hardcode_minus_L+ # to unsupported forces relinking+ hardcode_minus_L=yes+ hardcode_libdir_flag_spec='-L$libdir'+ hardcode_libdir_separator=+ fi+ ;;+ esac+ shared_flag='-shared'+ if test yes = "$aix_use_runtimelinking"; then+ shared_flag="$shared_flag "'$wl-G'+ fi+ # Need to ensure runtime linking is disabled for the traditional+ # shared library, or the linker may eventually find shared libraries+ # /with/ Import File - we do not want to mix them.+ shared_flag_aix='-shared'+ shared_flag_svr4='-shared $wl-G'+ else+ # not using gcc+ if test ia64 = "$host_cpu"; then+ # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release+ # chokes on -Wl,-G. The following line is correct:+ shared_flag='-G'+ else+ if test yes = "$aix_use_runtimelinking"; then+ shared_flag='$wl-G'+ else+ shared_flag='$wl-bM:SRE'+ fi+ shared_flag_aix='$wl-bM:SRE'+ shared_flag_svr4='$wl-G'+ fi+ fi++ export_dynamic_flag_spec='$wl-bexpall'+ # It seems that -bexpall does not export symbols beginning with+ # underscore (_), so it is better to generate a list of symbols to export.+ always_export_symbols=yes+ if test aix,yes = "$with_aix_soname,$aix_use_runtimelinking"; then+ # Warning - without using the other runtime loading flags (-brtl),+ # -berok will link without error, but may produce a broken library.+ allow_undefined_flag='-berok'+ # Determine the default libpath from the value encoded in an+ # empty executable.+ if test set = "${lt_cv_aix_libpath+set}"; then+ aix_libpath=$lt_cv_aix_libpath+else+ if test ${lt_cv_aix_libpath_+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :++ lt_aix_libpath_sed='+ /Import File Strings/,/^$/ {+ /^0/ {+ s/^0 *\([^ ]*\) *$/\1/+ p+ }+ }'+ lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`+ # Check for a 64-bit object if we didn't find anything.+ if test -z "$lt_cv_aix_libpath_"; then+ lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`+ fi+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ if test -z "$lt_cv_aix_libpath_"; then+ lt_cv_aix_libpath_=/usr/lib:/lib+ fi+ ;;+esac+fi++ aix_libpath=$lt_cv_aix_libpath_+fi++ hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"+ archive_expsym_cmds='$CC -o $output_objdir/$soname $libobjs $deplibs $wl'$no_entry_flag' $compiler_flags `if test -n "$allow_undefined_flag"; then func_echo_all "$wl$allow_undefined_flag"; else :; fi` $wl'$exp_sym_flag:\$export_symbols' '$shared_flag+ else+ if test ia64 = "$host_cpu"; then+ hardcode_libdir_flag_spec='$wl-R $libdir:/usr/lib:/lib'+ allow_undefined_flag="-z nodefs"+ archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs '"\$wl$no_entry_flag"' $compiler_flags $wl$allow_undefined_flag '"\$wl$exp_sym_flag:\$export_symbols"+ else+ # Determine the default libpath from the value encoded in an+ # empty executable.+ if test set = "${lt_cv_aix_libpath+set}"; then+ aix_libpath=$lt_cv_aix_libpath+else+ if test ${lt_cv_aix_libpath_+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :++ lt_aix_libpath_sed='+ /Import File Strings/,/^$/ {+ /^0/ {+ s/^0 *\([^ ]*\) *$/\1/+ p+ }+ }'+ lt_cv_aix_libpath_=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`+ # Check for a 64-bit object if we didn't find anything.+ if test -z "$lt_cv_aix_libpath_"; then+ lt_cv_aix_libpath_=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e "$lt_aix_libpath_sed"`+ fi+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ if test -z "$lt_cv_aix_libpath_"; then+ lt_cv_aix_libpath_=/usr/lib:/lib+ fi+ ;;+esac+fi++ aix_libpath=$lt_cv_aix_libpath_+fi++ hardcode_libdir_flag_spec='$wl-blibpath:$libdir:'"$aix_libpath"+ # Warning - without using the other run time loading flags,+ # -berok will link without error, but may produce a broken library.+ no_undefined_flag=' $wl-bernotok'+ allow_undefined_flag=' $wl-berok'+ if test yes = "$with_gnu_ld"; then+ # We only use this code for GNU lds that support --whole-archive.+ whole_archive_flag_spec='$wl--whole-archive$convenience $wl--no-whole-archive'+ else+ # Exported symbols can be pulled into shared objects from archives+ whole_archive_flag_spec='$convenience'+ fi+ archive_cmds_need_lc=yes+ archive_expsym_cmds='$RM -r $output_objdir/$realname.d~$MKDIR $output_objdir/$realname.d'+ # -brtl affects multiple linker settings, -berok does not and is overridden later+ compiler_flags_filtered='`func_echo_all "$compiler_flags " | $SED -e "s%-brtl\\([, ]\\)%-berok\\1%g"`'+ if test svr4 != "$with_aix_soname"; then+ # This is similar to how AIX traditionally builds its shared libraries.+ archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_aix' -o $output_objdir/$realname.d/$soname $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$realname.d/$soname'+ fi+ if test aix != "$with_aix_soname"; then+ archive_expsym_cmds="$archive_expsym_cmds"'~$CC '$shared_flag_svr4' -o $output_objdir/$realname.d/$shared_archive_member_spec.o $libobjs $deplibs $wl-bnoentry '$compiler_flags_filtered'$wl-bE:$export_symbols$allow_undefined_flag~$STRIP -e $output_objdir/$realname.d/$shared_archive_member_spec.o~( func_echo_all "#! $soname($shared_archive_member_spec.o)"; if test shr_64 = "$shared_archive_member_spec"; then func_echo_all "# 64"; else func_echo_all "# 32"; fi; cat $export_symbols ) > $output_objdir/$realname.d/$shared_archive_member_spec.imp~$AR $AR_FLAGS $output_objdir/$soname $output_objdir/$realname.d/$shared_archive_member_spec.o $output_objdir/$realname.d/$shared_archive_member_spec.imp'+ else+ # used by -dlpreopen to get the symbols+ archive_expsym_cmds="$archive_expsym_cmds"'~$MV $output_objdir/$realname.d/$soname $output_objdir'+ fi+ archive_expsym_cmds="$archive_expsym_cmds"'~$RM -r $output_objdir/$realname.d'+ fi+ fi+ ;;++ amigaos*)+ case $host_cpu in+ powerpc)+ # see comment about AmigaOS4 .so support+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'+ archive_expsym_cmds=''+ ;;+ m68k)+ archive_cmds='$RM $output_objdir/a2ixlibrary.data~$ECHO "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$ECHO "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$ECHO "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$ECHO "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'+ hardcode_libdir_flag_spec='-L$libdir'+ hardcode_minus_L=yes+ ;;+ esac+ ;;++ bsdi[45]*)+ export_dynamic_flag_spec=-rdynamic+ ;;++ cygwin* | mingw* | pw32* | cegcc*)+ # When not using gcc, we currently assume that we are using+ # Microsoft Visual C++ or Intel C++ Compiler.+ # hardcode_libdir_flag_spec is actually meaningless, as there is+ # no search path for DLLs.+ case $cc_basename in+ cl* | icl*)+ # Native MSVC or ICC+ hardcode_libdir_flag_spec=' '+ allow_undefined_flag=unsupported+ always_export_symbols=yes+ file_list_spec='@'+ # Tell ltmain to make .lib files, not .a files.+ libext=lib+ # Tell ltmain to make .dll files, not .so files.+ shrext_cmds=.dll+ # FIXME: Setting linknames here is a bad hack.+ archive_cmds='$CC -o $output_objdir/$soname $libobjs $compiler_flags $deplibs -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~linknames='+ archive_expsym_cmds='if test DEF = "`$SED -n -e '\''s/^[ ]*//'\'' -e '\''/^\(;.*\)*$/d'\'' -e '\''s/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p'\'' -e q $export_symbols`" ; then+ cp "$export_symbols" "$output_objdir/$soname.def";+ echo "$tool_output_objdir$soname.def" > "$output_objdir/$soname.exp";+ else+ $SED -e '\''s/^/-link -EXPORT:/'\'' < $export_symbols > $output_objdir/$soname.exp;+ fi~+ $CC -o $tool_output_objdir$soname $libobjs $compiler_flags $deplibs "@$tool_output_objdir$soname.exp" -Wl,-DLL,-IMPLIB:"$tool_output_objdir$libname.dll.lib"~+ linknames='+ # The linker will not automatically build a static lib if we build a DLL.+ # _LT_TAGVAR(old_archive_from_new_cmds, )='true'+ enable_shared_with_static_runtimes=yes+ exclude_expsyms='_NULL_IMPORT_DESCRIPTOR|_IMPORT_DESCRIPTOR_.*'+ export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS][ ]/s/.*[ ]\([^ ]*\)/\1,DATA/'\'' | $SED -e '\''/^[AITW][ ]/s/.*[ ]//'\'' | sort | uniq > $export_symbols'+ # Don't use ranlib+ old_postinstall_cmds='chmod 644 $oldlib'+ postlink_cmds='lt_outputfile="@OUTPUT@"~+ lt_tool_outputfile="@TOOL_OUTPUT@"~+ case $lt_outputfile in+ *.exe|*.EXE) ;;+ *)+ lt_outputfile=$lt_outputfile.exe+ lt_tool_outputfile=$lt_tool_outputfile.exe+ ;;+ esac~+ if test : != "$MANIFEST_TOOL" && test -f "$lt_outputfile.manifest"; then+ $MANIFEST_TOOL -manifest "$lt_tool_outputfile.manifest" -outputresource:"$lt_tool_outputfile" || exit 1;+ $RM "$lt_outputfile.manifest";+ fi'+ ;;+ *)+ # Assume MSVC and ICC wrapper+ hardcode_libdir_flag_spec=' '+ allow_undefined_flag=unsupported+ # Tell ltmain to make .lib files, not .a files.+ libext=lib+ # Tell ltmain to make .dll files, not .so files.+ shrext_cmds=.dll+ # FIXME: Setting linknames here is a bad hack.+ archive_cmds='$CC -o $lib $libobjs $compiler_flags `func_echo_all "$deplibs" | $SED '\''s/ -lc$//'\''` -link -dll~linknames='+ # The linker will automatically build a .lib file if we build a DLL.+ old_archive_from_new_cmds='true'+ # FIXME: Should let the user specify the lib program.+ old_archive_cmds='lib -OUT:$oldlib$oldobjs$old_deplibs'+ enable_shared_with_static_runtimes=yes+ ;;+ esac+ ;;++ darwin* | rhapsody*)+++ archive_cmds_need_lc=no+ hardcode_direct=no+ hardcode_automatic=yes+ hardcode_shlibpath_var=unsupported+ if test yes = "$lt_cv_ld_force_load"; then+ whole_archive_flag_spec='`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience $wl-force_load,$conv\"; done; func_echo_all \"$new_convenience\"`'++ else+ whole_archive_flag_spec=''+ fi+ link_all_deplibs=yes+ allow_undefined_flag=$_lt_dar_allow_undefined+ case $cc_basename in+ ifort*|nagfor*) _lt_dar_can_shared=yes ;;+ *) _lt_dar_can_shared=$GCC ;;+ esac+ if test yes = "$_lt_dar_can_shared"; then+ output_verbose_link_cmd=func_echo_all+ archive_cmds="\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dsymutil"+ module_cmds="\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dsymutil"+ archive_expsym_cmds="$SED 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC -dynamiclib \$allow_undefined_flag -o \$lib \$libobjs \$deplibs \$compiler_flags -install_name \$rpath/\$soname \$verstring $_lt_dar_single_mod$_lt_dar_export_syms$_lt_dsymutil"+ module_expsym_cmds="$SED -e 's|^|_|' < \$export_symbols > \$output_objdir/\$libname-symbols.expsym~\$CC \$allow_undefined_flag -o \$lib -bundle \$libobjs \$deplibs \$compiler_flags$_lt_dar_export_syms$_lt_dsymutil"++ else+ ld_shlibs=no+ fi++ ;;++ dgux*)+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'+ hardcode_libdir_flag_spec='-L$libdir'+ hardcode_shlibpath_var=no+ ;;++ # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor+ # support. Future versions do this automatically, but an explicit c++rt0.o+ # does not break anything, and helps significantly (at the cost of a little+ # extra space).+ freebsd2.2*)+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'+ hardcode_libdir_flag_spec='-R$libdir'+ hardcode_direct=yes+ hardcode_shlibpath_var=no+ ;;++ # Unfortunately, older versions of FreeBSD 2 do not have this feature.+ freebsd2.*)+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'+ hardcode_direct=yes+ hardcode_minus_L=yes+ hardcode_shlibpath_var=no+ ;;++ # FreeBSD 3 and greater uses gcc -shared to do shared libraries.+ freebsd* | dragonfly* | midnightbsd*)+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'+ hardcode_libdir_flag_spec='-R$libdir'+ hardcode_direct=yes+ hardcode_shlibpath_var=no+ ;;++ hpux9*)+ if test yes = "$GCC"; then+ archive_cmds='$RM $output_objdir/$soname~$CC -shared $pic_flag $wl+b $wl$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'+ else+ archive_cmds='$RM $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test "x$output_objdir/$soname" = "x$lib" || mv $output_objdir/$soname $lib'+ fi+ hardcode_libdir_flag_spec='$wl+b $wl$libdir'+ hardcode_libdir_separator=:+ hardcode_direct=yes++ # hardcode_minus_L: Not really in the search PATH,+ # but as the default location of the library.+ hardcode_minus_L=yes+ export_dynamic_flag_spec='$wl-E'+ ;;++ hpux10*)+ if test yes,no = "$GCC,$with_gnu_ld"; then+ archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'+ else+ archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'+ fi+ if test no = "$with_gnu_ld"; then+ hardcode_libdir_flag_spec='$wl+b $wl$libdir'+ hardcode_libdir_separator=:+ hardcode_direct=yes+ hardcode_direct_absolute=yes+ export_dynamic_flag_spec='$wl-E'+ # hardcode_minus_L: Not really in the search PATH,+ # but as the default location of the library.+ hardcode_minus_L=yes+ fi+ ;;++ hpux11*)+ if test yes,no = "$GCC,$with_gnu_ld"; then+ case $host_cpu in+ hppa*64*)+ archive_cmds='$CC -shared $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'+ ;;+ ia64*)+ archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'+ ;;+ *)+ archive_cmds='$CC -shared $pic_flag $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'+ ;;+ esac+ else+ case $host_cpu in+ hppa*64*)+ archive_cmds='$CC -b $wl+h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'+ ;;+ ia64*)+ archive_cmds='$CC -b $wl+h $wl$soname $wl+nodefaultrpath -o $lib $libobjs $deplibs $compiler_flags'+ ;;+ *)++ # Older versions of the 11.00 compiler do not understand -b yet+ # (HP92453-01 A.11.01.20 doesn't, HP92453-01 B.11.X.35175-35176.GP does)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC understands -b" >&5+printf %s "checking if $CC understands -b... " >&6; }+if test ${lt_cv_prog_compiler__b+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_prog_compiler__b=no+ save_LDFLAGS=$LDFLAGS+ LDFLAGS="$LDFLAGS -b"+ echo "$lt_simple_link_test_code" > conftest.$ac_ext+ if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then+ # The linker can only warn and ignore the option if not recognized+ # So say no if there are warnings+ if test -s conftest.err; then+ # Append any errors to the config.log.+ cat conftest.err 1>&5+ $ECHO "$_lt_linker_boilerplate" | $SED '/^$/d' > conftest.exp+ $SED '/^$/d; /^ *+/d' conftest.err >conftest.er2+ if diff conftest.exp conftest.er2 >/dev/null; then+ lt_cv_prog_compiler__b=yes+ fi+ else+ lt_cv_prog_compiler__b=yes+ fi+ fi+ $RM -r conftest*+ LDFLAGS=$save_LDFLAGS+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler__b" >&5+printf "%s\n" "$lt_cv_prog_compiler__b" >&6; }++if test yes = "$lt_cv_prog_compiler__b"; then+ archive_cmds='$CC -b $wl+h $wl$soname $wl+b $wl$install_libdir -o $lib $libobjs $deplibs $compiler_flags'+else+ archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'+fi++ ;;+ esac+ fi+ if test no = "$with_gnu_ld"; then+ hardcode_libdir_flag_spec='$wl+b $wl$libdir'+ hardcode_libdir_separator=:++ case $host_cpu in+ hppa*64*|ia64*)+ hardcode_direct=no+ hardcode_shlibpath_var=no+ ;;+ *)+ hardcode_direct=yes+ hardcode_direct_absolute=yes+ export_dynamic_flag_spec='$wl-E'++ # hardcode_minus_L: Not really in the search PATH,+ # but as the default location of the library.+ hardcode_minus_L=yes+ ;;+ esac+ fi+ ;;++ irix5* | irix6* | nonstopux*)+ if test yes = "$GCC"; then+ archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'+ # Try to use the -exported_symbol ld option, if it does not+ # work, assume that -exports_file does not work either and+ # implicitly export all symbols.+ # This should be the same for all languages, so no per-tag cache variable.+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the $host_os linker accepts -exported_symbol" >&5+printf %s "checking whether the $host_os linker accepts -exported_symbol... " >&6; }+if test ${lt_cv_irix_exported_symbol+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) save_LDFLAGS=$LDFLAGS+ LDFLAGS="$LDFLAGS -shared $wl-exported_symbol ${wl}foo $wl-update_registry $wl/dev/null"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+int foo (void) { return 0; }+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ lt_cv_irix_exported_symbol=yes+else case e in #(+ e) lt_cv_irix_exported_symbol=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ LDFLAGS=$save_LDFLAGS ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_irix_exported_symbol" >&5+printf "%s\n" "$lt_cv_irix_exported_symbol" >&6; }+ if test yes = "$lt_cv_irix_exported_symbol"; then+ archive_expsym_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations $wl-exports_file $wl$export_symbols -o $lib'+ fi+ else+ archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'+ archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -exports_file $export_symbols -o $lib'+ fi+ archive_cmds_need_lc='no'+ hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'+ hardcode_libdir_separator=:+ inherit_rpath=yes+ link_all_deplibs=yes+ ;;++ linux*)+ case $cc_basename in+ tcc*)+ # Fabrice Bellard et al's Tiny C Compiler+ ld_shlibs=yes+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'+ ;;+ esac+ ;;++ netbsd*)+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then+ archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags' # a.out+ else+ archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags' # ELF+ fi+ hardcode_libdir_flag_spec='-R$libdir'+ hardcode_direct=yes+ hardcode_shlibpath_var=no+ ;;++ newsos6)+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'+ hardcode_direct=yes+ hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'+ hardcode_libdir_separator=:+ hardcode_shlibpath_var=no+ ;;++ *nto* | *qnx*)+ ;;++ openbsd* | bitrig*)+ if test -f /usr/libexec/ld.so; then+ hardcode_direct=yes+ hardcode_shlibpath_var=no+ hardcode_direct_absolute=yes+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'+ archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags $wl-retain-symbols-file,$export_symbols'+ hardcode_libdir_flag_spec='$wl-rpath,$libdir'+ export_dynamic_flag_spec='$wl-E'+ else+ archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'+ hardcode_libdir_flag_spec='$wl-rpath,$libdir'+ fi+ else+ ld_shlibs=no+ fi+ ;;++ os2*)+ hardcode_libdir_flag_spec='-L$libdir'+ hardcode_minus_L=yes+ allow_undefined_flag=unsupported+ shrext_cmds=.dll+ archive_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~+ $ECHO EXPORTS >> $output_objdir/$libname.def~+ emxexp $libobjs | $SED /"_DLL_InitTerm"/d >> $output_objdir/$libname.def~+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~+ emximp -o $lib $output_objdir/$libname.def'+ archive_expsym_cmds='$ECHO "LIBRARY ${soname%$shared_ext} INITINSTANCE TERMINSTANCE" > $output_objdir/$libname.def~+ $ECHO "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~+ $ECHO "DATA MULTIPLE NONSHARED" >> $output_objdir/$libname.def~+ $ECHO EXPORTS >> $output_objdir/$libname.def~+ prefix_cmds="$SED"~+ if test EXPORTS = "`$SED 1q $export_symbols`"; then+ prefix_cmds="$prefix_cmds -e 1d";+ fi~+ prefix_cmds="$prefix_cmds -e \"s/^\(.*\)$/_\1/g\""~+ cat $export_symbols | $prefix_cmds >> $output_objdir/$libname.def~+ $CC -Zdll -Zcrtdll -o $output_objdir/$soname $libobjs $deplibs $compiler_flags $output_objdir/$libname.def~+ emximp -o $lib $output_objdir/$libname.def'+ old_archive_From_new_cmds='emximp -o $output_objdir/${libname}_dll.a $output_objdir/$libname.def'+ enable_shared_with_static_runtimes=yes+ file_list_spec='@'+ ;;++ osf3*)+ if test yes = "$GCC"; then+ allow_undefined_flag=' $wl-expect_unresolved $wl\*'+ archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'+ else+ allow_undefined_flag=' -expect_unresolved \*'+ archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'+ fi+ archive_cmds_need_lc='no'+ hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'+ hardcode_libdir_separator=:+ ;;++ osf4* | osf5*) # as osf3* with the addition of -msym flag+ if test yes = "$GCC"; then+ allow_undefined_flag=' $wl-expect_unresolved $wl\*'+ archive_cmds='$CC -shared$allow_undefined_flag $pic_flag $libobjs $deplibs $compiler_flags $wl-msym $wl-soname $wl$soname `test -n "$verstring" && func_echo_all "$wl-set_version $wl$verstring"` $wl-update_registry $wl$output_objdir/so_locations -o $lib'+ hardcode_libdir_flag_spec='$wl-rpath $wl$libdir'+ else+ allow_undefined_flag=' -expect_unresolved \*'+ archive_cmds='$CC -shared$allow_undefined_flag $libobjs $deplibs $compiler_flags -msym -soname $soname `test -n "$verstring" && func_echo_all "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib'+ archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; printf "%s\\n" "-hidden">> $lib.exp~+ $CC -shared$allow_undefined_flag $wl-input $wl$lib.exp $compiler_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && $ECHO "-set_version $verstring"` -update_registry $output_objdir/so_locations -o $lib~$RM $lib.exp'++ # Both c and cxx compiler support -rpath directly+ hardcode_libdir_flag_spec='-rpath $libdir'+ fi+ archive_cmds_need_lc='no'+ hardcode_libdir_separator=:+ ;;++ solaris*)+ no_undefined_flag=' -z defs'+ if test yes = "$GCC"; then+ wlarc='$wl'+ archive_cmds='$CC -shared $pic_flag $wl-z ${wl}text $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags'+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~+ $CC -shared $pic_flag $wl-z ${wl}text $wl-M $wl$lib.exp $wl-h $wl$soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'+ else+ case `$CC -V 2>&1` in+ *"Compilers 5.0"*)+ wlarc=''+ archive_cmds='$LD -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $linker_flags'+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~+ $LD -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$RM $lib.exp'+ ;;+ *)+ wlarc='$wl'+ archive_cmds='$CC -G$allow_undefined_flag -h $soname -o $lib $libobjs $deplibs $compiler_flags'+ archive_expsym_cmds='echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~echo "local: *; };" >> $lib.exp~+ $CC -G$allow_undefined_flag -M $lib.exp -h $soname -o $lib $libobjs $deplibs $compiler_flags~$RM $lib.exp'+ ;;+ esac+ fi+ hardcode_libdir_flag_spec='-R$libdir'+ hardcode_shlibpath_var=no+ case $host_os in+ solaris2.[0-5] | solaris2.[0-5].*) ;;+ *)+ # The compiler driver will combine and reorder linker options,+ # but understands '-z linker_flag'. GCC discards it without '$wl',+ # but is careful enough not to reorder.+ # Supported since Solaris 2.6 (maybe 2.5.1?)+ if test yes = "$GCC"; then+ whole_archive_flag_spec='$wl-z ${wl}allextract$convenience $wl-z ${wl}defaultextract'+ else+ whole_archive_flag_spec='-z allextract$convenience -z defaultextract'+ fi+ ;;+ esac+ link_all_deplibs=yes+ ;;++ sunos4*)+ if test sequent = "$host_vendor"; then+ # Use $CC to link under sequent, because it throws in some extra .o+ # files that make .init and .fini sections work.+ archive_cmds='$CC -G $wl-h $soname -o $lib $libobjs $deplibs $compiler_flags'+ else+ archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'+ fi+ hardcode_libdir_flag_spec='-L$libdir'+ hardcode_direct=yes+ hardcode_minus_L=yes+ hardcode_shlibpath_var=no+ ;;++ sysv4)+ case $host_vendor in+ sni)+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'+ hardcode_direct=yes # is this really true???+ ;;+ siemens)+ ## LD is ld it makes a PLAMLIB+ ## CC just makes a GrossModule.+ archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'+ reload_cmds='$CC -r -o $output$reload_objs'+ hardcode_direct=no+ ;;+ motorola)+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'+ hardcode_direct=no #Motorola manual says yes, but my tests say they lie+ ;;+ esac+ runpath_var='LD_RUN_PATH'+ hardcode_shlibpath_var=no+ ;;++ sysv4.3*)+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'+ hardcode_shlibpath_var=no+ export_dynamic_flag_spec='-Bexport'+ ;;++ sysv4*MP*)+ if test -d /usr/nec; then+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'+ hardcode_shlibpath_var=no+ runpath_var=LD_RUN_PATH+ hardcode_runpath_var=yes+ ld_shlibs=yes+ fi+ ;;++ sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)+ no_undefined_flag='$wl-z,text'+ archive_cmds_need_lc=no+ hardcode_shlibpath_var=no+ runpath_var='LD_RUN_PATH'++ if test yes = "$GCC"; then+ archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'+ archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'+ else+ archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'+ archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'+ fi+ ;;++ sysv5* | sco3.2v5* | sco5v6*)+ # Note: We CANNOT use -z defs as we might desire, because we do not+ # link with -lc, and that would cause any symbols used from libc to+ # always be unresolved, which means just about no library would+ # ever link correctly. If we're not using GNU ld we use -z text+ # though, which does catch some bad symbols but isn't as heavy-handed+ # as -z defs.+ no_undefined_flag='$wl-z,text'+ allow_undefined_flag='$wl-z,nodefs'+ archive_cmds_need_lc=no+ hardcode_shlibpath_var=no+ hardcode_libdir_flag_spec='$wl-R,$libdir'+ hardcode_libdir_separator=':'+ link_all_deplibs=yes+ export_dynamic_flag_spec='$wl-Bexport'+ runpath_var='LD_RUN_PATH'++ if test yes = "$GCC"; then+ archive_cmds='$CC -shared $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'+ archive_expsym_cmds='$CC -shared $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'+ else+ archive_cmds='$CC -G $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'+ archive_expsym_cmds='$CC -G $wl-Bexport:$export_symbols $wl-h,$soname -o $lib $libobjs $deplibs $compiler_flags'+ fi+ ;;++ uts4*)+ archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'+ hardcode_libdir_flag_spec='-L$libdir'+ hardcode_shlibpath_var=no+ ;;++ *)+ ld_shlibs=no+ ;;+ esac++ if test sni = "$host_vendor"; then+ case $host in+ sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)+ export_dynamic_flag_spec='$wl-Blargedynsym'+ ;;+ esac+ fi+ fi++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5+printf "%s\n" "$ld_shlibs" >&6; }+test no = "$ld_shlibs" && can_build_shared=no++with_gnu_ld=$with_gnu_ld++++++++++++++++#+# Do we need to explicitly link libc?+#+case "x$archive_cmds_need_lc" in+x|xyes)+ # Assume -lc should be added+ archive_cmds_need_lc=yes++ if test yes,yes = "$GCC,$enable_shared"; then+ case $archive_cmds in+ *'~'*)+ # FIXME: we may have to deal with multi-command sequences.+ ;;+ '$CC '*)+ # Test whether the compiler implicitly links with -lc since on some+ # systems, -lgcc has to come before -lc. If gcc already passes -lc+ # to ld, don't add -lc before -lgcc.+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5+printf %s "checking whether -lc should be explicitly linked in... " >&6; }+if test ${lt_cv_archive_cmds_need_lc+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) $RM conftest*+ echo "$lt_simple_compile_test_code" > conftest.$ac_ext++ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5+ (eval $ac_compile) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; } 2>conftest.err; then+ soname=conftest+ lib=conftest+ libobjs=conftest.$ac_objext+ deplibs=+ wl=$lt_prog_compiler_wl+ pic_flag=$lt_prog_compiler_pic+ compiler_flags=-v+ linker_flags=-v+ verstring=+ output_objdir=.+ libname=conftest+ lt_save_allow_undefined_flag=$allow_undefined_flag+ allow_undefined_flag=+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1\""; } >&5+ (eval $archive_cmds 2\>\&1 \| $GREP \" -lc \" \>/dev/null 2\>\&1) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; }+ then+ lt_cv_archive_cmds_need_lc=no+ else+ lt_cv_archive_cmds_need_lc=yes+ fi+ allow_undefined_flag=$lt_save_allow_undefined_flag+ else+ cat conftest.err 1>&5+ fi+ $RM conftest*+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_archive_cmds_need_lc" >&5+printf "%s\n" "$lt_cv_archive_cmds_need_lc" >&6; }+ archive_cmds_need_lc=$lt_cv_archive_cmds_need_lc+ ;;+ esac+ fi+ ;;+esac+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5+printf %s "checking dynamic linker characteristics... " >&6; }++if test yes = "$GCC"; then+ case $host_os in+ darwin*) lt_awk_arg='/^libraries:/,/LR/' ;;+ *) lt_awk_arg='/^libraries:/' ;;+ esac+ case $host_os in+ mingw* | cegcc*) lt_sed_strip_eq='s|=\([A-Za-z]:\)|\1|g' ;;+ *) lt_sed_strip_eq='s|=/|/|g' ;;+ esac+ lt_search_path_spec=`$CC -print-search-dirs | awk $lt_awk_arg | $SED -e "s/^libraries://" -e $lt_sed_strip_eq`+ case $lt_search_path_spec in+ *\;*)+ # if the path contains ";" then we assume it to be the separator+ # otherwise default to the standard path separator (i.e. ":") - it is+ # assumed that no part of a normal pathname contains ";" but that should+ # okay in the real world where ";" in dirpaths is itself problematic.+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED 's/;/ /g'`+ ;;+ *)+ lt_search_path_spec=`$ECHO "$lt_search_path_spec" | $SED "s/$PATH_SEPARATOR/ /g"`+ ;;+ esac+ # Ok, now we have the path, separated by spaces, we can step through it+ # and add multilib dir if necessary...+ lt_tmp_lt_search_path_spec=+ lt_multi_os_dir=/`$CC $CPPFLAGS $CFLAGS $LDFLAGS -print-multi-os-directory 2>/dev/null`+ # ...but if some path component already ends with the multilib dir we assume+ # that all is fine and trust -print-search-dirs as is (GCC 4.2? or newer).+ case "$lt_multi_os_dir; $lt_search_path_spec " in+ "/; "* | "/.; "* | "/./; "* | *"$lt_multi_os_dir "* | *"$lt_multi_os_dir/ "*)+ lt_multi_os_dir=+ ;;+ esac+ for lt_sys_path in $lt_search_path_spec; do+ if test -d "$lt_sys_path$lt_multi_os_dir"; then+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path$lt_multi_os_dir"+ elif test -n "$lt_multi_os_dir"; then+ test -d "$lt_sys_path" && \+ lt_tmp_lt_search_path_spec="$lt_tmp_lt_search_path_spec $lt_sys_path"+ fi+ done+ lt_search_path_spec=`$ECHO "$lt_tmp_lt_search_path_spec" | awk '+BEGIN {RS = " "; FS = "/|\n";} {+ lt_foo = "";+ lt_count = 0;+ for (lt_i = NF; lt_i > 0; lt_i--) {+ if ($lt_i != "" && $lt_i != ".") {+ if ($lt_i == "..") {+ lt_count++;+ } else {+ if (lt_count == 0) {+ lt_foo = "/" $lt_i lt_foo;+ } else {+ lt_count--;+ }+ }+ }+ }+ if (lt_foo != "") { lt_freq[lt_foo]++; }+ if (lt_freq[lt_foo] == 1) { print lt_foo; }+}'`+ # AWK program above erroneously prepends '/' to C:/dos/paths+ # for these hosts.+ case $host_os in+ mingw* | cegcc*) lt_search_path_spec=`$ECHO "$lt_search_path_spec" |\+ $SED 's|/\([A-Za-z]:\)|\1|g'` ;;+ esac+ sys_lib_search_path_spec=`$ECHO "$lt_search_path_spec" | $lt_NL2SP`+else+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"+fi+library_names_spec=+libname_spec='lib$name'+soname_spec=+shrext_cmds=.so+postinstall_cmds=+postuninstall_cmds=+finish_cmds=+finish_eval=+shlibpath_var=+shlibpath_overrides_runpath=unknown+version_type=none+dynamic_linker="$host_os ld.so"+sys_lib_dlsearch_path_spec="/lib /usr/lib"+need_lib_prefix=unknown+hardcode_into_libs=no++# when you set need_version to no, make sure it does not cause -set_version+# flags to be left without arguments+need_version=unknown++++case $host_os in+aix3*)+ version_type=linux # correct to gnu/linux during the next big refactor+ library_names_spec='$libname$release$shared_ext$versuffix $libname.a'+ shlibpath_var=LIBPATH++ # AIX 3 has no versioning support, so we append a major version to the name.+ soname_spec='$libname$release$shared_ext$major'+ ;;++aix[4-9]*)+ version_type=linux # correct to gnu/linux during the next big refactor+ need_lib_prefix=no+ need_version=no+ hardcode_into_libs=yes+ if test ia64 = "$host_cpu"; then+ # AIX 5 supports IA64+ library_names_spec='$libname$release$shared_ext$major $libname$release$shared_ext$versuffix $libname$shared_ext'+ shlibpath_var=LD_LIBRARY_PATH+ else+ # With GCC up to 2.95.x, collect2 would create an import file+ # for dependence libraries. The import file would start with+ # the line '#! .'. This would cause the generated library to+ # depend on '.', always an invalid library. This was fixed in+ # development snapshots of GCC prior to 3.0.+ case $host_os in+ aix4 | aix4.[01] | aix4.[01].*)+ if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'+ echo ' yes '+ echo '#endif'; } | $CC -E - | $GREP yes > /dev/null; then+ :+ else+ can_build_shared=no+ fi+ ;;+ esac+ # Using Import Files as archive members, it is possible to support+ # filename-based versioning of shared library archives on AIX. While+ # this would work for both with and without runtime linking, it will+ # prevent static linking of such archives. So we do filename-based+ # shared library versioning with .so extension only, which is used+ # when both runtime linking and shared linking is enabled.+ # Unfortunately, runtime linking may impact performance, so we do+ # not want this to be the default eventually. Also, we use the+ # versioned .so libs for executables only if there is the -brtl+ # linker flag in LDFLAGS as well, or --with-aix-soname=svr4 only.+ # To allow for filename-based versioning support, we need to create+ # libNAME.so.V as an archive file, containing:+ # *) an Import File, referring to the versioned filename of the+ # archive as well as the shared archive member, telling the+ # bitwidth (32 or 64) of that shared object, and providing the+ # list of exported symbols of that shared object, eventually+ # decorated with the 'weak' keyword+ # *) the shared object with the F_LOADONLY flag set, to really avoid+ # it being seen by the linker.+ # At run time we better use the real file rather than another symlink,+ # but for link time we create the symlink libNAME.so -> libNAME.so.V++ case $with_aix_soname,$aix_use_runtimelinking in+ # AIX (on Power*) has no versioning support, so currently we cannot hardcode correct+ # soname into executable. Probably we can add versioning support to+ # collect2, so additional links can be useful in future.+ aix,yes) # traditional libtool+ dynamic_linker='AIX unversionable lib.so'+ # If using run time linking (on AIX 4.2 or later) use lib<name>.so+ # instead of lib<name>.a to let people know that these are not+ # typical AIX shared libraries.+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ ;;+ aix,no) # traditional AIX only+ dynamic_linker='AIX lib.a(lib.so.V)'+ # We preserve .a as extension for shared libraries through AIX4.2+ # and later when we are not doing run time linking.+ library_names_spec='$libname$release.a $libname.a'+ soname_spec='$libname$release$shared_ext$major'+ ;;+ svr4,*) # full svr4 only+ dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o)"+ library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'+ # We do not specify a path in Import Files, so LIBPATH fires.+ shlibpath_overrides_runpath=yes+ ;;+ *,yes) # both, prefer svr4+ dynamic_linker="AIX lib.so.V($shared_archive_member_spec.o), lib.a(lib.so.V)"+ library_names_spec='$libname$release$shared_ext$major $libname$shared_ext'+ # unpreferred sharedlib libNAME.a needs extra handling+ postinstall_cmds='test -n "$linkname" || linkname="$realname"~func_stripname "" ".so" "$linkname"~$install_shared_prog "$dir/$func_stripname_result.$libext" "$destdir/$func_stripname_result.$libext"~test -z "$tstripme" || test -z "$striplib" || $striplib "$destdir/$func_stripname_result.$libext"'+ postuninstall_cmds='for n in $library_names $old_library; do :; done~func_stripname "" ".so" "$n"~test "$func_stripname_result" = "$n" || func_append rmfiles " $odir/$func_stripname_result.$libext"'+ # We do not specify a path in Import Files, so LIBPATH fires.+ shlibpath_overrides_runpath=yes+ ;;+ *,no) # both, prefer aix+ dynamic_linker="AIX lib.a(lib.so.V), lib.so.V($shared_archive_member_spec.o)"+ library_names_spec='$libname$release.a $libname.a'+ soname_spec='$libname$release$shared_ext$major'+ # unpreferred sharedlib libNAME.so.V and symlink libNAME.so need extra handling+ postinstall_cmds='test -z "$dlname" || $install_shared_prog $dir/$dlname $destdir/$dlname~test -z "$tstripme" || test -z "$striplib" || $striplib $destdir/$dlname~test -n "$linkname" || linkname=$realname~func_stripname "" ".a" "$linkname"~(cd "$destdir" && $LN_S -f $dlname $func_stripname_result.so)'+ postuninstall_cmds='test -z "$dlname" || func_append rmfiles " $odir/$dlname"~for n in $old_library $library_names; do :; done~func_stripname "" ".a" "$n"~func_append rmfiles " $odir/$func_stripname_result.so"'+ ;;+ esac+ shlibpath_var=LIBPATH+ fi+ ;;++amigaos*)+ case $host_cpu in+ powerpc)+ # Since July 2007 AmigaOS4 officially supports .so libraries.+ # When compiling the executable, add -use-dynld -Lsobjs: to the compileline.+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ ;;+ m68k)+ library_names_spec='$libname.ixlibrary $libname.a'+ # Create ${libname}_ixlibrary.a entries in /sys/libs.+ finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`func_echo_all "$lib" | $SED '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; $RM /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'+ ;;+ esac+ ;;++beos*)+ library_names_spec='$libname$shared_ext'+ dynamic_linker="$host_os ld.so"+ shlibpath_var=LIBRARY_PATH+ ;;++bsdi[45]*)+ version_type=linux # correct to gnu/linux during the next big refactor+ need_version=no+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'+ shlibpath_var=LD_LIBRARY_PATH+ sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"+ sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"+ # the default ld.so.conf also contains /usr/contrib/lib and+ # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow+ # libtool to hard-code these into programs+ ;;++cygwin* | mingw* | pw32* | cegcc*)+ version_type=windows+ shrext_cmds=.dll+ need_version=no+ need_lib_prefix=no++ case $GCC,$cc_basename in+ yes,*)+ # gcc+ library_names_spec='$libname.dll.a'+ # DLL is installed to $(libdir)/../bin by postinstall_cmds+ postinstall_cmds='base_file=`basename \$file`~+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~+ dldir=$destdir/`dirname \$dlpath`~+ test -d \$dldir || mkdir -p \$dldir~+ $install_prog $dir/$dlname \$dldir/$dlname~+ chmod a+x \$dldir/$dlname~+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;+ fi'+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~+ dlpath=$dir/\$dldll~+ $RM \$dlpath'+ shlibpath_overrides_runpath=yes++ case $host_os in+ cygwin*)+ # Cygwin DLLs use 'cyg' prefix rather than 'lib'+ soname_spec='`echo $libname | $SED -e 's/^lib/cyg/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'++ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/lib/w32api"+ ;;+ mingw* | cegcc*)+ # MinGW DLLs use traditional 'lib' prefix+ soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'+ ;;+ pw32*)+ # pw32 DLLs use 'pw' prefix rather than 'lib'+ library_names_spec='`echo $libname | $SED -e 's/^lib/pw/'``echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'+ ;;+ esac+ dynamic_linker='Win32 ld.exe'+ ;;++ *,cl* | *,icl*)+ # Native MSVC or ICC+ libname_spec='$name'+ soname_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext'+ library_names_spec='$libname.dll.lib'++ case $build_os in+ mingw*)+ sys_lib_search_path_spec=+ lt_save_ifs=$IFS+ IFS=';'+ for lt_path in $LIB+ do+ IFS=$lt_save_ifs+ # Let DOS variable expansion print the short 8.3 style file name.+ lt_path=`cd "$lt_path" 2>/dev/null && cmd //C "for %i in (".") do @echo %~si"`+ sys_lib_search_path_spec="$sys_lib_search_path_spec $lt_path"+ done+ IFS=$lt_save_ifs+ # Convert to MSYS style.+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's|\\\\|/|g' -e 's| \\([a-zA-Z]\\):| /\\1|g' -e 's|^ ||'`+ ;;+ cygwin*)+ # Convert to unix form, then to dos form, then back to unix form+ # but this time dos style (no spaces!) so that the unix form looks+ # like /cygdrive/c/PROGRA~1:/cygdr...+ sys_lib_search_path_spec=`cygpath --path --unix "$LIB"`+ sys_lib_search_path_spec=`cygpath --path --dos "$sys_lib_search_path_spec" 2>/dev/null`+ sys_lib_search_path_spec=`cygpath --path --unix "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`+ ;;+ *)+ sys_lib_search_path_spec=$LIB+ if $ECHO "$sys_lib_search_path_spec" | $GREP ';[c-zC-Z]:/' >/dev/null; then+ # It is most probably a Windows format PATH.+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`+ else+ sys_lib_search_path_spec=`$ECHO "$sys_lib_search_path_spec" | $SED -e "s/$PATH_SEPARATOR/ /g"`+ fi+ # FIXME: find the short name or the path components, as spaces are+ # common. (e.g. "Program Files" -> "PROGRA~1")+ ;;+ esac++ # DLL is installed to $(libdir)/../bin by postinstall_cmds+ postinstall_cmds='base_file=`basename \$file`~+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; echo \$dlname'\''`~+ dldir=$destdir/`dirname \$dlpath`~+ test -d \$dldir || mkdir -p \$dldir~+ $install_prog $dir/$dlname \$dldir/$dlname'+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~+ dlpath=$dir/\$dldll~+ $RM \$dlpath'+ shlibpath_overrides_runpath=yes+ dynamic_linker='Win32 link.exe'+ ;;++ *)+ # Assume MSVC and ICC wrapper+ library_names_spec='$libname`echo $release | $SED -e 's/[.]/-/g'`$versuffix$shared_ext $libname.lib'+ dynamic_linker='Win32 ld.exe'+ ;;+ esac+ # FIXME: first we should search . and the directory the executable is in+ shlibpath_var=PATH+ ;;++darwin* | rhapsody*)+ dynamic_linker="$host_os dyld"+ version_type=darwin+ need_lib_prefix=no+ need_version=no+ library_names_spec='$libname$release$major$shared_ext $libname$shared_ext'+ soname_spec='$libname$release$major$shared_ext'+ shlibpath_overrides_runpath=yes+ shlibpath_var=DYLD_LIBRARY_PATH+ shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'++ sys_lib_search_path_spec="$sys_lib_search_path_spec /usr/local/lib"+ sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'+ ;;++dgux*)+ version_type=linux # correct to gnu/linux during the next big refactor+ need_lib_prefix=no+ need_version=no+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ shlibpath_var=LD_LIBRARY_PATH+ ;;++freebsd* | dragonfly* | midnightbsd*)+ # DragonFly does not have aout. When/if they implement a new+ # versioning mechanism, adjust this.+ if test -x /usr/bin/objformat; then+ objformat=`/usr/bin/objformat`+ else+ case $host_os in+ freebsd[23].*) objformat=aout ;;+ *) objformat=elf ;;+ esac+ fi+ version_type=freebsd-$objformat+ case $version_type in+ freebsd-elf*)+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ need_version=no+ need_lib_prefix=no+ ;;+ freebsd-*)+ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'+ need_version=yes+ ;;+ esac+ shlibpath_var=LD_LIBRARY_PATH+ case $host_os in+ freebsd2.*)+ shlibpath_overrides_runpath=yes+ ;;+ freebsd3.[01]* | freebsdelf3.[01]*)+ shlibpath_overrides_runpath=yes+ hardcode_into_libs=yes+ ;;+ freebsd3.[2-9]* | freebsdelf3.[2-9]* | \+ freebsd4.[0-5] | freebsdelf4.[0-5] | freebsd4.1.1 | freebsdelf4.1.1)+ shlibpath_overrides_runpath=no+ hardcode_into_libs=yes+ ;;+ *) # from 4.6 on, and DragonFly+ shlibpath_overrides_runpath=yes+ hardcode_into_libs=yes+ ;;+ esac+ ;;++haiku*)+ version_type=linux # correct to gnu/linux during the next big refactor+ need_lib_prefix=no+ need_version=no+ dynamic_linker="$host_os runtime_loader"+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ shlibpath_var=LIBRARY_PATH+ shlibpath_overrides_runpath=no+ sys_lib_dlsearch_path_spec='/boot/home/config/lib /boot/common/lib /boot/system/lib'+ hardcode_into_libs=yes+ ;;++hpux9* | hpux10* | hpux11*)+ # Give a soname corresponding to the major version so that dld.sl refuses to+ # link against other versions.+ version_type=sunos+ need_lib_prefix=no+ need_version=no+ case $host_cpu in+ ia64*)+ shrext_cmds='.so'+ hardcode_into_libs=yes+ dynamic_linker="$host_os dld.so"+ shlibpath_var=LD_LIBRARY_PATH+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ if test 32 = "$HPUX_IA64_MODE"; then+ sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"+ sys_lib_dlsearch_path_spec=/usr/lib/hpux32+ else+ sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"+ sys_lib_dlsearch_path_spec=/usr/lib/hpux64+ fi+ ;;+ hppa*64*)+ shrext_cmds='.sl'+ hardcode_into_libs=yes+ dynamic_linker="$host_os dld.sl"+ shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH+ shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec+ ;;+ *)+ shrext_cmds='.sl'+ dynamic_linker="$host_os dld.sl"+ shlibpath_var=SHLIB_PATH+ shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ ;;+ esac+ # HP-UX runs *really* slowly unless shared libraries are mode 555, ...+ postinstall_cmds='chmod 555 $lib'+ # or fails outright, so override atomically:+ install_override_mode=555+ ;;++interix[3-9]*)+ version_type=linux # correct to gnu/linux during the next big refactor+ need_lib_prefix=no+ need_version=no+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ dynamic_linker='Interix 3.x ld.so.1 (PE, like ELF)'+ shlibpath_var=LD_LIBRARY_PATH+ shlibpath_overrides_runpath=no+ hardcode_into_libs=yes+ ;;++irix5* | irix6* | nonstopux*)+ case $host_os in+ nonstopux*) version_type=nonstopux ;;+ *)+ if test yes = "$lt_cv_prog_gnu_ld"; then+ version_type=linux # correct to gnu/linux during the next big refactor+ else+ version_type=irix+ fi ;;+ esac+ need_lib_prefix=no+ need_version=no+ soname_spec='$libname$release$shared_ext$major'+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$release$shared_ext $libname$shared_ext'+ case $host_os in+ irix5* | nonstopux*)+ libsuff= shlibsuff=+ ;;+ *)+ case $LD in # libtool.m4 will add one of these switches to LD+ *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")+ libsuff= shlibsuff= libmagic=32-bit;;+ *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")+ libsuff=32 shlibsuff=N32 libmagic=N32;;+ *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")+ libsuff=64 shlibsuff=64 libmagic=64-bit;;+ *) libsuff= shlibsuff= libmagic=never-match;;+ esac+ ;;+ esac+ shlibpath_var=LD_LIBRARY${shlibsuff}_PATH+ shlibpath_overrides_runpath=no+ sys_lib_search_path_spec="/usr/lib$libsuff /lib$libsuff /usr/local/lib$libsuff"+ sys_lib_dlsearch_path_spec="/usr/lib$libsuff /lib$libsuff"+ hardcode_into_libs=yes+ ;;++# No shared lib support for Linux oldld, aout, or coff.+linux*oldld* | linux*aout* | linux*coff*)+ dynamic_linker=no+ ;;++linux*android*)+ version_type=none # Android doesn't support versioned libraries.+ need_lib_prefix=no+ need_version=no+ library_names_spec='$libname$release$shared_ext'+ soname_spec='$libname$release$shared_ext'+ finish_cmds=+ shlibpath_var=LD_LIBRARY_PATH+ shlibpath_overrides_runpath=yes++ # This implies no fast_install, which is unacceptable.+ # Some rework will be needed to allow for fast_install+ # before this can be enabled.+ hardcode_into_libs=yes++ dynamic_linker='Android linker'+ # Don't embed -rpath directories since the linker doesn't support them.+ hardcode_libdir_flag_spec='-L$libdir'+ ;;++# This must be glibc/ELF.+linux* | k*bsd*-gnu | kopensolaris*-gnu | gnu*)+ version_type=linux # correct to gnu/linux during the next big refactor+ need_lib_prefix=no+ need_version=no+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'+ shlibpath_var=LD_LIBRARY_PATH+ shlibpath_overrides_runpath=no++ # Some binutils ld are patched to set DT_RUNPATH+ if test ${lt_cv_shlibpath_overrides_runpath+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) lt_cv_shlibpath_overrides_runpath=no+ save_LDFLAGS=$LDFLAGS+ save_libdir=$libdir+ eval "libdir=/foo; wl=\"$lt_prog_compiler_wl\"; \+ LDFLAGS=\"\$LDFLAGS $hardcode_libdir_flag_spec\""+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ if ($OBJDUMP -p conftest$ac_exeext) 2>/dev/null | grep "RUNPATH.*$libdir" >/dev/null+then :+ lt_cv_shlibpath_overrides_runpath=yes+fi+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ LDFLAGS=$save_LDFLAGS+ libdir=$save_libdir+ ;;+esac+fi++ shlibpath_overrides_runpath=$lt_cv_shlibpath_overrides_runpath++ # This implies no fast_install, which is unacceptable.+ # Some rework will be needed to allow for fast_install+ # before this can be enabled.+ hardcode_into_libs=yes++ # Ideally, we could use ldconfig to report *all* directores which are+ # searched for libraries, however this is still not possible. Aside from not+ # being certain /sbin/ldconfig is available, command+ # 'ldconfig -N -X -v | grep ^/' on 64bit Fedora does not report /usr/lib64,+ # even though it is searched at run-time. Try to do the best guess by+ # appending ld.so.conf contents (and includes) to the search path.+ if test -f /etc/ld.so.conf; then+ lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s 2>/dev/null", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;/^[ ]*hwcap[ ]/d;s/[:, ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;s/"//g;/^$/d' | tr '\n' ' '`+ sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"+ fi++ # We used to test for /lib/ld.so.1 and disable shared libraries on+ # powerpc, because MkLinux only supported shared libraries with the+ # GNU dynamic linker. Since this was broken with cross compilers,+ # most powerpc-linux boxes support dynamic linking these days and+ # people can always --disable-shared, the test was removed, and we+ # assume the GNU/Linux dynamic linker is in use.+ dynamic_linker='GNU/Linux ld.so'+ ;;++netbsd*)+ version_type=sunos+ need_lib_prefix=no+ need_version=no+ if echo __ELF__ | $CC -E - | $GREP __ELF__ >/dev/null; then+ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'+ dynamic_linker='NetBSD (a.out) ld.so'+ else+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ dynamic_linker='NetBSD ld.elf_so'+ fi+ shlibpath_var=LD_LIBRARY_PATH+ shlibpath_overrides_runpath=yes+ hardcode_into_libs=yes+ ;;++newsos6)+ version_type=linux # correct to gnu/linux during the next big refactor+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ shlibpath_var=LD_LIBRARY_PATH+ shlibpath_overrides_runpath=yes+ ;;++*nto* | *qnx*)+ version_type=qnx+ need_lib_prefix=no+ need_version=no+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ shlibpath_var=LD_LIBRARY_PATH+ shlibpath_overrides_runpath=no+ hardcode_into_libs=yes+ dynamic_linker='ldqnx.so'+ ;;++openbsd* | bitrig*)+ version_type=sunos+ sys_lib_dlsearch_path_spec=/usr/lib+ need_lib_prefix=no+ if test -z "`echo __ELF__ | $CC -E - | $GREP __ELF__`"; then+ need_version=no+ else+ need_version=yes+ fi+ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'+ finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'+ shlibpath_var=LD_LIBRARY_PATH+ shlibpath_overrides_runpath=yes+ ;;++os2*)+ libname_spec='$name'+ version_type=windows+ shrext_cmds=.dll+ need_version=no+ need_lib_prefix=no+ # OS/2 can only load a DLL with a base name of 8 characters or less.+ soname_spec='`test -n "$os2dllname" && libname="$os2dllname";+ v=$($ECHO $release$versuffix | tr -d .-);+ n=$($ECHO $libname | cut -b -$((8 - ${#v})) | tr . _);+ $ECHO $n$v`$shared_ext'+ library_names_spec='${libname}_dll.$libext'+ dynamic_linker='OS/2 ld.exe'+ shlibpath_var=BEGINLIBPATH+ sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec+ postinstall_cmds='base_file=`basename \$file`~+ dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\$base_file'\''i; $ECHO \$dlname'\''`~+ dldir=$destdir/`dirname \$dlpath`~+ test -d \$dldir || mkdir -p \$dldir~+ $install_prog $dir/$dlname \$dldir/$dlname~+ chmod a+x \$dldir/$dlname~+ if test -n '\''$stripme'\'' && test -n '\''$striplib'\''; then+ eval '\''$striplib \$dldir/$dlname'\'' || exit \$?;+ fi'+ postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; $ECHO \$dlname'\''`~+ dlpath=$dir/\$dldll~+ $RM \$dlpath'+ ;;++osf3* | osf4* | osf5*)+ version_type=osf+ need_lib_prefix=no+ need_version=no+ soname_spec='$libname$release$shared_ext$major'+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ shlibpath_var=LD_LIBRARY_PATH+ sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"+ sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec+ ;;++rdos*)+ dynamic_linker=no+ ;;++solaris*)+ version_type=linux # correct to gnu/linux during the next big refactor+ need_lib_prefix=no+ need_version=no+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ shlibpath_var=LD_LIBRARY_PATH+ shlibpath_overrides_runpath=yes+ hardcode_into_libs=yes+ # ldd complains unless libraries are executable+ postinstall_cmds='chmod +x $lib'+ ;;++sunos4*)+ version_type=sunos+ library_names_spec='$libname$release$shared_ext$versuffix $libname$shared_ext$versuffix'+ finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'+ shlibpath_var=LD_LIBRARY_PATH+ shlibpath_overrides_runpath=yes+ if test yes = "$with_gnu_ld"; then+ need_lib_prefix=no+ fi+ need_version=yes+ ;;++sysv4 | sysv4.3*)+ version_type=linux # correct to gnu/linux during the next big refactor+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ shlibpath_var=LD_LIBRARY_PATH+ case $host_vendor in+ sni)+ shlibpath_overrides_runpath=no+ need_lib_prefix=no+ runpath_var=LD_RUN_PATH+ ;;+ siemens)+ need_lib_prefix=no+ ;;+ motorola)+ need_lib_prefix=no+ need_version=no+ shlibpath_overrides_runpath=no+ sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'+ ;;+ esac+ ;;++sysv4*MP*)+ if test -d /usr/nec; then+ version_type=linux # correct to gnu/linux during the next big refactor+ library_names_spec='$libname$shared_ext.$versuffix $libname$shared_ext.$major $libname$shared_ext'+ soname_spec='$libname$shared_ext.$major'+ shlibpath_var=LD_LIBRARY_PATH+ fi+ ;;++sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)+ version_type=sco+ need_lib_prefix=no+ need_version=no+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ shlibpath_var=LD_LIBRARY_PATH+ shlibpath_overrides_runpath=yes+ hardcode_into_libs=yes+ if test yes = "$with_gnu_ld"; then+ sys_lib_search_path_spec='/usr/local/lib /usr/gnu/lib /usr/ccs/lib /usr/lib /lib'+ else+ sys_lib_search_path_spec='/usr/ccs/lib /usr/lib'+ case $host_os in+ sco3.2v5*)+ sys_lib_search_path_spec="$sys_lib_search_path_spec /lib"+ ;;+ esac+ fi+ sys_lib_dlsearch_path_spec='/usr/lib'+ ;;++tpf*)+ # TPF is a cross-target only. Preferred cross-host = GNU/Linux.+ version_type=linux # correct to gnu/linux during the next big refactor+ need_lib_prefix=no+ need_version=no+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ shlibpath_var=LD_LIBRARY_PATH+ shlibpath_overrides_runpath=no+ hardcode_into_libs=yes+ ;;++uts4*)+ version_type=linux # correct to gnu/linux during the next big refactor+ library_names_spec='$libname$release$shared_ext$versuffix $libname$release$shared_ext$major $libname$shared_ext'+ soname_spec='$libname$release$shared_ext$major'+ shlibpath_var=LD_LIBRARY_PATH+ ;;++*)+ dynamic_linker=no+ ;;+esac+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5+printf "%s\n" "$dynamic_linker" >&6; }+test no = "$dynamic_linker" && can_build_shared=no++variables_saved_for_relink="PATH $shlibpath_var $runpath_var"+if test yes = "$GCC"; then+ variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"+fi++if test set = "${lt_cv_sys_lib_search_path_spec+set}"; then+ sys_lib_search_path_spec=$lt_cv_sys_lib_search_path_spec+fi++if test set = "${lt_cv_sys_lib_dlsearch_path_spec+set}"; then+ sys_lib_dlsearch_path_spec=$lt_cv_sys_lib_dlsearch_path_spec+fi++# remember unaugmented sys_lib_dlsearch_path content for libtool script decls...+configure_time_dlsearch_path=$sys_lib_dlsearch_path_spec++# ... but it needs LT_SYS_LIBRARY_PATH munging for other configure-time code+func_munge_path_list sys_lib_dlsearch_path_spec "$LT_SYS_LIBRARY_PATH"++# to be used as default LT_SYS_LIBRARY_PATH value in generated libtool+configure_time_lt_sys_library_path=$LT_SYS_LIBRARY_PATH++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5+printf %s "checking how to hardcode library paths into programs... " >&6; }+hardcode_action=+if test -n "$hardcode_libdir_flag_spec" ||+ test -n "$runpath_var" ||+ test yes = "$hardcode_automatic"; then++ # We can hardcode non-existent directories.+ if test no != "$hardcode_direct" &&+ # If the only mechanism to avoid hardcoding is shlibpath_var, we+ # have to relink, otherwise we might link with an installed library+ # when we should be linking with a yet-to-be-installed one+ ## test no != "$_LT_TAGVAR(hardcode_shlibpath_var, )" &&+ test no != "$hardcode_minus_L"; then+ # Linking always hardcodes the temporary library directory.+ hardcode_action=relink+ else+ # We can link without hardcoding, and we can hardcode nonexisting dirs.+ hardcode_action=immediate+ fi+else+ # We cannot hardcode anything, or else we can only hardcode existing+ # directories.+ hardcode_action=unsupported+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5+printf "%s\n" "$hardcode_action" >&6; }++if test relink = "$hardcode_action" ||+ test yes = "$inherit_rpath"; then+ # Fast installation is not supported+ enable_fast_install=no+elif test yes = "$shlibpath_overrides_runpath" ||+ test no = "$enable_shared"; then+ # Fast installation is not necessary+ enable_fast_install=needless+fi+++++++ if test yes != "$enable_dlopen"; then+ enable_dlopen=unknown+ enable_dlopen_self=unknown+ enable_dlopen_self_static=unknown+else+ lt_cv_dlopen=no+ lt_cv_dlopen_libs=++ case $host_os in+ beos*)+ lt_cv_dlopen=load_add_on+ lt_cv_dlopen_libs=+ lt_cv_dlopen_self=yes+ ;;++ mingw* | pw32* | cegcc*)+ lt_cv_dlopen=LoadLibrary+ lt_cv_dlopen_libs=+ ;;++ cygwin*)+ lt_cv_dlopen=dlopen+ lt_cv_dlopen_libs=+ ;;++ darwin*)+ # if libdl is installed we need to link against it+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5+printf %s "checking for dlopen in -ldl... " >&6; }+if test ${ac_cv_lib_dl_dlopen+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_check_lib_save_LIBS=$LIBS+LIBS="-ldl $LIBS"+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++/* Override any GCC internal prototype to avoid an error.+ Use char because int might match the return type of a GCC+ builtin and then its argument prototype would still apply.+ The 'extern "C"' is for builds by C++ compilers;+ although this is not generally supported in C code supporting it here+ has little cost and some practical benefit (sr 110532). */+#ifdef __cplusplus+extern "C"+#endif+char dlopen (void);+int+main (void)+{+return dlopen ();+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ ac_cv_lib_dl_dlopen=yes+else case e in #(+ e) ac_cv_lib_dl_dlopen=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+LIBS=$ac_check_lib_save_LIBS ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5+printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; }+if test "x$ac_cv_lib_dl_dlopen" = xyes+then :+ lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl+else case e in #(+ e)+ lt_cv_dlopen=dyld+ lt_cv_dlopen_libs=+ lt_cv_dlopen_self=yes+ ;;+esac+fi++ ;;++ tpf*)+ # Don't try to run any link tests for TPF. We know it's impossible+ # because TPF is a cross-compiler, and we know how we open DSOs.+ lt_cv_dlopen=dlopen+ lt_cv_dlopen_libs=+ lt_cv_dlopen_self=no+ ;;++ *)+ ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"+if test "x$ac_cv_func_shl_load" = xyes+then :+ lt_cv_dlopen=shl_load+else case e in #(+ e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5+printf %s "checking for shl_load in -ldld... " >&6; }+if test ${ac_cv_lib_dld_shl_load+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_check_lib_save_LIBS=$LIBS+LIBS="-ldld $LIBS"+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++/* Override any GCC internal prototype to avoid an error.+ Use char because int might match the return type of a GCC+ builtin and then its argument prototype would still apply.+ The 'extern "C"' is for builds by C++ compilers;+ although this is not generally supported in C code supporting it here+ has little cost and some practical benefit (sr 110532). */+#ifdef __cplusplus+extern "C"+#endif+char shl_load (void);+int+main (void)+{+return shl_load ();+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ ac_cv_lib_dld_shl_load=yes+else case e in #(+ e) ac_cv_lib_dld_shl_load=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+LIBS=$ac_check_lib_save_LIBS ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5+printf "%s\n" "$ac_cv_lib_dld_shl_load" >&6; }+if test "x$ac_cv_lib_dld_shl_load" = xyes+then :+ lt_cv_dlopen=shl_load lt_cv_dlopen_libs=-ldld+else case e in #(+ e) ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"+if test "x$ac_cv_func_dlopen" = xyes+then :+ lt_cv_dlopen=dlopen+else case e in #(+ e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5+printf %s "checking for dlopen in -ldl... " >&6; }+if test ${ac_cv_lib_dl_dlopen+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_check_lib_save_LIBS=$LIBS+LIBS="-ldl $LIBS"+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++/* Override any GCC internal prototype to avoid an error.+ Use char because int might match the return type of a GCC+ builtin and then its argument prototype would still apply.+ The 'extern "C"' is for builds by C++ compilers;+ although this is not generally supported in C code supporting it here+ has little cost and some practical benefit (sr 110532). */+#ifdef __cplusplus+extern "C"+#endif+char dlopen (void);+int+main (void)+{+return dlopen ();+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ ac_cv_lib_dl_dlopen=yes+else case e in #(+ e) ac_cv_lib_dl_dlopen=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+LIBS=$ac_check_lib_save_LIBS ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5+printf "%s\n" "$ac_cv_lib_dl_dlopen" >&6; }+if test "x$ac_cv_lib_dl_dlopen" = xyes+then :+ lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-ldl+else case e in #(+ e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5+printf %s "checking for dlopen in -lsvld... " >&6; }+if test ${ac_cv_lib_svld_dlopen+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_check_lib_save_LIBS=$LIBS+LIBS="-lsvld $LIBS"+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++/* Override any GCC internal prototype to avoid an error.+ Use char because int might match the return type of a GCC+ builtin and then its argument prototype would still apply.+ The 'extern "C"' is for builds by C++ compilers;+ although this is not generally supported in C code supporting it here+ has little cost and some practical benefit (sr 110532). */+#ifdef __cplusplus+extern "C"+#endif+char dlopen (void);+int+main (void)+{+return dlopen ();+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ ac_cv_lib_svld_dlopen=yes+else case e in #(+ e) ac_cv_lib_svld_dlopen=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+LIBS=$ac_check_lib_save_LIBS ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5+printf "%s\n" "$ac_cv_lib_svld_dlopen" >&6; }+if test "x$ac_cv_lib_svld_dlopen" = xyes+then :+ lt_cv_dlopen=dlopen lt_cv_dlopen_libs=-lsvld+else case e in #(+ e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5+printf %s "checking for dld_link in -ldld... " >&6; }+if test ${ac_cv_lib_dld_dld_link+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_check_lib_save_LIBS=$LIBS+LIBS="-ldld $LIBS"+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++/* Override any GCC internal prototype to avoid an error.+ Use char because int might match the return type of a GCC+ builtin and then its argument prototype would still apply.+ The 'extern "C"' is for builds by C++ compilers;+ although this is not generally supported in C code supporting it here+ has little cost and some practical benefit (sr 110532). */+#ifdef __cplusplus+extern "C"+#endif+char dld_link (void);+int+main (void)+{+return dld_link ();+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ ac_cv_lib_dld_dld_link=yes+else case e in #(+ e) ac_cv_lib_dld_dld_link=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+LIBS=$ac_check_lib_save_LIBS ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5+printf "%s\n" "$ac_cv_lib_dld_dld_link" >&6; }+if test "x$ac_cv_lib_dld_dld_link" = xyes+then :+ lt_cv_dlopen=dld_link lt_cv_dlopen_libs=-ldld+fi++ ;;+esac+fi++ ;;+esac+fi++ ;;+esac+fi++ ;;+esac+fi++ ;;+esac+fi++ ;;+ esac++ if test no = "$lt_cv_dlopen"; then+ enable_dlopen=no+ else+ enable_dlopen=yes+ fi++ case $lt_cv_dlopen in+ dlopen)+ save_CPPFLAGS=$CPPFLAGS+ test yes = "$ac_cv_header_dlfcn_h" && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"++ save_LDFLAGS=$LDFLAGS+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"++ save_LIBS=$LIBS+ LIBS="$lt_cv_dlopen_libs $LIBS"++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5+printf %s "checking whether a program can dlopen itself... " >&6; }+if test ${lt_cv_dlopen_self+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test yes = "$cross_compiling"; then :+ lt_cv_dlopen_self=cross+else+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2+ lt_status=$lt_dlunknown+ cat > conftest.$ac_ext <<_LT_EOF+#line $LINENO "configure"+#include "confdefs.h"++#if HAVE_DLFCN_H+#include <dlfcn.h>+#endif++#include <stdio.h>++#ifdef RTLD_GLOBAL+# define LT_DLGLOBAL RTLD_GLOBAL+#else+# ifdef DL_GLOBAL+# define LT_DLGLOBAL DL_GLOBAL+# else+# define LT_DLGLOBAL 0+# endif+#endif++/* We may have to define LT_DLLAZY_OR_NOW in the command line if we+ find out it does not work in some platform. */+#ifndef LT_DLLAZY_OR_NOW+# ifdef RTLD_LAZY+# define LT_DLLAZY_OR_NOW RTLD_LAZY+# else+# ifdef DL_LAZY+# define LT_DLLAZY_OR_NOW DL_LAZY+# else+# ifdef RTLD_NOW+# define LT_DLLAZY_OR_NOW RTLD_NOW+# else+# ifdef DL_NOW+# define LT_DLLAZY_OR_NOW DL_NOW+# else+# define LT_DLLAZY_OR_NOW 0+# endif+# endif+# endif+# endif+#endif++/* When -fvisibility=hidden is used, assume the code has been annotated+ correspondingly for the symbols needed. */+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))+int fnord () __attribute__((visibility("default")));+#endif++int fnord () { return 42; }+int main ()+{+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);+ int status = $lt_dlunknown;++ if (self)+ {+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;+ else+ {+ if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;+ else puts (dlerror ());+ }+ /* dlclose (self); */+ }+ else+ puts (dlerror ());++ return status;+}+_LT_EOF+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5+ (eval $ac_link) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then+ (./conftest; exit; ) >&5 2>/dev/null+ lt_status=$?+ case x$lt_status in+ x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;+ x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;+ x$lt_dlunknown|x*) lt_cv_dlopen_self=no ;;+ esac+ else :+ # compilation failed+ lt_cv_dlopen_self=no+ fi+fi+rm -fr conftest*++ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5+printf "%s\n" "$lt_cv_dlopen_self" >&6; }++ if test yes = "$lt_cv_dlopen_self"; then+ wl=$lt_prog_compiler_wl eval LDFLAGS=\"\$LDFLAGS $lt_prog_compiler_static\"+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5+printf %s "checking whether a statically linked program can dlopen itself... " >&6; }+if test ${lt_cv_dlopen_self_static+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test yes = "$cross_compiling"; then :+ lt_cv_dlopen_self_static=cross+else+ lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2+ lt_status=$lt_dlunknown+ cat > conftest.$ac_ext <<_LT_EOF+#line $LINENO "configure"+#include "confdefs.h"++#if HAVE_DLFCN_H+#include <dlfcn.h>+#endif++#include <stdio.h>++#ifdef RTLD_GLOBAL+# define LT_DLGLOBAL RTLD_GLOBAL+#else+# ifdef DL_GLOBAL+# define LT_DLGLOBAL DL_GLOBAL+# else+# define LT_DLGLOBAL 0+# endif+#endif++/* We may have to define LT_DLLAZY_OR_NOW in the command line if we+ find out it does not work in some platform. */+#ifndef LT_DLLAZY_OR_NOW+# ifdef RTLD_LAZY+# define LT_DLLAZY_OR_NOW RTLD_LAZY+# else+# ifdef DL_LAZY+# define LT_DLLAZY_OR_NOW DL_LAZY+# else+# ifdef RTLD_NOW+# define LT_DLLAZY_OR_NOW RTLD_NOW+# else+# ifdef DL_NOW+# define LT_DLLAZY_OR_NOW DL_NOW+# else+# define LT_DLLAZY_OR_NOW 0+# endif+# endif+# endif+# endif+#endif++/* When -fvisibility=hidden is used, assume the code has been annotated+ correspondingly for the symbols needed. */+#if defined __GNUC__ && (((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)) || (__GNUC__ > 3))+int fnord () __attribute__((visibility("default")));+#endif++int fnord () { return 42; }+int main ()+{+ void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);+ int status = $lt_dlunknown;++ if (self)+ {+ if (dlsym (self,"fnord")) status = $lt_dlno_uscore;+ else+ {+ if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;+ else puts (dlerror ());+ }+ /* dlclose (self); */+ }+ else+ puts (dlerror ());++ return status;+}+_LT_EOF+ if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5+ (eval $ac_link) 2>&5+ ac_status=$?+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5+ test $ac_status = 0; } && test -s "conftest$ac_exeext" 2>/dev/null; then+ (./conftest; exit; ) >&5 2>/dev/null+ lt_status=$?+ case x$lt_status in+ x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;+ x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;+ x$lt_dlunknown|x*) lt_cv_dlopen_self_static=no ;;+ esac+ else :+ # compilation failed+ lt_cv_dlopen_self_static=no+ fi+fi+rm -fr conftest*++ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5+printf "%s\n" "$lt_cv_dlopen_self_static" >&6; }+ fi++ CPPFLAGS=$save_CPPFLAGS+ LDFLAGS=$save_LDFLAGS+ LIBS=$save_LIBS+ ;;+ esac++ case $lt_cv_dlopen_self in+ yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;+ *) enable_dlopen_self=unknown ;;+ esac++ case $lt_cv_dlopen_self_static in+ yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;+ *) enable_dlopen_self_static=unknown ;;+ esac+fi++++++++++++++++++striplib=+old_striplib=+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5+printf %s "checking whether stripping libraries is possible... " >&6; }+if test -z "$STRIP"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+else+ if $STRIP -V 2>&1 | $GREP "GNU strip" >/dev/null; then+ old_striplib="$STRIP --strip-debug"+ striplib="$STRIP --strip-unneeded"+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }+ else+ case $host_os in+ darwin*)+ # FIXME - insert some real tests, host_os isn't really good enough+ striplib="$STRIP -x"+ old_striplib="$STRIP -S"+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }+ ;;+ freebsd*)+ if $STRIP -V 2>&1 | $GREP "elftoolchain" >/dev/null; then+ old_striplib="$STRIP --strip-debug"+ striplib="$STRIP --strip-unneeded"+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }+ else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+ fi+ ;;+ *)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+ ;;+ esac+ fi+fi+++++++++++++ # Report what library types will actually be built+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5+printf %s "checking if libtool supports shared libraries... " >&6; }+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5+printf "%s\n" "$can_build_shared" >&6; }++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5+printf %s "checking whether to build shared libraries... " >&6; }+ test no = "$can_build_shared" && enable_shared=no++ # On AIX, shared libraries and static libraries use the same namespace, and+ # are all built from PIC.+ case $host_os in+ aix3*)+ test yes = "$enable_shared" && enable_static=no+ if test -n "$RANLIB"; then+ archive_cmds="$archive_cmds~\$RANLIB \$lib"+ postinstall_cmds='$RANLIB $lib'+ fi+ ;;++ aix[4-9]*)+ if test ia64 != "$host_cpu"; then+ case $enable_shared,$with_aix_soname,$aix_use_runtimelinking in+ yes,aix,yes) ;; # shared object as lib.so file only+ yes,svr4,*) ;; # shared object as lib.so archive member only+ yes,*) enable_static=no ;; # shared object in lib.a archive as well+ esac+ fi+ ;;+ esac+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5+printf "%s\n" "$enable_shared" >&6; }++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5+printf %s "checking whether to build static libraries... " >&6; }+ # Make sure either enable_shared or enable_static is yes.+ test yes = "$enable_shared" || enable_static=yes+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5+printf "%s\n" "$enable_static" >&6; }+++++fi+ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu++CC=$lt_save_CC++++++++++++++++ ac_config_commands="$ac_config_commands libtool"+++++# Only expand once:+++if test -n "$ac_tool_prefix"; then+ # Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args.+set dummy ${ac_tool_prefix}windres; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_RC+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$RC"; then+ ac_cv_prog_RC="$RC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_RC="${ac_tool_prefix}windres"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+RC=$ac_cv_prog_RC+if test -n "$RC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $RC" >&5+printf "%s\n" "$RC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++fi+if test -z "$ac_cv_prog_RC"; then+ ac_ct_RC=$RC+ # Extract the first word of "windres", so it can be a program name with args.+set dummy windres; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_prog_ac_ct_RC+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if test -n "$ac_ct_RC"; then+ ac_cv_prog_ac_ct_RC="$ac_ct_RC" # Let the user override the test.+else+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_prog_ac_ct_RC="windres"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++fi ;;+esac+fi+ac_ct_RC=$ac_cv_prog_ac_ct_RC+if test -n "$ac_ct_RC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RC" >&5+printf "%s\n" "$ac_ct_RC" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ if test "x$ac_ct_RC" = x; then+ RC=""+ else+ case $cross_compiling:$ac_tool_warned in+yes:)+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5+printf "%s\n" "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}+ac_tool_warned=yes ;;+esac+ RC=$ac_ct_RC+ fi+else+ RC="$ac_cv_prog_RC"+fi+++++# Source file extension for RC test sources.+ac_ext=rc++# Object file extension for compiled RC test sources.+objext=o+objext_RC=$objext++# Code to be used in simple compile tests+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }'++# Code to be used in simple link tests+lt_simple_link_test_code=$lt_simple_compile_test_code++# ltmain only uses $CC for tagged configurations so make sure $CC is set.+++++++# If no C compiler was specified, use CC.+LTCC=${LTCC-"$CC"}++# If no C compiler flags were specified, use CFLAGS.+LTCFLAGS=${LTCFLAGS-"$CFLAGS"}++# Allow CC to be a program name with arguments.+compiler=$CC+++# save warnings/boilerplate of simple test code+ac_outfile=conftest.$ac_objext+echo "$lt_simple_compile_test_code" >conftest.$ac_ext+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err+_lt_compiler_boilerplate=`cat conftest.err`+$RM conftest*++ac_outfile=conftest.$ac_objext+echo "$lt_simple_link_test_code" >conftest.$ac_ext+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d; /^ *+/d' >conftest.err+_lt_linker_boilerplate=`cat conftest.err`+$RM -r conftest*+++# Allow CC to be a program name with arguments.+lt_save_CC=$CC+lt_save_CFLAGS=$CFLAGS+lt_save_GCC=$GCC+GCC=+CC=${RC-"windres"}+CFLAGS=+compiler=$CC+compiler_RC=$CC+func_cc_basename $compiler+cc_basename=$func_cc_basename_result++lt_cv_prog_compiler_c_o_RC=yes++if test -n "$compiler"; then+ :++++fi++GCC=$lt_save_GCC+ac_ext=c+ac_cpp='$CPP $CPPFLAGS'+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'+ac_compiler_gnu=$ac_cv_c_compiler_gnu++CC=$lt_save_CC+CFLAGS=$lt_save_CFLAGS+++# This is a bit wrong since it is possible to request that only some libs+# are built as shared. Using that feature isn't so common though, and this+# breaks only on Windows (at least for now) if the user enables only some+# libs as shared.+ if test "x$enable_shared" != xno; then+ COND_SHARED_TRUE=+ COND_SHARED_FALSE='#'+else+ COND_SHARED_TRUE='#'+ COND_SHARED_FALSE=+fi+++#####################+# Symbol versioning #+#####################++# NOTE: This checks if we are building shared or static library+# and if --with-pic or --without-pic was used. Thus this check+# must be after Libtool initialization.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if library symbol versioning should be used" >&5+printf %s "checking if library symbol versioning should be used... " >&6; }+# Check whether --enable-symbol-versions was given.+if test ${enable_symbol_versions+y}+then :+ enableval=$enable_symbol_versions;+else case e in #(+ e) enable_symbol_versions=auto ;;+esac+fi++if test "x$enable_symbol_versions" = xauto; then+ case $host_os in+ # NOTE: Even if one omits -gnu on GNU/Linux (e.g.+ # i486-slackware-linux), configure will (via config.sub)+ # append -gnu (e.g. i486-slackware-linux-gnu), and this+ # test will work correctly.+ gnu* | *-gnu* | freebsd*)+ enable_symbol_versions=yes+ ;;+ *)+ enable_symbol_versions=no+ ;;+ esac+fi++# There are two variants for symbol versioning.+# See src/liblzma/validate_map.sh for details.+#+# On GNU/Linux, extra symbols are added in the C code. These extra symbols+# must not be put into a static library as they can cause problems (and+# even if they didn't cause problems, they would be useless). On other+# systems symbol versioning may be used too but there is no problem as only+# a linker script is specified in src/liblzma/Makefile.am and that isn't+# used when creating a static library.+#+# Libtool always uses -DPIC when building shared libraries by default and+# doesn't use it for static libs by default. This can be overridden with+# --with-pic and --without-pic though. As long as neither --with-pic nor+# --without-pic is used then we can use #ifdef PIC to detect if the file is+# being built for a shared library.+if test "x$enable_symbol_versions" = xno+then :++ enable_symbol_versions=no+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }++elif test "x$enable_shared" = xno+then :++ enable_symbol_versions=no+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no (not building a shared library)" >&5+printf "%s\n" "no (not building a shared library)" >&6; }++else case e in #(+ e)+ # "yes" means that symbol version are to be used but we need to+ # autodetect which variant to use.+ if test "x$enable_symbol_versions" = xyes ; then+ case "$host_cpu-$host_os" in+ microblaze*)+ # GCC 12 on MicroBlaze doesn't support+ # __symver__ attribute. It's simplest and+ # safest to use the generic version on that+ # platform since then only the linker script+ # is needed. The RHEL/CentOS 7 compatibility+ # symbols don't matter on MicroBlaze.+ enable_symbol_versions=generic+ ;;+ *-linux*)+ # NVIDIA HPC Compiler doesn't support symbol+ # versioning but the linker script can still+ # be used.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#ifdef __NVCOMPILER+ use_generic_symbol_versioning+ #endif+_ACEOF+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |+ $EGREP_TRADITIONAL "use_generic_symbol_versioning" >/dev/null 2>&1+then :+ enable_symbol_versions=generic+else case e in #(+ e) enable_symbol_versions=linux ;;+esac+fi+rm -rf conftest*++ ;;+ *)+ enable_symbol_versions=generic+ ;;+ esac+ fi++ if test "x$enable_symbol_versions" = xlinux ; then+ case "$pic_mode-$enable_static" in+ default-*)+ # Use symvers if PIC is defined.+ have_symbol_versions_linux=2+ ;;+ *-no)+ # Not building static library.+ # Use symvers unconditionally.+ have_symbol_versions_linux=1+ ;;+ *)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5+printf "%s\n" "" >&6; }+ as_fn_error $? "+ On GNU/Linux, building both shared and static library at the same time+ is not supported if --with-pic or --without-pic is used.+ Use either --disable-shared or --disable-static to build one type+ of library at a time. If both types are needed, build one at a time,+ possibly picking only src/liblzma/.libs/liblzma.a from the static build." "$LINENO" 5+ ;;+ esac++printf "%s\n" "#define HAVE_SYMBOL_VERSIONS_LINUX $have_symbol_versions_linux" >>confdefs.h++ elif test "x$enable_symbol_versions" != xgeneric ; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: " >&5+printf "%s\n" "" >&6; }+ as_fn_error $? "unknown symbol versioning variant '$enable_symbol_versions'" "$LINENO" 5+ fi+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes ($enable_symbol_versions)" >&5+printf "%s\n" "yes ($enable_symbol_versions)" >&6; }+ ;;+esac+fi++ if test "x$enable_symbol_versions" = xlinux; then+ COND_SYMVERS_LINUX_TRUE=+ COND_SYMVERS_LINUX_FALSE='#'+else+ COND_SYMVERS_LINUX_TRUE='#'+ COND_SYMVERS_LINUX_FALSE=+fi++ if test "x$enable_symbol_versions" = xgeneric; then+ COND_SYMVERS_GENERIC_TRUE=+ COND_SYMVERS_GENERIC_FALSE='#'+else+ COND_SYMVERS_GENERIC_TRUE='#'+ COND_SYMVERS_GENERIC_FALSE=+fi++++###############################################################################+# Checks for libraries.+###############################################################################++echo+echo "Initializing gettext:"+++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5+printf %s "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }+set x ${MAKE-make}+ac_make=`printf "%s\n" "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`+if eval test \${ac_cv_prog_make_${ac_make}_set+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat >conftest.make <<\_ACEOF+SHELL = /bin/sh+all:+ @echo '@@@%%%=$(MAKE)=@@@%%%'+_ACEOF+# GNU make sometimes prints "make[1]: Entering ...", which would confuse us.+case `${MAKE-make} -f conftest.make 2>/dev/null` in+ *@@@%%%=?*=@@@%%%*)+ eval ac_cv_prog_make_${ac_make}_set=yes;;+ *)+ eval ac_cv_prog_make_${ac_make}_set=no;;+esac+rm -f conftest.make ;;+esac+fi+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }+ SET_MAKE=+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+ SET_MAKE="MAKE=${MAKE-make}"+fi+++ # Find a good install program. We prefer a C program (faster),+# so one script is as good as another. But avoid the broken or+# incompatible versions:+# SysV /etc/install, /usr/sbin/install+# SunOS /usr/etc/install+# IRIX /sbin/install+# AIX /bin/install+# AmigaOS /C/install, which installs bootblocks on floppy discs+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag+# AFS /usr/afsws/bin/install, which mishandles nonexistent args+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"+# OS/2's system install, which has a completely different semantic+# ./install, which can be erroneously created by make from ./install.sh.+# Reject install programs that cannot install multiple files.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5+printf %s "checking for a BSD-compatible install... " >&6; }+if test -z "$INSTALL"; then+if test ${ac_cv_path_install+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ # Account for fact that we put trailing slashes in our PATH walk.+case $as_dir in #((+ ./ | /[cC]/* | \+ /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \+ ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \+ /usr/ucb/* ) ;;+ *)+ # OSF1 and SCO ODT 3.0 have their own names for install.+ # Don't use installbsd from OSF since it installs stuff as root+ # by default.+ for ac_prog in ginstall scoinst install; do+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext"; then+ if test $ac_prog = install &&+ grep dspmsg "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then+ # AIX install. It has an incompatible calling convention.+ :+ elif test $ac_prog = install &&+ grep pwplus "$as_dir$ac_prog$ac_exec_ext" >/dev/null 2>&1; then+ # program-specific install script used by HP pwplus--don't use.+ :+ else+ rm -rf conftest.one conftest.two conftest.dir+ echo one > conftest.one+ echo two > conftest.two+ mkdir conftest.dir+ if "$as_dir$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir/" &&+ test -s conftest.one && test -s conftest.two &&+ test -s conftest.dir/conftest.one &&+ test -s conftest.dir/conftest.two+ then+ ac_cv_path_install="$as_dir$ac_prog$ac_exec_ext -c"+ break 3+ fi+ fi+ fi+ done+ done+ ;;+esac++ done+IFS=$as_save_IFS++rm -rf conftest.one conftest.two conftest.dir+ ;;+esac+fi+ if test ${ac_cv_path_install+y}; then+ INSTALL=$ac_cv_path_install+ else+ # As a last resort, use the slow shell script. Don't cache a+ # value for INSTALL within a source directory, because that will+ # break other packages using the cache if that directory is+ # removed, or if the value is a relative name.+ INSTALL=$ac_install_sh+ fi+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5+printf "%s\n" "$INSTALL" >&6; }++# Use test -z because SunOS4 sh mishandles braces in ${var-val}.+# It thinks the first close brace ends the variable substitution.+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'++test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'++test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'+++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for a race-free mkdir -p" >&5+printf %s "checking for a race-free mkdir -p... " >&6; }+if test -z "$MKDIR_P"; then+ if test ${ac_cv_path_mkdir+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_prog in mkdir gmkdir; do+ for ac_exec_ext in '' $ac_executable_extensions; do+ as_fn_executable_p "$as_dir$ac_prog$ac_exec_ext" || continue+ case `"$as_dir$ac_prog$ac_exec_ext" --version 2>&1` in #(+ 'mkdir ('*'coreutils) '* | \+ *'BusyBox '* | \+ 'mkdir (fileutils) '4.1*)+ ac_cv_path_mkdir=$as_dir$ac_prog$ac_exec_ext+ break 3;;+ esac+ done+ done+ done+IFS=$as_save_IFS+ ;;+esac+fi++ test -d ./--version && rmdir ./--version+ if test ${ac_cv_path_mkdir+y}; then+ MKDIR_P="$ac_cv_path_mkdir -p"+ else+ # As a last resort, use plain mkdir -p,+ # in the hope it doesn't have the bugs of ancient mkdir.+ MKDIR_P='mkdir -p'+ fi+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5+printf "%s\n" "$MKDIR_P" >&6; }+++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether NLS is requested" >&5+printf %s "checking whether NLS is requested... " >&6; }+ # Check whether --enable-nls was given.+if test ${enable_nls+y}+then :+ enableval=$enable_nls; USE_NLS=$enableval+else case e in #(+ e) USE_NLS=yes ;;+esac+fi++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5+printf "%s\n" "$USE_NLS" >&6; }+++++ GETTEXT_MACRO_VERSION=0.20+++++# Prepare PATH_SEPARATOR.+# The user is always right.+if test "${PATH_SEPARATOR+set}" != set; then+ # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which+ # contains only /bin. Note that ksh looks also at the FPATH variable,+ # so we have to set that as well for the test.+ PATH_SEPARATOR=:+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \+ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \+ || PATH_SEPARATOR=';'+ }+fi++# Find out how to test for executable files. Don't use a zero-byte file,+# as systems may use methods other than mode bits to determine executability.+cat >conf$$.file <<_ASEOF+#! /bin/sh+exit 0+_ASEOF+chmod +x conf$$.file+if test -x conf$$.file >/dev/null 2>&1; then+ ac_executable_p="test -x"+else+ ac_executable_p="test -f"+fi+rm -f conf$$.file++# Extract the first word of "msgfmt", so it can be a program name with args.+set dummy msgfmt; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_path_MSGFMT+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) case "$MSGFMT" in+ [\\/]* | ?:[\\/]*)+ ac_cv_path_MSGFMT="$MSGFMT" # Let the user override the test with a path.+ ;;+ *)+ gt_saved_IFS="$IFS"; IFS=$PATH_SEPARATOR+ for ac_dir in $PATH; do+ IFS="$gt_saved_IFS"+ test -z "$ac_dir" && ac_dir=.+ for ac_exec_ext in '' $ac_executable_extensions; do+ if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then+ echo "$as_me: trying $ac_dir/$ac_word..." >&5+ if $ac_dir/$ac_word --statistics /dev/null >&5 2>&1 &&+ (if $ac_dir/$ac_word --statistics /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then+ ac_cv_path_MSGFMT="$ac_dir/$ac_word$ac_exec_ext"+ break 2+ fi+ fi+ done+ done+ IFS="$gt_saved_IFS"+ test -z "$ac_cv_path_MSGFMT" && ac_cv_path_MSGFMT=":"+ ;;+esac ;;+esac+fi+MSGFMT="$ac_cv_path_MSGFMT"+if test "$MSGFMT" != ":"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MSGFMT" >&5+printf "%s\n" "$MSGFMT" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ # Extract the first word of "gmsgfmt", so it can be a program name with args.+set dummy gmsgfmt; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_path_GMSGFMT+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) case $GMSGFMT in+ [\\/]* | ?:[\\/]*)+ ac_cv_path_GMSGFMT="$GMSGFMT" # Let the user override the test with a path.+ ;;+ *)+ as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ for ac_exec_ext in '' $ac_executable_extensions; do+ if as_fn_executable_p "$as_dir$ac_word$ac_exec_ext"; then+ ac_cv_path_GMSGFMT="$as_dir$ac_word$ac_exec_ext"+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: found $as_dir$ac_word$ac_exec_ext" >&5+ break 2+ fi+done+ done+IFS=$as_save_IFS++ test -z "$ac_cv_path_GMSGFMT" && ac_cv_path_GMSGFMT="$MSGFMT"+ ;;+esac ;;+esac+fi+GMSGFMT=$ac_cv_path_GMSGFMT+if test -n "$GMSGFMT"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $GMSGFMT" >&5+printf "%s\n" "$GMSGFMT" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++++ case `$GMSGFMT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in+ '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) GMSGFMT_015=: ;;+ *) GMSGFMT_015=$GMSGFMT ;;+ esac++++# Prepare PATH_SEPARATOR.+# The user is always right.+if test "${PATH_SEPARATOR+set}" != set; then+ # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which+ # contains only /bin. Note that ksh looks also at the FPATH variable,+ # so we have to set that as well for the test.+ PATH_SEPARATOR=:+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \+ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \+ || PATH_SEPARATOR=';'+ }+fi++# Find out how to test for executable files. Don't use a zero-byte file,+# as systems may use methods other than mode bits to determine executability.+cat >conf$$.file <<_ASEOF+#! /bin/sh+exit 0+_ASEOF+chmod +x conf$$.file+if test -x conf$$.file >/dev/null 2>&1; then+ ac_executable_p="test -x"+else+ ac_executable_p="test -f"+fi+rm -f conf$$.file++# Extract the first word of "xgettext", so it can be a program name with args.+set dummy xgettext; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_path_XGETTEXT+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) case "$XGETTEXT" in+ [\\/]* | ?:[\\/]*)+ ac_cv_path_XGETTEXT="$XGETTEXT" # Let the user override the test with a path.+ ;;+ *)+ gt_saved_IFS="$IFS"; IFS=$PATH_SEPARATOR+ for ac_dir in $PATH; do+ IFS="$gt_saved_IFS"+ test -z "$ac_dir" && ac_dir=.+ for ac_exec_ext in '' $ac_executable_extensions; do+ if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then+ echo "$as_me: trying $ac_dir/$ac_word..." >&5+ if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null >&5 2>&1 &&+ (if $ac_dir/$ac_word --omit-header --copyright-holder= --msgid-bugs-address= /dev/null 2>&1 >/dev/null | grep usage >/dev/null; then exit 1; else exit 0; fi); then+ ac_cv_path_XGETTEXT="$ac_dir/$ac_word$ac_exec_ext"+ break 2+ fi+ fi+ done+ done+ IFS="$gt_saved_IFS"+ test -z "$ac_cv_path_XGETTEXT" && ac_cv_path_XGETTEXT=":"+ ;;+esac ;;+esac+fi+XGETTEXT="$ac_cv_path_XGETTEXT"+if test "$XGETTEXT" != ":"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $XGETTEXT" >&5+printf "%s\n" "$XGETTEXT" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++ rm -f messages.po++ case `$XGETTEXT --version | sed 1q | sed -e 's,^[^0-9]*,,'` in+ '' | 0.[0-9] | 0.[0-9].* | 0.1[0-4] | 0.1[0-4].*) XGETTEXT_015=: ;;+ *) XGETTEXT_015=$XGETTEXT ;;+ esac++++# Prepare PATH_SEPARATOR.+# The user is always right.+if test "${PATH_SEPARATOR+set}" != set; then+ # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which+ # contains only /bin. Note that ksh looks also at the FPATH variable,+ # so we have to set that as well for the test.+ PATH_SEPARATOR=:+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \+ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \+ || PATH_SEPARATOR=';'+ }+fi++# Find out how to test for executable files. Don't use a zero-byte file,+# as systems may use methods other than mode bits to determine executability.+cat >conf$$.file <<_ASEOF+#! /bin/sh+exit 0+_ASEOF+chmod +x conf$$.file+if test -x conf$$.file >/dev/null 2>&1; then+ ac_executable_p="test -x"+else+ ac_executable_p="test -f"+fi+rm -f conf$$.file++# Extract the first word of "msgmerge", so it can be a program name with args.+set dummy msgmerge; ac_word=$2+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5+printf %s "checking for $ac_word... " >&6; }+if test ${ac_cv_path_MSGMERGE+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) case "$MSGMERGE" in+ [\\/]* | ?:[\\/]*)+ ac_cv_path_MSGMERGE="$MSGMERGE" # Let the user override the test with a path.+ ;;+ *)+ gt_saved_IFS="$IFS"; IFS=$PATH_SEPARATOR+ for ac_dir in $PATH; do+ IFS="$gt_saved_IFS"+ test -z "$ac_dir" && ac_dir=.+ for ac_exec_ext in '' $ac_executable_extensions; do+ if $ac_executable_p "$ac_dir/$ac_word$ac_exec_ext"; then+ echo "$as_me: trying $ac_dir/$ac_word..." >&5+ if $ac_dir/$ac_word --update -q /dev/null /dev/null >&5 2>&1; then+ ac_cv_path_MSGMERGE="$ac_dir/$ac_word$ac_exec_ext"+ break 2+ fi+ fi+ done+ done+ IFS="$gt_saved_IFS"+ test -z "$ac_cv_path_MSGMERGE" && ac_cv_path_MSGMERGE=":"+ ;;+esac ;;+esac+fi+MSGMERGE="$ac_cv_path_MSGMERGE"+if test "$MSGMERGE" != ":"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $MSGMERGE" >&5+printf "%s\n" "$MSGMERGE" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi+++ if LC_ALL=C $MSGMERGE --help | grep ' --for-msgfmt ' >/dev/null; then+ MSGMERGE_FOR_MSGFMT_OPTION='--for-msgfmt'+ else+ if LC_ALL=C $MSGMERGE --help | grep ' --no-fuzzy-matching ' >/dev/null; then+ MSGMERGE_FOR_MSGFMT_OPTION='--no-fuzzy-matching --no-location --quiet'+ else+ MSGMERGE_FOR_MSGFMT_OPTION='--no-location --quiet'+ fi+ fi+++ test -n "${XGETTEXT_EXTRA_OPTIONS+set}" || XGETTEXT_EXTRA_OPTIONS=+++ ac_config_commands="$ac_config_commands po-directories"++++ if test "X$prefix" = "XNONE"; then+ acl_final_prefix="$ac_default_prefix"+ else+ acl_final_prefix="$prefix"+ fi+ if test "X$exec_prefix" = "XNONE"; then+ acl_final_exec_prefix='${prefix}'+ else+ acl_final_exec_prefix="$exec_prefix"+ fi+ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ eval acl_final_exec_prefix=\"$acl_final_exec_prefix\"+ prefix="$acl_saved_prefix"++++# Check whether --with-gnu-ld was given.+if test ${with_gnu_ld+y}+then :+ withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes+else case e in #(+ e) with_gnu_ld=no ;;+esac+fi++# Prepare PATH_SEPARATOR.+# The user is always right.+if test "${PATH_SEPARATOR+set}" != set; then+ # Determine PATH_SEPARATOR by trying to find /bin/sh in a PATH which+ # contains only /bin. Note that ksh looks also at the FPATH variable,+ # so we have to set that as well for the test.+ PATH_SEPARATOR=:+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \+ && { (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 \+ || PATH_SEPARATOR=';'+ }+fi++if test -n "$LD"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld" >&5+printf %s "checking for ld... " >&6; }+elif test "$GCC" = yes; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5+printf %s "checking for ld used by $CC... " >&6; }+elif test "$with_gnu_ld" = yes; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5+printf %s "checking for GNU ld... " >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5+printf %s "checking for non-GNU ld... " >&6; }+fi+if test -n "$LD"; then+ # Let the user override the test with a path.+ :+else+ if test ${acl_cv_path_LD+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e)+ acl_cv_path_LD= # Final result of this test+ ac_prog=ld # Program to search in $PATH+ if test "$GCC" = yes; then+ # Check if gcc -print-prog-name=ld gives a path.+ case $host in+ *-*-mingw* | windows*)+ # gcc leaves a trailing carriage return which upsets mingw+ acl_output=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;+ *)+ acl_output=`($CC -print-prog-name=ld) 2>&5` ;;+ esac+ case $acl_output in+ # Accept absolute paths.+ [\\/]* | ?:[\\/]*)+ re_direlt='/[^/][^/]*/\.\./'+ # Canonicalize the pathname of ld+ acl_output=`echo "$acl_output" | sed 's%\\\\%/%g'`+ while echo "$acl_output" | grep "$re_direlt" > /dev/null 2>&1; do+ acl_output=`echo $acl_output | sed "s%$re_direlt%/%"`+ done+ # Got the pathname. No search in PATH is needed.+ acl_cv_path_LD="$acl_output"+ ac_prog=+ ;;+ "")+ # If it fails, then pretend we aren't using GCC.+ ;;+ *)+ # If it is relative, then search for the first ld in PATH.+ with_gnu_ld=unknown+ ;;+ esac+ fi+ if test -n "$ac_prog"; then+ # Search for $ac_prog in $PATH.+ acl_saved_IFS="$IFS"; IFS=$PATH_SEPARATOR+ for ac_dir in $PATH; do+ IFS="$acl_saved_IFS"+ test -z "$ac_dir" && ac_dir=.+ if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then+ acl_cv_path_LD="$ac_dir/$ac_prog"+ # Check to see if the program is GNU ld. I'd rather use --version,+ # but apparently some variants of GNU ld only accept -v.+ # Break only if it was the GNU/non-GNU ld that we prefer.+ case `"$acl_cv_path_LD" -v 2>&1 </dev/null` in+ *GNU* | *'with BFD'*)+ test "$with_gnu_ld" != no && break+ ;;+ *)+ test "$with_gnu_ld" != yes && break+ ;;+ esac+ fi+ done+ IFS="$acl_saved_IFS"+ fi+ case $host in+ *-*-aix*)+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#if defined __powerpc64__ || defined __LP64__+ int ok;+ #else+ error fail+ #endif++_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ # The compiler produces 64-bit code. Add option '-b64' so that the+ # linker groks 64-bit object files.+ case "$acl_cv_path_LD " in+ *" -b64 "*) ;;+ *) acl_cv_path_LD="$acl_cv_path_LD -b64" ;;+ esac++fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ ;;+ sparc64-*-netbsd*)+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#if defined __sparcv9 || defined __arch64__+ int ok;+ #else+ error fail+ #endif++_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++else case e in #(+ e) # The compiler produces 32-bit code. Add option '-m elf32_sparc'+ # so that the linker groks 32-bit object files.+ case "$acl_cv_path_LD " in+ *" -m elf32_sparc "*) ;;+ *) acl_cv_path_LD="$acl_cv_path_LD -m elf32_sparc" ;;+ esac+ ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ ;;+ esac+ ;;+esac+fi++ LD="$acl_cv_path_LD"+fi+if test -n "$LD"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LD" >&5+printf "%s\n" "$LD" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+ as_fn_error $? "no acceptable ld found in \$PATH" "$LINENO" 5+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5+printf %s "checking if the linker ($LD) is GNU ld... " >&6; }+if test ${acl_cv_prog_gnu_ld+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) # I'd rather use --version here, but apparently some GNU lds only accept -v.+case `$LD -v 2>&1 </dev/null` in+*GNU* | *'with BFD'*)+ acl_cv_prog_gnu_ld=yes+ ;;+*)+ acl_cv_prog_gnu_ld=no+ ;;+esac ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $acl_cv_prog_gnu_ld" >&5+printf "%s\n" "$acl_cv_prog_gnu_ld" >&6; }+with_gnu_ld=$acl_cv_prog_gnu_ld++++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for shared library run path origin" >&5+printf %s "checking for shared library run path origin... " >&6; }+if test ${acl_cv_rpath+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e)+ CC="$CC" GCC="$GCC" LDFLAGS="$LDFLAGS" LD="$LD" with_gnu_ld="$with_gnu_ld" \+ ${CONFIG_SHELL-/bin/sh} "$ac_aux_dir/config.rpath" "$host" > conftest.sh+ . ./conftest.sh+ rm -f ./conftest.sh+ acl_cv_rpath=done+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $acl_cv_rpath" >&5+printf "%s\n" "$acl_cv_rpath" >&6; }+ wl="$acl_cv_wl"+ acl_libext="$acl_cv_libext"+ acl_shlibext="$acl_cv_shlibext"+ acl_libname_spec="$acl_cv_libname_spec"+ acl_library_names_spec="$acl_cv_library_names_spec"+ acl_hardcode_libdir_flag_spec="$acl_cv_hardcode_libdir_flag_spec"+ acl_hardcode_libdir_separator="$acl_cv_hardcode_libdir_separator"+ acl_hardcode_direct="$acl_cv_hardcode_direct"+ acl_hardcode_minus_L="$acl_cv_hardcode_minus_L"+ # Check whether --enable-rpath was given.+if test ${enable_rpath+y}+then :+ enableval=$enable_rpath; :+else case e in #(+ e) enable_rpath=yes ;;+esac+fi+++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking 32-bit host C ABI" >&5+printf %s "checking 32-bit host C ABI... " >&6; }+if test ${gl_cv_host_cpu_c_abi_32bit+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) case "$host_cpu" in++ # CPUs that only support a 32-bit ABI.+ arc \+ | bfin \+ | cris* \+ | csky \+ | epiphany \+ | ft32 \+ | h8300 \+ | m68k \+ | microblaze | microblazeel \+ | nds32 | nds32le | nds32be \+ | nios2 | nios2eb | nios2el \+ | or1k* \+ | or32 \+ | sh | sh1234 | sh1234elb \+ | tic6x \+ | xtensa* )+ gl_cv_host_cpu_c_abi_32bit=yes+ ;;++ # CPUs that only support a 64-bit ABI.+ alpha | alphaev[4-8] | alphaev56 | alphapca5[67] | alphaev6[78] \+ | mmix )+ gl_cv_host_cpu_c_abi_32bit=no+ ;;++ *)+ if test -n "$gl_cv_host_cpu_c_abi"; then+ case "$gl_cv_host_cpu_c_abi" in+ i386 | x86_64-x32 | arm | armhf | arm64-ilp32 | hppa | ia64-ilp32 | mips | mipsn32 | powerpc | riscv*-ilp32* | s390 | sparc)+ gl_cv_host_cpu_c_abi_32bit=yes ;;+ x86_64 | alpha | arm64 | aarch64c | hppa64 | ia64 | mips64 | powerpc64 | powerpc64-elfv2 | riscv*-lp64* | s390x | sparc64 )+ gl_cv_host_cpu_c_abi_32bit=no ;;+ *)+ gl_cv_host_cpu_c_abi_32bit=unknown ;;+ esac+ else+ gl_cv_host_cpu_c_abi_32bit=unknown+ fi+ if test $gl_cv_host_cpu_c_abi_32bit = unknown; then+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+int test_pointer_size[sizeof (void *) - 5];++_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ gl_cv_host_cpu_c_abi_32bit=no+else case e in #(+ e) gl_cv_host_cpu_c_abi_32bit=yes ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ fi+ ;;+ esac+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_host_cpu_c_abi_32bit" >&5+printf "%s\n" "$gl_cv_host_cpu_c_abi_32bit" >&6; }++ HOST_CPU_C_ABI_32BIT="$gl_cv_host_cpu_c_abi_32bit"++++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for ELF binary format" >&5+printf %s "checking for ELF binary format... " >&6; }+if test ${gl_cv_elf+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#if defined __ELF__ || (defined __linux__ && defined __EDG__)+ Extensible Linking Format+ #endif++_ACEOF+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |+ $EGREP_TRADITIONAL "Extensible Linking Format" >/dev/null 2>&1+then :+ gl_cv_elf=yes+else case e in #(+ e) gl_cv_elf=no ;;+esac+fi+rm -rf conftest*++ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_elf" >&5+printf "%s\n" "$gl_cv_elf" >&6; }+ if test $gl_cv_elf = yes; then+ # Extract the ELF class of a file (5th byte) in decimal.+ # Cf. https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header+ if od -A x < /dev/null >/dev/null 2>/dev/null; then+ # Use POSIX od.+ func_elfclass ()+ {+ od -A n -t d1 -j 4 -N 1+ }+ else+ # Use BSD hexdump.+ func_elfclass ()+ {+ dd bs=1 count=1 skip=4 2>/dev/null | hexdump -e '1/1 "%3d "'+ echo+ }+ fi+ # Use 'expr', not 'test', to compare the values of func_elfclass, because on+ # Solaris 11 OpenIndiana and Solaris 11 OmniOS, the result is 001 or 002,+ # not 1 or 2.+ case $HOST_CPU_C_ABI_32BIT in+ yes)+ # 32-bit ABI.+ acl_is_expected_elfclass ()+ {+ expr "`func_elfclass | sed -e 's/[ ]//g'`" = 1 > /dev/null+ }+ ;;+ no)+ # 64-bit ABI.+ acl_is_expected_elfclass ()+ {+ expr "`func_elfclass | sed -e 's/[ ]//g'`" = 2 > /dev/null+ }+ ;;+ *)+ # Unknown.+ acl_is_expected_elfclass ()+ {+ :+ }+ ;;+ esac+ else+ acl_is_expected_elfclass ()+ {+ :+ }+ fi++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for the common suffixes of directories in the library search path" >&5+printf %s "checking for the common suffixes of directories in the library search path... " >&6; }+if test ${acl_cv_libdirstems+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) acl_libdirstem=lib+ acl_libdirstem2=+ acl_libdirstem3=+ case "$host_os" in+ solaris*)+ if test $HOST_CPU_C_ABI_32BIT = no; then+ acl_libdirstem2=lib/64+ case "$host_cpu" in+ sparc*) acl_libdirstem3=lib/sparcv9 ;;+ i*86 | x86_64) acl_libdirstem3=lib/amd64 ;;+ esac+ fi+ ;;+ netbsd*)+ if test $HOST_CPU_C_ABI_32BIT != no; then+ case "$host_cpu" in+ sparc*) acl_libdirstem2=lib/sparc ;;+ esac+ fi+ ;;+ *)+ searchpath=`(LC_ALL=C $CC $CPPFLAGS $CFLAGS -print-search-dirs) 2>/dev/null \+ | sed -n -e 's,^libraries: ,,p' | sed -e 's,^=,,'`+ if test $HOST_CPU_C_ABI_32BIT != no; then+ # 32-bit or unknown ABI.+ if test -d /usr/lib32; then+ acl_libdirstem2=lib32+ fi+ fi+ if test $HOST_CPU_C_ABI_32BIT != yes; then+ # 64-bit or unknown ABI.+ if test -d /usr/lib64; then+ acl_libdirstem3=lib64+ fi+ fi+ if test -n "$searchpath"; then+ acl_saved_IFS="${IFS= }"; IFS=":"+ for searchdir in $searchpath; do+ if test -d "$searchdir"; then+ case "$searchdir" in+ */lib32/ | */lib32 ) acl_libdirstem2=lib32 ;;+ */lib64/ | */lib64 ) acl_libdirstem3=lib64 ;;+ */../ | */.. )+ # Better ignore directories of this form. They are misleading.+ ;;+ *) searchdir=`cd "$searchdir" && pwd`+ case "$searchdir" in+ */lib32 ) acl_libdirstem2=lib32 ;;+ */lib64 ) acl_libdirstem3=lib64 ;;+ esac ;;+ esac+ fi+ done+ IFS="$acl_saved_IFS"+ if test $HOST_CPU_C_ABI_32BIT = yes; then+ # 32-bit ABI.+ acl_libdirstem3=+ fi+ if test $HOST_CPU_C_ABI_32BIT = no; then+ # 64-bit ABI.+ acl_libdirstem2=+ fi+ fi+ ;;+ esac+ test -n "$acl_libdirstem2" || acl_libdirstem2="$acl_libdirstem"+ test -n "$acl_libdirstem3" || acl_libdirstem3="$acl_libdirstem"+ acl_cv_libdirstems="$acl_libdirstem,$acl_libdirstem2,$acl_libdirstem3"+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $acl_cv_libdirstems" >&5+printf "%s\n" "$acl_cv_libdirstems" >&6; }+ acl_libdirstem=`echo "$acl_cv_libdirstems" | sed -e 's/,.*//'`+ acl_libdirstem2=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,//' -e 's/,.*//'`+ acl_libdirstem3=`echo "$acl_cv_libdirstems" | sed -e 's/^[^,]*,[^,]*,//' -e 's/,.*//'`++++++++++++ use_additional=yes++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"++ eval additional_includedir=\"$includedir\"+ eval additional_libdir=\"$libdir\"+ eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"+ eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"++ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"+++# Check whether --with-libiconv-prefix was given.+if test ${with_libiconv_prefix+y}+then :+ withval=$with_libiconv_prefix;+ if test "X$withval" = "Xno"; then+ use_additional=no+ else+ if test "X$withval" = "X"; then++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"++ eval additional_includedir=\"$includedir\"+ eval additional_libdir=\"$libdir\"+ eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"+ eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"++ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ else+ additional_includedir="$withval/include"+ additional_libdir="$withval/$acl_libdirstem"+ additional_libdir2="$withval/$acl_libdirstem2"+ additional_libdir3="$withval/$acl_libdirstem3"+ fi+ fi++fi++ if test "X$additional_libdir2" = "X$additional_libdir"; then+ additional_libdir2=+ fi+ if test "X$additional_libdir3" = "X$additional_libdir"; then+ additional_libdir3=+ fi+ LIBICONV=+ LTLIBICONV=+ INCICONV=+ LIBICONV_PREFIX=+ HAVE_LIBICONV=+ rpathdirs=+ ltrpathdirs=+ names_already_handled=+ names_next_round='iconv '+ while test -n "$names_next_round"; do+ names_this_round="$names_next_round"+ names_next_round=+ for name in $names_this_round; do+ already_handled=+ for n in $names_already_handled; do+ if test "$n" = "$name"; then+ already_handled=yes+ break+ fi+ done+ if test -z "$already_handled"; then+ names_already_handled="$names_already_handled $name"+ uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`+ eval value=\"\$HAVE_LIB$uppername\"+ if test -n "$value"; then+ if test "$value" = yes; then+ eval value=\"\$LIB$uppername\"+ test -z "$value" || LIBICONV="${LIBICONV}${LIBICONV:+ }$value"+ eval value=\"\$LTLIB$uppername\"+ test -z "$value" || LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$value"+ else+ :+ fi+ else+ found_dir=+ found_la=+ found_so=+ found_a=+ eval libname=\"$acl_libname_spec\" # typically: libname=lib$name+ if test -n "$acl_shlibext"; then+ shrext=".$acl_shlibext" # typically: shrext=.so+ else+ shrext=+ fi+ if test $use_additional = yes; then+ for additional_libdir_variable in additional_libdir additional_libdir2 additional_libdir3; do+ if test "X$found_dir" = "X"; then+ eval dir=\$$additional_libdir_variable+ if test -n "$dir"; then+ if test -n "$acl_shlibext"; then+ if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then+ found_dir="$dir"+ found_so="$dir/$libname$shrext"+ else+ if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then+ ver=`(cd "$dir" && \+ for f in "$libname$shrext".*; do echo "$f"; done \+ | sed -e "s,^$libname$shrext\\\\.,," \+ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \+ | sed 1q ) 2>/dev/null`+ if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then+ found_dir="$dir"+ found_so="$dir/$libname$shrext.$ver"+ fi+ else+ eval library_names=\"$acl_library_names_spec\"+ for f in $library_names; do+ if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then+ found_dir="$dir"+ found_so="$dir/$f"+ break+ fi+ done+ fi+ fi+ fi+ if test "X$found_dir" = "X"; then+ if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then+ found_dir="$dir"+ found_a="$dir/$libname.$acl_libext"+ fi+ fi+ if test "X$found_dir" != "X"; then+ if test -f "$dir/$libname.la"; then+ found_la="$dir/$libname.la"+ fi+ fi+ fi+ fi+ done+ fi+ if test "X$found_dir" = "X"; then+ for x in $LDFLAGS $LTLIBICONV; do++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"+ eval x=\"$x\"+ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ case "$x" in+ -L*)+ dir=`echo "X$x" | sed -e 's/^X-L//'`+ if test -n "$acl_shlibext"; then+ if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then+ found_dir="$dir"+ found_so="$dir/$libname$shrext"+ else+ if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then+ ver=`(cd "$dir" && \+ for f in "$libname$shrext".*; do echo "$f"; done \+ | sed -e "s,^$libname$shrext\\\\.,," \+ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \+ | sed 1q ) 2>/dev/null`+ if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then+ found_dir="$dir"+ found_so="$dir/$libname$shrext.$ver"+ fi+ else+ eval library_names=\"$acl_library_names_spec\"+ for f in $library_names; do+ if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then+ found_dir="$dir"+ found_so="$dir/$f"+ break+ fi+ done+ fi+ fi+ fi+ if test "X$found_dir" = "X"; then+ if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then+ found_dir="$dir"+ found_a="$dir/$libname.$acl_libext"+ fi+ fi+ if test "X$found_dir" != "X"; then+ if test -f "$dir/$libname.la"; then+ found_la="$dir/$libname.la"+ fi+ fi+ ;;+ esac+ if test "X$found_dir" != "X"; then+ break+ fi+ done+ fi+ if test "X$found_dir" != "X"; then+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$found_dir -l$name"+ if test "X$found_so" != "X"; then+ if test "$enable_rpath" = no \+ || test "X$found_dir" = "X/usr/$acl_libdirstem" \+ || test "X$found_dir" = "X/usr/$acl_libdirstem2" \+ || test "X$found_dir" = "X/usr/$acl_libdirstem3"; then+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"+ else+ haveit=+ for x in $ltrpathdirs; do+ if test "X$x" = "X$found_dir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ ltrpathdirs="$ltrpathdirs $found_dir"+ fi+ if test "$acl_hardcode_direct" = yes; then+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"+ else+ if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"+ haveit=+ for x in $rpathdirs; do+ if test "X$x" = "X$found_dir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ rpathdirs="$rpathdirs $found_dir"+ fi+ else+ haveit=+ for x in $LDFLAGS $LIBICONV; do++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"+ eval x=\"$x\"+ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ if test "X$x" = "X-L$found_dir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir"+ fi+ if test "$acl_hardcode_minus_L" != no; then+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_so"+ else+ LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"+ fi+ fi+ fi+ fi+ else+ if test "X$found_a" != "X"; then+ LIBICONV="${LIBICONV}${LIBICONV:+ }$found_a"+ else+ LIBICONV="${LIBICONV}${LIBICONV:+ }-L$found_dir -l$name"+ fi+ fi+ additional_includedir=+ case "$found_dir" in+ */$acl_libdirstem | */$acl_libdirstem/)+ basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`+ if test "$name" = 'iconv'; then+ LIBICONV_PREFIX="$basedir"+ fi+ additional_includedir="$basedir/include"+ ;;+ */$acl_libdirstem2 | */$acl_libdirstem2/)+ basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`+ if test "$name" = 'iconv'; then+ LIBICONV_PREFIX="$basedir"+ fi+ additional_includedir="$basedir/include"+ ;;+ */$acl_libdirstem3 | */$acl_libdirstem3/)+ basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem3/"'*$,,'`+ if test "$name" = 'iconv'; then+ LIBICONV_PREFIX="$basedir"+ fi+ additional_includedir="$basedir/include"+ ;;+ esac+ if test "X$additional_includedir" != "X"; then+ if test "X$additional_includedir" != "X/usr/include"; then+ haveit=+ if test "X$additional_includedir" = "X/usr/local/include"; then+ if test -n "$GCC"; then+ case $host_os in+ linux* | gnu* | k*bsd*-gnu) haveit=yes;;+ esac+ fi+ fi+ if test -z "$haveit"; then+ for x in $CPPFLAGS $INCICONV; do++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"+ eval x=\"$x\"+ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ if test "X$x" = "X-I$additional_includedir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ if test -d "$additional_includedir"; then+ INCICONV="${INCICONV}${INCICONV:+ }-I$additional_includedir"+ fi+ fi+ fi+ fi+ fi+ if test -n "$found_la"; then+ saved_libdir="$libdir"+ case "$found_la" in+ */* | *\\*) . "$found_la" ;;+ *) . "./$found_la" ;;+ esac+ libdir="$saved_libdir"+ for dep in $dependency_libs; do+ case "$dep" in+ -L*)+ dependency_libdir=`echo "X$dep" | sed -e 's/^X-L//'`+ if test "X$dependency_libdir" != "X/usr/$acl_libdirstem" \+ && test "X$dependency_libdir" != "X/usr/$acl_libdirstem2" \+ && test "X$dependency_libdir" != "X/usr/$acl_libdirstem3"; then+ haveit=+ if test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem" \+ || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem2" \+ || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem3"; then+ if test -n "$GCC"; then+ case $host_os in+ linux* | gnu* | k*bsd*-gnu) haveit=yes;;+ esac+ fi+ fi+ if test -z "$haveit"; then+ haveit=+ for x in $LDFLAGS $LIBICONV; do++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"+ eval x=\"$x\"+ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ if test "X$x" = "X-L$dependency_libdir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ if test -d "$dependency_libdir"; then+ LIBICONV="${LIBICONV}${LIBICONV:+ }-L$dependency_libdir"+ fi+ fi+ haveit=+ for x in $LDFLAGS $LTLIBICONV; do++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"+ eval x=\"$x\"+ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ if test "X$x" = "X-L$dependency_libdir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ if test -d "$dependency_libdir"; then+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-L$dependency_libdir"+ fi+ fi+ fi+ fi+ ;;+ -R*)+ dir=`echo "X$dep" | sed -e 's/^X-R//'`+ if test "$enable_rpath" != no; then+ haveit=+ for x in $rpathdirs; do+ if test "X$x" = "X$dir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ rpathdirs="$rpathdirs $dir"+ fi+ haveit=+ for x in $ltrpathdirs; do+ if test "X$x" = "X$dir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ ltrpathdirs="$ltrpathdirs $dir"+ fi+ fi+ ;;+ -l*)+ dep=`echo "X$dep" | sed -e 's/^X-l//'`+ if test "X$dep" != Xc \+ || case $host_os in+ linux* | gnu* | k*bsd*-gnu) false ;;+ *) true ;;+ esac; then+ names_next_round="$names_next_round $dep"+ fi+ ;;+ *.la)+ names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`+ ;;+ *)+ LIBICONV="${LIBICONV}${LIBICONV:+ }$dep"+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }$dep"+ ;;+ esac+ done+ fi+ else+ LIBICONV="${LIBICONV}${LIBICONV:+ }-l$name"+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-l$name"+ fi+ fi+ fi+ done+ done+ if test "X$rpathdirs" != "X"; then+ if test -n "$acl_hardcode_libdir_separator"; then+ alldirs=+ for found_dir in $rpathdirs; do+ alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"+ done+ acl_saved_libdir="$libdir"+ libdir="$alldirs"+ eval flag=\"$acl_hardcode_libdir_flag_spec\"+ libdir="$acl_saved_libdir"+ LIBICONV="${LIBICONV}${LIBICONV:+ }$flag"+ else+ for found_dir in $rpathdirs; do+ acl_saved_libdir="$libdir"+ libdir="$found_dir"+ eval flag=\"$acl_hardcode_libdir_flag_spec\"+ libdir="$acl_saved_libdir"+ LIBICONV="${LIBICONV}${LIBICONV:+ }$flag"+ done+ fi+ fi+ if test "X$ltrpathdirs" != "X"; then+ for found_dir in $ltrpathdirs; do+ LTLIBICONV="${LTLIBICONV}${LTLIBICONV:+ }-R$found_dir"+ done+ fi++++++++ gl_sed_double_backslashes='s/\\/\\\\/g'+ gl_sed_escape_doublequotes='s/"/\\"/g'+ gl_sed_escape_for_make_1="s,\\([ \"&'();<>\\\\\`|]\\),\\\\\\1,g"+ gl_sed_escape_for_make_2='s,\$,\\$$,g'+ case `echo r | tr -d '\r'` in+ '') gl_tr_cr='\015' ;;+ *) gl_tr_cr='\r' ;;+ esac++++++++++++++++++++++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CFPreferencesCopyAppValue" >&5+printf %s "checking for CFPreferencesCopyAppValue... " >&6; }+if test ${gt_cv_func_CFPreferencesCopyAppValue+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) gt_saved_LIBS="$LIBS"+ LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <CoreFoundation/CFPreferences.h>+int+main (void)+{+CFPreferencesCopyAppValue(NULL, NULL)+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ gt_cv_func_CFPreferencesCopyAppValue=yes+else case e in #(+ e) gt_cv_func_CFPreferencesCopyAppValue=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ LIBS="$gt_saved_LIBS" ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFPreferencesCopyAppValue" >&5+printf "%s\n" "$gt_cv_func_CFPreferencesCopyAppValue" >&6; }+ if test $gt_cv_func_CFPreferencesCopyAppValue = yes; then++printf "%s\n" "#define HAVE_CFPREFERENCESCOPYAPPVALUE 1" >>confdefs.h++ fi+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for CFLocaleCopyPreferredLanguages" >&5+printf %s "checking for CFLocaleCopyPreferredLanguages... " >&6; }+if test ${gt_cv_func_CFLocaleCopyPreferredLanguages+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) gt_saved_LIBS="$LIBS"+ LIBS="$LIBS -Wl,-framework -Wl,CoreFoundation"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <CoreFoundation/CFLocale.h>+int+main (void)+{+CFLocaleCopyPreferredLanguages();+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ gt_cv_func_CFLocaleCopyPreferredLanguages=yes+else case e in #(+ e) gt_cv_func_CFLocaleCopyPreferredLanguages=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ LIBS="$gt_saved_LIBS" ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_cv_func_CFLocaleCopyPreferredLanguages" >&5+printf "%s\n" "$gt_cv_func_CFLocaleCopyPreferredLanguages" >&6; }+ if test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then++printf "%s\n" "#define HAVE_CFLOCALECOPYPREFERREDLANGUAGES 1" >>confdefs.h++ fi+ INTL_MACOSX_LIBS=+ if test $gt_cv_func_CFPreferencesCopyAppValue = yes \+ || test $gt_cv_func_CFLocaleCopyPreferredLanguages = yes; then+ INTL_MACOSX_LIBS="-Wl,-framework -Wl,CoreFoundation -Wl,-framework -Wl,CoreServices"+ fi+++++++ LIBINTL=+ LTLIBINTL=+ POSUB=++ case " $gt_needs " in+ *" need-formatstring-macros "*) gt_api_version=3 ;;+ *" need-ngettext "*) gt_api_version=2 ;;+ *) gt_api_version=1 ;;+ esac+ gt_func_gnugettext_libc="gt_cv_func_gnugettext${gt_api_version}_libc"+ gt_func_gnugettext_libintl="gt_cv_func_gnugettext${gt_api_version}_libintl"++ if test "$USE_NLS" = "yes"; then+ gt_use_preinstalled_gnugettext=no+++ if test $gt_api_version -ge 3; then+ gt_revision_test_code='+#ifndef __GNU_GETTEXT_SUPPORTED_REVISION+#define __GNU_GETTEXT_SUPPORTED_REVISION(major) ((major) == 0 ? 0 : -1)+#endif+typedef int array [2 * (__GNU_GETTEXT_SUPPORTED_REVISION(0) >= 1) - 1];+'+ else+ gt_revision_test_code=+ fi+ if test $gt_api_version -ge 2; then+ gt_expression_test_code=' + * ngettext ("", "", 0)'+ else+ gt_expression_test_code=+ fi++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libc" >&5+printf %s "checking for GNU gettext in libc... " >&6; }+if eval test \${$gt_func_gnugettext_libc+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <libintl.h>+#ifndef __GNU_GETTEXT_SUPPORTED_REVISION+extern int _nl_msg_cat_cntr;+extern int *_nl_domain_bindings;+#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_domain_bindings)+#else+#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0+#endif+$gt_revision_test_code++int+main (void)+{++bindtextdomain ("", "");+return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ eval "$gt_func_gnugettext_libc=yes"+else case e in #(+ e) eval "$gt_func_gnugettext_libc=no" ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext ;;+esac+fi+eval ac_res=\$$gt_func_gnugettext_libc+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }++ if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" != "yes"; }; then++++++ gl_saved_CPPFLAGS="$CPPFLAGS"++ for element in $INCICONV; do+ haveit=+ for x in $CPPFLAGS; do++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"+ eval x=\"$x\"+ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ if test "X$x" = "X$element"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"+ fi+ done+++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for iconv" >&5+printf %s "checking for iconv... " >&6; }+if test ${am_cv_func_iconv+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e)+ am_cv_func_iconv="no, consider installing GNU libiconv"+ am_cv_lib_iconv=no+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <stdlib.h>+#include <iconv.h>++int+main (void)+{+iconv_t cd = iconv_open("","");+ iconv(cd,NULL,NULL,NULL,NULL);+ iconv_close(cd);+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ am_cv_func_iconv=yes+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ if test "$am_cv_func_iconv" != yes; then+ gl_saved_LIBS="$LIBS"+ LIBS="$LIBS $LIBICONV"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <stdlib.h>+#include <iconv.h>++int+main (void)+{+iconv_t cd = iconv_open("","");+ iconv(cd,NULL,NULL,NULL,NULL);+ iconv_close(cd);+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ am_cv_lib_iconv=yes+ am_cv_func_iconv=yes+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ LIBS="$gl_saved_LIBS"+ fi+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv" >&5+printf "%s\n" "$am_cv_func_iconv" >&6; }+ if test "$am_cv_func_iconv" = yes; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for working iconv" >&5+printf %s "checking for working iconv... " >&6; }+if test ${am_cv_func_iconv_works+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e)+ gl_saved_LIBS="$LIBS"+ if test $am_cv_lib_iconv = yes; then+ LIBS="$LIBS $LIBICONV"+ fi+ am_cv_func_iconv_works=no+ for ac_iconv_const in '' 'const'; do+ if test "$cross_compiling" = yes+then :+ case "$host_os" in+ aix* | hpux*) am_cv_func_iconv_works="guessing no" ;;+ *) am_cv_func_iconv_works="guessing yes" ;;+ esac+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <iconv.h>+#include <string.h>++#ifndef ICONV_CONST+# define ICONV_CONST $ac_iconv_const+#endif++int+main (void)+{+int result = 0;+ /* Test against AIX 5.1...7.2 bug: Failures are not distinguishable from+ successful returns. This is even documented in+ <https://www.ibm.com/support/knowledgecenter/ssw_aix_72/i_bostechref/iconv.html> */+ {+ iconv_t cd_utf8_to_88591 = iconv_open ("ISO8859-1", "UTF-8");+ if (cd_utf8_to_88591 != (iconv_t)(-1))+ {+ static ICONV_CONST char input[] = "\342\202\254"; /* EURO SIGN */+ char buf[10];+ ICONV_CONST char *inptr = input;+ size_t inbytesleft = strlen (input);+ char *outptr = buf;+ size_t outbytesleft = sizeof (buf);+ size_t res = iconv (cd_utf8_to_88591,+ &inptr, &inbytesleft,+ &outptr, &outbytesleft);+ if (res == 0)+ result |= 1;+ iconv_close (cd_utf8_to_88591);+ }+ }+ /* Test against Solaris 10 bug: Failures are not distinguishable from+ successful returns. */+ {+ iconv_t cd_ascii_to_88591 = iconv_open ("ISO8859-1", "646");+ if (cd_ascii_to_88591 != (iconv_t)(-1))+ {+ static ICONV_CONST char input[] = "\263";+ char buf[10];+ ICONV_CONST char *inptr = input;+ size_t inbytesleft = strlen (input);+ char *outptr = buf;+ size_t outbytesleft = sizeof (buf);+ size_t res = iconv (cd_ascii_to_88591,+ &inptr, &inbytesleft,+ &outptr, &outbytesleft);+ if (res == 0)+ result |= 2;+ iconv_close (cd_ascii_to_88591);+ }+ }+ /* Test against AIX 6.1..7.1 bug: Buffer overrun. */+ {+ iconv_t cd_88591_to_utf8 = iconv_open ("UTF-8", "ISO-8859-1");+ if (cd_88591_to_utf8 != (iconv_t)(-1))+ {+ static ICONV_CONST char input[] = "\304";+ static char buf[2] = { (char)0xDE, (char)0xAD };+ ICONV_CONST char *inptr = input;+ size_t inbytesleft = 1;+ char *outptr = buf;+ size_t outbytesleft = 1;+ size_t res = iconv (cd_88591_to_utf8,+ &inptr, &inbytesleft,+ &outptr, &outbytesleft);+ if (res != (size_t)(-1) || outptr - buf > 1 || buf[1] != (char)0xAD)+ result |= 4;+ iconv_close (cd_88591_to_utf8);+ }+ }+#if 0 /* This bug could be worked around by the caller. */+ /* Test against HP-UX 11.11 bug: Positive return value instead of 0. */+ {+ iconv_t cd_88591_to_utf8 = iconv_open ("utf8", "iso88591");+ if (cd_88591_to_utf8 != (iconv_t)(-1))+ {+ static ICONV_CONST char input[] = "\304rger mit b\366sen B\374bchen ohne Augenma\337";+ char buf[50];+ ICONV_CONST char *inptr = input;+ size_t inbytesleft = strlen (input);+ char *outptr = buf;+ size_t outbytesleft = sizeof (buf);+ size_t res = iconv (cd_88591_to_utf8,+ &inptr, &inbytesleft,+ &outptr, &outbytesleft);+ if ((int)res > 0)+ result |= 8;+ iconv_close (cd_88591_to_utf8);+ }+ }+#endif+ /* Test against HP-UX 11.11 bug: No converter from EUC-JP to UTF-8 is+ provided. */+ {+ /* Try standardized names. */+ iconv_t cd1 = iconv_open ("UTF-8", "EUC-JP");+ /* Try IRIX, OSF/1 names. */+ iconv_t cd2 = iconv_open ("UTF-8", "eucJP");+ /* Try AIX names. */+ iconv_t cd3 = iconv_open ("UTF-8", "IBM-eucJP");+ /* Try HP-UX names. */+ iconv_t cd4 = iconv_open ("utf8", "eucJP");+ if (cd1 == (iconv_t)(-1) && cd2 == (iconv_t)(-1)+ && cd3 == (iconv_t)(-1) && cd4 == (iconv_t)(-1))+ result |= 16;+ if (cd1 != (iconv_t)(-1))+ iconv_close (cd1);+ if (cd2 != (iconv_t)(-1))+ iconv_close (cd2);+ if (cd3 != (iconv_t)(-1))+ iconv_close (cd3);+ if (cd4 != (iconv_t)(-1))+ iconv_close (cd4);+ }+ return result;++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_run "$LINENO"+then :+ am_cv_func_iconv_works=yes+fi+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \+ conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi++ test "$am_cv_func_iconv_works" = no || break+ done+ LIBS="$gl_saved_LIBS"+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $am_cv_func_iconv_works" >&5+printf "%s\n" "$am_cv_func_iconv_works" >&6; }+ case "$am_cv_func_iconv_works" in+ *no) am_func_iconv=no am_cv_lib_iconv=no ;;+ *) am_func_iconv=yes ;;+ esac+ else+ am_func_iconv=no am_cv_lib_iconv=no+ fi+ if test "$am_func_iconv" = yes; then++printf "%s\n" "#define HAVE_ICONV 1" >>confdefs.h++ fi+ if test "$am_cv_lib_iconv" = yes; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to link with libiconv" >&5+printf %s "checking how to link with libiconv... " >&6; }+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIBICONV" >&5+printf "%s\n" "$LIBICONV" >&6; }+ else+ CPPFLAGS="$gl_saved_CPPFLAGS"+ LIBICONV=+ LTLIBICONV=+ fi+++++++++++ use_additional=yes++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"++ eval additional_includedir=\"$includedir\"+ eval additional_libdir=\"$libdir\"+ eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"+ eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"++ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"+++# Check whether --with-libintl-prefix was given.+if test ${with_libintl_prefix+y}+then :+ withval=$with_libintl_prefix;+ if test "X$withval" = "Xno"; then+ use_additional=no+ else+ if test "X$withval" = "X"; then++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"++ eval additional_includedir=\"$includedir\"+ eval additional_libdir=\"$libdir\"+ eval additional_libdir2=\"$exec_prefix/$acl_libdirstem2\"+ eval additional_libdir3=\"$exec_prefix/$acl_libdirstem3\"++ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ else+ additional_includedir="$withval/include"+ additional_libdir="$withval/$acl_libdirstem"+ additional_libdir2="$withval/$acl_libdirstem2"+ additional_libdir3="$withval/$acl_libdirstem3"+ fi+ fi++fi++ if test "X$additional_libdir2" = "X$additional_libdir"; then+ additional_libdir2=+ fi+ if test "X$additional_libdir3" = "X$additional_libdir"; then+ additional_libdir3=+ fi+ LIBINTL=+ LTLIBINTL=+ INCINTL=+ LIBINTL_PREFIX=+ HAVE_LIBINTL=+ rpathdirs=+ ltrpathdirs=+ names_already_handled=+ names_next_round='intl '+ while test -n "$names_next_round"; do+ names_this_round="$names_next_round"+ names_next_round=+ for name in $names_this_round; do+ already_handled=+ for n in $names_already_handled; do+ if test "$n" = "$name"; then+ already_handled=yes+ break+ fi+ done+ if test -z "$already_handled"; then+ names_already_handled="$names_already_handled $name"+ uppername=`echo "$name" | sed -e 'y|abcdefghijklmnopqrstuvwxyz./+-|ABCDEFGHIJKLMNOPQRSTUVWXYZ____|'`+ eval value=\"\$HAVE_LIB$uppername\"+ if test -n "$value"; then+ if test "$value" = yes; then+ eval value=\"\$LIB$uppername\"+ test -z "$value" || LIBINTL="${LIBINTL}${LIBINTL:+ }$value"+ eval value=\"\$LTLIB$uppername\"+ test -z "$value" || LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$value"+ else+ :+ fi+ else+ found_dir=+ found_la=+ found_so=+ found_a=+ eval libname=\"$acl_libname_spec\" # typically: libname=lib$name+ if test -n "$acl_shlibext"; then+ shrext=".$acl_shlibext" # typically: shrext=.so+ else+ shrext=+ fi+ if test $use_additional = yes; then+ for additional_libdir_variable in additional_libdir additional_libdir2 additional_libdir3; do+ if test "X$found_dir" = "X"; then+ eval dir=\$$additional_libdir_variable+ if test -n "$dir"; then+ if test -n "$acl_shlibext"; then+ if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then+ found_dir="$dir"+ found_so="$dir/$libname$shrext"+ else+ if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then+ ver=`(cd "$dir" && \+ for f in "$libname$shrext".*; do echo "$f"; done \+ | sed -e "s,^$libname$shrext\\\\.,," \+ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \+ | sed 1q ) 2>/dev/null`+ if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then+ found_dir="$dir"+ found_so="$dir/$libname$shrext.$ver"+ fi+ else+ eval library_names=\"$acl_library_names_spec\"+ for f in $library_names; do+ if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then+ found_dir="$dir"+ found_so="$dir/$f"+ break+ fi+ done+ fi+ fi+ fi+ if test "X$found_dir" = "X"; then+ if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then+ found_dir="$dir"+ found_a="$dir/$libname.$acl_libext"+ fi+ fi+ if test "X$found_dir" != "X"; then+ if test -f "$dir/$libname.la"; then+ found_la="$dir/$libname.la"+ fi+ fi+ fi+ fi+ done+ fi+ if test "X$found_dir" = "X"; then+ for x in $LDFLAGS $LTLIBINTL; do++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"+ eval x=\"$x\"+ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ case "$x" in+ -L*)+ dir=`echo "X$x" | sed -e 's/^X-L//'`+ if test -n "$acl_shlibext"; then+ if test -f "$dir/$libname$shrext" && acl_is_expected_elfclass < "$dir/$libname$shrext"; then+ found_dir="$dir"+ found_so="$dir/$libname$shrext"+ else+ if test "$acl_library_names_spec" = '$libname$shrext$versuffix'; then+ ver=`(cd "$dir" && \+ for f in "$libname$shrext".*; do echo "$f"; done \+ | sed -e "s,^$libname$shrext\\\\.,," \+ | sort -t '.' -n -r -k1,1 -k2,2 -k3,3 -k4,4 -k5,5 \+ | sed 1q ) 2>/dev/null`+ if test -n "$ver" && test -f "$dir/$libname$shrext.$ver" && acl_is_expected_elfclass < "$dir/$libname$shrext.$ver"; then+ found_dir="$dir"+ found_so="$dir/$libname$shrext.$ver"+ fi+ else+ eval library_names=\"$acl_library_names_spec\"+ for f in $library_names; do+ if test -f "$dir/$f" && acl_is_expected_elfclass < "$dir/$f"; then+ found_dir="$dir"+ found_so="$dir/$f"+ break+ fi+ done+ fi+ fi+ fi+ if test "X$found_dir" = "X"; then+ if test -f "$dir/$libname.$acl_libext" && ${AR-ar} -p "$dir/$libname.$acl_libext" | acl_is_expected_elfclass; then+ found_dir="$dir"+ found_a="$dir/$libname.$acl_libext"+ fi+ fi+ if test "X$found_dir" != "X"; then+ if test -f "$dir/$libname.la"; then+ found_la="$dir/$libname.la"+ fi+ fi+ ;;+ esac+ if test "X$found_dir" != "X"; then+ break+ fi+ done+ fi+ if test "X$found_dir" != "X"; then+ LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$found_dir -l$name"+ if test "X$found_so" != "X"; then+ if test "$enable_rpath" = no \+ || test "X$found_dir" = "X/usr/$acl_libdirstem" \+ || test "X$found_dir" = "X/usr/$acl_libdirstem2" \+ || test "X$found_dir" = "X/usr/$acl_libdirstem3"; then+ LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so"+ else+ haveit=+ for x in $ltrpathdirs; do+ if test "X$x" = "X$found_dir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ ltrpathdirs="$ltrpathdirs $found_dir"+ fi+ if test "$acl_hardcode_direct" = yes; then+ LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so"+ else+ if test -n "$acl_hardcode_libdir_flag_spec" && test "$acl_hardcode_minus_L" = no; then+ LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so"+ haveit=+ for x in $rpathdirs; do+ if test "X$x" = "X$found_dir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ rpathdirs="$rpathdirs $found_dir"+ fi+ else+ haveit=+ for x in $LDFLAGS $LIBINTL; do++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"+ eval x=\"$x\"+ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ if test "X$x" = "X-L$found_dir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir"+ fi+ if test "$acl_hardcode_minus_L" != no; then+ LIBINTL="${LIBINTL}${LIBINTL:+ }$found_so"+ else+ LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name"+ fi+ fi+ fi+ fi+ else+ if test "X$found_a" != "X"; then+ LIBINTL="${LIBINTL}${LIBINTL:+ }$found_a"+ else+ LIBINTL="${LIBINTL}${LIBINTL:+ }-L$found_dir -l$name"+ fi+ fi+ additional_includedir=+ case "$found_dir" in+ */$acl_libdirstem | */$acl_libdirstem/)+ basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem/"'*$,,'`+ if test "$name" = 'intl'; then+ LIBINTL_PREFIX="$basedir"+ fi+ additional_includedir="$basedir/include"+ ;;+ */$acl_libdirstem2 | */$acl_libdirstem2/)+ basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem2/"'*$,,'`+ if test "$name" = 'intl'; then+ LIBINTL_PREFIX="$basedir"+ fi+ additional_includedir="$basedir/include"+ ;;+ */$acl_libdirstem3 | */$acl_libdirstem3/)+ basedir=`echo "X$found_dir" | sed -e 's,^X,,' -e "s,/$acl_libdirstem3/"'*$,,'`+ if test "$name" = 'intl'; then+ LIBINTL_PREFIX="$basedir"+ fi+ additional_includedir="$basedir/include"+ ;;+ esac+ if test "X$additional_includedir" != "X"; then+ if test "X$additional_includedir" != "X/usr/include"; then+ haveit=+ if test "X$additional_includedir" = "X/usr/local/include"; then+ if test -n "$GCC"; then+ case $host_os in+ linux* | gnu* | k*bsd*-gnu) haveit=yes;;+ esac+ fi+ fi+ if test -z "$haveit"; then+ for x in $CPPFLAGS $INCINTL; do++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"+ eval x=\"$x\"+ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ if test "X$x" = "X-I$additional_includedir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ if test -d "$additional_includedir"; then+ INCINTL="${INCINTL}${INCINTL:+ }-I$additional_includedir"+ fi+ fi+ fi+ fi+ fi+ if test -n "$found_la"; then+ saved_libdir="$libdir"+ case "$found_la" in+ */* | *\\*) . "$found_la" ;;+ *) . "./$found_la" ;;+ esac+ libdir="$saved_libdir"+ for dep in $dependency_libs; do+ case "$dep" in+ -L*)+ dependency_libdir=`echo "X$dep" | sed -e 's/^X-L//'`+ if test "X$dependency_libdir" != "X/usr/$acl_libdirstem" \+ && test "X$dependency_libdir" != "X/usr/$acl_libdirstem2" \+ && test "X$dependency_libdir" != "X/usr/$acl_libdirstem3"; then+ haveit=+ if test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem" \+ || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem2" \+ || test "X$dependency_libdir" = "X/usr/local/$acl_libdirstem3"; then+ if test -n "$GCC"; then+ case $host_os in+ linux* | gnu* | k*bsd*-gnu) haveit=yes;;+ esac+ fi+ fi+ if test -z "$haveit"; then+ haveit=+ for x in $LDFLAGS $LIBINTL; do++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"+ eval x=\"$x\"+ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ if test "X$x" = "X-L$dependency_libdir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ if test -d "$dependency_libdir"; then+ LIBINTL="${LIBINTL}${LIBINTL:+ }-L$dependency_libdir"+ fi+ fi+ haveit=+ for x in $LDFLAGS $LTLIBINTL; do++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"+ eval x=\"$x\"+ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ if test "X$x" = "X-L$dependency_libdir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ if test -d "$dependency_libdir"; then+ LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-L$dependency_libdir"+ fi+ fi+ fi+ fi+ ;;+ -R*)+ dir=`echo "X$dep" | sed -e 's/^X-R//'`+ if test "$enable_rpath" != no; then+ haveit=+ for x in $rpathdirs; do+ if test "X$x" = "X$dir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ rpathdirs="$rpathdirs $dir"+ fi+ haveit=+ for x in $ltrpathdirs; do+ if test "X$x" = "X$dir"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ ltrpathdirs="$ltrpathdirs $dir"+ fi+ fi+ ;;+ -l*)+ dep=`echo "X$dep" | sed -e 's/^X-l//'`+ if test "X$dep" != Xc \+ || case $host_os in+ linux* | gnu* | k*bsd*-gnu) false ;;+ *) true ;;+ esac; then+ names_next_round="$names_next_round $dep"+ fi+ ;;+ *.la)+ names_next_round="$names_next_round "`echo "X$dep" | sed -e 's,^X.*/,,' -e 's,^lib,,' -e 's,\.la$,,'`+ ;;+ *)+ LIBINTL="${LIBINTL}${LIBINTL:+ }$dep"+ LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }$dep"+ ;;+ esac+ done+ fi+ else+ LIBINTL="${LIBINTL}${LIBINTL:+ }-l$name"+ LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-l$name"+ fi+ fi+ fi+ done+ done+ if test "X$rpathdirs" != "X"; then+ if test -n "$acl_hardcode_libdir_separator"; then+ alldirs=+ for found_dir in $rpathdirs; do+ alldirs="${alldirs}${alldirs:+$acl_hardcode_libdir_separator}$found_dir"+ done+ acl_saved_libdir="$libdir"+ libdir="$alldirs"+ eval flag=\"$acl_hardcode_libdir_flag_spec\"+ libdir="$acl_saved_libdir"+ LIBINTL="${LIBINTL}${LIBINTL:+ }$flag"+ else+ for found_dir in $rpathdirs; do+ acl_saved_libdir="$libdir"+ libdir="$found_dir"+ eval flag=\"$acl_hardcode_libdir_flag_spec\"+ libdir="$acl_saved_libdir"+ LIBINTL="${LIBINTL}${LIBINTL:+ }$flag"+ done+ fi+ fi+ if test "X$ltrpathdirs" != "X"; then+ for found_dir in $ltrpathdirs; do+ LTLIBINTL="${LTLIBINTL}${LTLIBINTL:+ }-R$found_dir"+ done+ fi++++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for GNU gettext in libintl" >&5+printf %s "checking for GNU gettext in libintl... " >&6; }+if eval test \${$gt_func_gnugettext_libintl+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) gt_save_CPPFLAGS="$CPPFLAGS"+ CPPFLAGS="$CPPFLAGS $INCINTL"+ gt_save_LIBS="$LIBS"+ LIBS="$LIBS $LIBINTL"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <libintl.h>+#ifndef __GNU_GETTEXT_SUPPORTED_REVISION+extern int _nl_msg_cat_cntr;+extern+#ifdef __cplusplus+"C"+#endif+const char *_nl_expand_alias (const char *);+#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias (""))+#else+#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0+#endif+$gt_revision_test_code++int+main (void)+{++bindtextdomain ("", "");+return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ eval "$gt_func_gnugettext_libintl=yes"+else case e in #(+ e) eval "$gt_func_gnugettext_libintl=no" ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ gt_LIBINTL_EXTRA="$INTL_MACOSX_LIBS"++ case "$host_os" in+ aix*) gt_LIBINTL_EXTRA="-lpthread" ;;+ esac+ if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" != yes; } \+ && { test -n "$LIBICONV" || test -n "$gt_LIBINTL_EXTRA"; }; then+ LIBS="$LIBS $LIBICONV $gt_LIBINTL_EXTRA"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <libintl.h>+#ifndef __GNU_GETTEXT_SUPPORTED_REVISION+extern int _nl_msg_cat_cntr;+extern+#ifdef __cplusplus+"C"+#endif+const char *_nl_expand_alias (const char *);+#define __GNU_GETTEXT_SYMBOL_EXPRESSION (_nl_msg_cat_cntr + *_nl_expand_alias (""))+#else+#define __GNU_GETTEXT_SYMBOL_EXPRESSION 0+#endif+$gt_revision_test_code++int+main (void)+{++bindtextdomain ("", "");+return * gettext ("")$gt_expression_test_code + __GNU_GETTEXT_SYMBOL_EXPRESSION++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ LIBINTL="$LIBINTL $LIBICONV $gt_LIBINTL_EXTRA"+ LTLIBINTL="$LTLIBINTL $LTLIBICONV $gt_LIBINTL_EXTRA"+ eval "$gt_func_gnugettext_libintl=yes"++fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ fi+ CPPFLAGS="$gt_save_CPPFLAGS"+ LIBS="$gt_save_LIBS" ;;+esac+fi+eval ac_res=\$$gt_func_gnugettext_libintl+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5+printf "%s\n" "$ac_res" >&6; }+ fi++ if { eval "gt_val=\$$gt_func_gnugettext_libc"; test "$gt_val" = "yes"; } \+ || { { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; } \+ && test "$PACKAGE" != gettext-runtime \+ && test "$PACKAGE" != gettext-tools \+ && test "$PACKAGE" != libintl; }; then+ gt_use_preinstalled_gnugettext=yes+ else+ LIBINTL=+ LTLIBINTL=+ INCINTL=+ fi++++ if test -n "$INTL_MACOSX_LIBS"; then+ if test "$gt_use_preinstalled_gnugettext" = "yes" \+ || test "$nls_cv_use_gnu_gettext" = "yes"; then+ LIBINTL="$LIBINTL $INTL_MACOSX_LIBS"+ LTLIBINTL="$LTLIBINTL $INTL_MACOSX_LIBS"+ fi+ fi++ if test "$gt_use_preinstalled_gnugettext" = "yes" \+ || test "$nls_cv_use_gnu_gettext" = "yes"; then++printf "%s\n" "#define ENABLE_NLS 1" >>confdefs.h++ else+ USE_NLS=no+ fi+ fi++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether to use NLS" >&5+printf %s "checking whether to use NLS... " >&6; }+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $USE_NLS" >&5+printf "%s\n" "$USE_NLS" >&6; }+ if test "$USE_NLS" = "yes"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking where the gettext function comes from" >&5+printf %s "checking where the gettext function comes from... " >&6; }+ if test "$gt_use_preinstalled_gnugettext" = "yes"; then+ if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then+ gt_source="external libintl"+ else+ gt_source="libc"+ fi+ else+ gt_source="included intl directory"+ fi+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gt_source" >&5+printf "%s\n" "$gt_source" >&6; }+ fi++ if test "$USE_NLS" = "yes"; then++ if test "$gt_use_preinstalled_gnugettext" = "yes"; then+ if { eval "gt_val=\$$gt_func_gnugettext_libintl"; test "$gt_val" = "yes"; }; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to link with libintl" >&5+printf %s "checking how to link with libintl... " >&6; }+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $LIBINTL" >&5+printf "%s\n" "$LIBINTL" >&6; }++ for element in $INCINTL; do+ haveit=+ for x in $CPPFLAGS; do++ acl_saved_prefix="$prefix"+ prefix="$acl_final_prefix"+ acl_saved_exec_prefix="$exec_prefix"+ exec_prefix="$acl_final_exec_prefix"+ eval x=\"$x\"+ exec_prefix="$acl_saved_exec_prefix"+ prefix="$acl_saved_prefix"++ if test "X$x" = "X$element"; then+ haveit=yes+ break+ fi+ done+ if test -z "$haveit"; then+ CPPFLAGS="${CPPFLAGS}${CPPFLAGS:+ }$element"+ fi+ done++ fi+++printf "%s\n" "#define HAVE_GETTEXT 1" >>confdefs.h+++printf "%s\n" "#define HAVE_DCGETTEXT 1" >>confdefs.h++ fi++ POSUB=po+ fi+++++ INTLLIBS="$LIBINTL"++++++++ gt_save_prefix="${prefix}"+ gt_save_datarootdir="${datarootdir}"+ gt_save_localedir="${localedir}"+ if test "X$prefix" = "XNONE"; then+ prefix="$ac_default_prefix"+ fi+ eval datarootdir="$datarootdir"+ eval localedir="$localedir"++++++ gl_final_localedir="$localedir"+ case "$build_os" in+ cygwin*)+ case "$host_os" in+ mingw* | windows*)+ gl_final_localedir=`cygpath -w "$gl_final_localedir"` ;;+ esac+ ;;+ esac+ localedir_c=`printf '%s\n' "$gl_final_localedir" | sed -e "$gl_sed_double_backslashes" -e "$gl_sed_escape_doublequotes" | tr -d "$gl_tr_cr"`+ localedir_c='"'"$localedir_c"'"'+++ localedir_c_make=`printf '%s\n' "$localedir_c" | sed -e "$gl_sed_escape_for_make_1" -e "$gl_sed_escape_for_make_2" | tr -d "$gl_tr_cr"`+ if test "$localedir_c_make" = '\"'"${gl_final_localedir}"'\"'; then+ localedir_c_make='\"$(localedir)\"'+ fi+++ localedir="${gt_save_localedir}"+ datarootdir="${gt_save_datarootdir}"+ prefix="${gt_save_prefix}"++++###############################################################################+# Checks for header files.+###############################################################################++echo+echo "System headers and functions:"++# immintrin.h allows the use of the intrinsic functions if they are available.+# cpuid.h may be used for detecting x86 processor features at runtime.+ac_fn_c_check_header_compile "$LINENO" "immintrin.h" "ac_cv_header_immintrin_h" "$ac_includes_default"+if test "x$ac_cv_header_immintrin_h" = xyes+then :+ printf "%s\n" "#define HAVE_IMMINTRIN_H 1" >>confdefs.h++fi+ac_fn_c_check_header_compile "$LINENO" "cpuid.h" "ac_cv_header_cpuid_h" "$ac_includes_default"+if test "x$ac_cv_header_cpuid_h" = xyes+then :+ printf "%s\n" "#define HAVE_CPUID_H 1" >>confdefs.h++fi++++###############################################################################+# Checks for typedefs, structures, and compiler characteristics.+###############################################################################++ac_fn_c_check_type "$LINENO" "_Bool" "ac_cv_type__Bool" "$ac_includes_default"+if test "x$ac_cv_type__Bool" = xyes+then :++printf "%s\n" "#define HAVE__BOOL 1" >>confdefs.h+++fi++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for stdbool.h that conforms to C99 or later" >&5+printf %s "checking for stdbool.h that conforms to C99 or later... " >&6; }+if test ${ac_cv_header_stdbool_h+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <stdbool.h>++ /* "true" and "false" should be usable in #if expressions and+ integer constant expressions, and "bool" should be a valid+ type name.++ Although C99 requires bool, true, and false to be macros,+ C23 and C++11 overrule that, so do not test for that.+ Although C99 requires __bool_true_false_are_defined and+ _Bool, C23 says they are obsolescent, so do not require+ them. */++ #if !true+ #error "'true' is not true"+ #endif+ #if true != 1+ #error "'true' is not equal to 1"+ #endif+ char b[true == 1 ? 1 : -1];+ char c[true];++ #if false+ #error "'false' is not false"+ #endif+ #if false != 0+ #error "'false' is not equal to 0"+ #endif+ char d[false == 0 ? 1 : -1];++ enum { e = false, f = true, g = false * true, h = true * 256 };++ char i[(bool) 0.5 == true ? 1 : -1];+ char j[(bool) 0.0 == false ? 1 : -1];+ char k[sizeof (bool) > 0 ? 1 : -1];++ struct sb { bool s: 1; bool t; } s;+ char l[sizeof s.t > 0 ? 1 : -1];++ /* The following fails for+ HP aC++/ANSI C B3910B A.05.55 [Dec 04 2003]. */+ bool m[h];+ char n[sizeof m == h * sizeof m[0] ? 1 : -1];+ char o[-1 - (bool) 0 < 0 ? 1 : -1];+ /* Catch a bug in an HP-UX C compiler. See+ https://gcc.gnu.org/ml/gcc-patches/2003-12/msg02303.html+ https://lists.gnu.org/r/bug-coreutils/2005-11/msg00161.html+ */+ bool p = true;+ bool *pp = &p;++int+main (void)+{++ bool ps = &s;+ *pp |= p;+ *pp |= ! p;++ /* Refer to every declared value, so they cannot be+ discarded as unused. */+ return (!b + !c + !d + !e + !f + !g + !h + !i + !j + !k+ + !l + !m + !n + !o + !p + !pp + !ps);++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_header_stdbool_h=yes+else case e in #(+ e) ac_cv_header_stdbool_h=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdbool_h" >&5+printf "%s\n" "$ac_cv_header_stdbool_h" >&6; }++if test $ac_cv_header_stdbool_h = yes; then++printf "%s\n" "#define HAVE_STDBOOL_H 1" >>confdefs.h++fi+++ac_fn_c_find_uintX_t "$LINENO" "8" "ac_cv_c_uint8_t"+case $ac_cv_c_uint8_t in #(+ no|yes) ;; #(+ *)++printf "%s\n" "#define _UINT8_T 1" >>confdefs.h+++printf "%s\n" "#define uint8_t $ac_cv_c_uint8_t" >>confdefs.h+;;+ esac++ac_fn_c_find_uintX_t "$LINENO" "16" "ac_cv_c_uint16_t"+case $ac_cv_c_uint16_t in #(+ no|yes) ;; #(+ *)+++printf "%s\n" "#define uint16_t $ac_cv_c_uint16_t" >>confdefs.h+;;+ esac++ac_fn_c_find_intX_t "$LINENO" "32" "ac_cv_c_int32_t"+case $ac_cv_c_int32_t in #(+ no|yes) ;; #(+ *)++printf "%s\n" "#define int32_t $ac_cv_c_int32_t" >>confdefs.h+;;+esac++ac_fn_c_find_uintX_t "$LINENO" "32" "ac_cv_c_uint32_t"+case $ac_cv_c_uint32_t in #(+ no|yes) ;; #(+ *)++printf "%s\n" "#define _UINT32_T 1" >>confdefs.h+++printf "%s\n" "#define uint32_t $ac_cv_c_uint32_t" >>confdefs.h+;;+ esac++ac_fn_c_find_intX_t "$LINENO" "64" "ac_cv_c_int64_t"+case $ac_cv_c_int64_t in #(+ no|yes) ;; #(+ *)++printf "%s\n" "#define int64_t $ac_cv_c_int64_t" >>confdefs.h+;;+esac++ac_fn_c_find_uintX_t "$LINENO" "64" "ac_cv_c_uint64_t"+case $ac_cv_c_uint64_t in #(+ no|yes) ;; #(+ *)++printf "%s\n" "#define _UINT64_T 1" >>confdefs.h+++printf "%s\n" "#define uint64_t $ac_cv_c_uint64_t" >>confdefs.h+;;+ esac+++ ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"+if test "x$ac_cv_type_uintptr_t" = xyes+then :++printf "%s\n" "#define HAVE_UINTPTR_T 1" >>confdefs.h++else case e in #(+ e) for ac_type in 'unsigned int' 'unsigned long int' \+ 'unsigned long long int'; do+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_includes_default+int+main (void)+{+static int test_array [1 - 2 * !(sizeof (void *) <= sizeof ($ac_type))];+test_array [0] = 0;+return test_array [0];++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++printf "%s\n" "#define uintptr_t $ac_type" >>confdefs.h++ ac_type=+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ test -z "$ac_type" && break+ done ;;+esac+fi++++# The cast to long int works around a bug in the HP C Compiler+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects+# declarations like 'int a3[[(sizeof (unsigned char)) >= 0]];'.+# This bug is HP SR number 8606223364.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking size of size_t" >&5+printf %s "checking size of size_t... " >&6; }+if test ${ac_cv_sizeof_size_t+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (size_t))" "ac_cv_sizeof_size_t" "$ac_includes_default"+then :++else case e in #(+ e) if test "$ac_cv_type_size_t" = yes; then+ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}+as_fn_error 77 "cannot compute sizeof (size_t)+See 'config.log' for more details" "$LINENO" 5; }+ else+ ac_cv_sizeof_size_t=0+ fi ;;+esac+fi+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_size_t" >&5+printf "%s\n" "$ac_cv_sizeof_size_t" >&6; }++++printf "%s\n" "#define SIZEOF_SIZE_T $ac_cv_sizeof_size_t" >>confdefs.h++++# The command line tool can copy high resolution timestamps if such+# information is available in struct stat. Otherwise one second accuracy+# is used.+ac_fn_c_check_member "$LINENO" "struct stat" "st_atim.tv_nsec" "ac_cv_member_struct_stat_st_atim_tv_nsec" "$ac_includes_default"+if test "x$ac_cv_member_struct_stat_st_atim_tv_nsec" = xyes+then :++printf "%s\n" "#define HAVE_STRUCT_STAT_ST_ATIM_TV_NSEC 1" >>confdefs.h+++fi+ac_fn_c_check_member "$LINENO" "struct stat" "st_atimespec.tv_nsec" "ac_cv_member_struct_stat_st_atimespec_tv_nsec" "$ac_includes_default"+if test "x$ac_cv_member_struct_stat_st_atimespec_tv_nsec" = xyes+then :++printf "%s\n" "#define HAVE_STRUCT_STAT_ST_ATIMESPEC_TV_NSEC 1" >>confdefs.h+++fi+ac_fn_c_check_member "$LINENO" "struct stat" "st_atimensec" "ac_cv_member_struct_stat_st_atimensec" "$ac_includes_default"+if test "x$ac_cv_member_struct_stat_st_atimensec" = xyes+then :++printf "%s\n" "#define HAVE_STRUCT_STAT_ST_ATIMENSEC 1" >>confdefs.h+++fi+ac_fn_c_check_member "$LINENO" "struct stat" "st_uatime" "ac_cv_member_struct_stat_st_uatime" "$ac_includes_default"+if test "x$ac_cv_member_struct_stat_st_uatime" = xyes+then :++printf "%s\n" "#define HAVE_STRUCT_STAT_ST_UATIME 1" >>confdefs.h+++fi+ac_fn_c_check_member "$LINENO" "struct stat" "st_atim.st__tim.tv_nsec" "ac_cv_member_struct_stat_st_atim_st__tim_tv_nsec" "$ac_includes_default"+if test "x$ac_cv_member_struct_stat_st_atim_st__tim_tv_nsec" = xyes+then :++printf "%s\n" "#define HAVE_STRUCT_STAT_ST_ATIM_ST__TIM_TV_NSEC 1" >>confdefs.h+++fi+++# Check whether --enable-largefile was given.+if test ${enable_largefile+y}+then :+ enableval=$enable_largefile;+fi+if test "$enable_largefile,$enable_year2038" != no,no+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CPPFLAGS option for large files" >&5+printf %s "checking for $CPPFLAGS option for large files... " >&6; }+if test ${ac_cv_sys_largefile_opts+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_save_CPPFLAGS=$CPPFLAGS+ ac_opt_found=no+ for ac_opt in "none needed" "-D_FILE_OFFSET_BITS=64" "-D_LARGE_FILES=1"; do+ if test x"$ac_opt" != x"none needed"+then :+ CPPFLAGS="$ac_save_CPPFLAGS $ac_opt"+fi+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <sys/types.h>+#ifndef FTYPE+# define FTYPE off_t+#endif+ /* Check that FTYPE can represent 2**63 - 1 correctly.+ We can't simply define LARGE_FTYPE to be 9223372036854775807,+ since some C++ compilers masquerading as C compilers+ incorrectly reject 9223372036854775807. */+#define LARGE_FTYPE (((FTYPE) 1 << 31 << 31) - 1 + ((FTYPE) 1 << 31 << 31))+ int FTYPE_is_large[(LARGE_FTYPE % 2147483629 == 721+ && LARGE_FTYPE % 2147483647 == 1)+ ? 1 : -1];+int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ if test x"$ac_opt" = x"none needed"+then :+ # GNU/Linux s390x and alpha need _FILE_OFFSET_BITS=64 for wide ino_t.+ CPPFLAGS="$CPPFLAGS -DFTYPE=ino_t"+ if ac_fn_c_try_compile "$LINENO"+then :++else case e in #(+ e) CPPFLAGS="$CPPFLAGS -D_FILE_OFFSET_BITS=64"+ if ac_fn_c_try_compile "$LINENO"+then :+ ac_opt='-D_FILE_OFFSET_BITS=64'+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam+fi+ ac_cv_sys_largefile_opts=$ac_opt+ ac_opt_found=yes+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ test $ac_opt_found = no || break+ done+ CPPFLAGS=$ac_save_CPPFLAGS++ test $ac_opt_found = yes || ac_cv_sys_largefile_opts="support not detected" ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_largefile_opts" >&5+printf "%s\n" "$ac_cv_sys_largefile_opts" >&6; }++ac_have_largefile=yes+case $ac_cv_sys_largefile_opts in #(+ "none needed") :+ ;; #(+ "supported through gnulib") :+ ;; #(+ "support not detected") :+ ac_have_largefile=no ;; #(+ "-D_FILE_OFFSET_BITS=64") :++printf "%s\n" "#define _FILE_OFFSET_BITS 64" >>confdefs.h+ ;; #(+ "-D_LARGE_FILES=1") :++printf "%s\n" "#define _LARGE_FILES 1" >>confdefs.h+ ;; #(+ *) :+ as_fn_error $? "internal error: bad value for \$ac_cv_sys_largefile_opts" "$LINENO" 5 ;;+esac++if test "$enable_year2038" != no+then :+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CPPFLAGS option for timestamps after 2038" >&5+printf %s "checking for $CPPFLAGS option for timestamps after 2038... " >&6; }+if test ${ac_cv_sys_year2038_opts+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_save_CPPFLAGS="$CPPFLAGS"+ ac_opt_found=no+ for ac_opt in "none needed" "-D_TIME_BITS=64" "-D__MINGW_USE_VC2005_COMPAT" "-U_USE_32_BIT_TIME_T -D__MINGW_USE_VC2005_COMPAT"; do+ if test x"$ac_opt" != x"none needed"+then :+ CPPFLAGS="$ac_save_CPPFLAGS $ac_opt"+fi+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++ #include <time.h>+ /* Check that time_t can represent 2**32 - 1 correctly. */+ #define LARGE_TIME_T \\+ ((time_t) (((time_t) 1 << 30) - 1 + 3 * ((time_t) 1 << 30)))+ int verify_time_t_range[(LARGE_TIME_T / 65537 == 65535+ && LARGE_TIME_T % 65537 == 0)+ ? 1 : -1];++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_sys_year2038_opts="$ac_opt"+ ac_opt_found=yes+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ test $ac_opt_found = no || break+ done+ CPPFLAGS="$ac_save_CPPFLAGS"+ test $ac_opt_found = yes || ac_cv_sys_year2038_opts="support not detected" ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sys_year2038_opts" >&5+printf "%s\n" "$ac_cv_sys_year2038_opts" >&6; }++ac_have_year2038=yes+case $ac_cv_sys_year2038_opts in #(+ "none needed") :+ ;; #(+ "support not detected") :+ ac_have_year2038=no ;; #(+ "-D_TIME_BITS=64") :++printf "%s\n" "#define _TIME_BITS 64" >>confdefs.h+ ;; #(+ "-D__MINGW_USE_VC2005_COMPAT") :++printf "%s\n" "#define __MINGW_USE_VC2005_COMPAT 1" >>confdefs.h+ ;; #(+ "-U_USE_32_BIT_TIME_T"*) :+ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}+as_fn_error $? "the 'time_t' type is currently forced to be 32-bit. It+will stop working after mid-January 2038. Remove+_USE_32BIT_TIME_T from the compiler flags.+See 'config.log' for more details" "$LINENO" 5; } ;; #(+ *) :+ as_fn_error $? "internal error: bad value for \$ac_cv_sys_year2038_opts" "$LINENO" 5 ;;+esac++fi++fi+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5+printf %s "checking whether byte ordering is bigendian... " >&6; }+if test ${ac_cv_c_bigendian+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_cv_c_bigendian=unknown+ # See if we're dealing with a universal compiler.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#ifndef __APPLE_CC__+ not a universal capable compiler+ #endif+ typedef int dummy;++_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++ # Check for potential -arch flags. It is not universal unless+ # there are at least two -arch flags with different values.+ ac_arch=+ ac_prev=+ for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do+ if test -n "$ac_prev"; then+ case $ac_word in+ i?86 | x86_64 | ppc | ppc64)+ if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then+ ac_arch=$ac_word+ else+ ac_cv_c_bigendian=universal+ break+ fi+ ;;+ esac+ ac_prev=+ elif test "x$ac_word" = "x-arch"; then+ ac_prev=arch+ fi+ done+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ if test $ac_cv_c_bigendian = unknown; then+ # See if sys/param.h defines the BYTE_ORDER macro.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <sys/types.h>+ #include <sys/param.h>++int+main (void)+{+#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \\+ && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \\+ && LITTLE_ENDIAN)+ bogus endian macros+ #endif++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ # It does; now see whether it defined to BIG_ENDIAN or not.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <sys/types.h>+ #include <sys/param.h>++int+main (void)+{+#if BYTE_ORDER != BIG_ENDIAN+ not big endian+ #endif++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_c_bigendian=yes+else case e in #(+ e) ac_cv_c_bigendian=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ fi+ if test $ac_cv_c_bigendian = unknown; then+ # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <limits.h>++int+main (void)+{+#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)+ bogus endian macros+ #endif++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ # It does; now see whether it defined to _BIG_ENDIAN or not.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <limits.h>++int+main (void)+{+#ifndef _BIG_ENDIAN+ not big endian+ #endif++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ ac_cv_c_bigendian=yes+else case e in #(+ e) ac_cv_c_bigendian=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ fi+ if test $ac_cv_c_bigendian = unknown; then+ # Compile a test program.+ if test "$cross_compiling" = yes+then :+ # Try to guess by grepping values from an object file.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+unsigned short int ascii_mm[] =+ { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };+ unsigned short int ascii_ii[] =+ { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };+ int use_ascii (int i) {+ return ascii_mm[i] + ascii_ii[i];+ }+ unsigned short int ebcdic_ii[] =+ { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };+ unsigned short int ebcdic_mm[] =+ { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };+ int use_ebcdic (int i) {+ return ebcdic_mm[i] + ebcdic_ii[i];+ }+ int+ main (int argc, char **argv)+ {+ /* Intimidate the compiler so that it does not+ optimize the arrays away. */+ char *p = argv[0];+ ascii_mm[1] = *p++; ebcdic_mm[1] = *p++;+ ascii_ii[1] = *p++; ebcdic_ii[1] = *p++;+ return use_ascii (argc) == use_ebcdic (*p);+ }+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ if grep BIGenDianSyS conftest$ac_exeext >/dev/null; then+ ac_cv_c_bigendian=yes+ fi+ if grep LiTTleEnDian conftest$ac_exeext >/dev/null ; then+ if test "$ac_cv_c_bigendian" = unknown; then+ ac_cv_c_bigendian=no+ else+ # finding both strings is unlikely to happen, but who knows?+ ac_cv_c_bigendian=unknown+ fi+ fi+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+$ac_includes_default+int+main (void)+{++ /* Are we little or big endian? From Harbison&Steele. */+ union+ {+ long int l;+ char c[sizeof (long int)];+ } u;+ u.l = 1;+ return u.c[sizeof (long int) - 1] == 1;++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_run "$LINENO"+then :+ ac_cv_c_bigendian=no+else case e in #(+ e) ac_cv_c_bigendian=yes ;;+esac+fi+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \+ conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi++ fi ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5+printf "%s\n" "$ac_cv_c_bigendian" >&6; }+ case $ac_cv_c_bigendian in #(+ yes)+ printf "%s\n" "#define WORDS_BIGENDIAN 1" >>confdefs.h+;; #(+ no)+ ;; #(+ universal)++printf "%s\n" "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h++ ;; #(+ *)+ as_fn_error $? "unknown endianness+ presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;+ esac+++# __attribute__((__constructor__)) can be used for one-time initializations.+# Use -Werror because some compilers accept unknown attributes and just+# give a warning.+#+# FIXME? Unfortunately -Werror can cause trouble if CFLAGS contains options+# that produce warnings for unrelated reasons. For example, GCC and Clang+# support -Wunused-macros which will warn about "#define _GNU_SOURCE 1"+# which will be among the #defines that Autoconf inserts to the beginning of+# the test program. There seems to be no nice way to prevent Autoconf from+# inserting the any defines to the test program.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if __attribute__((__constructor__)) can be used" >&5+printf %s "checking if __attribute__((__constructor__)) can be used... " >&6; }+have_func_attribute_constructor=no+OLD_CFLAGS="$CFLAGS"+CFLAGS="$CFLAGS -Werror"+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++ __attribute__((__constructor__))+ static void my_constructor_func(void) { return; }++_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+++printf "%s\n" "#define HAVE_FUNC_ATTRIBUTE_CONSTRUCTOR 1" >>confdefs.h++ have_func_attribute_constructor=yes+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }++else case e in #(+ e)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+ ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+CFLAGS="$OLD_CFLAGS"++# The Win95 threading lacks a thread-safe one-time initialization function.+# The one-time initialization is needed for crc32_small.c and crc64_small.c+# create the CRC tables. So if small mode is enabled, the threading mode is+# win95, and the compiler does not support attribute constructor, then we+# would end up with a multithreaded build that is thread-unsafe. As a+# result this configuration is not allowed.+if test "x$enable_small$enable_threads$have_func_attribute_constructor" \+ = xyeswin95no; then+ as_fn_error $? "+ --enable-threads=win95 and --enable-small cannot be used+ at the same time with a compiler that doesn't support+ __attribute__((__constructor__))" "$LINENO" 5+fi+++###############################################################################+# Checks for library functions.+###############################################################################++# Gnulib replacements as needed+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CC options needed to detect all undeclared functions" >&5+printf %s "checking for $CC options needed to detect all undeclared functions... " >&6; }+if test ${ac_cv_c_undeclared_builtin_options+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_save_CFLAGS=$CFLAGS+ ac_cv_c_undeclared_builtin_options='cannot detect'+ for ac_arg in '' -fno-builtin; do+ CFLAGS="$ac_save_CFLAGS $ac_arg"+ # This test program should *not* compile successfully.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{+(void) strchr;+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++else case e in #(+ e) # This test program should compile successfully.+ # No library function is consistently available on+ # freestanding implementations, so test against a dummy+ # declaration. Include always-available headers on the+ # off chance that they somehow elicit warnings.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <float.h>+#include <limits.h>+#include <stdarg.h>+#include <stddef.h>+extern void ac_decl (int, char *);++int+main (void)+{+(void) ac_decl (0, (char *) 0);+ (void) ac_decl;++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ if test x"$ac_arg" = x+then :+ ac_cv_c_undeclared_builtin_options='none needed'+else case e in #(+ e) ac_cv_c_undeclared_builtin_options=$ac_arg ;;+esac+fi+ break+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ done+ CFLAGS=$ac_save_CFLAGS+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_undeclared_builtin_options" >&5+printf "%s\n" "$ac_cv_c_undeclared_builtin_options" >&6; }+ case $ac_cv_c_undeclared_builtin_options in #(+ 'cannot detect') :+ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}+as_fn_error $? "cannot make $CC report undeclared builtins+See 'config.log' for more details" "$LINENO" 5; } ;; #(+ 'none needed') :+ ac_c_undeclared_builtin_options='' ;; #(+ *) :+ ac_c_undeclared_builtin_options=$ac_cv_c_undeclared_builtin_options ;;+esac+++ gl_replace_getopt=++ if test -z "$gl_replace_getopt"; then+ for ac_header in getopt.h+do :+ ac_fn_c_check_header_compile "$LINENO" "getopt.h" "ac_cv_header_getopt_h" "$ac_includes_default"+if test "x$ac_cv_header_getopt_h" = xyes+then :+ printf "%s\n" "#define HAVE_GETOPT_H 1" >>confdefs.h++else case e in #(+ e) gl_replace_getopt=yes ;;+esac+fi++done+ fi++ if test -z "$gl_replace_getopt"; then++ for ac_func in getopt_long+do :+ ac_fn_c_check_func "$LINENO" "getopt_long" "ac_cv_func_getopt_long"+if test "x$ac_cv_func_getopt_long" = xyes+then :+ printf "%s\n" "#define HAVE_GETOPT_LONG 1" >>confdefs.h++else case e in #(+ e) gl_replace_getopt=yes ;;+esac+fi++done+ fi++ if test -z "$gl_replace_getopt"; then+ ac_fn_check_decl "$LINENO" "optreset" "ac_cv_have_decl_optreset" "#include <getopt.h>+" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl_optreset" = xyes+then :++printf "%s\n" "#define HAVE_OPTRESET 1" >>confdefs.h++fi+ fi+++++++++ if test -n "$gl_replace_getopt"; then++ case " $LIBOBJS " in+ *" getopt.$ac_objext "* ) ;;+ *) LIBOBJS="$LIBOBJS getopt.$ac_objext"+ ;;+esac++ case " $LIBOBJS " in+ *" getopt1.$ac_objext "* ) ;;+ *) LIBOBJS="$LIBOBJS getopt1.$ac_objext"+ ;;+esac++++++printf "%s\n" "#define __GETOPT_PREFIX rpl_" >>confdefs.h+++ GETOPT_H=getopt.h+++ fi+++# If clock_gettime() is available, liblzma with pthreads may use it, and+# xz may use it even when threading support is disabled. In XZ Utils 5.4.x+# and older, configure checked for clock_gettime() only when using pthreads.+# This way non-threaded builds of liblzma didn't get a useless dependency on+# librt which further had a dependency on libpthread. Avoiding these was+# useful when a small build was needed, for example, for initramfs use.+#+# The above reasoning is thoroughly obsolete: On GNU/Linux, librt hasn't+# been needed for clock_gettime() since glibc 2.17 (2012-12-25).+# Solaris 10 needs librt but Solaris 11 doesn't anymore.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing clock_gettime" >&5+printf %s "checking for library containing clock_gettime... " >&6; }+if test ${ac_cv_search_clock_gettime+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_func_search_save_LIBS=$LIBS+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++/* Override any GCC internal prototype to avoid an error.+ Use char because int might match the return type of a GCC+ builtin and then its argument prototype would still apply.+ The 'extern "C"' is for builds by C++ compilers;+ although this is not generally supported in C code supporting it here+ has little cost and some practical benefit (sr 110532). */+#ifdef __cplusplus+extern "C"+#endif+char clock_gettime (void);+int+main (void)+{+return clock_gettime ();+ ;+ return 0;+}+_ACEOF+for ac_lib in '' rt+do+ if test -z "$ac_lib"; then+ ac_res="none required"+ else+ ac_res=-l$ac_lib+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"+ fi+ if ac_fn_c_try_link "$LINENO"+then :+ ac_cv_search_clock_gettime=$ac_res+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext+ if test ${ac_cv_search_clock_gettime+y}+then :+ break+fi+done+if test ${ac_cv_search_clock_gettime+y}+then :++else case e in #(+ e) ac_cv_search_clock_gettime=no ;;+esac+fi+rm conftest.$ac_ext+LIBS=$ac_func_search_save_LIBS ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_clock_gettime" >&5+printf "%s\n" "$ac_cv_search_clock_gettime" >&6; }+ac_res=$ac_cv_search_clock_gettime+if test "$ac_res" != no+then :+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"++fi++ac_fn_c_check_func "$LINENO" "clock_gettime" "ac_cv_func_clock_gettime"+if test "x$ac_cv_func_clock_gettime" = xyes+then :+ printf "%s\n" "#define HAVE_CLOCK_GETTIME 1" >>confdefs.h++fi++ac_fn_check_decl "$LINENO" "CLOCK_MONOTONIC" "ac_cv_have_decl_CLOCK_MONOTONIC" "#include <time.h>+" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl_CLOCK_MONOTONIC" = xyes+then :++printf "%s\n" "#define HAVE_CLOCK_MONOTONIC 1" >>confdefs.h++fi++# Find the best function to set timestamps.++ for ac_func in futimens futimes futimesat utimes _futime utime+do :+ as_ac_var=`printf "%s\n" "ac_cv_func_$ac_func" | sed "$as_sed_sh"`+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"+if eval test \"x\$"$as_ac_var"\" = x"yes"+then :+ cat >>confdefs.h <<_ACEOF+#define `printf "%s\n" "HAVE_$ac_func" | sed "$as_sed_cpp"` 1+_ACEOF+ break+fi++done++# This is nice to have but not mandatory.+ac_fn_c_check_func "$LINENO" "posix_fadvise" "ac_cv_func_posix_fadvise"+if test "x$ac_cv_func_posix_fadvise" = xyes+then :+ printf "%s\n" "#define HAVE_POSIX_FADVISE 1" >>confdefs.h++fi++++++++++ac_fn_check_decl "$LINENO" "program_invocation_name" "ac_cv_have_decl_program_invocation_name" "#include <errno.h>+" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl_program_invocation_name" = xyes+then :++printf "%s\n" "#define HAVE_PROGRAM_INVOCATION_NAME 1" >>confdefs.h++fi++++++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if __builtin_bswap16/32/64 are supported" >&5+printf %s "checking if __builtin_bswap16/32/64 are supported... " >&6; }+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{+__builtin_bswap16(1);+ __builtin_bswap32(1);+ __builtin_bswap64(1);+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+++printf "%s\n" "#define HAVE___BUILTIN_BSWAPXX 1" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }++else case e in #(+ e)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }++ # Look for other byteswapping methods.+ for ac_header in byteswap.h sys/endian.h sys/byteorder.h+do :+ as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | sed "$as_sed_sh"`+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"+if eval test \"x\$"$as_ac_Header"\" = x"yes"+then :+ cat >>confdefs.h <<_ACEOF+#define `printf "%s\n" "HAVE_$ac_header" | sed "$as_sed_cpp"` 1+_ACEOF+ break+fi++done++ # Even if we have byteswap.h we may lack the specific macros/functions.+ if test x$ac_cv_header_byteswap_h = xyes ; then++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if bswap_16 is available" >&5+printf %s "checking if bswap_16 is available... " >&6; }+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <byteswap.h>+int+main(void)+{+ bswap_16(42);+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+++printf "%s\n" "#define HAVE_BSWAP_16 1" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }++else case e in #(+ e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; } ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if bswap_32 is available" >&5+printf %s "checking if bswap_32 is available... " >&6; }+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <byteswap.h>+int+main(void)+{+ bswap_32(42);+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+++printf "%s\n" "#define HAVE_BSWAP_32 1" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }++else case e in #(+ e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; } ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if bswap_64 is available" >&5+printf %s "checking if bswap_64 is available... " >&6; }+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <byteswap.h>+int+main(void)+{+ bswap_64(42);+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+++printf "%s\n" "#define HAVE_BSWAP_64 1" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }++else case e in #(+ e) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; } ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext++ fi+ ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if unaligned memory access should be used" >&5+printf %s "checking if unaligned memory access should be used... " >&6; }+# Check whether --enable-unaligned-access was given.+if test ${enable_unaligned_access+y}+then :+ enableval=$enable_unaligned_access;+else case e in #(+ e) enable_unaligned_access=auto ;;+esac+fi++if test "x$enable_unaligned_access" = xauto ; then+ # NOTE: There might be other architectures on which unaligned access+ # is fast.+ case $host_cpu in+ i?86|x86_64|powerpc|powerpc64|powerpc64le)+ enable_unaligned_access=yes+ ;;+ arm*|aarch64*|riscv*)+ # On 32-bit and 64-bit ARM, GCC and Clang+ # #define __ARM_FEATURE_UNALIGNED if+ # unaligned access is supported.+ #+ # Exception: GCC at least up to 13.2.0+ # defines it even when using -mstrict-align+ # so in that case this autodetection goes wrong.+ # Most of the time -mstrict-align isn't used so it+ # shouldn't be a common problem in practice. See:+ # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111555+ #+ # RISC-V C API Specification says that if+ # __riscv_misaligned_fast is defined then+ # unaligned access is known to be fast.+ #+ # MSVC is handled as a special case: We assume that+ # 32/64-bit ARM supports fast unaligned access.+ # If MSVC gets RISC-V support then this will assume+ # fast unaligned access on RISC-V too.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#if !defined(__ARM_FEATURE_UNALIGNED) \+ && !defined(__riscv_misaligned_fast) \+ && !defined(_MSC_VER)+compile error+#endif+int main(void) { return 0; }++_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ enable_unaligned_access=yes+else case e in #(+ e) enable_unaligned_access=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ ;;+ *)+ enable_unaligned_access=no+ ;;+ esac+fi+if test "x$enable_unaligned_access" = xyes ; then++printf "%s\n" "#define TUKLIB_FAST_UNALIGNED_ACCESS 1" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if unsafe type punning should be used" >&5+printf %s "checking if unsafe type punning should be used... " >&6; }+# Check whether --enable-unsafe-type-punning was given.+if test ${enable_unsafe_type_punning+y}+then :+ enableval=$enable_unsafe_type_punning;+else case e in #(+ e) enable_unsafe_type_punning=no ;;+esac+fi++if test "x$enable_unsafe_type_punning" = xyes ; then++printf "%s\n" "#define TUKLIB_USE_UNSAFE_TYPE_PUNNING 1" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }+else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+fi++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if __builtin_assume_aligned is supported" >&5+printf %s "checking if __builtin_assume_aligned is supported... " >&6; }+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{+__builtin_assume_aligned("", 1);+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+++printf "%s\n" "#define HAVE___BUILTIN_ASSUME_ALIGNED 1" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }++else case e in #(+ e)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+ ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+++++# sys/param.h might be needed by sys/sysctl.h.+ac_fn_c_check_header_compile "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default"+if test "x$ac_cv_header_sys_param_h" = xyes+then :+ printf "%s\n" "#define HAVE_SYS_PARAM_H 1" >>confdefs.h++fi+++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to detect the amount of physical memory" >&5+printf %s "checking how to detect the amount of physical memory... " >&6; }+if test ${tuklib_cv_physmem_method+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e)++# Maybe checking $host_os would be enough but this matches what+# tuklib_physmem.c does.+#+# NOTE: IRIX has a compiler that doesn't error out with #error, so use+# a non-compilable text instead of #error to generate an error.+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#if defined(_WIN32) || defined(__CYGWIN__) || defined(__OS2__) \+ || defined(__DJGPP__) || defined(__VMS) \+ || defined(AMIGA) || defined(__AROS__) || defined(__QNX__)+int main(void) { return 0; }+#else+compile error+#endif++_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ tuklib_cv_physmem_method=special+else case e in #(+ e)++# Look for AIX-specific solution before sysconf(), because the test+# for sysconf() will pass on AIX but won't actually work+# (sysconf(_SC_PHYS_PAGES) compiles but always returns -1 on AIX).+#+# NOTE: There is no need to link the check program because it's not calling+# any functions and thus implicit function declarations aren't a problem.+# The unused reference to _system_configuration.physmem might get optimized+# away, and thus the linker might not see that symbol anyway.+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <sys/systemcfg.h>++int+main(void)+{+ (void)_system_configuration.physmem;+ return 0;+}++_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ tuklib_cv_physmem_method=aix+else case e in #(+ e)++cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <unistd.h>+int+main(void)+{+ long i;+ i = sysconf(_SC_PAGESIZE);+ i = sysconf(_SC_PHYS_PAGES);+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ tuklib_cv_physmem_method=sysconf+else case e in #(+ e)++cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#ifdef HAVE_SYS_PARAM_H+# include <sys/param.h>+#endif+#include <sys/sysctl.h>+int+main(void)+{+ int name[2] = { CTL_HW, HW_PHYSMEM };+ unsigned long mem;+ size_t mem_ptr_size = sizeof(mem);+ sysctl(name, 2, &mem, &mem_ptr_size, NULL, 0);+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ tuklib_cv_physmem_method=sysctl+else case e in #(+ e)++cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <sys/sysinfo.h>+#include <machine/hal_sysinfo.h>++int+main(void)+{+ int memkb;+ int start = 0;+ getsysinfo(GSI_PHYSMEM, (caddr_t)&memkb, sizeof(memkb), &start);+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ tuklib_cv_physmem_method=getsysinfo+else case e in #(+ e)++cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <sys/param.h>+#include <sys/pstat.h>++int+main(void)+{+ struct pst_static pst;+ pstat_getstatic(&pst, sizeof(pst), 1, 0);+ (void)pst.physical_memory;+ (void)pst.page_size;+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ tuklib_cv_physmem_method=pstat_getstatic+else case e in #(+ e)++cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <invent.h>+int+main(void)+{+ inv_state_t *st = NULL;+ setinvent_r(&st);+ getinvent_r(st);+ endinvent_r(st);+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ tuklib_cv_physmem_method=getinvent_r+else case e in #(+ e)++# This version of sysinfo() is Linux-specific. Some non-Linux systems have+# different sysinfo() so we must check $host_os.+case $host_os in+ linux*)+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <sys/sysinfo.h>+int+main(void)+{+ struct sysinfo si;+ sysinfo(&si);+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :++ tuklib_cv_physmem_method=sysinfo++else case e in #(+ e)+ tuklib_cv_physmem_method=unknown+ ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ ;;+ *)+ tuklib_cv_physmem_method=unknown+ ;;+esac+ ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tuklib_cv_physmem_method" >&5+printf "%s\n" "$tuklib_cv_physmem_method" >&6; }++case $tuklib_cv_physmem_method in+ aix)++printf "%s\n" "#define TUKLIB_PHYSMEM_AIX 1" >>confdefs.h++ ;;+ sysconf)++printf "%s\n" "#define TUKLIB_PHYSMEM_SYSCONF 1" >>confdefs.h++ ;;+ sysctl)++printf "%s\n" "#define TUKLIB_PHYSMEM_SYSCTL 1" >>confdefs.h++ ;;+ getsysinfo)++printf "%s\n" "#define TUKLIB_PHYSMEM_GETSYSINFO 1" >>confdefs.h++ ;;+ pstat_getstatic)++printf "%s\n" "#define TUKLIB_PHYSMEM_PSTAT_GETSTATIC 1" >>confdefs.h++ ;;+ getinvent_r)++printf "%s\n" "#define TUKLIB_PHYSMEM_GETINVENT_R 1" >>confdefs.h++ ;;+ sysinfo)++printf "%s\n" "#define TUKLIB_PHYSMEM_SYSINFO 1" >>confdefs.h++ ;;+esac+++++# sys/param.h might be needed by sys/sysctl.h.+ac_fn_c_check_header_compile "$LINENO" "sys/param.h" "ac_cv_header_sys_param_h" "$ac_includes_default"+if test "x$ac_cv_header_sys_param_h" = xyes+then :+ printf "%s\n" "#define HAVE_SYS_PARAM_H 1" >>confdefs.h++fi+++{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking how to detect the number of available CPU cores" >&5+printf %s "checking how to detect the number of available CPU cores... " >&6; }+if test ${tuklib_cv_cpucores_method+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e)++# Maybe checking $host_os would be enough but this matches what+# tuklib_cpucores.c does.+#+# NOTE: IRIX has a compiler that doesn't error out with #error, so use+# a non-compilable text instead of #error to generate an error.+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#if defined(_WIN32) || defined(__CYGWIN__)+int main(void) { return 0; }+#else+compile error+#endif++_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ tuklib_cv_cpucores_method=special+else case e in #(+ e)++# glibc-based systems (GNU/Linux and GNU/kFreeBSD) have sched_getaffinity().+# The CPU_COUNT() macro was added in glibc 2.9 so we try to link the+# test program instead of merely compiling it. glibc 2.9 is old enough that+# if someone uses the code on older glibc, the fallback to sysconf() should+# be good enough.+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <sched.h>+int+main(void)+{+ cpu_set_t cpu_mask;+ sched_getaffinity(0, sizeof(cpu_mask), &cpu_mask);+ return CPU_COUNT(&cpu_mask);+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ tuklib_cv_cpucores_method=sched_getaffinity+else case e in #(+ e)++# FreeBSD has both cpuset and sysctl. Look for cpuset first because+# it's a better approach.+#+# This test would match on GNU/kFreeBSD too but it would require+# -lfreebsd-glue when linking and thus in the current form this would+# fail on GNU/kFreeBSD. The above test for sched_getaffinity() matches+# on GNU/kFreeBSD so the test below should never run on that OS.+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <sys/param.h>+#include <sys/cpuset.h>++int+main(void)+{+ cpuset_t set;+ cpuset_getaffinity(CPU_LEVEL_WHICH, CPU_WHICH_PID, -1,+ sizeof(set), &set);+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ tuklib_cv_cpucores_method=cpuset+else case e in #(+ e)++# On OS/2, both sysconf() and sysctl() pass the tests in this file,+# but only sysctl() works. On QNX it's the opposite: only sysconf() works+# (although it assumes that _POSIX_SOURCE, _XOPEN_SOURCE, and _POSIX_C_SOURCE+# are undefined or alternatively _QNX_SOURCE is defined).+#+# We test sysctl() first and intentionally break the sysctl() test on QNX+# so that sysctl() is never used on QNX.+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#ifdef __QNX__+compile error+#endif+#ifdef HAVE_SYS_PARAM_H+# include <sys/param.h>+#endif+#include <sys/sysctl.h>+int+main(void)+{+#ifdef HW_NCPUONLINE+ /* This is preferred on OpenBSD, see tuklib_cpucores.c. */+ int name[2] = { CTL_HW, HW_NCPUONLINE };+#else+ int name[2] = { CTL_HW, HW_NCPU };+#endif+ int cpus;+ size_t cpus_size = sizeof(cpus);+ sysctl(name, 2, &cpus, &cpus_size, NULL, 0);+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ tuklib_cv_cpucores_method=sysctl+else case e in #(+ e)++cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <unistd.h>+int+main(void)+{+ long i;+#ifdef _SC_NPROCESSORS_ONLN+ /* Many systems using sysconf() */+ i = sysconf(_SC_NPROCESSORS_ONLN);+#else+ /* IRIX */+ i = sysconf(_SC_NPROC_ONLN);+#endif+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ tuklib_cv_cpucores_method=sysconf+else case e in #(+ e)++cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <sys/param.h>+#include <sys/pstat.h>++int+main(void)+{+ struct pst_dynamic pst;+ pstat_getdynamic(&pst, sizeof(pst), 1, 0);+ (void)pst.psd_proc_cnt;+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ tuklib_cv_cpucores_method=pstat_getdynamic+else case e in #(+ e)++ tuklib_cv_cpucores_method=unknown+ ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $tuklib_cv_cpucores_method" >&5+printf "%s\n" "$tuklib_cv_cpucores_method" >&6; }++case $tuklib_cv_cpucores_method in+ sched_getaffinity)++printf "%s\n" "#define TUKLIB_CPUCORES_SCHED_GETAFFINITY 1" >>confdefs.h++ ;;+ cpuset)++printf "%s\n" "#define TUKLIB_CPUCORES_CPUSET 1" >>confdefs.h++ ;;+ sysctl)++printf "%s\n" "#define TUKLIB_CPUCORES_SYSCTL 1" >>confdefs.h++ ;;+ sysconf)++printf "%s\n" "#define TUKLIB_CPUCORES_SYSCONF 1" >>confdefs.h++ ;;+ pstat_getdynamic)++printf "%s\n" "#define TUKLIB_CPUCORES_PSTAT_GETDYNAMIC 1" >>confdefs.h++ ;;+esac+++++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether mbrtowc and mbstate_t are properly declared" >&5+printf %s "checking whether mbrtowc and mbstate_t are properly declared... " >&6; }+if test ${ac_cv_func_mbrtowc+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+#include <wchar.h>+int+main (void)+{+wchar_t wc;+ char const s[] = "";+ size_t n = 1;+ mbstate_t state;+ return ! (sizeof state && (mbrtowc) (&wc, s, n, &state));+ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+ ac_cv_func_mbrtowc=yes+else case e in #(+ e) ac_cv_func_mbrtowc=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_mbrtowc" >&5+printf "%s\n" "$ac_cv_func_mbrtowc" >&6; }+ if test $ac_cv_func_mbrtowc = yes; then++printf "%s\n" "#define HAVE_MBRTOWC 1" >>confdefs.h++ fi++ac_fn_c_check_func "$LINENO" "wcwidth" "ac_cv_func_wcwidth"+if test "x$ac_cv_func_wcwidth" = xyes+then :+ printf "%s\n" "#define HAVE_WCWIDTH 1" >>confdefs.h++fi++++# If requested, check for system-provided SHA-256. At least the following+# implementations are supported:+#+# OS Headers Library Type Function+# FreeBSD sys/types.h + sha256.h libmd SHA256_CTX SHA256_Init+# NetBSD sys/types.h + sha2.h SHA256_CTX SHA256_Init+# OpenBSD sys/types.h + sha2.h SHA2_CTX SHA256Init+# Solaris sys/types.h + sha2.h libmd SHA256_CTX SHA256Init+# MINIX 3 sys/types.h + sha2.h SHA256_CTX SHA256_Init+# Darwin CommonCrypto/CommonDigest.h CC_SHA256_CTX CC_SHA256_Init+#+# Note that Darwin's CC_SHA256_Update takes buffer size as uint32_t instead+# of size_t.+#+sha256_header_found=no+sha256_type_found=no+sha256_func_found=no+if test "x$enable_external_sha256" = "xyes"+then :++ # Test for Common Crypto before others, because Darwin has sha256.h+ # too and we don't want to use that, because on older versions it+ # uses OpenSSL functions, whose SHA256_Init is not guaranteed to+ # succeed.+ for ac_header in CommonCrypto/CommonDigest.h sha256.h sha2.h+do :+ as_ac_Header=`printf "%s\n" "ac_cv_header_$ac_header" | sed "$as_sed_sh"`+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"+if eval test \"x\$"$as_ac_Header"\" = x"yes"+then :+ cat >>confdefs.h <<_ACEOF+#define `printf "%s\n" "HAVE_$ac_header" | sed "$as_sed_cpp"` 1+_ACEOF+ sha256_header_found=yes ; break+fi++done+ if test "x$sha256_header_found" = xyes; then+ ac_fn_c_check_type "$LINENO" "CC_SHA256_CTX" "ac_cv_type_CC_SHA256_CTX" "#ifdef HAVE_SYS_TYPES_H+ # include <sys/types.h>+ #endif+ #ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H+ # include <CommonCrypto/CommonDigest.h>+ #endif+ #ifdef HAVE_SHA256_H+ # include <sha256.h>+ #endif+ #ifdef HAVE_SHA2_H+ # include <sha2.h>+ #endif+"+if test "x$ac_cv_type_CC_SHA256_CTX" = xyes+then :++printf "%s\n" "#define HAVE_CC_SHA256_CTX 1" >>confdefs.h++sha256_type_found=yes+fi+ac_fn_c_check_type "$LINENO" "SHA256_CTX" "ac_cv_type_SHA256_CTX" "#ifdef HAVE_SYS_TYPES_H+ # include <sys/types.h>+ #endif+ #ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H+ # include <CommonCrypto/CommonDigest.h>+ #endif+ #ifdef HAVE_SHA256_H+ # include <sha256.h>+ #endif+ #ifdef HAVE_SHA2_H+ # include <sha2.h>+ #endif+"+if test "x$ac_cv_type_SHA256_CTX" = xyes+then :++printf "%s\n" "#define HAVE_SHA256_CTX 1" >>confdefs.h++sha256_type_found=yes+fi+ac_fn_c_check_type "$LINENO" "SHA2_CTX" "ac_cv_type_SHA2_CTX" "#ifdef HAVE_SYS_TYPES_H+ # include <sys/types.h>+ #endif+ #ifdef HAVE_COMMONCRYPTO_COMMONDIGEST_H+ # include <CommonCrypto/CommonDigest.h>+ #endif+ #ifdef HAVE_SHA256_H+ # include <sha256.h>+ #endif+ #ifdef HAVE_SHA2_H+ # include <sha2.h>+ #endif+"+if test "x$ac_cv_type_SHA2_CTX" = xyes+then :++printf "%s\n" "#define HAVE_SHA2_CTX 1" >>confdefs.h++sha256_type_found=yes+fi++ if test "x$sha256_type_found" = xyes ; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing SHA256Init" >&5+printf %s "checking for library containing SHA256Init... " >&6; }+if test ${ac_cv_search_SHA256Init+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_func_search_save_LIBS=$LIBS+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++/* Override any GCC internal prototype to avoid an error.+ Use char because int might match the return type of a GCC+ builtin and then its argument prototype would still apply.+ The 'extern "C"' is for builds by C++ compilers;+ although this is not generally supported in C code supporting it here+ has little cost and some practical benefit (sr 110532). */+#ifdef __cplusplus+extern "C"+#endif+char SHA256Init (void);+int+main (void)+{+return SHA256Init ();+ ;+ return 0;+}+_ACEOF+for ac_lib in '' md+do+ if test -z "$ac_lib"; then+ ac_res="none required"+ else+ ac_res=-l$ac_lib+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"+ fi+ if ac_fn_c_try_link "$LINENO"+then :+ ac_cv_search_SHA256Init=$ac_res+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext+ if test ${ac_cv_search_SHA256Init+y}+then :+ break+fi+done+if test ${ac_cv_search_SHA256Init+y}+then :++else case e in #(+ e) ac_cv_search_SHA256Init=no ;;+esac+fi+rm conftest.$ac_ext+LIBS=$ac_func_search_save_LIBS ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_SHA256Init" >&5+printf "%s\n" "$ac_cv_search_SHA256Init" >&6; }+ac_res=$ac_cv_search_SHA256Init+if test "$ac_res" != no+then :+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"++fi++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for library containing SHA256_Init" >&5+printf %s "checking for library containing SHA256_Init... " >&6; }+if test ${ac_cv_search_SHA256_Init+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) ac_func_search_save_LIBS=$LIBS+cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++/* Override any GCC internal prototype to avoid an error.+ Use char because int might match the return type of a GCC+ builtin and then its argument prototype would still apply.+ The 'extern "C"' is for builds by C++ compilers;+ although this is not generally supported in C code supporting it here+ has little cost and some practical benefit (sr 110532). */+#ifdef __cplusplus+extern "C"+#endif+char SHA256_Init (void);+int+main (void)+{+return SHA256_Init ();+ ;+ return 0;+}+_ACEOF+for ac_lib in '' md+do+ if test -z "$ac_lib"; then+ ac_res="none required"+ else+ ac_res=-l$ac_lib+ LIBS="-l$ac_lib $ac_func_search_save_LIBS"+ fi+ if ac_fn_c_try_link "$LINENO"+then :+ ac_cv_search_SHA256_Init=$ac_res+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext+ if test ${ac_cv_search_SHA256_Init+y}+then :+ break+fi+done+if test ${ac_cv_search_SHA256_Init+y}+then :++else case e in #(+ e) ac_cv_search_SHA256_Init=no ;;+esac+fi+rm conftest.$ac_ext+LIBS=$ac_func_search_save_LIBS ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_SHA256_Init" >&5+printf "%s\n" "$ac_cv_search_SHA256_Init" >&6; }+ac_res=$ac_cv_search_SHA256_Init+if test "$ac_res" != no+then :+ test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"++fi+++ for ac_func in CC_SHA256_Init SHA256Init SHA256_Init+do :+ as_ac_var=`printf "%s\n" "ac_cv_func_$ac_func" | sed "$as_sed_sh"`+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"+if eval test \"x\$"$as_ac_var"\" = x"yes"+then :+ cat >>confdefs.h <<_ACEOF+#define `printf "%s\n" "HAVE_$ac_func" | sed "$as_sed_cpp"` 1+_ACEOF+ sha256_func_found=yes ; break+fi++done+ fi+ fi++fi+ if test "x$sha256_func_found" = xno; then+ COND_INTERNAL_SHA256_TRUE=+ COND_INTERNAL_SHA256_FALSE='#'+else+ COND_INTERNAL_SHA256_TRUE='#'+ COND_INTERNAL_SHA256_FALSE=+fi++if test "x$enable_external_sha256$sha256_func_found" = xyesno; then+ as_fn_error $? "--enable-external-sha256 was specified but no supported external SHA-256 implementation was found" "$LINENO" 5+fi++# Check for SSE2 intrinsics. There is no run-time detection for SSE2 so if+# compiler options enable SSE2 then SSE2 support is required by the binaries.+# The compile-time check for SSE2 is done with #ifdefs because some compilers+# (ICC, MSVC) allow SSE2 intrinsics even when SSE2 isn't enabled.+ac_fn_check_decl "$LINENO" "_mm_movemask_epi8" "ac_cv_have_decl__mm_movemask_epi8" "#ifdef HAVE_IMMINTRIN_H+#include <immintrin.h>+#endif+" "$ac_c_undeclared_builtin_options" "CFLAGS"+if test "x$ac_cv_have_decl__mm_movemask_epi8" = xyes+then :++printf "%s\n" "#define HAVE__MM_MOVEMASK_EPI8 1" >>confdefs.h++fi++# For faster CRC on 32/64-bit x86 and E2K (see also crc64_fast.c):+#+# - Check for the CLMUL intrinsic _mm_clmulepi64_si128 in <immintrin.h>.+# Check also for _mm_set_epi64x for consistency with CMake build+# where it's needed to disable CLMUL with VS2013.+#+# - Check that __attribute__((__target__("ssse3,sse4.1,pclmul"))) works+# together with _mm_clmulepi64_si128 from <immintrin.h>. The attribute+# was added in GCC 4.4 but some GCC 4.x versions don't allow intrinsics+# with it. Exception: it must be not be used with EDG-based compilers+# like ICC and the compiler on E2K.+#+# If everything above is supported, runtime detection will be used to keep the+# binaries working on systems that don't support the required extensions.+#+# NOTE: Use a check that links and not merely compiles to ensure that+# missing intrinsics don't get accepted with compilers that allow+# implicit function declarations.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if _mm_clmulepi64_si128 is usable" >&5+printf %s "checking if _mm_clmulepi64_si128 is usable... " >&6; }+if test "x$enable_clmul_crc" = xno+then :++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, --disable-clmul-crc was used" >&5+printf "%s\n" "no, --disable-clmul-crc was used" >&6; }++else case e in #(+ e)+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <immintrin.h>++// CLMUL works on older E2K instruction set but it is slow due to emulation.+#if defined(__e2k__) && __iset__ < 6+# error+#endif++// Intel's old compiler (ICC) can define __GNUC__ but the attribute must not+// be used with it. The new Clang-based ICX needs the attribute.+// Checking for !defined(__EDG__) catches ICC and other EDG-based compilers.+#if (defined(__GNUC__) || defined(__clang__)) && !defined(__EDG__)+__attribute__((__target__("ssse3,sse4.1,pclmul")))+#endif+int main(void)+{+ __m128i a = _mm_set_epi64x(1, 2);+ a = _mm_clmulepi64_si128(a, a, 0);+ return 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+++printf "%s\n" "#define HAVE_USABLE_CLMUL 1" >>confdefs.h++ enable_clmul_crc=yes++else case e in #(+ e)+ enable_clmul_crc=no+ ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_clmul_crc" >&5+printf "%s\n" "$enable_clmul_crc" >&6; }+ ;;+esac+fi++# ARM64 C Language Extensions define CRC32 functions in arm_acle.h.+# These are supported by at least GCC and Clang which both need+# __attribute__((__target__("+crc"))), unless the needed compiler flags+# are used to support the CRC instruction.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if ARM64 CRC32 instruction is usable" >&5+printf %s "checking if ARM64 CRC32 instruction is usable... " >&6; }+if test "x$enable_arm64_crc32" = xno+then :++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, --disable-arm64-crc32 was used" >&5+printf "%s\n" "no, --disable-arm64-crc32 was used" >&6; }++else case e in #(+ e)+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#include <arm_acle.h>+#include <stdint.h>++#if (defined(__GNUC__) || defined(__clang__)) && !defined(__EDG__)+__attribute__((__target__("+crc")))+#endif+int main(void)+{+ return __crc32d(1, 2) != 0;+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+++printf "%s\n" "#define HAVE_ARM64_CRC32 1" >>confdefs.h++ enable_arm64_crc32=yes++else case e in #(+ e)+ enable_arm64_crc32=no+ ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_arm64_crc32" >&5+printf "%s\n" "$enable_arm64_crc32" >&6; }+ ;;+esac+fi++# Check for ARM64 CRC32 instruction runtime detection.+#+# - getauxval() is supported on Linux.+#+# - elf_aux_info() is supported on FreeBSD and OpenBSD >= 7.6.+#+# - sysctlbyname("hw.optional.armv8_crc32", ...) is supported on Darwin+# (macOS, iOS, etc.). Note that sysctlbyname() is supported on FreeBSD,+# NetBSD, and possibly others too but the string is specific to Apple+# OSes. The C code is responsible for checking defined(__APPLE__)+# before using sysctlbyname("hw.optional.armv8_crc32", ...).+#+if test "x$enable_arm64_crc32" = xyes+then :+++ for ac_func in getauxval elf_aux_info sysctlbyname+do :+ as_ac_var=`printf "%s\n" "ac_cv_func_$ac_func" | sed "$as_sed_sh"`+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"+if eval test \"x\$"$as_ac_var"\" = x"yes"+then :+ cat >>confdefs.h <<_ACEOF+#define `printf "%s\n" "HAVE_$ac_func" | sed "$as_sed_cpp"` 1+_ACEOF+ break+fi++done++fi+++# LoongArch CRC32 intrinsics are in larchintrin.h.+# These are supported by at least GCC and Clang.+#+# Only 64-bit LoongArch is currently supported.+# It doesn't need runtime detection.+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if LoongArch CRC32 instructions are usable" >&5+printf %s "checking if LoongArch CRC32 instructions are usable... " >&6; }+if test "x$enable_loongarch_crc32" = xno+then :++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no, --disable-loongarch-crc32 was used" >&5+printf "%s\n" "no, --disable-loongarch-crc32 was used" >&6; }++else case e in #(+ e)+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++#if !(defined(__loongarch__) && __loongarch_grlen >= 64)+# error+#endif++#include <larchintrin.h>+int main(void)+{+ return __crc_w_w_w(1, 2);+}++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :+++printf "%s\n" "#define HAVE_LOONGARCH_CRC32 1" >>confdefs.h++ enable_loongarch_crc32=yes++else case e in #(+ e)+ enable_loongarch_crc32=no+ ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $enable_loongarch_crc32" >&5+printf "%s\n" "$enable_loongarch_crc32" >&6; }+ ;;+esac+fi+++# Check for sandbox support. If one is found, set enable_sandbox=found.+#+# About -fsanitize: Of our three sandbox methods, only Landlock is+# incompatible with -fsanitize. FreeBSD 13.2 with Capsicum was tested with+# -fsanitize=address,undefined and had no issues. OpenBSD (as of version+# 7.4) has minimal support for process instrumentation. OpenBSD does not+# distribute the additional libraries needed (libasan, libubsan, etc.) with+# GCC or Clang needed for runtime sanitization support and instead only+# support -fsanitize-minimal-runtime for minimal undefined behavior+# sanitization. This minimal support is compatible with our use of the+# Pledge sandbox. So only Landlock will result in a build that cannot+# compress or decompress a single file to standard out.+case $enable_sandbox in #(+ auto | capsicum) :+++ for ac_func in cap_rights_limit+do :+ ac_fn_c_check_func "$LINENO" "cap_rights_limit" "ac_cv_func_cap_rights_limit"+if test "x$ac_cv_func_cap_rights_limit" = xyes+then :+ printf "%s\n" "#define HAVE_CAP_RIGHTS_LIMIT 1" >>confdefs.h+ enable_sandbox=found+fi++done++ ;; #(+ *) :+ ;;+esac+case $enable_sandbox in #(+ auto | pledge) :+++ for ac_func in pledge+do :+ ac_fn_c_check_func "$LINENO" "pledge" "ac_cv_func_pledge"+if test "x$ac_cv_func_pledge" = xyes+then :+ printf "%s\n" "#define HAVE_PLEDGE 1" >>confdefs.h+ enable_sandbox=found+fi++done++ ;; #(+ *) :+ ;;+esac+case $enable_sandbox in #(+ auto | landlock) :++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if Linux Landlock is usable" >&5+printf %s "checking if Linux Landlock is usable... " >&6; }++ # A compile check is done here because some systems have+ # linux/landlock.h, but do not have the syscalls defined+ # in order to actually use Linux Landlock.+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++ #include <linux/landlock.h>+ #include <sys/syscall.h>+ #include <sys/prctl.h>++ int main(void)+ {+ (void)prctl(PR_SET_NO_NEW_PRIVS, 1, 0, 0, 0);+ (void)SYS_landlock_create_ruleset;+ (void)SYS_landlock_restrict_self;+ (void)LANDLOCK_CREATE_RULESET_VERSION;+ return 0;+ }++_ACEOF+if ac_fn_c_try_link "$LINENO"+then :++ enable_sandbox=found++ case $CFLAGS in #(+ *-fsanitize=*) :+ as_fn_error $? "+ CFLAGS contains '-fsanitize=' which is incompatible with the Landlock+ sandboxing. Use --disable-sandbox when using '-fsanitize'." "$LINENO" 5 ;; #(+ *) :+ ;;+esac+++printf "%s\n" "#define HAVE_LINUX_LANDLOCK 1" >>confdefs.h++ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }++else case e in #(+ e)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+ ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam \+ conftest$ac_exeext conftest.$ac_ext++ ;; #(+ *) :+ ;;+esac++# If a specific sandboxing method was explicitly requested and it wasn't+# found, give an error.+case $enable_sandbox in+ auto | no | found)+ ;;+ *)+ as_fn_error $? "$enable_sandbox support not found" "$LINENO" 5+ ;;+esac+++###############################################################################+# If using GCC, set some additional AM_CFLAGS:+###############################################################################++if test "$GCC" = yes ; then+ echo+ echo "GCC extensions:"+fi++# Always do the visibility check but don't set AM_CFLAGS on Windows.+# This way things get set properly even on Windows.+++ CFLAG_VISIBILITY=+ HAVE_VISIBILITY=0+ if test -n "$GCC"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the -Werror option is usable" >&5+printf %s "checking whether the -Werror option is usable... " >&6; }+if test ${gl_cv_cc_vis_werror+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) gl_saved_CFLAGS="$CFLAGS"+ CFLAGS="$CFLAGS -Werror"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ gl_cv_cc_vis_werror=yes+else case e in #(+ e) gl_cv_cc_vis_werror=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ CFLAGS="$gl_saved_CFLAGS"+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_vis_werror" >&5+printf "%s\n" "$gl_cv_cc_vis_werror" >&6; }+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for simple visibility declarations" >&5+printf %s "checking for simple visibility declarations... " >&6; }+if test ${gl_cv_cc_visibility+y}+then :+ printf %s "(cached) " >&6+else case e in #(+ e) gl_saved_CFLAGS="$CFLAGS"+ CFLAGS="$CFLAGS -fvisibility=hidden"+ if test $gl_cv_cc_vis_werror = yes; then+ CFLAGS="$CFLAGS -Werror"+ fi+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+extern __attribute__((__visibility__("hidden"))) int hiddenvar;+ extern __attribute__((__visibility__("default"))) int exportedvar;+ extern __attribute__((__visibility__("hidden"))) int hiddenfunc (void);+ extern __attribute__((__visibility__("default"))) int exportedfunc (void);+ void dummyfunc (void);+ int hiddenvar;+ int exportedvar;+ int hiddenfunc (void) { return 51; }+ int exportedfunc (void) { return 1225736919; }+ void dummyfunc (void) {}++int+main (void)+{++ ;+ return 0;+}+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :+ gl_cv_cc_visibility=yes+else case e in #(+ e) gl_cv_cc_visibility=no ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ CFLAGS="$gl_saved_CFLAGS"+ ;;+esac+fi+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $gl_cv_cc_visibility" >&5+printf "%s\n" "$gl_cv_cc_visibility" >&6; }+ if test $gl_cv_cc_visibility = yes; then+ CFLAG_VISIBILITY="-fvisibility=hidden"+ HAVE_VISIBILITY=1+ fi+ fi++++printf "%s\n" "#define HAVE_VISIBILITY $HAVE_VISIBILITY" >>confdefs.h+++if test -n "$CFLAG_VISIBILITY" && test "$is_w32" = no; then+ AM_CFLAGS="$AM_CFLAGS $CFLAG_VISIBILITY"+fi++if test "$GCC" = yes+then :++ # Enable as much warnings as possible. These commented warnings won't+ # work for this package though:+ # * -Wunreachable-code breaks several assert(0) cases, which are+ # backed up with "return LZMA_PROG_ERROR".+ # * -Wcast-qual would break various things where we need a non-const+ # pointer although we don't modify anything through it.+ # * -Winline, -Wdisabled-optimization, -Wunsafe-loop-optimizations+ # don't seem so useful here; at least the last one gives some+ # warnings which are not bugs.+ # * -Wconversion still shows too many warnings.+ #+ # The flags before the empty line are for GCC and many of them+ # are supported by Clang too. The flags after the empty line are+ # for Clang.+ for NEW_FLAG in \+ -Wall \+ -Wextra \+ -Wvla \+ -Wformat=2 \+ -Winit-self \+ -Wmissing-include-dirs \+ -Wshift-overflow=2 \+ -Wstrict-overflow=3 \+ -Walloc-zero \+ -Wduplicated-cond \+ -Wfloat-equal \+ -Wundef \+ -Wshadow \+ -Wpointer-arith \+ -Wbad-function-cast \+ -Wwrite-strings \+ -Wdate-time \+ -Wsign-conversion \+ -Wfloat-conversion \+ -Wlogical-op \+ -Waggregate-return \+ -Wstrict-prototypes \+ -Wold-style-definition \+ -Wmissing-prototypes \+ -Wmissing-declarations \+ -Wredundant-decls \+ \+ -Wc99-compat \+ -Wc11-extensions \+ -Wc2x-compat \+ -Wc2x-extensions \+ -Wpre-c2x-compat \+ -Warray-bounds-pointer-arithmetic \+ -Wassign-enum \+ -Wconditional-uninitialized \+ -Wdocumentation \+ -Wduplicate-enum \+ -Wempty-translation-unit \+ -Wflexible-array-extensions \+ -Wmissing-variable-declarations \+ -Wnewline-eof \+ -Wshift-sign-overflow \+ -Wstring-conversion+ do+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if $CC accepts $NEW_FLAG" >&5+printf %s "checking if $CC accepts $NEW_FLAG... " >&6; }+ OLD_CFLAGS="$CFLAGS"+ CFLAGS="$CFLAGS $NEW_FLAG -Werror"+ cat confdefs.h - <<_ACEOF >conftest.$ac_ext+/* end confdefs.h. */+void foo(void); void foo(void) { }+_ACEOF+if ac_fn_c_try_compile "$LINENO"+then :++ AM_CFLAGS="$AM_CFLAGS $NEW_FLAG"+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5+printf "%s\n" "yes" >&6; }++else case e in #(+ e)+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5+printf "%s\n" "no" >&6; }+ ;;+esac+fi+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext+ CFLAGS="$OLD_CFLAGS"+ done++ # Check whether --enable-werror was given.+if test ${enable_werror+y}+then :+ enableval=$enable_werror;+else case e in #(+ e) enable_werror=no ;;+esac+fi++ if test "x$enable_werror" = "xyes"; then+ AM_CFLAGS="$AM_CFLAGS -Werror"+ fi++fi+++###############################################################################+# Create the makefiles and config.h+###############################################################################++echo++# Don't build the lib directory at all if we don't need any replacement+# functions.+ if test -n "$LIBOBJS"; then+ COND_GNULIB_TRUE=+ COND_GNULIB_FALSE='#'+else+ COND_GNULIB_TRUE='#'+ COND_GNULIB_FALSE=+fi+++# Add default AM_CFLAGS.+++# This is needed for src/scripts.+xz=`echo xz | sed "$program_transform_name"`++++cat >confcache <<\_ACEOF+# This file is a shell script that caches the results of configure+# tests run on this system so they can be shared between configure+# scripts and configure runs, see configure's option --config-cache.+# It is not useful on other systems. If it contains results you don't+# want to keep, you may remove or edit it.+#+# config.status only pays attention to the cache file if you give it+# the --recheck option to rerun configure.+#+# 'ac_cv_env_foo' variables (set or unset) will be overridden when+# loading this file, other *unset* 'ac_cv_foo' will be assigned the+# following values.++_ACEOF++# The following way of writing the cache mishandles newlines in values,+# but we know of no workaround that is simple, portable, and efficient.+# So, we kill variables containing newlines.+# Ultrix sh set writes to stderr and can't be redirected directly,+# and sets the high bit in the cache file unless we assign to the vars.+(+ for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do+ eval ac_val=\$$ac_var+ case $ac_val in #(+ *${as_nl}*)+ case $ac_var in #(+ *_cv_*) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5+printf "%s\n" "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;+ esac+ case $ac_var in #(+ _ | IFS | as_nl) ;; #(+ BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(+ *) { eval $ac_var=; unset $ac_var;} ;;+ esac ;;+ esac+ done++ (set) 2>&1 |+ case $as_nl`(ac_space=' '; set) 2>&1` in #(+ *${as_nl}ac_space=\ *)+ # 'set' does not quote correctly, so add quotes: double-quote+ # substitution turns \\\\ into \\, and sed turns \\ into \.+ sed -n \+ "s/'/'\\\\''/g;+ s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"+ ;; #(+ *)+ # 'set' quotes correctly as required by POSIX, so do not add quotes.+ sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"+ ;;+ esac |+ sort+) |+ sed '+ /^ac_cv_env_/b end+ t clear+ :clear+ s/^\([^=]*\)=\(.*[{}].*\)$/test ${\1+y} || &/+ t end+ s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/+ :end' >>confcache+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else+ if test -w "$cache_file"; then+ if test "x$cache_file" != "x/dev/null"; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5+printf "%s\n" "$as_me: updating cache $cache_file" >&6;}+ if test ! -f "$cache_file" || test -h "$cache_file"; then+ cat confcache >"$cache_file"+ else+ case $cache_file in #(+ */* | ?:*)+ mv -f confcache "$cache_file"$$ &&+ mv -f "$cache_file"$$ "$cache_file" ;; #(+ *)+ mv -f confcache "$cache_file" ;;+ esac+ fi+ fi+ else+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5+printf "%s\n" "$as_me: not updating unwritable cache $cache_file" >&6;}+ fi+fi+rm -f confcache++test "x$prefix" = xNONE && prefix=$ac_default_prefix+# Let make expand exec_prefix.+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'++DEFS=-DHAVE_CONFIG_H++ac_libobjs=+ac_ltlibobjs=+U=+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue+ # 1. Remove the extension, and $U if already installed.+ ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'+ ac_i=`printf "%s\n" "$ac_i" | sed "$ac_script"`+ # 2. Prepend LIBOBJDIR. When used with automake>=1.10 LIBOBJDIR+ # will be set to the directory where LIBOBJS objects are built.+ as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"+ as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'+done+LIBOBJS=$ac_libobjs++LTLIBOBJS=$ac_ltlibobjs+++if test -z "${COND_W32_TRUE}" && test -z "${COND_W32_FALSE}"; then+ as_fn_error $? "conditional \"COND_W32\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_MAIN_ENCODER_TRUE}" && test -z "${COND_MAIN_ENCODER_FALSE}"; then+ as_fn_error $? "conditional \"COND_MAIN_ENCODER\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_MAIN_DECODER_TRUE}" && test -z "${COND_MAIN_DECODER_FALSE}"; then+ as_fn_error $? "conditional \"COND_MAIN_DECODER\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_FILTER_LZMA1_TRUE}" && test -z "${COND_FILTER_LZMA1_FALSE}"; then+ as_fn_error $? "conditional \"COND_FILTER_LZMA1\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ENCODER_LZMA1_TRUE}" && test -z "${COND_ENCODER_LZMA1_FALSE}"; then+ as_fn_error $? "conditional \"COND_ENCODER_LZMA1\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DECODER_LZMA1_TRUE}" && test -z "${COND_DECODER_LZMA1_FALSE}"; then+ as_fn_error $? "conditional \"COND_DECODER_LZMA1\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_FILTER_LZMA2_TRUE}" && test -z "${COND_FILTER_LZMA2_FALSE}"; then+ as_fn_error $? "conditional \"COND_FILTER_LZMA2\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ENCODER_LZMA2_TRUE}" && test -z "${COND_ENCODER_LZMA2_FALSE}"; then+ as_fn_error $? "conditional \"COND_ENCODER_LZMA2\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DECODER_LZMA2_TRUE}" && test -z "${COND_DECODER_LZMA2_FALSE}"; then+ as_fn_error $? "conditional \"COND_DECODER_LZMA2\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_FILTER_DELTA_TRUE}" && test -z "${COND_FILTER_DELTA_FALSE}"; then+ as_fn_error $? "conditional \"COND_FILTER_DELTA\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ENCODER_DELTA_TRUE}" && test -z "${COND_ENCODER_DELTA_FALSE}"; then+ as_fn_error $? "conditional \"COND_ENCODER_DELTA\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DECODER_DELTA_TRUE}" && test -z "${COND_DECODER_DELTA_FALSE}"; then+ as_fn_error $? "conditional \"COND_DECODER_DELTA\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_FILTER_X86_TRUE}" && test -z "${COND_FILTER_X86_FALSE}"; then+ as_fn_error $? "conditional \"COND_FILTER_X86\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ENCODER_X86_TRUE}" && test -z "${COND_ENCODER_X86_FALSE}"; then+ as_fn_error $? "conditional \"COND_ENCODER_X86\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DECODER_X86_TRUE}" && test -z "${COND_DECODER_X86_FALSE}"; then+ as_fn_error $? "conditional \"COND_DECODER_X86\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_FILTER_POWERPC_TRUE}" && test -z "${COND_FILTER_POWERPC_FALSE}"; then+ as_fn_error $? "conditional \"COND_FILTER_POWERPC\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ENCODER_POWERPC_TRUE}" && test -z "${COND_ENCODER_POWERPC_FALSE}"; then+ as_fn_error $? "conditional \"COND_ENCODER_POWERPC\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DECODER_POWERPC_TRUE}" && test -z "${COND_DECODER_POWERPC_FALSE}"; then+ as_fn_error $? "conditional \"COND_DECODER_POWERPC\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_FILTER_IA64_TRUE}" && test -z "${COND_FILTER_IA64_FALSE}"; then+ as_fn_error $? "conditional \"COND_FILTER_IA64\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ENCODER_IA64_TRUE}" && test -z "${COND_ENCODER_IA64_FALSE}"; then+ as_fn_error $? "conditional \"COND_ENCODER_IA64\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DECODER_IA64_TRUE}" && test -z "${COND_DECODER_IA64_FALSE}"; then+ as_fn_error $? "conditional \"COND_DECODER_IA64\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_FILTER_ARM_TRUE}" && test -z "${COND_FILTER_ARM_FALSE}"; then+ as_fn_error $? "conditional \"COND_FILTER_ARM\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ENCODER_ARM_TRUE}" && test -z "${COND_ENCODER_ARM_FALSE}"; then+ as_fn_error $? "conditional \"COND_ENCODER_ARM\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DECODER_ARM_TRUE}" && test -z "${COND_DECODER_ARM_FALSE}"; then+ as_fn_error $? "conditional \"COND_DECODER_ARM\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_FILTER_ARMTHUMB_TRUE}" && test -z "${COND_FILTER_ARMTHUMB_FALSE}"; then+ as_fn_error $? "conditional \"COND_FILTER_ARMTHUMB\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ENCODER_ARMTHUMB_TRUE}" && test -z "${COND_ENCODER_ARMTHUMB_FALSE}"; then+ as_fn_error $? "conditional \"COND_ENCODER_ARMTHUMB\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DECODER_ARMTHUMB_TRUE}" && test -z "${COND_DECODER_ARMTHUMB_FALSE}"; then+ as_fn_error $? "conditional \"COND_DECODER_ARMTHUMB\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_FILTER_ARM64_TRUE}" && test -z "${COND_FILTER_ARM64_FALSE}"; then+ as_fn_error $? "conditional \"COND_FILTER_ARM64\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ENCODER_ARM64_TRUE}" && test -z "${COND_ENCODER_ARM64_FALSE}"; then+ as_fn_error $? "conditional \"COND_ENCODER_ARM64\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DECODER_ARM64_TRUE}" && test -z "${COND_DECODER_ARM64_FALSE}"; then+ as_fn_error $? "conditional \"COND_DECODER_ARM64\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_FILTER_SPARC_TRUE}" && test -z "${COND_FILTER_SPARC_FALSE}"; then+ as_fn_error $? "conditional \"COND_FILTER_SPARC\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ENCODER_SPARC_TRUE}" && test -z "${COND_ENCODER_SPARC_FALSE}"; then+ as_fn_error $? "conditional \"COND_ENCODER_SPARC\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DECODER_SPARC_TRUE}" && test -z "${COND_DECODER_SPARC_FALSE}"; then+ as_fn_error $? "conditional \"COND_DECODER_SPARC\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_FILTER_RISCV_TRUE}" && test -z "${COND_FILTER_RISCV_FALSE}"; then+ as_fn_error $? "conditional \"COND_FILTER_RISCV\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ENCODER_RISCV_TRUE}" && test -z "${COND_ENCODER_RISCV_FALSE}"; then+ as_fn_error $? "conditional \"COND_ENCODER_RISCV\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DECODER_RISCV_TRUE}" && test -z "${COND_DECODER_RISCV_FALSE}"; then+ as_fn_error $? "conditional \"COND_DECODER_RISCV\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_FILTER_SIMPLE_TRUE}" && test -z "${COND_FILTER_SIMPLE_FALSE}"; then+ as_fn_error $? "conditional \"COND_FILTER_SIMPLE\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ENCODER_SIMPLE_TRUE}" && test -z "${COND_ENCODER_SIMPLE_FALSE}"; then+ as_fn_error $? "conditional \"COND_ENCODER_SIMPLE\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DECODER_SIMPLE_TRUE}" && test -z "${COND_DECODER_SIMPLE_FALSE}"; then+ as_fn_error $? "conditional \"COND_DECODER_SIMPLE\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_FILTER_LZ_TRUE}" && test -z "${COND_FILTER_LZ_FALSE}"; then+ as_fn_error $? "conditional \"COND_FILTER_LZ\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ENCODER_LZ_TRUE}" && test -z "${COND_ENCODER_LZ_FALSE}"; then+ as_fn_error $? "conditional \"COND_ENCODER_LZ\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DECODER_LZ_TRUE}" && test -z "${COND_DECODER_LZ_FALSE}"; then+ as_fn_error $? "conditional \"COND_DECODER_LZ\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_CHECK_CRC32_TRUE}" && test -z "${COND_CHECK_CRC32_FALSE}"; then+ as_fn_error $? "conditional \"COND_CHECK_CRC32\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_CHECK_CRC64_TRUE}" && test -z "${COND_CHECK_CRC64_FALSE}"; then+ as_fn_error $? "conditional \"COND_CHECK_CRC64\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_CHECK_SHA256_TRUE}" && test -z "${COND_CHECK_SHA256_FALSE}"; then+ as_fn_error $? "conditional \"COND_CHECK_SHA256\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_MICROLZMA_TRUE}" && test -z "${COND_MICROLZMA_FALSE}"; then+ as_fn_error $? "conditional \"COND_MICROLZMA\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_LZIP_DECODER_TRUE}" && test -z "${COND_LZIP_DECODER_FALSE}"; then+ as_fn_error $? "conditional \"COND_LZIP_DECODER\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_ASM_X86_TRUE}" && test -z "${COND_ASM_X86_FALSE}"; then+ as_fn_error $? "conditional \"COND_ASM_X86\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_SMALL_TRUE}" && test -z "${COND_SMALL_FALSE}"; then+ as_fn_error $? "conditional \"COND_SMALL\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_XZ_TRUE}" && test -z "${COND_XZ_FALSE}"; then+ as_fn_error $? "conditional \"COND_XZ\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_XZDEC_TRUE}" && test -z "${COND_XZDEC_FALSE}"; then+ as_fn_error $? "conditional \"COND_XZDEC\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_LZMADEC_TRUE}" && test -z "${COND_LZMADEC_FALSE}"; then+ as_fn_error $? "conditional \"COND_LZMADEC\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_LZMAINFO_TRUE}" && test -z "${COND_LZMAINFO_FALSE}"; then+ as_fn_error $? "conditional \"COND_LZMAINFO\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_LZMALINKS_TRUE}" && test -z "${COND_LZMALINKS_FALSE}"; then+ as_fn_error $? "conditional \"COND_LZMALINKS\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_SCRIPTS_TRUE}" && test -z "${COND_SCRIPTS_FALSE}"; then+ as_fn_error $? "conditional \"COND_SCRIPTS\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DOC_TRUE}" && test -z "${COND_DOC_FALSE}"; then+ as_fn_error $? "conditional \"COND_DOC\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_DOXYGEN_TRUE}" && test -z "${COND_DOXYGEN_FALSE}"; then+ as_fn_error $? "conditional \"COND_DOXYGEN\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then+ as_fn_error $? "conditional \"AMDEP\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${am__fastdepCCAS_TRUE}" && test -z "${am__fastdepCCAS_FALSE}"; then+ as_fn_error $? "conditional \"am__fastdepCCAS\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_THREADS_TRUE}" && test -z "${COND_THREADS_FALSE}"; then+ as_fn_error $? "conditional \"COND_THREADS\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_SHARED_TRUE}" && test -z "${COND_SHARED_FALSE}"; then+ as_fn_error $? "conditional \"COND_SHARED\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_SYMVERS_LINUX_TRUE}" && test -z "${COND_SYMVERS_LINUX_FALSE}"; then+ as_fn_error $? "conditional \"COND_SYMVERS_LINUX\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_SYMVERS_GENERIC_TRUE}" && test -z "${COND_SYMVERS_GENERIC_FALSE}"; then+ as_fn_error $? "conditional \"COND_SYMVERS_GENERIC\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+# Check whether --enable-year2038 was given.+if test ${enable_year2038+y}+then :+ enableval=$enable_year2038;+fi+++if test -z "${COND_INTERNAL_SHA256_TRUE}" && test -z "${COND_INTERNAL_SHA256_FALSE}"; then+ as_fn_error $? "conditional \"COND_INTERNAL_SHA256\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi+if test -z "${COND_GNULIB_TRUE}" && test -z "${COND_GNULIB_FALSE}"; then+ as_fn_error $? "conditional \"COND_GNULIB\" was never defined.+Usually this means the macro was only invoked conditionally." "$LINENO" 5+fi++: "${CONFIG_STATUS=./config.status}"+ac_write_fail=0+ac_clean_files_save=$ac_clean_files+ac_clean_files="$ac_clean_files $CONFIG_STATUS"+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5+printf "%s\n" "$as_me: creating $CONFIG_STATUS" >&6;}+as_write_fail=0+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1+#! $SHELL+# Generated by $as_me.+# Run this file to recreate the current configuration.+# Compiler output produced by configure, useful for debugging+# configure, is in config.log if it exists.++debug=false+ac_cs_recheck=false+ac_cs_silent=false++SHELL=\${CONFIG_SHELL-$SHELL}+export SHELL+_ASEOF+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1+## -------------------- ##+## M4sh Initialization. ##+## -------------------- ##++# Be more Bourne compatible+DUALCASE=1; export DUALCASE # for MKS sh+if test ${ZSH_VERSION+y} && (emulate sh) >/dev/null 2>&1+then :+ emulate sh+ NULLCMD=:+ # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which+ # is contrary to our usage. Disable this feature.+ alias -g '${1+"$@"}'='"$@"'+ setopt NO_GLOB_SUBST+else case e in #(+ e) case `(set -o) 2>/dev/null` in #(+ *posix*) :+ set -o posix ;; #(+ *) :+ ;;+esac ;;+esac+fi++++# Reset variables that may have inherited troublesome values from+# the environment.++# IFS needs to be set, to space, tab, and newline, in precisely that order.+# (If _AS_PATH_WALK were called with IFS unset, it would have the+# side effect of setting IFS to empty, thus disabling word splitting.)+# Quoting is to prevent editors from complaining about space-tab.+as_nl='+'+export as_nl+IFS=" "" $as_nl"++PS1='$ '+PS2='> '+PS4='+ '++# Ensure predictable behavior from utilities with locale-dependent output.+LC_ALL=C+export LC_ALL+LANGUAGE=C+export LANGUAGE++# We cannot yet rely on "unset" to work, but we need these variables+# to be unset--not just set to an empty or harmless value--now, to+# avoid bugs in old shells (e.g. pre-3.0 UWIN ksh). This construct+# also avoids known problems related to "unset" and subshell syntax+# in other old shells (e.g. bash 2.01 and pdksh 5.2.14).+for as_var in BASH_ENV ENV MAIL MAILPATH CDPATH+do eval test \${$as_var+y} \+ && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :+done++# Ensure that fds 0, 1, and 2 are open.+if (exec 3>&0) 2>/dev/null; then :; else exec 0</dev/null; fi+if (exec 3>&1) 2>/dev/null; then :; else exec 1>/dev/null; fi+if (exec 3>&2) ; then :; else exec 2>/dev/null; fi++# The user is always right.+if ${PATH_SEPARATOR+false} :; then+ PATH_SEPARATOR=:+ (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {+ (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||+ PATH_SEPARATOR=';'+ }+fi+++# Find who we are. Look in the path if we contain no directory separator.+as_myself=+case $0 in #((+ *[\\/]* ) as_myself=$0 ;;+ *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR+for as_dir in $PATH+do+ IFS=$as_save_IFS+ case $as_dir in #(((+ '') as_dir=./ ;;+ */) ;;+ *) as_dir=$as_dir/ ;;+ esac+ test -r "$as_dir$0" && as_myself=$as_dir$0 && break+ done+IFS=$as_save_IFS++ ;;+esac+# We did not find ourselves, most probably we were run as 'sh COMMAND'+# in which case we are not to be found in the path.+if test "x$as_myself" = x; then+ as_myself=$0+fi+if test ! -f "$as_myself"; then+ printf "%s\n" "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2+ exit 1+fi++++# as_fn_error STATUS ERROR [LINENO LOG_FD]+# ----------------------------------------+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the+# script with STATUS, using 1 if that was 0.+as_fn_error ()+{+ as_status=$1; test $as_status -eq 0 && as_status=1+ if test "$4"; then+ as_lineno=${as_lineno-"$3"} as_lineno_stack=as_lineno_stack=$as_lineno_stack+ printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: $2" >&$4+ fi+ printf "%s\n" "$as_me: error: $2" >&2+ as_fn_exit $as_status+} # as_fn_error+++# as_fn_set_status STATUS+# -----------------------+# Set $? to STATUS, without forking.+as_fn_set_status ()+{+ return $1+} # as_fn_set_status++# as_fn_exit STATUS+# -----------------+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.+as_fn_exit ()+{+ set +e+ as_fn_set_status $1+ exit $1+} # as_fn_exit++# as_fn_unset VAR+# ---------------+# Portably unset VAR.+as_fn_unset ()+{+ { eval $1=; unset $1;}+}+as_unset=as_fn_unset++# as_fn_append VAR VALUE+# ----------------------+# Append the text in VALUE to the end of the definition contained in VAR. Take+# advantage of any shell optimizations that allow amortized linear growth over+# repeated appends, instead of the typical quadratic growth present in naive+# implementations.+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null+then :+ eval 'as_fn_append ()+ {+ eval $1+=\$2+ }'+else case e in #(+ e) as_fn_append ()+ {+ eval $1=\$$1\$2+ } ;;+esac+fi # as_fn_append++# as_fn_arith ARG...+# ------------------+# Perform arithmetic evaluation on the ARGs, and store the result in the+# global $as_val. Take advantage of shells that can avoid forks. The arguments+# must be portable across $(()) and expr.+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null+then :+ eval 'as_fn_arith ()+ {+ as_val=$(( $* ))+ }'+else case e in #(+ e) as_fn_arith ()+ {+ as_val=`expr "$@" || test $? -eq 1`+ } ;;+esac+fi # as_fn_arith+++if expr a : '\(a\)' >/dev/null 2>&1 &&+ test "X`expr 00001 : '.*\(...\)'`" = X001; then+ as_expr=expr+else+ as_expr=false+fi++if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then+ as_basename=basename+else+ as_basename=false+fi++if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then+ as_dirname=dirname+else+ as_dirname=false+fi++as_me=`$as_basename -- "$0" ||+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \+ X"$0" : 'X\(//\)$' \| \+ X"$0" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X/"$0" |+ sed '/^.*\/\([^/][^/]*\)\/*$/{+ s//\1/+ q+ }+ /^X\/\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\/\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`++# Avoid depending upon Character Ranges.+as_cr_letters='abcdefghijklmnopqrstuvwxyz'+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'+as_cr_Letters=$as_cr_letters$as_cr_LETTERS+as_cr_digits='0123456789'+as_cr_alnum=$as_cr_Letters$as_cr_digits+++# Determine whether it's possible to make 'echo' print without a newline.+# These variables are no longer used directly by Autoconf, but are AC_SUBSTed+# for compatibility with existing Makefiles.+ECHO_C= ECHO_N= ECHO_T=+case `echo -n x` in #(((((+-n*)+ case `echo 'xy\c'` in+ *c*) ECHO_T=' ';; # ECHO_T is single tab character.+ xy) ECHO_C='\c';;+ *) echo `echo ksh88 bug on AIX 6.1` > /dev/null+ ECHO_T=' ';;+ esac;;+*)+ ECHO_N='-n';;+esac++# For backward compatibility with old third-party macros, we provide+# the shell variables $as_echo and $as_echo_n. New code should use+# AS_ECHO(["message"]) and AS_ECHO_N(["message"]), respectively.+as_echo='printf %s\n'+as_echo_n='printf %s'++rm -f conf$$ conf$$.exe conf$$.file+if test -d conf$$.dir; then+ rm -f conf$$.dir/conf$$.file+else+ rm -f conf$$.dir+ mkdir conf$$.dir 2>/dev/null+fi+if (echo >conf$$.file) 2>/dev/null; then+ if ln -s conf$$.file conf$$ 2>/dev/null; then+ as_ln_s='ln -s'+ # ... but there are two gotchas:+ # 1) On MSYS, both 'ln -s file dir' and 'ln file dir' fail.+ # 2) DJGPP < 2.04 has no symlinks; 'ln -s' creates a wrapper executable.+ # In both cases, we have to default to 'cp -pR'.+ ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||+ as_ln_s='cp -pR'+ elif ln conf$$.file conf$$ 2>/dev/null; then+ as_ln_s=ln+ else+ as_ln_s='cp -pR'+ fi+else+ as_ln_s='cp -pR'+fi+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file+rmdir conf$$.dir 2>/dev/null+++# as_fn_mkdir_p+# -------------+# Create "$as_dir" as a directory, including parents if necessary.+as_fn_mkdir_p ()+{++ case $as_dir in #(+ -*) as_dir=./$as_dir;;+ esac+ test -d "$as_dir" || eval $as_mkdir_p || {+ as_dirs=+ while :; do+ case $as_dir in #(+ *\'*) as_qdir=`printf "%s\n" "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(+ *) as_qdir=$as_dir;;+ esac+ as_dirs="'$as_qdir' $as_dirs"+ as_dir=`$as_dirname -- "$as_dir" ||+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+ X"$as_dir" : 'X\(//\)[^/]' \| \+ X"$as_dir" : 'X\(//\)$' \| \+ X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X"$as_dir" |+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+ s//\1/+ q+ }+ /^X\(\/\/\)[^/].*/{+ s//\1/+ q+ }+ /^X\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ test -d "$as_dir" && break+ done+ test -z "$as_dirs" || eval "mkdir $as_dirs"+ } || test -d "$as_dir" || as_fn_error $? "cannot create directory $as_dir"+++} # as_fn_mkdir_p+if mkdir -p . 2>/dev/null; then+ as_mkdir_p='mkdir -p "$as_dir"'+else+ test -d ./-p && rmdir ./-p+ as_mkdir_p=false+fi+++# as_fn_executable_p FILE+# -----------------------+# Test if FILE is an executable regular file.+as_fn_executable_p ()+{+ test -f "$1" && test -x "$1"+} # as_fn_executable_p+as_test_x='test -x'+as_executable_p=as_fn_executable_p++# Sed expression to map a string onto a valid CPP name.+as_sed_cpp="y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g"+as_tr_cpp="eval sed '$as_sed_cpp'" # deprecated++# Sed expression to map a string onto a valid variable name.+as_sed_sh="y%*+%pp%;s%[^_$as_cr_alnum]%_%g"+as_tr_sh="eval sed '$as_sed_sh'" # deprecated+++exec 6>&1+## ----------------------------------- ##+## Main body of $CONFIG_STATUS script. ##+## ----------------------------------- ##+_ASEOF+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+# Save the log message, to keep $0 and so on meaningful, and to+# report actual input values of CONFIG_FILES etc. instead of their+# values after options handling.+ac_log="+This file was extended by XZ Utils $as_me 5.6.3, which was+generated by GNU Autoconf 2.72. Invocation command line was++ CONFIG_FILES = $CONFIG_FILES+ CONFIG_HEADERS = $CONFIG_HEADERS+ CONFIG_LINKS = $CONFIG_LINKS+ CONFIG_COMMANDS = $CONFIG_COMMANDS+ $ $0 $@++on `(hostname || uname -n) 2>/dev/null | sed 1q`+"++_ACEOF+++case $ac_config_headers in *"+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;+esac+++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+# Files that config.status was made for.+config_headers="$ac_config_headers"+config_commands="$ac_config_commands"++_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+ac_cs_usage="\+'$as_me' instantiates files and other configuration actions+from templates according to the current configuration. Unless the files+and actions are specified as TAGs, all are instantiated by default.++Usage: $0 [OPTION]... [TAG]...++ -h, --help print this help, then exit+ -V, --version print version number and configuration settings, then exit+ --config print configuration, then exit+ -q, --quiet, --silent+ do not print progress messages+ -d, --debug don't remove temporary files+ --recheck update $as_me by reconfiguring in the same conditions+ --header=FILE[:TEMPLATE]+ instantiate the configuration header FILE++Configuration headers:+$config_headers++Configuration commands:+$config_commands++Report bugs to <lasse.collin@tukaani.org>.+XZ Utils home page: <https://tukaani.org/xz/>."++_ACEOF+ac_cs_config=`printf "%s\n" "$ac_configure_args" | sed "$ac_safe_unquote"`+ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\''/g"`+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+ac_cs_config='$ac_cs_config_escaped'+ac_cs_version="\\+XZ Utils config.status 5.6.3+configured by $0, generated by GNU Autoconf 2.72,+ with options \\"\$ac_cs_config\\"++Copyright (C) 2023 Free Software Foundation, Inc.+This config.status script is free software; the Free Software Foundation+gives unlimited permission to copy, distribute and modify it."++ac_pwd='$ac_pwd'+srcdir='$srcdir'+INSTALL='$INSTALL'+MKDIR_P='$MKDIR_P'+AWK='$AWK'+test -n "\$AWK" || AWK=awk+_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+# The default lists apply if the user does not specify any file.+ac_need_defaults=:+while test $# != 0+do+ case $1 in+ --*=?*)+ ac_option=`expr "X$1" : 'X\([^=]*\)='`+ ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`+ ac_shift=:+ ;;+ --*=)+ ac_option=`expr "X$1" : 'X\([^=]*\)='`+ ac_optarg=+ ac_shift=:+ ;;+ *)+ ac_option=$1+ ac_optarg=$2+ ac_shift=shift+ ;;+ esac++ case $ac_option in+ # Handling of the options.+ -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)+ ac_cs_recheck=: ;;+ --version | --versio | --versi | --vers | --ver | --ve | --v | -V )+ printf "%s\n" "$ac_cs_version"; exit ;;+ --config | --confi | --conf | --con | --co | --c )+ printf "%s\n" "$ac_cs_config"; exit ;;+ --debug | --debu | --deb | --de | --d | -d )+ debug=: ;;+ --header | --heade | --head | --hea )+ $ac_shift+ case $ac_optarg in+ *\'*) ac_optarg=`printf "%s\n" "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;+ esac+ as_fn_append CONFIG_HEADERS " '$ac_optarg'"+ ac_need_defaults=false;;+ --he | --h)+ # Conflict between --help and --header+ as_fn_error $? "ambiguous option: '$1'+Try '$0 --help' for more information.";;+ --help | --hel | -h )+ printf "%s\n" "$ac_cs_usage"; exit ;;+ -q | -quiet | --quiet | --quie | --qui | --qu | --q \+ | -silent | --silent | --silen | --sile | --sil | --si | --s)+ ac_cs_silent=: ;;++ # This is an error.+ -*) as_fn_error $? "unrecognized option: '$1'+Try '$0 --help' for more information." ;;++ *) as_fn_append ac_config_targets " $1"+ ac_need_defaults=false ;;++ esac+ shift+done++ac_configure_extra_args=++if $ac_cs_silent; then+ exec 6>/dev/null+ ac_configure_extra_args="$ac_configure_extra_args --silent"+fi++_ACEOF+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+if \$ac_cs_recheck; then+ set X $SHELL '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion+ shift+ \printf "%s\n" "running CONFIG_SHELL=$SHELL \$*" >&6+ CONFIG_SHELL='$SHELL'+ export CONFIG_SHELL+ exec "\$@"+fi++_ACEOF+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+exec 5>>config.log+{+ echo+ sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX+## Running $as_me. ##+_ASBOX+ printf "%s\n" "$ac_log"+} >&5++_ACEOF+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+#+# INIT-COMMANDS+#+AMDEP_TRUE="$AMDEP_TRUE" MAKE="${MAKE-make}"+++# The HP-UX ksh and POSIX shell print the target directory to stdout+# if CDPATH is set.+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH++sed_quote_subst='$sed_quote_subst'+double_quote_subst='$double_quote_subst'+delay_variable_subst='$delay_variable_subst'+macro_version='`$ECHO "$macro_version" | $SED "$delay_single_quote_subst"`'+macro_revision='`$ECHO "$macro_revision" | $SED "$delay_single_quote_subst"`'+AS='`$ECHO "$AS" | $SED "$delay_single_quote_subst"`'+DLLTOOL='`$ECHO "$DLLTOOL" | $SED "$delay_single_quote_subst"`'+OBJDUMP='`$ECHO "$OBJDUMP" | $SED "$delay_single_quote_subst"`'+enable_shared='`$ECHO "$enable_shared" | $SED "$delay_single_quote_subst"`'+enable_static='`$ECHO "$enable_static" | $SED "$delay_single_quote_subst"`'+pic_mode='`$ECHO "$pic_mode" | $SED "$delay_single_quote_subst"`'+enable_fast_install='`$ECHO "$enable_fast_install" | $SED "$delay_single_quote_subst"`'+shared_archive_member_spec='`$ECHO "$shared_archive_member_spec" | $SED "$delay_single_quote_subst"`'+SHELL='`$ECHO "$SHELL" | $SED "$delay_single_quote_subst"`'+ECHO='`$ECHO "$ECHO" | $SED "$delay_single_quote_subst"`'+PATH_SEPARATOR='`$ECHO "$PATH_SEPARATOR" | $SED "$delay_single_quote_subst"`'+host_alias='`$ECHO "$host_alias" | $SED "$delay_single_quote_subst"`'+host='`$ECHO "$host" | $SED "$delay_single_quote_subst"`'+host_os='`$ECHO "$host_os" | $SED "$delay_single_quote_subst"`'+build_alias='`$ECHO "$build_alias" | $SED "$delay_single_quote_subst"`'+build='`$ECHO "$build" | $SED "$delay_single_quote_subst"`'+build_os='`$ECHO "$build_os" | $SED "$delay_single_quote_subst"`'+SED='`$ECHO "$SED" | $SED "$delay_single_quote_subst"`'+Xsed='`$ECHO "$Xsed" | $SED "$delay_single_quote_subst"`'+GREP='`$ECHO "$GREP" | $SED "$delay_single_quote_subst"`'+EGREP='`$ECHO "$EGREP" | $SED "$delay_single_quote_subst"`'+FGREP='`$ECHO "$FGREP" | $SED "$delay_single_quote_subst"`'+LD='`$ECHO "$LD" | $SED "$delay_single_quote_subst"`'+NM='`$ECHO "$NM" | $SED "$delay_single_quote_subst"`'+LN_S='`$ECHO "$LN_S" | $SED "$delay_single_quote_subst"`'+max_cmd_len='`$ECHO "$max_cmd_len" | $SED "$delay_single_quote_subst"`'+ac_objext='`$ECHO "$ac_objext" | $SED "$delay_single_quote_subst"`'+exeext='`$ECHO "$exeext" | $SED "$delay_single_quote_subst"`'+lt_unset='`$ECHO "$lt_unset" | $SED "$delay_single_quote_subst"`'+lt_SP2NL='`$ECHO "$lt_SP2NL" | $SED "$delay_single_quote_subst"`'+lt_NL2SP='`$ECHO "$lt_NL2SP" | $SED "$delay_single_quote_subst"`'+lt_cv_to_host_file_cmd='`$ECHO "$lt_cv_to_host_file_cmd" | $SED "$delay_single_quote_subst"`'+lt_cv_to_tool_file_cmd='`$ECHO "$lt_cv_to_tool_file_cmd" | $SED "$delay_single_quote_subst"`'+reload_flag='`$ECHO "$reload_flag" | $SED "$delay_single_quote_subst"`'+reload_cmds='`$ECHO "$reload_cmds" | $SED "$delay_single_quote_subst"`'+FILECMD='`$ECHO "$FILECMD" | $SED "$delay_single_quote_subst"`'+deplibs_check_method='`$ECHO "$deplibs_check_method" | $SED "$delay_single_quote_subst"`'+file_magic_cmd='`$ECHO "$file_magic_cmd" | $SED "$delay_single_quote_subst"`'+file_magic_glob='`$ECHO "$file_magic_glob" | $SED "$delay_single_quote_subst"`'+want_nocaseglob='`$ECHO "$want_nocaseglob" | $SED "$delay_single_quote_subst"`'+sharedlib_from_linklib_cmd='`$ECHO "$sharedlib_from_linklib_cmd" | $SED "$delay_single_quote_subst"`'+AR='`$ECHO "$AR" | $SED "$delay_single_quote_subst"`'+lt_ar_flags='`$ECHO "$lt_ar_flags" | $SED "$delay_single_quote_subst"`'+AR_FLAGS='`$ECHO "$AR_FLAGS" | $SED "$delay_single_quote_subst"`'+archiver_list_spec='`$ECHO "$archiver_list_spec" | $SED "$delay_single_quote_subst"`'+STRIP='`$ECHO "$STRIP" | $SED "$delay_single_quote_subst"`'+RANLIB='`$ECHO "$RANLIB" | $SED "$delay_single_quote_subst"`'+old_postinstall_cmds='`$ECHO "$old_postinstall_cmds" | $SED "$delay_single_quote_subst"`'+old_postuninstall_cmds='`$ECHO "$old_postuninstall_cmds" | $SED "$delay_single_quote_subst"`'+old_archive_cmds='`$ECHO "$old_archive_cmds" | $SED "$delay_single_quote_subst"`'+lock_old_archive_extraction='`$ECHO "$lock_old_archive_extraction" | $SED "$delay_single_quote_subst"`'+CC='`$ECHO "$CC" | $SED "$delay_single_quote_subst"`'+CFLAGS='`$ECHO "$CFLAGS" | $SED "$delay_single_quote_subst"`'+compiler='`$ECHO "$compiler" | $SED "$delay_single_quote_subst"`'+GCC='`$ECHO "$GCC" | $SED "$delay_single_quote_subst"`'+lt_cv_sys_global_symbol_pipe='`$ECHO "$lt_cv_sys_global_symbol_pipe" | $SED "$delay_single_quote_subst"`'+lt_cv_sys_global_symbol_to_cdecl='`$ECHO "$lt_cv_sys_global_symbol_to_cdecl" | $SED "$delay_single_quote_subst"`'+lt_cv_sys_global_symbol_to_import='`$ECHO "$lt_cv_sys_global_symbol_to_import" | $SED "$delay_single_quote_subst"`'+lt_cv_sys_global_symbol_to_c_name_address='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address" | $SED "$delay_single_quote_subst"`'+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='`$ECHO "$lt_cv_sys_global_symbol_to_c_name_address_lib_prefix" | $SED "$delay_single_quote_subst"`'+lt_cv_nm_interface='`$ECHO "$lt_cv_nm_interface" | $SED "$delay_single_quote_subst"`'+nm_file_list_spec='`$ECHO "$nm_file_list_spec" | $SED "$delay_single_quote_subst"`'+lt_sysroot='`$ECHO "$lt_sysroot" | $SED "$delay_single_quote_subst"`'+lt_cv_truncate_bin='`$ECHO "$lt_cv_truncate_bin" | $SED "$delay_single_quote_subst"`'+objdir='`$ECHO "$objdir" | $SED "$delay_single_quote_subst"`'+MAGIC_CMD='`$ECHO "$MAGIC_CMD" | $SED "$delay_single_quote_subst"`'+lt_prog_compiler_no_builtin_flag='`$ECHO "$lt_prog_compiler_no_builtin_flag" | $SED "$delay_single_quote_subst"`'+lt_prog_compiler_pic='`$ECHO "$lt_prog_compiler_pic" | $SED "$delay_single_quote_subst"`'+lt_prog_compiler_wl='`$ECHO "$lt_prog_compiler_wl" | $SED "$delay_single_quote_subst"`'+lt_prog_compiler_static='`$ECHO "$lt_prog_compiler_static" | $SED "$delay_single_quote_subst"`'+lt_cv_prog_compiler_c_o='`$ECHO "$lt_cv_prog_compiler_c_o" | $SED "$delay_single_quote_subst"`'+need_locks='`$ECHO "$need_locks" | $SED "$delay_single_quote_subst"`'+MANIFEST_TOOL='`$ECHO "$MANIFEST_TOOL" | $SED "$delay_single_quote_subst"`'+DSYMUTIL='`$ECHO "$DSYMUTIL" | $SED "$delay_single_quote_subst"`'+NMEDIT='`$ECHO "$NMEDIT" | $SED "$delay_single_quote_subst"`'+LIPO='`$ECHO "$LIPO" | $SED "$delay_single_quote_subst"`'+OTOOL='`$ECHO "$OTOOL" | $SED "$delay_single_quote_subst"`'+OTOOL64='`$ECHO "$OTOOL64" | $SED "$delay_single_quote_subst"`'+libext='`$ECHO "$libext" | $SED "$delay_single_quote_subst"`'+shrext_cmds='`$ECHO "$shrext_cmds" | $SED "$delay_single_quote_subst"`'+extract_expsyms_cmds='`$ECHO "$extract_expsyms_cmds" | $SED "$delay_single_quote_subst"`'+archive_cmds_need_lc='`$ECHO "$archive_cmds_need_lc" | $SED "$delay_single_quote_subst"`'+enable_shared_with_static_runtimes='`$ECHO "$enable_shared_with_static_runtimes" | $SED "$delay_single_quote_subst"`'+export_dynamic_flag_spec='`$ECHO "$export_dynamic_flag_spec" | $SED "$delay_single_quote_subst"`'+whole_archive_flag_spec='`$ECHO "$whole_archive_flag_spec" | $SED "$delay_single_quote_subst"`'+compiler_needs_object='`$ECHO "$compiler_needs_object" | $SED "$delay_single_quote_subst"`'+old_archive_from_new_cmds='`$ECHO "$old_archive_from_new_cmds" | $SED "$delay_single_quote_subst"`'+old_archive_from_expsyms_cmds='`$ECHO "$old_archive_from_expsyms_cmds" | $SED "$delay_single_quote_subst"`'+archive_cmds='`$ECHO "$archive_cmds" | $SED "$delay_single_quote_subst"`'+archive_expsym_cmds='`$ECHO "$archive_expsym_cmds" | $SED "$delay_single_quote_subst"`'+module_cmds='`$ECHO "$module_cmds" | $SED "$delay_single_quote_subst"`'+module_expsym_cmds='`$ECHO "$module_expsym_cmds" | $SED "$delay_single_quote_subst"`'+with_gnu_ld='`$ECHO "$with_gnu_ld" | $SED "$delay_single_quote_subst"`'+allow_undefined_flag='`$ECHO "$allow_undefined_flag" | $SED "$delay_single_quote_subst"`'+no_undefined_flag='`$ECHO "$no_undefined_flag" | $SED "$delay_single_quote_subst"`'+hardcode_libdir_flag_spec='`$ECHO "$hardcode_libdir_flag_spec" | $SED "$delay_single_quote_subst"`'+hardcode_libdir_separator='`$ECHO "$hardcode_libdir_separator" | $SED "$delay_single_quote_subst"`'+hardcode_direct='`$ECHO "$hardcode_direct" | $SED "$delay_single_quote_subst"`'+hardcode_direct_absolute='`$ECHO "$hardcode_direct_absolute" | $SED "$delay_single_quote_subst"`'+hardcode_minus_L='`$ECHO "$hardcode_minus_L" | $SED "$delay_single_quote_subst"`'+hardcode_shlibpath_var='`$ECHO "$hardcode_shlibpath_var" | $SED "$delay_single_quote_subst"`'+hardcode_automatic='`$ECHO "$hardcode_automatic" | $SED "$delay_single_quote_subst"`'+inherit_rpath='`$ECHO "$inherit_rpath" | $SED "$delay_single_quote_subst"`'+link_all_deplibs='`$ECHO "$link_all_deplibs" | $SED "$delay_single_quote_subst"`'+always_export_symbols='`$ECHO "$always_export_symbols" | $SED "$delay_single_quote_subst"`'+export_symbols_cmds='`$ECHO "$export_symbols_cmds" | $SED "$delay_single_quote_subst"`'+exclude_expsyms='`$ECHO "$exclude_expsyms" | $SED "$delay_single_quote_subst"`'+include_expsyms='`$ECHO "$include_expsyms" | $SED "$delay_single_quote_subst"`'+prelink_cmds='`$ECHO "$prelink_cmds" | $SED "$delay_single_quote_subst"`'+postlink_cmds='`$ECHO "$postlink_cmds" | $SED "$delay_single_quote_subst"`'+file_list_spec='`$ECHO "$file_list_spec" | $SED "$delay_single_quote_subst"`'+variables_saved_for_relink='`$ECHO "$variables_saved_for_relink" | $SED "$delay_single_quote_subst"`'+need_lib_prefix='`$ECHO "$need_lib_prefix" | $SED "$delay_single_quote_subst"`'+need_version='`$ECHO "$need_version" | $SED "$delay_single_quote_subst"`'+version_type='`$ECHO "$version_type" | $SED "$delay_single_quote_subst"`'+runpath_var='`$ECHO "$runpath_var" | $SED "$delay_single_quote_subst"`'+shlibpath_var='`$ECHO "$shlibpath_var" | $SED "$delay_single_quote_subst"`'+shlibpath_overrides_runpath='`$ECHO "$shlibpath_overrides_runpath" | $SED "$delay_single_quote_subst"`'+libname_spec='`$ECHO "$libname_spec" | $SED "$delay_single_quote_subst"`'+library_names_spec='`$ECHO "$library_names_spec" | $SED "$delay_single_quote_subst"`'+soname_spec='`$ECHO "$soname_spec" | $SED "$delay_single_quote_subst"`'+install_override_mode='`$ECHO "$install_override_mode" | $SED "$delay_single_quote_subst"`'+postinstall_cmds='`$ECHO "$postinstall_cmds" | $SED "$delay_single_quote_subst"`'+postuninstall_cmds='`$ECHO "$postuninstall_cmds" | $SED "$delay_single_quote_subst"`'+finish_cmds='`$ECHO "$finish_cmds" | $SED "$delay_single_quote_subst"`'+finish_eval='`$ECHO "$finish_eval" | $SED "$delay_single_quote_subst"`'+hardcode_into_libs='`$ECHO "$hardcode_into_libs" | $SED "$delay_single_quote_subst"`'+sys_lib_search_path_spec='`$ECHO "$sys_lib_search_path_spec" | $SED "$delay_single_quote_subst"`'+configure_time_dlsearch_path='`$ECHO "$configure_time_dlsearch_path" | $SED "$delay_single_quote_subst"`'+configure_time_lt_sys_library_path='`$ECHO "$configure_time_lt_sys_library_path" | $SED "$delay_single_quote_subst"`'+hardcode_action='`$ECHO "$hardcode_action" | $SED "$delay_single_quote_subst"`'+enable_dlopen='`$ECHO "$enable_dlopen" | $SED "$delay_single_quote_subst"`'+enable_dlopen_self='`$ECHO "$enable_dlopen_self" | $SED "$delay_single_quote_subst"`'+enable_dlopen_self_static='`$ECHO "$enable_dlopen_self_static" | $SED "$delay_single_quote_subst"`'+old_striplib='`$ECHO "$old_striplib" | $SED "$delay_single_quote_subst"`'+striplib='`$ECHO "$striplib" | $SED "$delay_single_quote_subst"`'+LD_RC='`$ECHO "$LD_RC" | $SED "$delay_single_quote_subst"`'+reload_flag_RC='`$ECHO "$reload_flag_RC" | $SED "$delay_single_quote_subst"`'+reload_cmds_RC='`$ECHO "$reload_cmds_RC" | $SED "$delay_single_quote_subst"`'+old_archive_cmds_RC='`$ECHO "$old_archive_cmds_RC" | $SED "$delay_single_quote_subst"`'+compiler_RC='`$ECHO "$compiler_RC" | $SED "$delay_single_quote_subst"`'+GCC_RC='`$ECHO "$GCC_RC" | $SED "$delay_single_quote_subst"`'+lt_prog_compiler_no_builtin_flag_RC='`$ECHO "$lt_prog_compiler_no_builtin_flag_RC" | $SED "$delay_single_quote_subst"`'+lt_prog_compiler_pic_RC='`$ECHO "$lt_prog_compiler_pic_RC" | $SED "$delay_single_quote_subst"`'+lt_prog_compiler_wl_RC='`$ECHO "$lt_prog_compiler_wl_RC" | $SED "$delay_single_quote_subst"`'+lt_prog_compiler_static_RC='`$ECHO "$lt_prog_compiler_static_RC" | $SED "$delay_single_quote_subst"`'+lt_cv_prog_compiler_c_o_RC='`$ECHO "$lt_cv_prog_compiler_c_o_RC" | $SED "$delay_single_quote_subst"`'+archive_cmds_need_lc_RC='`$ECHO "$archive_cmds_need_lc_RC" | $SED "$delay_single_quote_subst"`'+enable_shared_with_static_runtimes_RC='`$ECHO "$enable_shared_with_static_runtimes_RC" | $SED "$delay_single_quote_subst"`'+export_dynamic_flag_spec_RC='`$ECHO "$export_dynamic_flag_spec_RC" | $SED "$delay_single_quote_subst"`'+whole_archive_flag_spec_RC='`$ECHO "$whole_archive_flag_spec_RC" | $SED "$delay_single_quote_subst"`'+compiler_needs_object_RC='`$ECHO "$compiler_needs_object_RC" | $SED "$delay_single_quote_subst"`'+old_archive_from_new_cmds_RC='`$ECHO "$old_archive_from_new_cmds_RC" | $SED "$delay_single_quote_subst"`'+old_archive_from_expsyms_cmds_RC='`$ECHO "$old_archive_from_expsyms_cmds_RC" | $SED "$delay_single_quote_subst"`'+archive_cmds_RC='`$ECHO "$archive_cmds_RC" | $SED "$delay_single_quote_subst"`'+archive_expsym_cmds_RC='`$ECHO "$archive_expsym_cmds_RC" | $SED "$delay_single_quote_subst"`'+module_cmds_RC='`$ECHO "$module_cmds_RC" | $SED "$delay_single_quote_subst"`'+module_expsym_cmds_RC='`$ECHO "$module_expsym_cmds_RC" | $SED "$delay_single_quote_subst"`'+with_gnu_ld_RC='`$ECHO "$with_gnu_ld_RC" | $SED "$delay_single_quote_subst"`'+allow_undefined_flag_RC='`$ECHO "$allow_undefined_flag_RC" | $SED "$delay_single_quote_subst"`'+no_undefined_flag_RC='`$ECHO "$no_undefined_flag_RC" | $SED "$delay_single_quote_subst"`'+hardcode_libdir_flag_spec_RC='`$ECHO "$hardcode_libdir_flag_spec_RC" | $SED "$delay_single_quote_subst"`'+hardcode_libdir_separator_RC='`$ECHO "$hardcode_libdir_separator_RC" | $SED "$delay_single_quote_subst"`'+hardcode_direct_RC='`$ECHO "$hardcode_direct_RC" | $SED "$delay_single_quote_subst"`'+hardcode_direct_absolute_RC='`$ECHO "$hardcode_direct_absolute_RC" | $SED "$delay_single_quote_subst"`'+hardcode_minus_L_RC='`$ECHO "$hardcode_minus_L_RC" | $SED "$delay_single_quote_subst"`'+hardcode_shlibpath_var_RC='`$ECHO "$hardcode_shlibpath_var_RC" | $SED "$delay_single_quote_subst"`'+hardcode_automatic_RC='`$ECHO "$hardcode_automatic_RC" | $SED "$delay_single_quote_subst"`'+inherit_rpath_RC='`$ECHO "$inherit_rpath_RC" | $SED "$delay_single_quote_subst"`'+link_all_deplibs_RC='`$ECHO "$link_all_deplibs_RC" | $SED "$delay_single_quote_subst"`'+always_export_symbols_RC='`$ECHO "$always_export_symbols_RC" | $SED "$delay_single_quote_subst"`'+export_symbols_cmds_RC='`$ECHO "$export_symbols_cmds_RC" | $SED "$delay_single_quote_subst"`'+exclude_expsyms_RC='`$ECHO "$exclude_expsyms_RC" | $SED "$delay_single_quote_subst"`'+include_expsyms_RC='`$ECHO "$include_expsyms_RC" | $SED "$delay_single_quote_subst"`'+prelink_cmds_RC='`$ECHO "$prelink_cmds_RC" | $SED "$delay_single_quote_subst"`'+postlink_cmds_RC='`$ECHO "$postlink_cmds_RC" | $SED "$delay_single_quote_subst"`'+file_list_spec_RC='`$ECHO "$file_list_spec_RC" | $SED "$delay_single_quote_subst"`'+hardcode_action_RC='`$ECHO "$hardcode_action_RC" | $SED "$delay_single_quote_subst"`'++LTCC='$LTCC'+LTCFLAGS='$LTCFLAGS'+compiler='$compiler_DEFAULT'++# A function that is used when there is no print builtin or printf.+func_fallback_echo ()+{+ eval 'cat <<_LTECHO_EOF+\$1+_LTECHO_EOF'+}++# Quote evaled strings.+for var in AS \+DLLTOOL \+OBJDUMP \+SHELL \+ECHO \+PATH_SEPARATOR \+SED \+GREP \+EGREP \+FGREP \+LD \+NM \+LN_S \+lt_SP2NL \+lt_NL2SP \+reload_flag \+FILECMD \+deplibs_check_method \+file_magic_cmd \+file_magic_glob \+want_nocaseglob \+sharedlib_from_linklib_cmd \+AR \+archiver_list_spec \+STRIP \+RANLIB \+CC \+CFLAGS \+compiler \+lt_cv_sys_global_symbol_pipe \+lt_cv_sys_global_symbol_to_cdecl \+lt_cv_sys_global_symbol_to_import \+lt_cv_sys_global_symbol_to_c_name_address \+lt_cv_sys_global_symbol_to_c_name_address_lib_prefix \+lt_cv_nm_interface \+nm_file_list_spec \+lt_cv_truncate_bin \+lt_prog_compiler_no_builtin_flag \+lt_prog_compiler_pic \+lt_prog_compiler_wl \+lt_prog_compiler_static \+lt_cv_prog_compiler_c_o \+need_locks \+MANIFEST_TOOL \+DSYMUTIL \+NMEDIT \+LIPO \+OTOOL \+OTOOL64 \+shrext_cmds \+export_dynamic_flag_spec \+whole_archive_flag_spec \+compiler_needs_object \+with_gnu_ld \+allow_undefined_flag \+no_undefined_flag \+hardcode_libdir_flag_spec \+hardcode_libdir_separator \+exclude_expsyms \+include_expsyms \+file_list_spec \+variables_saved_for_relink \+libname_spec \+library_names_spec \+soname_spec \+install_override_mode \+finish_eval \+old_striplib \+striplib \+LD_RC \+reload_flag_RC \+compiler_RC \+lt_prog_compiler_no_builtin_flag_RC \+lt_prog_compiler_pic_RC \+lt_prog_compiler_wl_RC \+lt_prog_compiler_static_RC \+lt_cv_prog_compiler_c_o_RC \+export_dynamic_flag_spec_RC \+whole_archive_flag_spec_RC \+compiler_needs_object_RC \+with_gnu_ld_RC \+allow_undefined_flag_RC \+no_undefined_flag_RC \+hardcode_libdir_flag_spec_RC \+hardcode_libdir_separator_RC \+exclude_expsyms_RC \+include_expsyms_RC \+file_list_spec_RC; do+ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in+ *[\\\\\\\`\\"\\\$]*)+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED \\"\\\$sed_quote_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes+ ;;+ *)+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""+ ;;+ esac+done++# Double-quote double-evaled strings.+for var in reload_cmds \+old_postinstall_cmds \+old_postuninstall_cmds \+old_archive_cmds \+extract_expsyms_cmds \+old_archive_from_new_cmds \+old_archive_from_expsyms_cmds \+archive_cmds \+archive_expsym_cmds \+module_cmds \+module_expsym_cmds \+export_symbols_cmds \+prelink_cmds \+postlink_cmds \+postinstall_cmds \+postuninstall_cmds \+finish_cmds \+sys_lib_search_path_spec \+configure_time_dlsearch_path \+configure_time_lt_sys_library_path \+reload_cmds_RC \+old_archive_cmds_RC \+old_archive_from_new_cmds_RC \+old_archive_from_expsyms_cmds_RC \+archive_cmds_RC \+archive_expsym_cmds_RC \+module_cmds_RC \+module_expsym_cmds_RC \+export_symbols_cmds_RC \+prelink_cmds_RC \+postlink_cmds_RC; do+ case \`eval \\\\\$ECHO \\\\""\\\\\$\$var"\\\\"\` in+ *[\\\\\\\`\\"\\\$]*)+ eval "lt_\$var=\\\\\\"\\\`\\\$ECHO \\"\\\$\$var\\" | \\\$SED -e \\"\\\$double_quote_subst\\" -e \\"\\\$sed_quote_subst\\" -e \\"\\\$delay_variable_subst\\"\\\`\\\\\\"" ## exclude from sc_prohibit_nested_quotes+ ;;+ *)+ eval "lt_\$var=\\\\\\"\\\$\$var\\\\\\""+ ;;+ esac+done++ac_aux_dir='$ac_aux_dir'++# See if we are running on zsh, and set the options that allow our+# commands through without removal of \ escapes INIT.+if test -n "\${ZSH_VERSION+set}"; then+ setopt NO_GLOB_SUBST+fi+++ PACKAGE='$PACKAGE'+ VERSION='$VERSION'+ RM='$RM'+ ofile='$ofile'++++++# Capture the value of obsolete ALL_LINGUAS because we need it to compute+ # POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES, CATALOGS.+ OBSOLETE_ALL_LINGUAS="$ALL_LINGUAS"+ # Capture the value of LINGUAS because we need it to compute CATALOGS.+ LINGUAS="${LINGUAS-%UNSET%}"+++_ACEOF++cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1++# Handling of arguments.+for ac_config_target in $ac_config_targets+do+ case $ac_config_target in+ "cbits/config.h") CONFIG_HEADERS="$CONFIG_HEADERS cbits/config.h" ;;+ "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;+ "libtool") CONFIG_COMMANDS="$CONFIG_COMMANDS libtool" ;;+ "po-directories") CONFIG_COMMANDS="$CONFIG_COMMANDS po-directories" ;;++ *) as_fn_error $? "invalid argument: '$ac_config_target'" "$LINENO" 5;;+ esac+done+++# If the user did not use the arguments to specify the items to instantiate,+# then the envvar interface is used. Set only those that are not.+# We use the long form for the default assignment because of an extremely+# bizarre bug on SunOS 4.1.3.+if $ac_need_defaults; then+ test ${CONFIG_HEADERS+y} || CONFIG_HEADERS=$config_headers+ test ${CONFIG_COMMANDS+y} || CONFIG_COMMANDS=$config_commands+fi++# Have a temporary directory for convenience. Make it in the build tree+# simply because there is no reason against having it here, and in addition,+# creating and moving files from /tmp can sometimes cause problems.+# Hook for its removal unless debugging.+# Note that there is a small window in which the directory will not be cleaned:+# after its creation but before its name has been assigned to '$tmp'.+$debug ||+{+ tmp= ac_tmp=+ trap 'exit_status=$?+ : "${ac_tmp:=$tmp}"+ { test ! -d "$ac_tmp" || rm -fr "$ac_tmp"; } && exit $exit_status+' 0+ trap 'as_fn_exit 1' 1 2 13 15+}+# Create a (secure) tmp directory for tmp files.++{+ tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&+ test -d "$tmp"+} ||+{+ tmp=./conf$$-$RANDOM+ (umask 077 && mkdir "$tmp")+} || as_fn_error $? "cannot create a temporary directory in ." "$LINENO" 5+ac_tmp=$tmp++# Set up the scripts for CONFIG_HEADERS section.+# No need to generate them if there are no CONFIG_HEADERS.+# This happens for instance with './config.status Makefile'.+if test -n "$CONFIG_HEADERS"; then+cat >"$ac_tmp/defines.awk" <<\_ACAWK ||+BEGIN {+_ACEOF++# Transform confdefs.h into an awk script 'defines.awk', embedded as+# here-document in config.status, that substitutes the proper values into+# config.h.in to produce config.h.++# Create a delimiter string that does not exist in confdefs.h, to ease+# handling of long lines.+ac_delim='%!_!# '+for ac_last_try in false false :; do+ ac_tt=`sed -n "/$ac_delim/p" confdefs.h`+ if test -z "$ac_tt"; then+ break+ elif $ac_last_try; then+ as_fn_error $? "could not make $CONFIG_HEADERS" "$LINENO" 5+ else+ ac_delim="$ac_delim!$ac_delim _$ac_delim!! "+ fi+done++# For the awk script, D is an array of macro values keyed by name,+# likewise P contains macro parameters if any. Preserve backslash+# newline sequences.++ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*+sed -n '+s/.\{148\}/&'"$ac_delim"'/g+t rset+:rset+s/^[ ]*#[ ]*define[ ][ ]*/ /+t def+d+:def+s/\\$//+t bsnl+s/["\\]/\\&/g+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\+D["\1"]=" \3"/p+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2"/p+d+:bsnl+s/["\\]/\\&/g+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[ ]*\(.*\)/P["\1"]="\2"\+D["\1"]=" \3\\\\\\n"\\/p+t cont+s/^ \('"$ac_word_re"'\)[ ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p+t cont+d+:cont+n+s/.\{148\}/&'"$ac_delim"'/g+t clear+:clear+s/\\$//+t bsnlc+s/["\\]/\\&/g; s/^/"/; s/$/"/p+d+:bsnlc+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p+b cont+' <confdefs.h | sed '+s/'"$ac_delim"'/"\\\+"/g' >>$CONFIG_STATUS || ac_write_fail=1++cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1+ for (key in D) D_is_set[key] = 1+ FS = ""+}+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {+ line = \$ 0+ split(line, arg, " ")+ if (arg[1] == "#") {+ defundef = arg[2]+ mac1 = arg[3]+ } else {+ defundef = substr(arg[1], 2)+ mac1 = arg[2]+ }+ split(mac1, mac2, "(") #)+ macro = mac2[1]+ prefix = substr(line, 1, index(line, defundef) - 1)+ if (D_is_set[macro]) {+ # Preserve the white space surrounding the "#".+ print prefix "define", macro P[macro] D[macro]+ next+ } else {+ # Replace #undef with comments. This is necessary, for example,+ # in the case of _POSIX_SOURCE, which is predefined and required+ # on some systems where configure will not decide to define it.+ if (defundef == "undef") {+ print "/*", prefix defundef, macro, "*/"+ next+ }+ }+}+{ print }+_ACAWK+_ACEOF+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1+ as_fn_error $? "could not setup config headers machinery" "$LINENO" 5+fi # test -n "$CONFIG_HEADERS"+++eval set X " :H $CONFIG_HEADERS :C $CONFIG_COMMANDS"+shift+for ac_tag+do+ case $ac_tag in+ :[FHLC]) ac_mode=$ac_tag; continue;;+ esac+ case $ac_mode$ac_tag in+ :[FHL]*:*);;+ :L* | :C*:*) as_fn_error $? "invalid tag '$ac_tag'" "$LINENO" 5;;+ :[FH]-) ac_tag=-:-;;+ :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;+ esac+ ac_save_IFS=$IFS+ IFS=:+ set x $ac_tag+ IFS=$ac_save_IFS+ shift+ ac_file=$1+ shift++ case $ac_mode in+ :L) ac_source=$1;;+ :[FH])+ ac_file_inputs=+ for ac_f+ do+ case $ac_f in+ -) ac_f="$ac_tmp/stdin";;+ *) # Look for the file first in the build tree, then in the source tree+ # (if the path is not absolute). The absolute path cannot be DOS-style,+ # because $ac_f cannot contain ':'.+ test -f "$ac_f" ||+ case $ac_f in+ [\\/$]*) false;;+ *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;+ esac ||+ as_fn_error 1 "cannot find input file: '$ac_f'" "$LINENO" 5;;+ esac+ case $ac_f in *\'*) ac_f=`printf "%s\n" "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac+ as_fn_append ac_file_inputs " '$ac_f'"+ done++ # Let's still pretend it is 'configure' which instantiates (i.e., don't+ # use $as_me), people would be surprised to read:+ # /* config.h. Generated by config.status. */+ configure_input='Generated from '`+ printf "%s\n" "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'+ `' by configure.'+ if test x"$ac_file" != x-; then+ configure_input="$ac_file. $configure_input"+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5+printf "%s\n" "$as_me: creating $ac_file" >&6;}+ fi+ # Neutralize special characters interpreted by sed in replacement strings.+ case $configure_input in #(+ *\&* | *\|* | *\\* )+ ac_sed_conf_input=`printf "%s\n" "$configure_input" |+ sed 's/[\\\\&|]/\\\\&/g'`;; #(+ *) ac_sed_conf_input=$configure_input;;+ esac++ case $ac_tag in+ *:-:* | *:-) cat >"$ac_tmp/stdin" \+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5 ;;+ esac+ ;;+ esac++ ac_dir=`$as_dirname -- "$ac_file" ||+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+ X"$ac_file" : 'X\(//\)[^/]' \| \+ X"$ac_file" : 'X\(//\)$' \| \+ X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X"$ac_file" |+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+ s//\1/+ q+ }+ /^X\(\/\/\)[^/].*/{+ s//\1/+ q+ }+ /^X\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ as_dir="$ac_dir"; as_fn_mkdir_p+ ac_builddir=.++case "$ac_dir" in+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;+*)+ ac_dir_suffix=/`printf "%s\n" "$ac_dir" | sed 's|^\.[\\/]||'`+ # A ".." for each directory in $ac_dir_suffix.+ ac_top_builddir_sub=`printf "%s\n" "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`+ case $ac_top_builddir_sub in+ "") ac_top_builddir_sub=. ac_top_build_prefix= ;;+ *) ac_top_build_prefix=$ac_top_builddir_sub/ ;;+ esac ;;+esac+ac_abs_top_builddir=$ac_pwd+ac_abs_builddir=$ac_pwd$ac_dir_suffix+# for backward compatibility:+ac_top_builddir=$ac_top_build_prefix++case $srcdir in+ .) # We are building in place.+ ac_srcdir=.+ ac_top_srcdir=$ac_top_builddir_sub+ ac_abs_top_srcdir=$ac_pwd ;;+ [\\/]* | ?:[\\/]* ) # Absolute name.+ ac_srcdir=$srcdir$ac_dir_suffix;+ ac_top_srcdir=$srcdir+ ac_abs_top_srcdir=$srcdir ;;+ *) # Relative name.+ ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix+ ac_top_srcdir=$ac_top_build_prefix$srcdir+ ac_abs_top_srcdir=$ac_pwd/$srcdir ;;+esac+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix+++ case $ac_mode in++ :H)+ #+ # CONFIG_HEADER+ #+ if test x"$ac_file" != x-; then+ {+ printf "%s\n" "/* $configure_input */" >&1 \+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs"+ } >"$ac_tmp/config.h" \+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5+ if diff "$ac_file" "$ac_tmp/config.h" >/dev/null 2>&1; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5+printf "%s\n" "$as_me: $ac_file is unchanged" >&6;}+ else+ rm -f "$ac_file"+ mv "$ac_tmp/config.h" "$ac_file" \+ || as_fn_error $? "could not create $ac_file" "$LINENO" 5+ fi+ else+ printf "%s\n" "/* $configure_input */" >&1 \+ && eval '$AWK -f "$ac_tmp/defines.awk"' "$ac_file_inputs" \+ || as_fn_error $? "could not create -" "$LINENO" 5+ fi+ ;;++ :C) { printf "%s\n" "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5+printf "%s\n" "$as_me: executing $ac_file commands" >&6;}+ ;;+ esac+++ case $ac_file$ac_mode in+ "depfiles":C) test x"$AMDEP_TRUE" != x"" || {+ # Older Autoconf quotes --file arguments for eval, but not when files+ # are listed without --file. Let's play safe and only enable the eval+ # if we detect the quoting.+ # TODO: see whether this extra hack can be removed once we start+ # requiring Autoconf 2.70 or later.+ case $CONFIG_FILES in #(+ *\'*) :+ eval set x "$CONFIG_FILES" ;; #(+ *) :+ set x $CONFIG_FILES ;; #(+ *) :+ ;;+esac+ shift+ # Used to flag and report bootstrapping failures.+ am_rc=0+ for am_mf+ do+ # Strip MF so we end up with the name of the file.+ am_mf=`printf "%s\n" "$am_mf" | sed -e 's/:.*$//'`+ # Check whether this is an Automake generated Makefile which includes+ # dependency-tracking related rules and includes.+ # Grep'ing the whole file directly is not great: AIX grep has a line+ # limit of 2048, but all sed's we know have understand at least 4000.+ sed -n 's,^am--depfiles:.*,X,p' "$am_mf" | grep X >/dev/null 2>&1 \+ || continue+ am_dirpart=`$as_dirname -- "$am_mf" ||+$as_expr X"$am_mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \+ X"$am_mf" : 'X\(//\)[^/]' \| \+ X"$am_mf" : 'X\(//\)$' \| \+ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X"$am_mf" |+ sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{+ s//\1/+ q+ }+ /^X\(\/\/\)[^/].*/{+ s//\1/+ q+ }+ /^X\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ am_filepart=`$as_basename -- "$am_mf" ||+$as_expr X/"$am_mf" : '.*/\([^/][^/]*\)/*$' \| \+ X"$am_mf" : 'X\(//\)$' \| \+ X"$am_mf" : 'X\(/\)' \| . 2>/dev/null ||+printf "%s\n" X/"$am_mf" |+ sed '/^.*\/\([^/][^/]*\)\/*$/{+ s//\1/+ q+ }+ /^X\/\(\/\/\)$/{+ s//\1/+ q+ }+ /^X\/\(\/\).*/{+ s//\1/+ q+ }+ s/.*/./; q'`+ { echo "$as_me:$LINENO: cd "$am_dirpart" \+ && sed -e '/# am--include-marker/d' "$am_filepart" \+ | $MAKE -f - am--depfiles" >&5+ (cd "$am_dirpart" \+ && sed -e '/# am--include-marker/d' "$am_filepart" \+ | $MAKE -f - am--depfiles) >&5 2>&5+ ac_status=$?+ echo "$as_me:$LINENO: \$? = $ac_status" >&5+ (exit $ac_status); } || am_rc=$?+ done+ if test $am_rc -ne 0; then+ { { printf "%s\n" "$as_me:${as_lineno-$LINENO}: error: in '$ac_pwd':" >&5+printf "%s\n" "$as_me: error: in '$ac_pwd':" >&2;}+as_fn_error $? "Something went wrong bootstrapping makefile fragments+ for automatic dependency tracking. If GNU make was not used, consider+ re-running the configure script with MAKE=\"gmake\" (or whatever is+ necessary). You can also try re-running configure with the+ '--disable-dependency-tracking' option to at least be able to build+ the package (albeit without support for automatic dependency tracking).+See 'config.log' for more details" "$LINENO" 5; }+ fi+ { am_dirpart=; unset am_dirpart;}+ { am_filepart=; unset am_filepart;}+ { am_mf=; unset am_mf;}+ { am_rc=; unset am_rc;}+ rm -f conftest-deps.mk+}+ ;;+ "libtool":C)++ # See if we are running on zsh, and set the options that allow our+ # commands through without removal of \ escapes.+ if test -n "${ZSH_VERSION+set}"; then+ setopt NO_GLOB_SUBST+ fi++ cfgfile=${ofile}T+ trap "$RM \"$cfgfile\"; exit 1" 1 2 15+ $RM "$cfgfile"++ cat <<_LT_EOF >> "$cfgfile"+#! $SHELL+# Generated automatically by $as_me ($PACKAGE) $VERSION+# NOTE: Changes made to this file will be lost: look at ltmain.sh.++# Provide generalized library-building support services.+# Written by Gordon Matzigkeit, 1996++# Copyright (C) 2014 Free Software Foundation, Inc.+# This is free software; see the source for copying conditions. There is NO+# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.++# GNU Libtool 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 of the License, or+# (at your option) any later version.+#+# As a special exception to the GNU General Public License, if you+# distribute this file as part of a program or library that is built+# using GNU Libtool, you may include this file under the same+# distribution terms that you use for the rest of that program.+#+# GNU Libtool 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/>.+++# The names of the tagged configurations supported by this script.+available_tags='RC '++# Configured defaults for sys_lib_dlsearch_path munging.+: \${LT_SYS_LIBRARY_PATH="$configure_time_lt_sys_library_path"}++# ### BEGIN LIBTOOL CONFIG++# Which release of libtool.m4 was used?+macro_version=$macro_version+macro_revision=$macro_revision++# Assembler program.+AS=$lt_AS++# DLL creation program.+DLLTOOL=$lt_DLLTOOL++# Object dumper program.+OBJDUMP=$lt_OBJDUMP++# Whether or not to build shared libraries.+build_libtool_libs=$enable_shared++# Whether or not to build static libraries.+build_old_libs=$enable_static++# What type of objects to build.+pic_mode=$pic_mode++# Whether or not to optimize for fast installation.+fast_install=$enable_fast_install++# Shared archive member basename,for filename based shared library versioning on AIX.+shared_archive_member_spec=$shared_archive_member_spec++# Shell to use when invoking shell scripts.+SHELL=$lt_SHELL++# An echo program that protects backslashes.+ECHO=$lt_ECHO++# The PATH separator for the build system.+PATH_SEPARATOR=$lt_PATH_SEPARATOR++# The host system.+host_alias=$host_alias+host=$host+host_os=$host_os++# The build system.+build_alias=$build_alias+build=$build+build_os=$build_os++# A sed program that does not truncate output.+SED=$lt_SED++# Sed that helps us avoid accidentally triggering echo(1) options like -n.+Xsed="\$SED -e 1s/^X//"++# A grep program that handles long lines.+GREP=$lt_GREP++# An ERE matcher.+EGREP=$lt_EGREP++# A literal string matcher.+FGREP=$lt_FGREP++# A BSD- or MS-compatible name lister.+NM=$lt_NM++# Whether we need soft or hard links.+LN_S=$lt_LN_S++# What is the maximum length of a command?+max_cmd_len=$max_cmd_len++# Object file suffix (normally "o").+objext=$ac_objext++# Executable file suffix (normally "").+exeext=$exeext++# whether the shell understands "unset".+lt_unset=$lt_unset++# turn spaces into newlines.+SP2NL=$lt_lt_SP2NL++# turn newlines into spaces.+NL2SP=$lt_lt_NL2SP++# convert \$build file names to \$host format.+to_host_file_cmd=$lt_cv_to_host_file_cmd++# convert \$build files to toolchain format.+to_tool_file_cmd=$lt_cv_to_tool_file_cmd++# A file(cmd) program that detects file types.+FILECMD=$lt_FILECMD++# Method to check whether dependent libraries are shared objects.+deplibs_check_method=$lt_deplibs_check_method++# Command to use when deplibs_check_method = "file_magic".+file_magic_cmd=$lt_file_magic_cmd++# How to find potential files when deplibs_check_method = "file_magic".+file_magic_glob=$lt_file_magic_glob++# Find potential files using nocaseglob when deplibs_check_method = "file_magic".+want_nocaseglob=$lt_want_nocaseglob++# Command to associate shared and link libraries.+sharedlib_from_linklib_cmd=$lt_sharedlib_from_linklib_cmd++# The archiver.+AR=$lt_AR++# Flags to create an archive (by configure).+lt_ar_flags=$lt_ar_flags++# Flags to create an archive.+AR_FLAGS=\${ARFLAGS-"\$lt_ar_flags"}++# How to feed a file listing to the archiver.+archiver_list_spec=$lt_archiver_list_spec++# A symbol stripping program.+STRIP=$lt_STRIP++# Commands used to install an old-style archive.+RANLIB=$lt_RANLIB+old_postinstall_cmds=$lt_old_postinstall_cmds+old_postuninstall_cmds=$lt_old_postuninstall_cmds++# Whether to use a lock for old archive extraction.+lock_old_archive_extraction=$lock_old_archive_extraction++# A C compiler.+LTCC=$lt_CC++# LTCC compiler flags.+LTCFLAGS=$lt_CFLAGS++# Take the output of nm and produce a listing of raw symbols and C names.+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe++# Transform the output of nm in a proper C declaration.+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl++# Transform the output of nm into a list of symbols to manually relocate.+global_symbol_to_import=$lt_lt_cv_sys_global_symbol_to_import++# Transform the output of nm in a C name address pair.+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address++# Transform the output of nm in a C name address pair when lib prefix is needed.+global_symbol_to_c_name_address_lib_prefix=$lt_lt_cv_sys_global_symbol_to_c_name_address_lib_prefix++# The name lister interface.+nm_interface=$lt_lt_cv_nm_interface++# Specify filename containing input files for \$NM.+nm_file_list_spec=$lt_nm_file_list_spec++# The root where to search for dependent libraries,and where our libraries should be installed.+lt_sysroot=$lt_sysroot++# Command to truncate a binary pipe.+lt_truncate_bin=$lt_lt_cv_truncate_bin++# The name of the directory that contains temporary libtool files.+objdir=$objdir++# Used to examine libraries when file_magic_cmd begins with "file".+MAGIC_CMD=$MAGIC_CMD++# Must we lock files when doing compilation?+need_locks=$lt_need_locks++# Manifest tool.+MANIFEST_TOOL=$lt_MANIFEST_TOOL++# Tool to manipulate archived DWARF debug symbol files on Mac OS X.+DSYMUTIL=$lt_DSYMUTIL++# Tool to change global to local symbols on Mac OS X.+NMEDIT=$lt_NMEDIT++# Tool to manipulate fat objects and archives on Mac OS X.+LIPO=$lt_LIPO++# ldd/readelf like tool for Mach-O binaries on Mac OS X.+OTOOL=$lt_OTOOL++# ldd/readelf like tool for 64 bit Mach-O binaries on Mac OS X 10.4.+OTOOL64=$lt_OTOOL64++# Old archive suffix (normally "a").+libext=$libext++# Shared library suffix (normally ".so").+shrext_cmds=$lt_shrext_cmds++# The commands to extract the exported symbol list from a shared archive.+extract_expsyms_cmds=$lt_extract_expsyms_cmds++# Variables whose values should be saved in libtool wrapper scripts and+# restored at link time.+variables_saved_for_relink=$lt_variables_saved_for_relink++# Do we need the "lib" prefix for modules?+need_lib_prefix=$need_lib_prefix++# Do we need a version for libraries?+need_version=$need_version++# Library versioning type.+version_type=$version_type++# Shared library runtime path variable.+runpath_var=$runpath_var++# Shared library path variable.+shlibpath_var=$shlibpath_var++# Is shlibpath searched before the hard-coded library search path?+shlibpath_overrides_runpath=$shlibpath_overrides_runpath++# Format of library name prefix.+libname_spec=$lt_libname_spec++# List of archive names. First name is the real one, the rest are links.+# The last name is the one that the linker finds with -lNAME+library_names_spec=$lt_library_names_spec++# The coded name of the library, if different from the real name.+soname_spec=$lt_soname_spec++# Permission mode override for installation of shared libraries.+install_override_mode=$lt_install_override_mode++# Command to use after installation of a shared archive.+postinstall_cmds=$lt_postinstall_cmds++# Command to use after uninstallation of a shared archive.+postuninstall_cmds=$lt_postuninstall_cmds++# Commands used to finish a libtool library installation in a directory.+finish_cmds=$lt_finish_cmds++# As "finish_cmds", except a single script fragment to be evaled but+# not shown.+finish_eval=$lt_finish_eval++# Whether we should hardcode library paths into libraries.+hardcode_into_libs=$hardcode_into_libs++# Compile-time system search path for libraries.+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec++# Detected run-time system search path for libraries.+sys_lib_dlsearch_path_spec=$lt_configure_time_dlsearch_path++# Explicit LT_SYS_LIBRARY_PATH set during ./configure time.+configure_time_lt_sys_library_path=$lt_configure_time_lt_sys_library_path++# Whether dlopen is supported.+dlopen_support=$enable_dlopen++# Whether dlopen of programs is supported.+dlopen_self=$enable_dlopen_self++# Whether dlopen of statically linked programs is supported.+dlopen_self_static=$enable_dlopen_self_static++# Commands to strip libraries.+old_striplib=$lt_old_striplib+striplib=$lt_striplib+++# The linker used to build libraries.+LD=$lt_LD++# How to create reloadable object files.+reload_flag=$lt_reload_flag+reload_cmds=$lt_reload_cmds++# Commands used to build an old-style archive.+old_archive_cmds=$lt_old_archive_cmds++# A language specific compiler.+CC=$lt_compiler++# Is the compiler the GNU compiler?+with_gcc=$GCC++# Compiler flag to turn off builtin functions.+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag++# Additional compiler flags for building library objects.+pic_flag=$lt_lt_prog_compiler_pic++# How to pass a linker flag through the compiler.+wl=$lt_lt_prog_compiler_wl++# Compiler flag to prevent dynamic linking.+link_static_flag=$lt_lt_prog_compiler_static++# Does compiler simultaneously support -c and -o options?+compiler_c_o=$lt_lt_cv_prog_compiler_c_o++# Whether or not to add -lc for building shared libraries.+build_libtool_need_lc=$archive_cmds_need_lc++# Whether or not to disallow shared libs when runtime libs are static.+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes++# Compiler flag to allow reflexive dlopens.+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec++# Compiler flag to generate shared objects directly from archives.+whole_archive_flag_spec=$lt_whole_archive_flag_spec++# Whether the compiler copes with passing no objects directly.+compiler_needs_object=$lt_compiler_needs_object++# Create an old-style archive from a shared archive.+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds++# Create a temporary old-style archive to link instead of a shared archive.+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds++# Commands used to build a shared archive.+archive_cmds=$lt_archive_cmds+archive_expsym_cmds=$lt_archive_expsym_cmds++# Commands used to build a loadable module if different from building+# a shared archive.+module_cmds=$lt_module_cmds+module_expsym_cmds=$lt_module_expsym_cmds++# Whether we are building with GNU ld or not.+with_gnu_ld=$lt_with_gnu_ld++# Flag that allows shared libraries with undefined symbols to be built.+allow_undefined_flag=$lt_allow_undefined_flag++# Flag that enforces no undefined symbols.+no_undefined_flag=$lt_no_undefined_flag++# Flag to hardcode \$libdir into a binary during linking.+# This must work even if \$libdir does not exist+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec++# Whether we need a single "-rpath" flag with a separated argument.+hardcode_libdir_separator=$lt_hardcode_libdir_separator++# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes+# DIR into the resulting binary.+hardcode_direct=$hardcode_direct++# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes+# DIR into the resulting binary and the resulting library dependency is+# "absolute",i.e impossible to change by setting \$shlibpath_var if the+# library is relocated.+hardcode_direct_absolute=$hardcode_direct_absolute++# Set to "yes" if using the -LDIR flag during linking hardcodes DIR+# into the resulting binary.+hardcode_minus_L=$hardcode_minus_L++# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR+# into the resulting binary.+hardcode_shlibpath_var=$hardcode_shlibpath_var++# Set to "yes" if building a shared library automatically hardcodes DIR+# into the library and all subsequent libraries and executables linked+# against it.+hardcode_automatic=$hardcode_automatic++# Set to yes if linker adds runtime paths of dependent libraries+# to runtime path list.+inherit_rpath=$inherit_rpath++# Whether libtool must link a program against all its dependency libraries.+link_all_deplibs=$link_all_deplibs++# Set to "yes" if exported symbols are required.+always_export_symbols=$always_export_symbols++# The commands to list exported symbols.+export_symbols_cmds=$lt_export_symbols_cmds++# Symbols that should not be listed in the preloaded symbols.+exclude_expsyms=$lt_exclude_expsyms++# Symbols that must always be exported.+include_expsyms=$lt_include_expsyms++# Commands necessary for linking programs (against libraries) with templates.+prelink_cmds=$lt_prelink_cmds++# Commands necessary for finishing linking programs.+postlink_cmds=$lt_postlink_cmds++# Specify filename containing input files.+file_list_spec=$lt_file_list_spec++# How to hardcode a shared library path into an executable.+hardcode_action=$hardcode_action++# ### END LIBTOOL CONFIG++_LT_EOF++ cat <<'_LT_EOF' >> "$cfgfile"++# ### BEGIN FUNCTIONS SHARED WITH CONFIGURE++# func_munge_path_list VARIABLE PATH+# -----------------------------------+# VARIABLE is name of variable containing _space_ separated list of+# directories to be munged by the contents of PATH, which is string+# having a format:+# "DIR[:DIR]:"+# string "DIR[ DIR]" will be prepended to VARIABLE+# ":DIR[:DIR]"+# string "DIR[ DIR]" will be appended to VARIABLE+# "DIRP[:DIRP]::[DIRA:]DIRA"+# string "DIRP[ DIRP]" will be prepended to VARIABLE and string+# "DIRA[ DIRA]" will be appended to VARIABLE+# "DIR[:DIR]"+# VARIABLE will be replaced by "DIR[ DIR]"+func_munge_path_list ()+{+ case x$2 in+ x)+ ;;+ *:)+ eval $1=\"`$ECHO $2 | $SED 's/:/ /g'` \$$1\"+ ;;+ x:*)+ eval $1=\"\$$1 `$ECHO $2 | $SED 's/:/ /g'`\"+ ;;+ *::*)+ eval $1=\"\$$1\ `$ECHO $2 | $SED -e 's/.*:://' -e 's/:/ /g'`\"+ eval $1=\"`$ECHO $2 | $SED -e 's/::.*//' -e 's/:/ /g'`\ \$$1\"+ ;;+ *)+ eval $1=\"`$ECHO $2 | $SED 's/:/ /g'`\"+ ;;+ esac+}+++# Calculate cc_basename. Skip known compiler wrappers and cross-prefix.+func_cc_basename ()+{+ for cc_temp in $*""; do+ case $cc_temp in+ compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;+ distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;+ \-*) ;;+ *) break;;+ esac+ done+ func_cc_basename_result=`$ECHO "$cc_temp" | $SED "s%.*/%%; s%^$host_alias-%%"`+}+++# ### END FUNCTIONS SHARED WITH CONFIGURE++_LT_EOF++ case $host_os in+ aix3*)+ cat <<\_LT_EOF >> "$cfgfile"+# AIX sometimes has problems with the GCC collect2 program. For some+# reason, if we set the COLLECT_NAMES environment variable, the problems+# vanish in a puff of smoke.+if test set != "${COLLECT_NAMES+set}"; then+ COLLECT_NAMES=+ export COLLECT_NAMES+fi+_LT_EOF+ ;;+ esac++++ltmain=$ac_aux_dir/ltmain.sh+++ # We use sed instead of cat because bash on DJGPP gets confused if+ # if finds mixed CR/LF and LF-only lines. Since sed operates in+ # text mode, it properly converts lines to CR/LF. This bash problem+ # is reportedly fixed, but why not run on old versions too?+ $SED '$q' "$ltmain" >> "$cfgfile" \+ || (rm -f "$cfgfile"; exit 1)++ mv -f "$cfgfile" "$ofile" ||+ (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")+ chmod +x "$ofile"+++ cat <<_LT_EOF >> "$ofile"++# ### BEGIN LIBTOOL TAG CONFIG: RC++# The linker used to build libraries.+LD=$lt_LD_RC++# How to create reloadable object files.+reload_flag=$lt_reload_flag_RC+reload_cmds=$lt_reload_cmds_RC++# Commands used to build an old-style archive.+old_archive_cmds=$lt_old_archive_cmds_RC++# A language specific compiler.+CC=$lt_compiler_RC++# Is the compiler the GNU compiler?+with_gcc=$GCC_RC++# Compiler flag to turn off builtin functions.+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC++# Additional compiler flags for building library objects.+pic_flag=$lt_lt_prog_compiler_pic_RC++# How to pass a linker flag through the compiler.+wl=$lt_lt_prog_compiler_wl_RC++# Compiler flag to prevent dynamic linking.+link_static_flag=$lt_lt_prog_compiler_static_RC++# Does compiler simultaneously support -c and -o options?+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC++# Whether or not to add -lc for building shared libraries.+build_libtool_need_lc=$archive_cmds_need_lc_RC++# Whether or not to disallow shared libs when runtime libs are static.+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC++# Compiler flag to allow reflexive dlopens.+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC++# Compiler flag to generate shared objects directly from archives.+whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC++# Whether the compiler copes with passing no objects directly.+compiler_needs_object=$lt_compiler_needs_object_RC++# Create an old-style archive from a shared archive.+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC++# Create a temporary old-style archive to link instead of a shared archive.+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC++# Commands used to build a shared archive.+archive_cmds=$lt_archive_cmds_RC+archive_expsym_cmds=$lt_archive_expsym_cmds_RC++# Commands used to build a loadable module if different from building+# a shared archive.+module_cmds=$lt_module_cmds_RC+module_expsym_cmds=$lt_module_expsym_cmds_RC++# Whether we are building with GNU ld or not.+with_gnu_ld=$lt_with_gnu_ld_RC++# Flag that allows shared libraries with undefined symbols to be built.+allow_undefined_flag=$lt_allow_undefined_flag_RC++# Flag that enforces no undefined symbols.+no_undefined_flag=$lt_no_undefined_flag_RC++# Flag to hardcode \$libdir into a binary during linking.+# This must work even if \$libdir does not exist+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC++# Whether we need a single "-rpath" flag with a separated argument.+hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC++# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes+# DIR into the resulting binary.+hardcode_direct=$hardcode_direct_RC++# Set to "yes" if using DIR/libNAME\$shared_ext during linking hardcodes+# DIR into the resulting binary and the resulting library dependency is+# "absolute",i.e impossible to change by setting \$shlibpath_var if the+# library is relocated.+hardcode_direct_absolute=$hardcode_direct_absolute_RC++# Set to "yes" if using the -LDIR flag during linking hardcodes DIR+# into the resulting binary.+hardcode_minus_L=$hardcode_minus_L_RC++# Set to "yes" if using SHLIBPATH_VAR=DIR during linking hardcodes DIR+# into the resulting binary.+hardcode_shlibpath_var=$hardcode_shlibpath_var_RC++# Set to "yes" if building a shared library automatically hardcodes DIR+# into the library and all subsequent libraries and executables linked+# against it.+hardcode_automatic=$hardcode_automatic_RC++# Set to yes if linker adds runtime paths of dependent libraries+# to runtime path list.+inherit_rpath=$inherit_rpath_RC++# Whether libtool must link a program against all its dependency libraries.+link_all_deplibs=$link_all_deplibs_RC++# Set to "yes" if exported symbols are required.+always_export_symbols=$always_export_symbols_RC++# The commands to list exported symbols.+export_symbols_cmds=$lt_export_symbols_cmds_RC++# Symbols that should not be listed in the preloaded symbols.+exclude_expsyms=$lt_exclude_expsyms_RC++# Symbols that must always be exported.+include_expsyms=$lt_include_expsyms_RC++# Commands necessary for linking programs (against libraries) with templates.+prelink_cmds=$lt_prelink_cmds_RC++# Commands necessary for finishing linking programs.+postlink_cmds=$lt_postlink_cmds_RC++# Specify filename containing input files.+file_list_spec=$lt_file_list_spec_RC++# How to hardcode a shared library path into an executable.+hardcode_action=$hardcode_action_RC++# ### END LIBTOOL TAG CONFIG: RC+_LT_EOF++ ;;+ "po-directories":C)+ for ac_file in $CONFIG_FILES; do+ # Support "outfile[:infile[:infile...]]"+ case "$ac_file" in+ *:*) ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;;+ esac+ # PO directories have a Makefile.in generated from Makefile.in.in.+ case "$ac_file" in */Makefile.in)+ # Adjust a relative srcdir.+ ac_dir=`echo "$ac_file"|sed 's%/[^/][^/]*$%%'`+ ac_dir_suffix=/`echo "$ac_dir"|sed 's%^\./%%'`+ ac_dots=`echo "$ac_dir_suffix"|sed 's%/[^/]*%../%g'`+ # In autoconf-2.13 it is called $ac_given_srcdir.+ # In autoconf-2.50 it is called $srcdir.+ test -n "$ac_given_srcdir" || ac_given_srcdir="$srcdir"+ case "$ac_given_srcdir" in+ .) top_srcdir=`echo $ac_dots|sed 's%/$%%'` ;;+ /*) top_srcdir="$ac_given_srcdir" ;;+ *) top_srcdir="$ac_dots$ac_given_srcdir" ;;+ esac+ # Treat a directory as a PO directory if and only if it has a+ # POTFILES.in file. This allows packages to have multiple PO+ # directories under different names or in different locations.+ if test -f "$ac_given_srcdir/$ac_dir/POTFILES.in"; then+ rm -f "$ac_dir/POTFILES"+ test -n "$as_me" && echo "$as_me: creating $ac_dir/POTFILES" || echo "creating $ac_dir/POTFILES"+ gt_tab=`printf '\t'`+ cat "$ac_given_srcdir/$ac_dir/POTFILES.in" | sed -e "/^#/d" -e "/^[ ${gt_tab}]*\$/d" -e "s,.*, $top_srcdir/& \\\\," | sed -e "\$s/\(.*\) \\\\/\1/" > "$ac_dir/POTFILES"+ POMAKEFILEDEPS="POTFILES.in"+ # ALL_LINGUAS, POFILES, UPDATEPOFILES, DUMMYPOFILES, GMOFILES depend+ # on $ac_dir but don't depend on user-specified configuration+ # parameters.+ if test -f "$ac_given_srcdir/$ac_dir/LINGUAS"; then+ # The LINGUAS file contains the set of available languages.+ if test -n "$OBSOLETE_ALL_LINGUAS"; then+ test -n "$as_me" && echo "$as_me: setting ALL_LINGUAS in configure.in is obsolete" || echo "setting ALL_LINGUAS in configure.in is obsolete"+ fi+ ALL_LINGUAS=`sed -e "/^#/d" -e "s/#.*//" "$ac_given_srcdir/$ac_dir/LINGUAS"`+ POMAKEFILEDEPS="$POMAKEFILEDEPS LINGUAS"+ else+ # The set of available languages was given in configure.in.+ ALL_LINGUAS=$OBSOLETE_ALL_LINGUAS+ fi+ # Compute POFILES+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).po)+ # Compute UPDATEPOFILES+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).po-update)+ # Compute DUMMYPOFILES+ # as $(foreach lang, $(ALL_LINGUAS), $(lang).nop)+ # Compute GMOFILES+ # as $(foreach lang, $(ALL_LINGUAS), $(srcdir)/$(lang).gmo)+ case "$ac_given_srcdir" in+ .) srcdirpre= ;;+ *) srcdirpre='$(srcdir)/' ;;+ esac+ POFILES=+ UPDATEPOFILES=+ DUMMYPOFILES=+ GMOFILES=+ for lang in $ALL_LINGUAS; do+ POFILES="$POFILES $srcdirpre$lang.po"+ UPDATEPOFILES="$UPDATEPOFILES $lang.po-update"+ DUMMYPOFILES="$DUMMYPOFILES $lang.nop"+ GMOFILES="$GMOFILES $srcdirpre$lang.gmo"+ done+ # CATALOGS depends on both $ac_dir and the user's LINGUAS+ # environment variable.+ INST_LINGUAS=+ if test -n "$ALL_LINGUAS"; then+ for presentlang in $ALL_LINGUAS; do+ useit=no+ if test "%UNSET%" != "$LINGUAS"; then+ desiredlanguages="$LINGUAS"+ else+ desiredlanguages="$ALL_LINGUAS"+ fi+ for desiredlang in $desiredlanguages; do+ # Use the presentlang catalog if desiredlang is+ # a. equal to presentlang, or+ # b. a variant of presentlang (because in this case,+ # presentlang can be used as a fallback for messages+ # which are not translated in the desiredlang catalog).+ case "$desiredlang" in+ "$presentlang" | "$presentlang"_* | "$presentlang".* | "$presentlang"@*)+ useit=yes+ ;;+ esac+ done+ if test $useit = yes; then+ INST_LINGUAS="$INST_LINGUAS $presentlang"+ fi+ done+ fi+ CATALOGS=+ if test -n "$INST_LINGUAS"; then+ for lang in $INST_LINGUAS; do+ CATALOGS="$CATALOGS $lang.gmo"+ done+ fi+ test -n "$as_me" && echo "$as_me: creating $ac_dir/Makefile" || echo "creating $ac_dir/Makefile"+ sed -e "/^POTFILES =/r $ac_dir/POTFILES" -e "/^# Makevars/r $ac_given_srcdir/$ac_dir/Makevars" -e "s|@POFILES@|$POFILES|g" -e "s|@UPDATEPOFILES@|$UPDATEPOFILES|g" -e "s|@DUMMYPOFILES@|$DUMMYPOFILES|g" -e "s|@GMOFILES@|$GMOFILES|g" -e "s|@CATALOGS@|$CATALOGS|g" -e "s|@POMAKEFILEDEPS@|$POMAKEFILEDEPS|g" "$ac_dir/Makefile.in" > "$ac_dir/Makefile"+ for f in "$ac_given_srcdir/$ac_dir"/Rules-*; do+ if test -f "$f"; then+ case "$f" in+ *.orig | *.bak | *~) ;;+ *) cat "$f" >> "$ac_dir/Makefile" ;;+ esac+ fi+ done+ fi+ ;;+ esac+ done ;;++ esac+done # for ac_tag+++as_fn_exit 0+_ACEOF+ac_clean_files=$ac_clean_files_save++test $ac_write_fail = 0 ||+ as_fn_error $? "write failure creating $CONFIG_STATUS" "$LINENO" 5+++# configure is writing to config.log, and then calls config.status.+# config.status does its own redirection, appending to config.log.+# Unfortunately, on DOS this fails, as config.log is still kept open+# by configure, so config.status won't be able to write to it; its+# output is simply discarded. So we exec the FD to /dev/null,+# effectively closing config.log, so it can be properly (re)opened and+# appended to by config.status. When coming back to configure, we+# need to make the FD available again.+if test "$no_create" != yes; then+ ac_cs_success=:+ ac_config_status_args=+ test "$silent" = yes &&+ ac_config_status_args="$ac_config_status_args --quiet"+ exec 5>/dev/null+ $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false+ exec 5>>config.log+ # Use ||, not &&, to avoid exiting from the if with $? = 1, which+ # would make configure fail if this is the last instruction.+ $ac_cs_success || as_fn_exit 1+fi+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then+ { printf "%s\n" "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5+printf "%s\n" "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}+fi+++# Some warnings+if test x$tuklib_cv_physmem_method = xunknown; then+ echo+ echo "WARNING:"+ echo "No supported method to detect the amount of RAM."+ echo "Consider using --enable-assume-ram (if you didn't already)"+ echo "or make a patch to add support for this operating system."+fi++if test x$tuklib_cv_cpucores_method = xunknown; then+ echo+ echo "WARNING:"+ echo "No supported method to detect the number of CPU cores."+fi++if test "x$enable_threads$enable_small$have_func_attribute_constructor" \+ = xnoyesno; then+ echo+ echo "NOTE:"+ echo "liblzma will be thread-unsafe due to the combination"+ echo "of --disable-threads --enable-small when using a compiler"+ echo "that doesn't support __attribute__((__constructor__))."+fi+
+ xz-clib.cabal view
@@ -0,0 +1,168 @@+cabal-version: 2.2+name: xz-clib+version: 5.6.3++synopsis: LZMA/XZ clibs+description: C source code for the LZMA/XZ compression and decompression library+homepage: https://github.com/hasufell/lzma-static+bug-reports: https://github.com/hasufell/lzma-static/issues+license: 0BSD+license-file: cbits/LICENSE+author: Julian Ospald+maintainer: hasufell@posteo.de+copyright: (c) 2021 Julian Ospald+stability: experimental+category: Codec, Compression+build-type: Configure++extra-doc-files:+ Changelog.md++extra-source-files:+ cbits/common/*.c+ cbits/common/*.h+ cbits/liblzma/api/lzma.h+ cbits/liblzma/api/lzma/*.h+ cbits/liblzma/check/*.c+ cbits/liblzma/check/*.h+ cbits/liblzma/common/*.c+ cbits/liblzma/common/*.h+ cbits/liblzma/delta/*.c+ cbits/liblzma/delta/*.h+ cbits/liblzma/lz/*.c+ cbits/liblzma/lz/*.h+ cbits/liblzma/lzma/*.c+ cbits/liblzma/lzma/*.h+ cbits/liblzma/rangecoder/*.c+ cbits/liblzma/rangecoder/*.h+ cbits/liblzma/simple/*.c+ cbits/liblzma/simple/*.h+ cbits/config.h.in+ build/autoconf/config.guess+ build/autoconf/config.rpath+ build/autoconf/config.sub+ build/autoconf/install-sh+ build/autoconf/ltmain.sh+ configure++source-repository head+ type: git+ location: https://github.com/hasufell/lzma-static.git+ subdir: xz-clib++library+ default-language: Haskell2010+ c-sources:+ cbits/common/tuklib_cpucores.c+ cbits/common/tuklib_physmem.c+ cbits/liblzma/check/check.c+ cbits/liblzma/check/crc32_fast.c+ cbits/liblzma/check/crc32_table.c+ cbits/liblzma/check/crc64_fast.c+ cbits/liblzma/check/crc64_table.c+ cbits/liblzma/check/sha256.c+ cbits/liblzma/common/alone_decoder.c+ cbits/liblzma/common/alone_encoder.c+ cbits/liblzma/common/auto_decoder.c+ cbits/liblzma/common/block_buffer_decoder.c+ cbits/liblzma/common/block_buffer_encoder.c+ cbits/liblzma/common/block_decoder.c+ cbits/liblzma/common/block_encoder.c+ cbits/liblzma/common/block_header_decoder.c+ cbits/liblzma/common/block_header_encoder.c+ cbits/liblzma/common/block_util.c+ cbits/liblzma/common/common.c+ cbits/liblzma/common/easy_buffer_encoder.c+ cbits/liblzma/common/easy_decoder_memusage.c+ cbits/liblzma/common/easy_encoder.c+ cbits/liblzma/common/easy_encoder_memusage.c+ cbits/liblzma/common/easy_preset.c+ cbits/liblzma/common/file_info.c+ cbits/liblzma/common/filter_buffer_decoder.c+ cbits/liblzma/common/filter_buffer_encoder.c+ cbits/liblzma/common/filter_common.c+ cbits/liblzma/common/filter_decoder.c+ cbits/liblzma/common/filter_encoder.c+ cbits/liblzma/common/filter_flags_decoder.c+ cbits/liblzma/common/filter_flags_encoder.c+ cbits/liblzma/common/hardware_cputhreads.c+ cbits/liblzma/common/hardware_physmem.c+ cbits/liblzma/common/index.c+ cbits/liblzma/common/index_decoder.c+ cbits/liblzma/common/index_encoder.c+ cbits/liblzma/common/index_hash.c+ cbits/liblzma/common/lzip_decoder.c+ cbits/liblzma/common/microlzma_decoder.c+ cbits/liblzma/common/microlzma_encoder.c+ cbits/liblzma/common/outqueue.c+ cbits/liblzma/common/stream_buffer_decoder.c+ cbits/liblzma/common/stream_buffer_encoder.c+ cbits/liblzma/common/stream_decoder.c+ cbits/liblzma/common/stream_decoder_mt.c+ cbits/liblzma/common/stream_encoder.c+ cbits/liblzma/common/stream_encoder_mt.c+ cbits/liblzma/common/stream_flags_common.c+ cbits/liblzma/common/stream_flags_decoder.c+ cbits/liblzma/common/stream_flags_encoder.c+ cbits/liblzma/common/string_conversion.c+ cbits/liblzma/common/vli_decoder.c+ cbits/liblzma/common/vli_encoder.c+ cbits/liblzma/common/vli_size.c+ cbits/liblzma/delta/delta_common.c+ cbits/liblzma/delta/delta_decoder.c+ cbits/liblzma/delta/delta_encoder.c+ cbits/liblzma/lz/lz_decoder.c+ cbits/liblzma/lz/lz_encoder.c+ cbits/liblzma/lz/lz_encoder_mf.c+ cbits/liblzma/lzma/fastpos_table.c+ cbits/liblzma/lzma/lzma2_decoder.c+ cbits/liblzma/lzma/lzma2_encoder.c+ cbits/liblzma/lzma/lzma_decoder.c+ cbits/liblzma/lzma/lzma_encoder.c+ cbits/liblzma/lzma/lzma_encoder_optimum_fast.c+ cbits/liblzma/lzma/lzma_encoder_optimum_normal.c+ cbits/liblzma/lzma/lzma_encoder_presets.c+ cbits/liblzma/rangecoder/price_table.c+ cbits/liblzma/simple/arm.c+ cbits/liblzma/simple/arm64.c+ cbits/liblzma/simple/armthumb.c+ cbits/liblzma/simple/ia64.c+ cbits/liblzma/simple/powerpc.c+ cbits/liblzma/simple/riscv.c+ cbits/liblzma/simple/simple_coder.c+ cbits/liblzma/simple/simple_decoder.c+ cbits/liblzma/simple/simple_encoder.c+ cbits/liblzma/simple/sparc.c+ cbits/liblzma/simple/x86.c++ include-dirs:+ cbits/liblzma/api+ cbits/liblzma/common+ cbits/liblzma/check+ cbits/liblzma/delta+ cbits/liblzma/lz+ cbits/liblzma/lzma+ cbits/liblzma/rangecoder+ cbits/liblzma/simple+ cbits/common+ cbits/++ install-includes:+ lzma.h+ lzma/base.h+ lzma/bcj.h+ lzma/block.h+ lzma/check.h+ lzma/container.h+ lzma/delta.h+ lzma/filter.h+ lzma/hardware.h+ lzma/index.h+ lzma/index_hash.h+ lzma/lzma12.h+ lzma/stream_flags.h+ lzma/version.h+ lzma/vli.h++ cc-options: -std=gnu99 -DHAVE_CONFIG_H -DTUKLIB_SYMBOL_PREFIX=lzma_+