diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2009-04-13 11:27:40 +0300 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2009-04-13 11:27:40 +0300 |
commit | 02ddf09bc3079b3e17297729b9e43f14d407b8fc (patch) | |
tree | 4a3b92a91c5eacbd7ea6229dd02ffeae6688b02f /src/liblzma/check | |
parent | Fix off-by-one in LZ decoder. (diff) | |
download | xz-02ddf09bc3079b3e17297729b9e43f14d407b8fc.tar.xz |
Put the interesting parts of XZ Utils into the public domain.
Some minor documentation cleanups were made at the same time.
Diffstat (limited to '')
-rw-r--r-- | src/liblzma/check/Makefile.am | 8 | ||||
-rw-r--r-- | src/liblzma/check/check.c | 7 | ||||
-rw-r--r-- | src/liblzma/check/check.h | 7 | ||||
-rw-r--r-- | src/liblzma/check/crc32_fast.c | 30 | ||||
-rw-r--r-- | src/liblzma/check/crc32_small.c | 7 | ||||
-rw-r--r-- | src/liblzma/check/crc32_table.c | 7 | ||||
-rw-r--r-- | src/liblzma/check/crc32_tablegen.c | 7 | ||||
-rw-r--r-- | src/liblzma/check/crc32_x86.S | 21 | ||||
-rw-r--r-- | src/liblzma/check/crc64_fast.c | 20 | ||||
-rw-r--r-- | src/liblzma/check/crc64_small.c | 7 | ||||
-rw-r--r-- | src/liblzma/check/crc64_table.c | 7 | ||||
-rw-r--r-- | src/liblzma/check/crc64_tablegen.c | 7 | ||||
-rw-r--r-- | src/liblzma/check/crc64_x86.S | 14 | ||||
-rw-r--r-- | src/liblzma/check/crc_macros.h | 9 | ||||
-rw-r--r-- | src/liblzma/check/sha256.c | 23 |
15 files changed, 88 insertions, 93 deletions
diff --git a/src/liblzma/check/Makefile.am b/src/liblzma/check/Makefile.am index 74011695..1409bec0 100644 --- a/src/liblzma/check/Makefile.am +++ b/src/liblzma/check/Makefile.am @@ -1,10 +1,8 @@ ## -## This code has been put into the public domain. +## Author: Lasse Collin ## -## This library is distributed in the hope that it will be useful, -## but WITHOUT ANY WARRANTY; without even the implied warranty of -## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -## Lesser General Public License for more details. +## This file has been put into the public domain. +## You can do whatever you want with this file. ## EXTRA_DIST = crc32_tablegen.c crc64_tablegen.c diff --git a/src/liblzma/check/check.c b/src/liblzma/check/check.c index 484be594..ba8622e6 100644 --- a/src/liblzma/check/check.c +++ b/src/liblzma/check/check.c @@ -3,11 +3,10 @@ /// \file check.c /// \brief Single API to access different integrity checks // -// This code has been put into the public domain. +// Author: Lasse Collin // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// This file has been put into the public domain. +// You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// diff --git a/src/liblzma/check/check.h b/src/liblzma/check/check.h index 1dfc4d73..e100d2b8 100644 --- a/src/liblzma/check/check.h +++ b/src/liblzma/check/check.h @@ -3,11 +3,10 @@ /// \file check.h /// \brief Internal API to different integrity check functions // -// This code has been put into the public domain. +// Author: Lasse Collin // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// This file has been put into the public domain. +// You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// diff --git a/src/liblzma/check/crc32_fast.c b/src/liblzma/check/crc32_fast.c index 61eacd61..a308eff5 100644 --- a/src/liblzma/check/crc32_fast.c +++ b/src/liblzma/check/crc32_fast.c @@ -2,12 +2,17 @@ // /// \file crc32.c /// \brief CRC32 calculation +/// +/// Calculate the CRC32 using the slice-by-eight algorithm. +/// It is explained in this document: +/// http://www.intel.com/technology/comms/perfnet/download/CRC_generators.pdf +/// The code in this file is not the same as in Intel's paper, but +/// the basic principle is identical. // -// This code has been put into the public domain. +// Author: Lasse Collin // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// This file has been put into the public domain. +// You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// @@ -43,17 +48,6 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc) size &= (size_t)(7); // Calculate the CRC32 using the slice-by-eight algorithm. - // It is explained in this document: - // http://www.intel.com/technology/comms/perfnet/download/CRC_generators.pdf - // - // The code below is different than the code in Intel's - // paper, but the principle is identical. This should be - // faster with GCC than Intel's code. This is tested only - // with GCC 3.4.6 and 4.1.2 on x86, so your results may vary. - // - // Using -Os and -fomit-frame-pointer seem to give the best - // results at least with GCC 4.1.2 on x86. It's sill far - // from the speed of hand-optimized assembler. while (buf < limit) { crc ^= *(uint32_t *)(buf); buf += 4; @@ -66,9 +60,9 @@ lzma_crc32(const uint8_t *buf, size_t size, uint32_t crc) const uint32_t tmp = *(uint32_t *)(buf); buf += 4; - // It is critical for performance, that - // the crc variable is XORed between the - // two table-lookup pairs. + // 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 diff --git a/src/liblzma/check/crc32_small.c b/src/liblzma/check/crc32_small.c index 8507436b..5f8a3286 100644 --- a/src/liblzma/check/crc32_small.c +++ b/src/liblzma/check/crc32_small.c @@ -3,11 +3,10 @@ /// \file crc32_small.c /// \brief CRC32 calculation (size-optimized) // -// This code has been put into the public domain. +// Author: Lasse Collin // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// This file has been put into the public domain. +// You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// diff --git a/src/liblzma/check/crc32_table.c b/src/liblzma/check/crc32_table.c index 4fcebc2b..368874eb 100644 --- a/src/liblzma/check/crc32_table.c +++ b/src/liblzma/check/crc32_table.c @@ -3,11 +3,10 @@ /// \file crc32_table.c /// \brief Precalculated CRC32 table with correct endianness // -// This code has been put into the public domain. +// Author: Lasse Collin // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// This file has been put into the public domain. +// You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// diff --git a/src/liblzma/check/crc32_tablegen.c b/src/liblzma/check/crc32_tablegen.c index fbcbf474..0cbfecd8 100644 --- a/src/liblzma/check/crc32_tablegen.c +++ b/src/liblzma/check/crc32_tablegen.c @@ -6,11 +6,10 @@ /// Compiling: gcc -std=c99 -o crc32_tablegen crc32_tablegen.c /// Add -DWORDS_BIGENDIAN to generate big endian table. // -// This code has been put into the public domain. +// Author: Lasse Collin // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// This file has been put into the public domain. +// You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// diff --git a/src/liblzma/check/crc32_x86.S b/src/liblzma/check/crc32_x86.S index ec28cf5d..b3c7538f 100644 --- a/src/liblzma/check/crc32_x86.S +++ b/src/liblzma/check/crc32_x86.S @@ -1,11 +1,18 @@ /* * Speed-optimized CRC32 using slicing-by-eight algorithm - * Instruction set: i386 - * Optimized for: i686 * - * This code has been put into the public domain by its authors: - * Original code by Igor Pavlov <http://7-zip.org/> - * Position-independent version by Lasse Collin <lasse.collin@tukaani.org> + * This uses only i386 instructions, but it is optimized for i686 and later + * (including e.g. Pentium II/III/IV, Athlon XP, and Core 2). For i586 + * (e.g. Pentium), slicing-by-four would be better, and even the C version + * of slicing-by-eight built with gcc -march=i586 tends to be a little bit + * better than this. Very few probably run this code on i586 or older x86 + * so this shouldn't be a problem in practice. + * + * Authors: Igor Pavlov (original version) + * Lasse Collin (AT&T syntax, PIC support, better portability) + * + * This file has been put into the public domain. + * You can do whatever you want with this file. * * This code needs lzma_crc32_table, which can be created using the * following C code: @@ -15,10 +22,10 @@ uint32_t lzma_crc32_table[8][256]; void init_table(void) { - // IEEE-802.3 (CRC32) + // IEEE-802.3 static const uint32_t poly32 = UINT32_C(0xEDB88320); - // Castagnoli (CRC32C) + // Castagnoli // static const uint32_t poly32 = UINT32_C(0x82F63B78); // Koopman diff --git a/src/liblzma/check/crc64_fast.c b/src/liblzma/check/crc64_fast.c index d2d1d60f..25557264 100644 --- a/src/liblzma/check/crc64_fast.c +++ b/src/liblzma/check/crc64_fast.c @@ -2,12 +2,15 @@ // /// \file crc64.c /// \brief CRC64 calculation +/// +/// Calculate the CRC64 using the slice-by-four algorithm. This is the same +/// idea that is used in crc32_fast.c, but for CRC64 we use only four tables +/// instead of eight to avoid increasing CPU cache usage. // -// This code has been put into the public domain. +// Author: Lasse Collin // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// This file has been put into the public domain. +// You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// @@ -22,7 +25,7 @@ #endif -// See comments in crc32.c. +// See the comments in crc32_fast.c. They aren't duplicated here. extern LZMA_API(uint64_t) lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc) { @@ -41,10 +44,6 @@ lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc) const uint8_t *const limit = buf + (size & ~(size_t)(3)); size &= (size_t)(3); - // Calculate the CRC64 using the slice-by-four algorithm. - // - // In contrast to CRC32 code, this one seems to be fastest - // with -O3 -fomit-frame-pointer. while (buf < limit) { #ifdef WORDS_BIGENDIAN const uint32_t tmp = (crc >> 32) ^ *(uint32_t *)(buf); @@ -53,9 +52,6 @@ lzma_crc64(const uint8_t *buf, size_t size, uint64_t crc) #endif buf += 4; - // It is critical for performance, that - // the crc variable is XORed between the - // two table-lookup pairs. crc = lzma_crc64_table[3][A(tmp)] ^ lzma_crc64_table[2][B(tmp)] ^ S32(crc) diff --git a/src/liblzma/check/crc64_small.c b/src/liblzma/check/crc64_small.c index 26b04997..55d72316 100644 --- a/src/liblzma/check/crc64_small.c +++ b/src/liblzma/check/crc64_small.c @@ -3,11 +3,10 @@ /// \file crc64_small.c /// \brief CRC64 calculation (size-optimized) // -// This code has been put into the public domain. +// Author: Lasse Collin // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// This file has been put into the public domain. +// You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// diff --git a/src/liblzma/check/crc64_table.c b/src/liblzma/check/crc64_table.c index 983ed31f..1fbcd947 100644 --- a/src/liblzma/check/crc64_table.c +++ b/src/liblzma/check/crc64_table.c @@ -3,11 +3,10 @@ /// \file crc64_table.c /// \brief Precalculated CRC64 table with correct endianness // -// This code has been put into the public domain. +// Author: Lasse Collin // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// This file has been put into the public domain. +// You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// diff --git a/src/liblzma/check/crc64_tablegen.c b/src/liblzma/check/crc64_tablegen.c index a0fa4ab2..92b9a7da 100644 --- a/src/liblzma/check/crc64_tablegen.c +++ b/src/liblzma/check/crc64_tablegen.c @@ -6,11 +6,10 @@ /// Compiling: gcc -std=c99 -o crc64_tablegen crc64_tablegen.c /// Add -DWORDS_BIGENDIAN to generate big endian table. // -// This code has been put into the public domain. +// Author: Lasse Collin // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// This file has been put into the public domain. +// You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// diff --git a/src/liblzma/check/crc64_x86.S b/src/liblzma/check/crc64_x86.S index 3c25d42d..5e170bc8 100644 --- a/src/liblzma/check/crc64_x86.S +++ b/src/liblzma/check/crc64_x86.S @@ -1,11 +1,14 @@ /* * Speed-optimized CRC64 using slicing-by-four algorithm - * Instruction set: i386 - * Optimized for: i686 * - * This code has been put into the public domain by its authors: - * Igor Pavlov <http://7-zip.org/> - * Lasse Collin <lasse.collin@tukaani.org> + * This uses only i386 instructions, but it is optimized for i686 and later + * (including e.g. Pentium II/III/IV, Athlon XP, and Core 2). + * + * Authors: Igor Pavlov (original CRC32 assembly code) + * Lasse Collin (CRC64 adaptation of the modified CRC32 code) + * + * This file has been put into the public domain. + * You can do whatever you want with this file. * * This code needs lzma_crc64_table, which can be created using the * following C code: @@ -15,6 +18,7 @@ uint64_t lzma_crc64_table[4][256]; void init_table(void) { + // ECMA-182 static const uint64_t poly64 = UINT64_C(0xC96C5795D7870F42); for (size_t s = 0; s < 4; ++s) { diff --git a/src/liblzma/check/crc_macros.h b/src/liblzma/check/crc_macros.h index e827d07d..9e2c0303 100644 --- a/src/liblzma/check/crc_macros.h +++ b/src/liblzma/check/crc_macros.h @@ -1,13 +1,12 @@ /////////////////////////////////////////////////////////////////////////////// // -/// \file crc_macros +/// \file crc_macros.h /// \brief Some endian-dependent macros for CRC32 and CRC64 // -// This code has been put into the public domain. +// Author: Lasse Collin // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// This file has been put into the public domain. +// You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// diff --git a/src/liblzma/check/sha256.c b/src/liblzma/check/sha256.c index 9f90f7e7..978fc668 100644 --- a/src/liblzma/check/sha256.c +++ b/src/liblzma/check/sha256.c @@ -1,19 +1,24 @@ /////////////////////////////////////////////////////////////////////////////// // /// \file sha256.c -/// \brief SHA256 -// -// Based on the public domain code found from Wei Dai's Crypto++ library -// version 5.5.1: http://www.cryptopp.com/ -// This code has been put into the public domain. -// +/// \brief SHA-256 +/// /// \todo Crypto++ has x86 ASM optimizations. They use SSE so if they /// are imported to liblzma, SSE instructions need to be used /// conditionally to keep the code working on older boxes. +/// We could also support using some external libary for SHA-256. +// +// This code is based on the code found from 7-Zip, which has a modified +// version of the SHA-256 found from Crypto++ <http://www.cryptopp.com/>. +// The code was modified a little to fit into liblzma. +// +// Authors: Kevin Springle +// Wei Dai +// Igor Pavlov +// Lasse Collin // -// This library is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY; without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +// This file has been put into the public domain. +// You can do whatever you want with this file. // /////////////////////////////////////////////////////////////////////////////// |