├── .github └── workflows │ └── test.yml ├── .gitignore ├── CMakeLists.txt ├── LICENSE ├── README.md ├── ext ├── htslib │ ├── .gitignore │ ├── .travis.yml │ ├── Makefile │ ├── README.md │ ├── bgzf.c │ ├── bgzip.c │ ├── config.h │ ├── cram │ │ ├── cram.h │ │ ├── cram_codecs.c │ │ ├── cram_codecs.h │ │ ├── cram_decode.c │ │ ├── cram_decode.h │ │ ├── cram_encode.c │ │ ├── cram_encode.h │ │ ├── cram_index.c │ │ ├── cram_index.h │ │ ├── cram_io.c │ │ ├── cram_io.h │ │ ├── cram_samtools.c │ │ ├── cram_samtools.h │ │ ├── cram_stats.c │ │ ├── cram_stats.h │ │ ├── cram_structs.h │ │ ├── files.c │ │ ├── mFILE.c │ │ ├── mFILE.h │ │ ├── md5.c │ │ ├── md5.h │ │ ├── misc.h │ │ ├── open_trace_file.c │ │ ├── open_trace_file.h │ │ ├── os.h │ │ ├── pooled_alloc.c │ │ ├── pooled_alloc.h │ │ ├── sam_header.c │ │ ├── sam_header.h │ │ ├── string_alloc.c │ │ ├── string_alloc.h │ │ ├── thread_pool.c │ │ ├── thread_pool.h │ │ ├── vlen.c │ │ ├── vlen.h │ │ ├── zfio.c │ │ └── zfio.h │ ├── faidx.5 │ ├── faidx.c │ ├── hfile.c │ ├── hfile_internal.h │ ├── hfile_net.c │ ├── hts.c │ ├── htslib.mk │ ├── htslib │ │ ├── bgzf.h │ │ ├── faidx.h │ │ ├── hfile.h │ │ ├── hts.h │ │ ├── hts_defs.h │ │ ├── kfunc.h │ │ ├── khash.h │ │ ├── khash_str2int.h │ │ ├── klist.h │ │ ├── knetfile.h │ │ ├── kseq.h │ │ ├── ksort.h │ │ ├── kstdint.h │ │ ├── kstring.h │ │ ├── sam.h │ │ ├── synced_bcf_reader.h │ │ ├── tbx.h │ │ ├── vcf.h │ │ ├── vcf_sweep.h │ │ └── vcfutils.h │ ├── htslib_vars.mk │ ├── kfunc.c │ ├── knetfile.c │ ├── kstring.c │ ├── sam.5 │ ├── sam.c │ ├── synced_bcf_reader.c │ ├── tabix.1 │ ├── tabix.c │ ├── tbx.c │ ├── vcf.5 │ ├── vcf.c │ ├── vcf_sweep.c │ └── vcfutils.c └── zlib-ng │ ├── .codecov.yaml │ ├── .gitattributes │ ├── .github │ └── workflows │ │ ├── analyze.yml │ │ ├── cmake.yml │ │ ├── configure.yml │ │ ├── fuzz.yml │ │ ├── libpng.yml │ │ ├── link.yml │ │ ├── nmake.yml │ │ ├── pigz.yml │ │ ├── pkgcheck.yml │ │ └── release.yml │ ├── .gitignore │ ├── .shellcheckrc │ ├── CMakeLists.txt │ ├── FAQ.zlib │ ├── INDEX.md │ ├── LICENSE.md │ ├── Makefile.in │ ├── PORTING.md │ ├── README.md │ ├── adler32.c │ ├── adler32_fold.c │ ├── adler32_fold.h │ ├── adler32_p.h │ ├── arch │ ├── .gitignore │ ├── arm │ │ ├── Makefile.in │ │ ├── adler32_neon.c │ │ ├── arm_features.c │ │ ├── arm_features.h │ │ ├── chunkset_neon.c │ │ ├── compare256_neon.c │ │ ├── crc32_acle.c │ │ ├── ctzl.h │ │ ├── insert_string_acle.c │ │ └── slide_hash_neon.c │ ├── generic │ │ ├── Makefile.in │ │ └── chunk_permute_table.h │ ├── power │ │ ├── Makefile.in │ │ ├── adler32_power8.c │ │ ├── adler32_vmx.c │ │ ├── chunkset_power8.c │ │ ├── compare256_power9.c │ │ ├── crc32_constants.h │ │ ├── crc32_power8.c │ │ ├── fallback_builtins.h │ │ ├── power_features.c │ │ ├── power_features.h │ │ ├── slide_hash_power8.c │ │ ├── slide_hash_vmx.c │ │ └── slide_ppc_tpl.h │ ├── s390 │ │ ├── Makefile.in │ │ ├── README.md │ │ ├── crc32-vx.c │ │ ├── dfltcc_common.c │ │ ├── dfltcc_common.h │ │ ├── dfltcc_deflate.c │ │ ├── dfltcc_deflate.h │ │ ├── dfltcc_detail.h │ │ ├── dfltcc_inflate.c │ │ ├── dfltcc_inflate.h │ │ ├── s390_features.c │ │ ├── s390_features.h │ │ └── self-hosted-builder │ │ │ ├── actions-runner.Dockerfile │ │ │ ├── actions-runner.service │ │ │ ├── fs │ │ │ └── usr │ │ │ │ └── bin │ │ │ │ ├── actions-runner │ │ │ │ └── entrypoint │ │ │ └── qemu-user-static.service │ └── x86 │ │ ├── Makefile.in │ │ ├── adler32_avx2.c │ │ ├── adler32_avx2_p.h │ │ ├── adler32_avx2_tpl.h │ │ ├── adler32_avx512.c │ │ ├── adler32_avx512_p.h │ │ ├── adler32_avx512_tpl.h │ │ ├── adler32_avx512_vnni.c │ │ ├── adler32_sse42.c │ │ ├── adler32_ssse3.c │ │ ├── adler32_ssse3_p.h │ │ ├── chunkset_avx.c │ │ ├── chunkset_sse2.c │ │ ├── chunkset_sse41.c │ │ ├── compare256_avx2.c │ │ ├── compare256_sse2.c │ │ ├── crc32_fold_pclmulqdq.c │ │ ├── crc32_fold_pclmulqdq_tpl.h │ │ ├── crc32_fold_vpclmulqdq.c │ │ ├── crc32_fold_vpclmulqdq_tpl.h │ │ ├── insert_string_sse42.c │ │ ├── slide_hash_avx2.c │ │ ├── slide_hash_sse2.c │ │ ├── x86_features.c │ │ └── x86_features.h │ ├── chunkset.c │ ├── chunkset_tpl.h │ ├── cmake │ ├── detect-arch.c │ ├── detect-arch.cmake │ ├── detect-coverage.cmake │ ├── detect-install-dirs.cmake │ ├── detect-intrinsics.cmake │ ├── detect-sanitizer.cmake │ ├── fallback-macros.cmake │ ├── toolchain-aarch64.cmake │ ├── toolchain-arm.cmake │ ├── toolchain-armhf.cmake │ ├── toolchain-mingw-i686.cmake │ ├── toolchain-mingw-x86_64.cmake │ ├── toolchain-powerpc.cmake │ ├── toolchain-powerpc64.cmake │ ├── toolchain-powerpc64le.cmake │ ├── toolchain-s390x.cmake │ └── toolchain-sparc64.cmake │ ├── compare256.c │ ├── compress.c │ ├── configure │ ├── cpu_features.c │ ├── cpu_features.h │ ├── crc32_braid.c │ ├── crc32_braid_comb.c │ ├── crc32_braid_comb_p.h │ ├── crc32_braid_p.h │ ├── crc32_braid_tbl.h │ ├── crc32_fold.c │ ├── crc32_fold.h │ ├── deflate.c │ ├── deflate.h │ ├── deflate_fast.c │ ├── deflate_huff.c │ ├── deflate_medium.c │ ├── deflate_p.h │ ├── deflate_quick.c │ ├── deflate_rle.c │ ├── deflate_slow.c │ ├── deflate_stored.c │ ├── doc │ ├── algorithm.txt │ ├── crc-doc.1.0.pdf │ ├── crc-pclmulqdq.pdf │ ├── rfc1950.txt │ ├── rfc1951.txt │ ├── rfc1952.txt │ └── txtvsbin.txt │ ├── fallback_builtins.h │ ├── functable.c │ ├── functable.h │ ├── gzguts.h │ ├── gzlib.c │ ├── gzread.c.in │ ├── gzwrite.c │ ├── infback.c │ ├── inffast.c │ ├── inffast.h │ ├── inffixed_tbl.h │ ├── inflate.c │ ├── inflate.h │ ├── inflate_p.h │ ├── inftrees.c │ ├── inftrees.h │ ├── insert_string.c │ ├── insert_string_roll.c │ ├── insert_string_tpl.h │ ├── match_tpl.h │ ├── slide_hash.c │ ├── test │ ├── .gitignore │ ├── CMakeLists.txt │ ├── CVE-2002-0059 │ │ └── test.gz │ ├── CVE-2004-0797 │ │ └── test.gz │ ├── CVE-2005-1849 │ │ └── test.gz │ ├── CVE-2005-2096 │ │ └── test.gz │ ├── CVE-2018-25032 │ │ ├── default.txt │ │ └── fixed.txt │ ├── GH-361 │ │ └── test.txt │ ├── GH-364 │ │ └── test.bin │ ├── GH-382 │ │ └── defneg3.dat │ ├── GH-751 │ │ └── test.txt │ ├── GH-979 │ │ └── pigz-2.6.tar.gz │ ├── Makefile.in │ ├── README.md │ ├── abi │ │ ├── ignore │ │ ├── zlib-ng-843c16c87afd53a20bf915661012b02acdd30281-x86_64-pc-linux-gnu.abi │ │ ├── zlib-v1.2.11-arm-linux-gnueabihf.abi │ │ ├── zlib-v1.2.11-x86_64-linux-gnu.abi │ │ └── zlib-v1.2.12-x86_64-pc-linux-gnu.abi │ ├── abicheck.md │ ├── abicheck.sh │ ├── add-subdirectory-project │ │ ├── CMakeLists.txt │ │ └── main.c │ ├── benchmarks │ │ ├── CMakeLists.txt │ │ ├── README.md │ │ ├── benchmark_adler32.cc │ │ ├── benchmark_adler32_copy.cc │ │ ├── benchmark_compare256.cc │ │ ├── benchmark_crc32.cc │ │ ├── benchmark_main.cc │ │ ├── benchmark_png_decode.cc │ │ ├── benchmark_png_encode.cc │ │ ├── benchmark_png_shared.h │ │ └── benchmark_slidehash.cc │ ├── cmake │ │ ├── compress-and-verify.cmake │ │ ├── run-and-compare.cmake │ │ ├── run-and-redirect.cmake │ │ ├── test-cves.cmake │ │ ├── test-data.cmake │ │ ├── test-issues.cmake │ │ └── test-tools.cmake │ ├── data │ │ ├── fireworks.jpg │ │ ├── lcet10.txt │ │ └── paper-100k.pdf │ ├── example.c │ ├── fuzz │ │ ├── CMakeLists.txt │ │ ├── fuzzer_checksum.c │ │ ├── fuzzer_compress.c │ │ ├── fuzzer_example_dict.c │ │ ├── fuzzer_example_flush.c │ │ ├── fuzzer_example_large.c │ │ ├── fuzzer_example_small.c │ │ ├── fuzzer_minigzip.c │ │ └── standalone_fuzz_target_runner.c │ ├── gh1235.c │ ├── infcover.c │ ├── minideflate.c │ ├── minigzip.c │ ├── pigz │ │ └── CMakeLists.txt │ ├── pkgcheck.sh │ ├── switchlevels.c │ ├── test_adler32.cc │ ├── test_aligned_alloc.cc │ ├── test_compare256.cc │ ├── test_compress.cc │ ├── test_compress_bound.cc │ ├── test_compress_dual.cc │ ├── test_crc32.cc │ ├── test_cve-2003-0107.cc │ ├── test_deflate_bound.cc │ ├── test_deflate_concurrency.cc │ ├── test_deflate_copy.cc │ ├── test_deflate_dict.cc │ ├── test_deflate_hash_head_0.cc │ ├── test_deflate_header.cc │ ├── test_deflate_params.cc │ ├── test_deflate_pending.cc │ ├── test_deflate_prime.cc │ ├── test_deflate_quick_bi_valid.cc │ ├── test_deflate_quick_block_open.cc │ ├── test_deflate_tune.cc │ ├── test_dict.cc │ ├── test_gzio.cc │ ├── test_inflate_adler32.cc │ ├── test_inflate_sync.cc │ ├── test_large_buffers.cc │ ├── test_main.cc │ ├── test_shared.h │ ├── test_small_buffers.cc │ └── test_version.cc │ ├── tools │ ├── config.sub │ ├── makecrct.c │ ├── makefixed.c │ └── maketrees.c │ ├── trees.c │ ├── trees.h │ ├── trees_emit.h │ ├── trees_tbl.h │ ├── uncompr.c │ ├── win32 │ ├── Makefile.a64 │ ├── Makefile.arm │ ├── Makefile.msc │ ├── replace.vbs │ ├── zlib-ng.def.in │ ├── zlib-ng1.rc │ ├── zlib.def.in │ ├── zlib1.rc │ └── zlibcompat.def.in │ ├── zbuild.h │ ├── zconf-ng.h.in │ ├── zconf.h.in │ ├── zendian.h │ ├── zlib-ng.h.in │ ├── zlib-ng.map │ ├── zlib.h.in │ ├── zlib.map │ ├── zlib.pc.cmakein │ ├── zlib.pc.in │ ├── zlib_name_mangling-ng.h.in │ ├── zlib_name_mangling.h.empty │ ├── zlib_name_mangling.h.in │ ├── zutil.c │ ├── zutil.h │ └── zutil_p.h ├── figures ├── splitcode_example.png ├── splitcode_figure.png └── splitcode_logo.png ├── func_tests ├── A_1.fastq.gz ├── A_2.fastq.gz ├── B_1.fastq.gz ├── B_2.fastq.gz ├── CMakeLists.txt ├── b.fastq ├── config_fastassign.txt ├── config_fastassign_2.txt ├── configb.txt ├── even.txt ├── example.SJ.tab ├── from_name.fq ├── nest.test.1.R1.fa ├── nest.test.1.R1.fq ├── nest.test.1.R2.fq ├── nest.test.2.R1.fq ├── nest.test.2.R2.fq ├── nest.test.3.R1.fq ├── nest.test.3.R2.fq ├── nest_config.txt ├── nest_config_2.txt ├── nest_config_3.txt ├── nest_config_4.txt ├── nest_config_5.txt ├── odd.txt ├── runtests.sh ├── splitcode_example_config.txt ├── splitcode_example_config_2.txt ├── splitcode_example_config_3.txt ├── splitcode_example_config_4.txt ├── test_1.vcf.gz ├── test_2.vcf.gz └── vcf_validation.fa.gz └── src ├── CMakeLists.txt ├── LiftWorkflow.h ├── ProcessReads.cpp ├── ProcessReads.h ├── SplitCode.h ├── common.h ├── kseq.h ├── main.cpp ├── robin_hood.h └── unordered_dense.h /.github/workflows/test.yml: -------------------------------------------------------------------------------- 1 | name: Test 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | build-linux: 8 | name: Build and test linux 9 | runs-on: ubuntu-22.04 10 | env: 11 | RELEASE_OS: linux 12 | steps: 13 | - name: checkout branch 14 | uses: actions/checkout@master 15 | - name: Setup environment 16 | id: setup 17 | run: echo ::set-output name=RELEASE_VERSION::${GITHUB_REF##*/} 18 | - name: make 19 | run: | 20 | mkdir build && cd build && cmake .. -DZLIBNG=ON -DBUILD_FUNCTESTING=ON -DNO_HTSLIB=ON && make && make install && cd .. 21 | - name: Functional testing 22 | run: | 23 | cd build && make test 24 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.DS_Store 2 | *.swp 3 | 4 | build/* 5 | 6 | ext/zlib-ng/src/ 7 | ext/zlib-ng/build/ 8 | ext/zlib-ng/tmp/ 9 | 10 | ext/htslib/tmp/ 11 | ext/htslib/src/ 12 | 13 | *.pyc 14 | 15 | CMakeCache.txt 16 | CMakeFiles 17 | Makefile 18 | !ext/htslib/Makefile 19 | cmake_install.cmake 20 | CTestTestfile.cmake 21 | *~ 22 | *.orig 23 | debug/ 24 | release/ 25 | .snakemake 26 | src/.Rhistory 27 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.12) 2 | 3 | project(splitcode) 4 | 5 | include(GNUInstallDirs) 6 | 7 | set(EXT_PROJECTS_DIR ${PROJECT_SOURCE_DIR}/ext) 8 | set(CMAKE_CXX_FLAGS_PROFILE "-g") 9 | 10 | if(NOT CMAKE_BUILD_TYPE) 11 | set(CMAKE_BUILD_TYPE "Release") 12 | endif() 13 | 14 | if(${CMAKE_VERSION} VERSION_LESS 3.1) 15 | add_compile_options(-std=c++11) 16 | else() 17 | set(CMAKE_CXX_STANDARD 11) 18 | set(CMAKE_CXX_STANDARD_REQUIRED ON) 19 | set(CMAKE_CXX_EXTENSIONS OFF) 20 | endif() 21 | 22 | if(LINK MATCHES static) 23 | message("static build") 24 | ELSE(LINK MATCHES shared) 25 | message("shared build") 26 | ENDIF(LINK MATCHES static) 27 | 28 | set(USE_HTSLIB "ON") 29 | if (NO_HTSLIB) 30 | set(USE_HTSLIB OFF) 31 | endif() 32 | 33 | if(EMSCRIPTEN_BUILD) 34 | set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -s USE_ZLIB=1") 35 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -s USE_ZLIB=1") 36 | set(USE_HTSLIB OFF) 37 | endif() 38 | 39 | add_subdirectory(src) 40 | 41 | if (BUILD_FUNCTESTING) 42 | add_subdirectory(func_tests) 43 | message("Functional testing enabled.") 44 | add_custom_target(test 45 | COMMAND /bin/bash ./func_tests/runtests.sh 46 | DEPENDS ./src/splitcode 47 | ) 48 | endif(BUILD_FUNCTESTING) 49 | 50 | include(ExternalProject) 51 | 52 | 53 | 54 | if (NOT ZLIBNG_DISABLE) 55 | message("zlib-ng enabled.") 56 | set(ZLIBNG "ON") 57 | ExternalProject_Add(zlib-ng 58 | PREFIX ${PROJECT_SOURCE_DIR}/ext/zlib-ng 59 | SOURCE_DIR ${PROJECT_SOURCE_DIR}/ext/zlib-ng 60 | BUILD_IN_SOURCE 1 61 | CONFIGURE_COMMAND mkdir -p zlib-ng && cd zlib-ng && cmake .. -DZLIB_COMPAT=ON -DZLIB_ENABLE_TESTS=OFF -DCMAKE_INSTALL_PREFIX=${PREFIX} 62 | BUILD_COMMAND cd zlib-ng && make 63 | INSTALL_COMMAND "" 64 | ) 65 | endif(ZLIBNG_DISABLE) 66 | 67 | 68 | if (USE_HTSLIB) 69 | message("using htslib") 70 | ExternalProject_Add(htslib 71 | PREFIX ${PROJECT_SOURCE_DIR}/ext/htslib 72 | SOURCE_DIR ${PROJECT_SOURCE_DIR}/ext/htslib 73 | BUILD_IN_SOURCE 1 74 | CONFIGURE_COMMAND "" 75 | BUILD_COMMAND make lib-static 76 | INSTALL_COMMAND "" 77 | ) 78 | else() 79 | set(NO_HTSLIB "ON") 80 | add_compile_definitions("NO_HTSLIB=ON") 81 | message("not using htslib") 82 | endif() 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 2-Clause License 2 | 3 | Copyright (c) 2021, Yenaled 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | 1. Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | 2. Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 17 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 18 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 20 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 21 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 22 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 23 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 24 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # splitcode 2 | 3 | **splitcode** is a tool that enables flexible and efficient parsing, interpreting and editing of sequencing reads according to a user’s specifications. Please visit the manual at https://splitcode.readthedocs.io/ 4 | 5 | ![alt text](https://raw.githubusercontent.com/Yenaled/splitcode/main/figures/splitcode_figure.png?raw=true) 6 | 7 | ## Graphical User Interface (GUI) 8 | 9 | The GUI for **splitcode** is at https://pachterlab.github.io/splitcode/ 10 | 11 | ## License 12 | 13 | **splitcode** is distributed under the BSD-2 license. 14 | 15 | ## Issues and Pull Requests 16 | 17 | For help running **splitcode** or reporting bugs, please submit a GitHub issue. 18 | 19 | Additionally, please submit a GitHub issue or a GitHub pull request for feature requests and suggested documentation improvements. 20 | 21 | ## Citing splitcode 22 | 23 | Sullivan DK, Pachter L. (2024). Flexible parsing, interpretation, and editing of technical sequences with splitcode. *Bioinformatics*. https://doi.org/10.1093/bioinformatics/btae331 24 | -------------------------------------------------------------------------------- /ext/htslib/.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.pico 3 | /version.h 4 | 5 | lib*.a 6 | lib*.dylib 7 | lib*.so 8 | lib*.so.* 9 | 10 | /bgzip 11 | /tabix 12 | /test/fieldarith 13 | /test/hfile 14 | /test/sam 15 | /test/test-vcf-api 16 | /test/test-vcf-sweep 17 | /test/test_view 18 | /test/*.tmp 19 | /test/*.tmp.* 20 | 21 | /TAGS 22 | -------------------------------------------------------------------------------- /ext/htslib/.travis.yml: -------------------------------------------------------------------------------- 1 | # Control file for continuous integration testing at http://travis-ci.org/ 2 | 3 | language: c 4 | compiler: 5 | - clang 6 | - gcc 7 | 8 | script: make -e && make test 9 | -------------------------------------------------------------------------------- /ext/htslib/README.md: -------------------------------------------------------------------------------- 1 | HTSlib is an implementation of a unified C library for accessing common file 2 | formats, such as [SAM, CRAM and VCF][1], used for high-throughput sequencing 3 | data, and is the core library used by [samtools][2] and [bcftools][3]. 4 | HTSlib only depends on [zlib][4]. 5 | It is known to be compatible with gcc, g++ and clang. 6 | 7 | HTSlib implements a generalized BAM index, with file extension `.csi` 8 | (coordinate-sorted index). The HTSlib file reader first looks for the new index 9 | and then for the old if the new index is absent. 10 | 11 | This project also includes the popular tabix indexer, which indexes both `.tbi` 12 | and `.csi` formats, and the bgzip compression utility. 13 | 14 | [1]: http://samtools.github.io/hts-specs/ 15 | [2]: http://samtools.github.io/bcftools/ 16 | [3]: http://github.com/samtools/samtools 17 | [4]: http://zlib.net/ 18 | -------------------------------------------------------------------------------- /ext/htslib/config.h: -------------------------------------------------------------------------------- 1 | #define _USE_KNETFILE 2 | #define BGZF_CACHE 3 | #define BGZF_MT 4 | -------------------------------------------------------------------------------- /ext/htslib/cram/cram.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2013 Genome Research Ltd. 3 | Author: James Bonfield 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger 16 | Institute nor the names of its contributors may be used to endorse or promote 17 | products derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH LTD OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /*! \file 32 | * CRAM interface. 33 | * 34 | * Consider using the higher level scram_*() API for programs that wish to 35 | * be file format agnostic. 36 | * 37 | * This API should be used for CRAM specific code. The specifics of the 38 | * public API are implemented in cram_io.h, cram_encode.h and cram_decode.h 39 | * although these should not be included directly (use this file instead). 40 | */ 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #ifdef SAMTOOLS 47 | # include "cram/cram_samtools.h" 48 | #endif 49 | 50 | #ifndef _CRAM_H_ 51 | #define _CRAM_H_ 52 | 53 | #include "cram/sam_header.h" 54 | #include "cram_structs.h" 55 | #include "cram_io.h" 56 | #include "cram_encode.h" 57 | #include "cram_decode.h" 58 | #include "cram_stats.h" 59 | #include "cram_codecs.h" 60 | #include "cram_index.h" 61 | 62 | #endif 63 | 64 | #ifdef __cplusplus 65 | } 66 | #endif 67 | -------------------------------------------------------------------------------- /ext/htslib/cram/cram_stats.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2012-2013 Genome Research Ltd. 3 | Author: James Bonfield 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger 16 | Institute nor the names of its contributors may be used to endorse or promote 17 | products derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH LTD OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _CRAM_STATS_H_ 32 | #define _CRAM_STATS_H_ 33 | 34 | #ifdef __cplusplus 35 | extern "C" { 36 | #endif 37 | 38 | cram_stats *cram_stats_create(void); 39 | void cram_stats_add(cram_stats *st, int32_t val); 40 | void cram_stats_del(cram_stats *st, int32_t val); 41 | void cram_stats_dump(cram_stats *st); 42 | void cram_stats_free(cram_stats *st); 43 | 44 | /* 45 | * Computes entropy from integer frequencies for various encoding methods and 46 | * picks the best encoding. 47 | * 48 | * FIXME: we could reuse some of the code here for the actual encoding 49 | * parameters too. Eg the best 'k' for SUBEXP or the code lengths for huffman. 50 | * 51 | * Returns the best codec to use. 52 | */ 53 | enum cram_encoding cram_stats_encoding(cram_fd *fd, cram_stats *st); 54 | 55 | #ifdef __cplusplus 56 | } 57 | #endif 58 | 59 | #endif 60 | -------------------------------------------------------------------------------- /ext/htslib/cram/md5.h: -------------------------------------------------------------------------------- 1 | #ifdef __cplusplus 2 | extern "C" { 3 | #endif 4 | 5 | /* 6 | * This is an OpenSSL-compatible implementation of the RSA Data Security, Inc. 7 | * MD5 Message-Digest Algorithm (RFC 1321). 8 | * 9 | * Homepage: 10 | * http://openwall.info/wiki/people/solar/software/public-domain-source-code/md5 11 | * 12 | * Author: 13 | * Alexander Peslyak, better known as Solar Designer 14 | * 15 | * This software was written by Alexander Peslyak in 2001. No copyright is 16 | * claimed, and the software is hereby placed in the public domain. 17 | * In case this attempt to disclaim copyright and place the software in the 18 | * public domain is deemed null and void, then the software is 19 | * Copyright (c) 2001 Alexander Peslyak and it is hereby released to the 20 | * general public under the following terms: 21 | * 22 | * Redistribution and use in source and binary forms, with or without 23 | * modification, are permitted. 24 | * 25 | * There's ABSOLUTELY NO WARRANTY, express or implied. 26 | * 27 | * See md5.c for more information. 28 | */ 29 | 30 | #ifdef HAVE_OPENSSL 31 | #include 32 | #elif !defined(_MD5_H) 33 | #define _MD5_H 34 | 35 | /* Any 32-bit or wider unsigned integer data type will do */ 36 | typedef unsigned int MD5_u32plus; 37 | 38 | typedef struct { 39 | MD5_u32plus lo, hi; 40 | MD5_u32plus a, b, c, d; 41 | unsigned char buffer[64]; 42 | MD5_u32plus block[16]; 43 | } MD5_CTX; 44 | 45 | extern void MD5_Init(MD5_CTX *ctx); 46 | extern void MD5_Update(MD5_CTX *ctx, void *data, unsigned long size); 47 | extern void MD5_Final(unsigned char *result, MD5_CTX *ctx); 48 | 49 | #endif 50 | 51 | #ifdef __cplusplus 52 | } 53 | #endif 54 | 55 | -------------------------------------------------------------------------------- /ext/htslib/cram/pooled_alloc.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009 Genome Research Ltd. 3 | Author: Rob Davies 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger 16 | Institute nor the names of its contributors may be used to endorse or promote 17 | products derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH LTD OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _POOLED_ALLOC_H_ 32 | #define _POOLED_ALLOC_H_ 33 | 34 | /* 35 | * Implements a pooled block allocator where all items are the same size, 36 | * but we need many of them. 37 | */ 38 | typedef struct { 39 | void *pool; 40 | size_t used; 41 | } pool_t; 42 | 43 | typedef struct { 44 | size_t dsize; 45 | size_t npools; 46 | pool_t *pools; 47 | void *free; 48 | } pool_alloc_t; 49 | 50 | pool_alloc_t *pool_create(size_t dsize); 51 | void pool_destroy(pool_alloc_t *p); 52 | void *pool_alloc(pool_alloc_t *p); 53 | void pool_free(pool_alloc_t *p, void *ptr); 54 | 55 | 56 | #endif /*_POOLED_ALLOC_H_*/ 57 | -------------------------------------------------------------------------------- /ext/htslib/cram/vlen.h: -------------------------------------------------------------------------------- 1 | /* 2 | Author: James Bonfield (jkb@sanger.ac.uk) 3 | 4 | Copyright (c) 1995-1996 MEDICAL RESEARCH COUNCIL 5 | All rights reserved 6 | 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | 10 | 1 Redistributions of source code must retain the above copyright notice, 11 | this list of conditions and the following disclaimer. 12 | 13 | 2 Redistributions in binary form must reproduce the above copyright notice, 14 | this list of conditions and the following disclaimer in the documentation 15 | and/or other materials provided with the distribution. 16 | 17 | 3 Neither the name of the MEDICAL RESEARCH COUNCIL, THE LABORATORY OF 18 | MOLECULAR BIOLOGY nor the names of its contributors may be used to endorse or 19 | promote products derived from this software without specific prior written 20 | permission. 21 | 22 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 23 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 24 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 25 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR 26 | ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 27 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 28 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON 29 | ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 30 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 31 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 32 | */ 33 | 34 | #ifndef _VLEN_H_ 35 | #define _VLEN_H_ 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | extern int vflen(char *fmt, va_list ap); 42 | extern int flen(char *fmt, ...); 43 | 44 | #ifdef __cplusplus 45 | } 46 | #endif 47 | 48 | #endif /* _VLEN_H_ */ 49 | -------------------------------------------------------------------------------- /ext/htslib/cram/zfio.h: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2009-2013 Genome Research Ltd. 3 | Author: James Bonfield 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | 8 | 1. Redistributions of source code must retain the above copyright notice, 9 | this list of conditions and the following disclaimer. 10 | 11 | 2. Redistributions in binary form must reproduce the above copyright notice, 12 | this list of conditions and the following disclaimer in the documentation 13 | and/or other materials provided with the distribution. 14 | 15 | 3. Neither the names Genome Research Ltd and Wellcome Trust Sanger 16 | Institute nor the names of its contributors may be used to endorse or promote 17 | products derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY GENOME RESEARCH LTD AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL GENOME RESEARCH LTD OR CONTRIBUTORS BE LIABLE 23 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 25 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 26 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 27 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | #ifndef _ZFIO_H_ 32 | #define _ZFIO_H_ 33 | 34 | #include 35 | #include 36 | 37 | /* 38 | * Either a gzFile or a FILE. 39 | */ 40 | typedef struct { 41 | FILE *fp; 42 | gzFile gz; 43 | } zfp; 44 | 45 | off_t zftello(zfp *zf); 46 | int zfseeko(zfp *zf, off_t offset, int whence); 47 | char *zfgets(char *line, int size, zfp *zf); 48 | int zfputs(char *line, zfp *zf); 49 | zfp *zfopen(const char *path, const char *mode); 50 | int zfclose(zfp *zf); 51 | int zfpeek(zfp *zf); 52 | int zfeof(zfp *zf); 53 | 54 | #endif /* _ZFIO_H_ */ 55 | -------------------------------------------------------------------------------- /ext/htslib/htslib/hts_defs.h: -------------------------------------------------------------------------------- 1 | /* hts_defs.h -- Miscellaneous definitions. 2 | 3 | Copyright (C) 2013-2014 Genome Research Ltd. 4 | 5 | Author: John Marshall 6 | 7 | Permission is hereby granted, free of charge, to any person obtaining a copy 8 | of this software and associated documentation files (the "Software"), to deal 9 | in the Software without restriction, including without limitation the rights 10 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | copies of the Software, and to permit persons to whom the Software is 12 | furnished to do so, subject to the following conditions: 13 | 14 | The above copyright notices and this permission notice shall be included in 15 | all copies or substantial portions of the Software. 16 | 17 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 20 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 22 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 23 | DEALINGS IN THE SOFTWARE. */ 24 | 25 | #ifndef HTSLIB_HTS_DEFS_H 26 | #define HTSLIB_HTS_DEFS_H 27 | 28 | #if __clang__major__ >= 2 || __GNUC__ >= 3 29 | #define HTS_NORETURN __attribute__ ((__noreturn__)) 30 | #else 31 | #define HTS_NORETURN 32 | #endif 33 | 34 | #if (defined __clang__ && __clang_major__ >= 3) || \ 35 | (defined __GNUC__ && (__GNUC__ > 4 || (__GNUC__==4 && __GNUC_MINOR__ >= 5))) 36 | #define HTS_RESULT_USED __attribute__ ((__warn_unused_result__)) 37 | #else 38 | #define HTS_RESULT_USED 39 | #endif 40 | 41 | #if defined __clang__ || defined __GNUC__ 42 | #define HTS_UNUSED __attribute__ ((__unused__)) 43 | #else 44 | #define HTS_UNUSED 45 | #endif 46 | 47 | #endif 48 | -------------------------------------------------------------------------------- /ext/htslib/htslib/kfunc.h: -------------------------------------------------------------------------------- 1 | #ifndef __KFUNC_H__ 2 | #define __KFUNC_H__ 3 | 4 | /* Log gamma function 5 | * \log{\Gamma(z)} 6 | * AS245, 2nd algorithm, http://lib.stat.cmu.edu/apstat/245 7 | */ 8 | double kf_lgamma(double z); 9 | 10 | /* complementary error function 11 | * \frac{2}{\sqrt{\pi}} \int_x^{\infty} e^{-t^2} dt 12 | * AS66, 2nd algorithm, http://lib.stat.cmu.edu/apstat/66 13 | */ 14 | double kf_erfc(double x); 15 | 16 | /* The following computes regularized incomplete gamma functions. 17 | * Formulas are taken from Wiki, with additional input from Numerical 18 | * Recipes in C (for modified Lentz's algorithm) and AS245 19 | * (http://lib.stat.cmu.edu/apstat/245). 20 | * 21 | * A good online calculator is available at: 22 | * 23 | * http://www.danielsoper.com/statcalc/calc23.aspx 24 | * 25 | * It calculates upper incomplete gamma function, which equals 26 | * kf_gammaq(s,z)*tgamma(s). 27 | */ 28 | 29 | double kf_gammap(double s, double z); 30 | double kf_gammaq(double s, double z); 31 | 32 | /* Regularized incomplete beta function. The method is taken from 33 | * Numerical Recipe in C, 2nd edition, section 6.4. The following web 34 | * page calculates the incomplete beta function, which equals 35 | * kf_betai(a,b,x) * gamma(a) * gamma(b) / gamma(a+b): 36 | * 37 | * http://www.danielsoper.com/statcalc/calc36.aspx 38 | */ 39 | double kf_betai(double a, double b, double x); 40 | 41 | /* 42 | * n11 n12 | n1_ 43 | * n21 n22 | n2_ 44 | * -----------+---- 45 | * n_1 n_2 | n 46 | */ 47 | double kt_fisher_exact(int n11, int n12, int n21, int n22, double *_left, double *_right, double *two); 48 | 49 | #endif 50 | -------------------------------------------------------------------------------- /ext/htslib/htslib/knetfile.h: -------------------------------------------------------------------------------- 1 | #ifndef KNETFILE_H 2 | #define KNETFILE_H 3 | 4 | #include 5 | #include 6 | 7 | #ifndef _WIN32 8 | #define netread(fd, ptr, len) read(fd, ptr, len) 9 | #define netwrite(fd, ptr, len) write(fd, ptr, len) 10 | #define netclose(fd) close(fd) 11 | #else 12 | #include 13 | #define netread(fd, ptr, len) recv(fd, ptr, len, 0) 14 | #define netwrite(fd, ptr, len) send(fd, ptr, len, 0) 15 | #define netclose(fd) closesocket(fd) 16 | #endif 17 | 18 | // FIXME: currently I/O is unbuffered 19 | 20 | #define KNF_TYPE_LOCAL 1 21 | #define KNF_TYPE_FTP 2 22 | #define KNF_TYPE_HTTP 3 23 | 24 | typedef struct knetFile_s { 25 | int type, fd; 26 | int64_t offset; 27 | char *host, *port; 28 | 29 | // the following are for FTP only 30 | int ctrl_fd, pasv_ip[4], pasv_port, max_response, no_reconnect, is_ready; 31 | char *response, *retr, *size_cmd; 32 | int64_t seek_offset; // for lazy seek 33 | int64_t file_size; 34 | 35 | // the following are for HTTP only 36 | char *path, *http_host; 37 | } knetFile; 38 | 39 | #define knet_tell(fp) ((fp)->offset) 40 | #define knet_fileno(fp) ((fp)->fd) 41 | 42 | #ifdef __cplusplus 43 | extern "C" { 44 | #endif 45 | 46 | #ifdef _WIN32 47 | int knet_win32_init(); 48 | void knet_win32_destroy(); 49 | #endif 50 | 51 | knetFile *knet_open(const char *fn, const char *mode); 52 | 53 | /* 54 | This only works with local files. 55 | */ 56 | knetFile *knet_dopen(int fd, const char *mode); 57 | 58 | /* 59 | If ->is_ready==0, this routine updates ->fd; otherwise, it simply 60 | reads from ->fd. 61 | */ 62 | ssize_t knet_read(knetFile *fp, void *buf, size_t len); 63 | 64 | /* 65 | This routine only sets ->offset and ->is_ready=0. It does not 66 | communicate with the FTP server. 67 | */ 68 | off_t knet_seek(knetFile *fp, off_t off, int whence); 69 | int knet_close(knetFile *fp); 70 | 71 | #ifdef __cplusplus 72 | } 73 | #endif 74 | 75 | #endif 76 | -------------------------------------------------------------------------------- /ext/htslib/htslib/kstdint.h: -------------------------------------------------------------------------------- 1 | #ifndef KSTDINT_H 2 | #define KSTDINT_H 3 | 4 | #include 5 | 6 | /* Basic assumptions: 1) "char" is 8-bit; 2) there is a 8-bit, 16-bit, 32-bit 7 | * and 64-bit integer type, respectively; 3) "short" is no less than "char", 8 | * "int" is no less than "short", "long" is no less than "int" and "long long" 9 | * is no less than "long"; 4) "int" is at least 16-bit, "long" at least 32-bit 10 | * and "long long" at least 64-bit. The last two assumptions are enforced by 11 | * the C99 spec. 12 | * 13 | * Following assumptions 1) and 2), we know that "signed char"=="int8_t" and 14 | * "short"=="int16_t" for sure. Further from the assumptions, a 32-bit integer 15 | * type must be either "int" or "long". We can test (UINT16_MAX==UINT_MAX) to 16 | * see which is the case. Similarly, a 64-bit integer must be either "long" or 17 | * "long long". We can test (UINT16_MAX==UINT_MAX) to get the definite answer. 18 | */ 19 | 20 | /* 8-bit integers */ 21 | typedef signed char int8_t; 22 | typedef unsigned char uint8_t; 23 | #define INT8_MIN (-SCHAR_MAX-1) 24 | #define INT8_MAX SCHAR_MAX 25 | #define UINT8_MAX UCHAR_MAX 26 | 27 | /* 16-bit integers */ 28 | typedef signed short int16_t; 29 | typedef unsigned short uint16_t; 30 | #define INT16_MIN (-SHRT_MAX-1) 31 | #define INT16_MAX SHRT_MAX 32 | #define UINT16_MAX USHRT_MAX 33 | 34 | /* 32-bit integers */ 35 | #if UINT16_MAX != UINT_MAX 36 | typedef signed int int32_t; 37 | typedef unsigned int uint32_t; 38 | #define INT32_MIN (-INT_MAX-1) 39 | #define INT32_MAX INT_MAX 40 | #define UINT32_MAX UINT_MAX 41 | #else /* then int is 16-bit and long is 32-bit, which may happen to compilers for embedded CPUs */ 42 | typedef signed long int32_t; 43 | typedef unsigned long uint32_t; 44 | #define INT32_MIN (-LONG_MAX-1) 45 | #define INT32_MAX LONG_MAX 46 | #define UINT32_MAX ULONG_MAX 47 | #endif /* ~UINT16_MAX!=UINT_MAX */ 48 | 49 | /* 64-bit integers */ 50 | #if UINT32_MAX != ULONG_MAX 51 | typedef signed long int64_t; 52 | typedef unsigned long uint64_t; 53 | #define INT64_MIN (-LONG_MAX-1) 54 | #define INT64_MAX LONG_MAX 55 | #define UINT64_MAX ULONG_MAX 56 | #else 57 | typedef signed long long int64_t; 58 | typedef unsigned long long uint64_t; 59 | #define INT64_MIN (-LLONG_MAX-1) 60 | #define INT64_MAX LLONG_MAX 61 | #define UINT64_MAX ULLONG_MAX 62 | #endif /* ~UINT32_MAX!=ULONG_MAX */ 63 | 64 | #endif /* ~defined(KSTDINT_H) */ 65 | -------------------------------------------------------------------------------- /ext/htslib/htslib/tbx.h: -------------------------------------------------------------------------------- 1 | #ifndef TBX_H 2 | #define TBX_H 3 | 4 | #include "hts.h" 5 | 6 | #define TBX_MAX_SHIFT 31 7 | 8 | #define TBX_GENERIC 0 9 | #define TBX_SAM 1 10 | #define TBX_VCF 2 11 | #define TBX_UCSC 0x10000 12 | 13 | typedef struct { 14 | int32_t preset; 15 | int32_t sc, bc, ec; // seq col., beg col. and end col. 16 | int32_t meta_char, line_skip; 17 | } tbx_conf_t; 18 | 19 | typedef struct { 20 | tbx_conf_t conf; 21 | hts_idx_t *idx; 22 | void *dict; 23 | } tbx_t; 24 | 25 | extern tbx_conf_t tbx_conf_gff, tbx_conf_bed, tbx_conf_psltbl, tbx_conf_sam, tbx_conf_vcf; 26 | 27 | #ifdef __cplusplus 28 | extern "C" { 29 | #endif 30 | 31 | #define tbx_itr_destroy(iter) hts_itr_destroy(iter) 32 | #define tbx_itr_queryi(tbx, tid, beg, end) hts_itr_query((tbx)->idx, (tid), (beg), (end), tbx_readrec) 33 | #define tbx_itr_querys(tbx, s) hts_itr_querys((tbx)->idx, (s), (hts_name2id_f)(tbx_name2id), (tbx), hts_itr_query, tbx_readrec) 34 | #define tbx_itr_next(htsfp, tbx, itr, r) hts_itr_next(hts_get_bgzfp(htsfp), (itr), (r), (tbx)) 35 | #define tbx_bgzf_itr_next(bgzfp, tbx, itr, r) hts_itr_next((bgzfp), (itr), (r), (tbx)) 36 | 37 | int tbx_name2id(tbx_t *tbx, const char *ss); 38 | 39 | /* Internal helper function used by tbx_itr_next() */ 40 | BGZF *hts_get_bgzfp(htsFile *fp); 41 | int tbx_readrec(BGZF *fp, void *tbxv, void *sv, int *tid, int *beg, int *end); 42 | 43 | int tbx_index_build(const char *fn, int min_shift, const tbx_conf_t *conf); 44 | tbx_t *tbx_index_load(const char *fn); 45 | const char **tbx_seqnames(tbx_t *tbx, int *n); // free the array but not the values 46 | void tbx_destroy(tbx_t *tbx); 47 | 48 | #ifdef __cplusplus 49 | } 50 | #endif 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /ext/htslib/htslib/vcf_sweep.h: -------------------------------------------------------------------------------- 1 | #ifndef __VCF_SWEEP_H__ 2 | #define __VCF_SWEEP_H__ 3 | 4 | #include "hts.h" 5 | #include "vcf.h" 6 | 7 | typedef struct _bcf_sweep_t bcf_sweep_t; 8 | 9 | bcf_sweep_t *bcf_sweep_init(const char *fname); 10 | void bcf_sweep_destroy(bcf_sweep_t *sw); 11 | bcf_hdr_t *bcf_sweep_hdr(bcf_sweep_t *sw); 12 | bcf1_t *bcf_sweep_fwd(bcf_sweep_t *sw); 13 | bcf1_t *bcf_sweep_bwd(bcf_sweep_t *sw); 14 | 15 | #endif 16 | -------------------------------------------------------------------------------- /ext/htslib/htslib_vars.mk: -------------------------------------------------------------------------------- 1 | # Makefile variables useful for third-party code using htslib's public API. 2 | # 3 | # Copyright (C) 2013-2014 Genome Research Ltd. 4 | # 5 | # Author: John Marshall 6 | 7 | # These variables can be used to express dependencies on htslib headers. 8 | # See htslib.mk for details. 9 | 10 | htslib_bgzf_h = $(HTSPREFIX)htslib/bgzf.h 11 | htslib_faidx_h = $(HTSPREFIX)htslib/faidx.h 12 | htslib_hfile_h = $(HTSPREFIX)htslib/hfile.h $(htslib_hts_defs_h) 13 | htslib_hts_h = $(HTSPREFIX)htslib/hts.h 14 | htslib_hts_defs_h = $(HTSPREFIX)htslib/hts_defs.h 15 | htslib_sam_h = $(HTSPREFIX)htslib/sam.h $(htslib_hts_h) 16 | htslib_synced_bcf_reader_h = $(HTSPREFIX)htslib/synced_bcf_reader.h $(htslib_hts_h) $(htslib_vcf_h) $(htslib_tbx_h) 17 | htslib_tbx_h = $(HTSPREFIX)htslib/tbx.h $(htslib_hts_h) 18 | htslib_vcf_h = $(HTSPREFIX)htslib/vcf.h $(htslib_hts_h) $(HTSPREFIX)htslib/kstring.h 19 | htslib_vcf_sweep_h = $(HTSPREFIX)htslib/vcf_sweep.h $(htslib_hts_h) $(htslib_vcf_h) 20 | htslib_vcfutils_h = $(HTSPREFIX)htslib/vcfutils.h $(htslib_vcf_h) 21 | -------------------------------------------------------------------------------- /ext/htslib/sam.5: -------------------------------------------------------------------------------- 1 | '\" t 2 | .TH sam 5 "August 2013" "htslib" "Bioinformatics formats" 3 | .SH NAME 4 | sam \- Sequence Alignment/Map file format 5 | .SH DESCRIPTION 6 | Sequence Alignment/Map (SAM) format is TAB-delimited. Apart from the header lines, which are started 7 | with the `@' symbol, each alignment line consists of: 8 | .TS 9 | nlbl. 10 | 1 QNAME Query template/pair NAME 11 | 2 FLAG bitwise FLAG 12 | 3 RNAME Reference sequence NAME 13 | 4 POS 1-based leftmost POSition/coordinate of clipped sequence 14 | 5 MAPQ MAPping Quality (Phred-scaled) 15 | 6 CIGAR extended CIGAR string 16 | 7 MRNM Mate Reference sequence NaMe (`=' if same as RNAME) 17 | 8 MPOS 1-based Mate POSistion 18 | 9 TLEN inferred Template LENgth (insert size) 19 | 10 SEQ query SEQuence on the same strand as the reference 20 | 11 QUAL query QUALity (ASCII-33 gives the Phred base quality) 21 | 12+ OPT variable OPTional fields in the format TAG:VTYPE:VALUE 22 | .TE 23 | .PP 24 | Each bit in the FLAG field is defined as: 25 | .TS 26 | lcbl. 27 | 0x0001 p the read is paired in sequencing 28 | 0x0002 P the read is mapped in a proper pair 29 | 0x0004 u the query sequence itself is unmapped 30 | 0x0008 U the mate is unmapped 31 | 0x0010 r strand of the query (1 for reverse) 32 | 0x0020 R strand of the mate 33 | 0x0040 1 the read is the first read in a pair 34 | 0x0080 2 the read is the second read in a pair 35 | 0x0100 s the alignment is not primary 36 | 0x0200 f the read fails platform/vendor quality checks 37 | 0x0400 d the read is either a PCR or an optical duplicate 38 | 0x0800 S the alignment is supplementary 39 | .TE 40 | .P 41 | where the second column gives the string representation of the FLAG field. 42 | .SH SEE ALSO 43 | .TP 44 | https://github.com/samtools/hts-specs 45 | The full SAM/BAM file format specification 46 | -------------------------------------------------------------------------------- /ext/zlib-ng/.codecov.yaml: -------------------------------------------------------------------------------- 1 | codecov: 2 | max_report_age: off 3 | notify: 4 | wait_for_ci: false 5 | require_ci_to_pass: false 6 | comment: 7 | require_base: false 8 | require_head: false 9 | coverage: 10 | status: 11 | project: 12 | default: 13 | threshold: 0.07 14 | fixes: 15 | - '/home/actions-runner/_work/zlib-ng/zlib-ng::' 16 | - '/home/actions-runner/_work/zlib-ng/zlib-ng/build/::' 17 | ignore: 18 | - usr/include/.* 19 | - /usr/include/.* 20 | - /build/usr/include/.* 21 | - usr/lib/.* 22 | - /usr/lib/.* 23 | - /build/usr/lib/.* 24 | - usr/lib64/.* 25 | - /usr/lib64/.* 26 | - /build/usr/lib64/.* 27 | - _deps/**/* 28 | -------------------------------------------------------------------------------- /ext/zlib-ng/.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | *.c text 3 | *.h text 4 | Makefile text 5 | configure text eol=lf 6 | -------------------------------------------------------------------------------- /ext/zlib-ng/.github/workflows/analyze.yml: -------------------------------------------------------------------------------- 1 | name: Static Analysis 2 | on: [push, pull_request] 3 | jobs: 4 | static-analysis: 5 | name: GCC 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Checkout repository 9 | uses: actions/checkout@v3 10 | 11 | - name: Install packages (Ubuntu) 12 | run: sudo apt-get install -y gcc-10 13 | 14 | - name: Generate project files 15 | run: | 16 | cmake . \ 17 | -DCMAKE_BUILD_TYPE=Release \ 18 | -DBUILD_SHARED_LIBS=OFF \ 19 | -DWITH_FUZZERS=OFF \ 20 | -DWITH_CODE_COVERAGE=OFF \ 21 | -DWITH_MAINTAINER_WARNINGS=OFF 22 | env: 23 | CC: gcc-10 24 | CFLAGS: 25 | -fanalyzer 26 | -Werror 27 | -Wanalyzer-double-fclose 28 | -Wanalyzer-double-free 29 | -Wanalyzer-exposure-through-output-file 30 | -Wanalyzer-file-leak 31 | -Wanalyzer-free-of-non-heap 32 | -Wanalyzer-malloc-leak 33 | -Wanalyzer-null-argument 34 | -Wanalyzer-null-dereference 35 | -Wanalyzer-possible-null-argument 36 | -Wanalyzer-possible-null-dereference 37 | -Wanalyzer-stale-setjmp-buffer 38 | -Wanalyzer-tainted-array-index 39 | -Wanalyzer-unsafe-call-within-signal-handler 40 | -Wanalyzer-use-after-free 41 | -Wanalyzer-use-of-pointer-in-stale-stack-frame 42 | CI: true 43 | 44 | - name: Compile source code 45 | run: cmake --build . --config Release > /dev/null 46 | 47 | Clang: 48 | runs-on: ubuntu-latest 49 | steps: 50 | - name: Checkout repository 51 | uses: actions/checkout@v3 52 | 53 | - name: Install packages (Ubuntu) 54 | run: sudo apt-get install -y clang-tools 55 | 56 | - name: Generate project files 57 | run: | 58 | scan-build --status-bugs \ 59 | cmake . \ 60 | -DCMAKE_BUILD_TYPE=Release \ 61 | -DBUILD_SHARED_LIBS=OFF \ 62 | -DWITH_FUZZERS=OFF \ 63 | -DWITH_CODE_COVERAGE=OFF \ 64 | -DWITH_MAINTAINER_WARNINGS=OFF 65 | env: 66 | CI: true 67 | 68 | - name: Compile source code 69 | run: | 70 | scan-build --status-bugs \ 71 | cmake --build . --config Release > /dev/null 72 | -------------------------------------------------------------------------------- /ext/zlib-ng/.github/workflows/fuzz.yml: -------------------------------------------------------------------------------- 1 | name: OSS-Fuzz 2 | on: 3 | pull_request: 4 | push: 5 | branches: 6 | - stable 7 | - develop 8 | - pre-release 9 | - '2.*' 10 | tags: 11 | - '*' 12 | 13 | jobs: 14 | fuzzing: 15 | name: Fuzzing 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Build Fuzzers 19 | uses: google/oss-fuzz/infra/cifuzz/actions/build_fuzzers@master 20 | with: 21 | oss-fuzz-project-name: 'zlib-ng' 22 | dry-run: false 23 | 24 | - name: Run Fuzzers 25 | uses: google/oss-fuzz/infra/cifuzz/actions/run_fuzzers@master 26 | with: 27 | oss-fuzz-project-name: 'zlib-ng' 28 | fuzz-seconds: 600 29 | dry-run: false 30 | 31 | - name: Upload Crash 32 | uses: actions/upload-artifact@v1 33 | if: failure() 34 | with: 35 | name: artifacts 36 | path: ./out/artifacts 37 | -------------------------------------------------------------------------------- /ext/zlib-ng/.github/workflows/libpng.yml: -------------------------------------------------------------------------------- 1 | name: Libpng 2 | on: [push, pull_request] 3 | jobs: 4 | libpng: 5 | name: Ubuntu Clang 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Checkout repository (zlib-ng) 9 | uses: actions/checkout@v3 10 | 11 | - name: Generate project files (zlib-ng) 12 | run: | 13 | cmake . \ 14 | -DCMAKE_BUILD_TYPE=Release \ 15 | -DBUILD_SHARED_LIBS=OFF \ 16 | -DZLIB_COMPAT=ON \ 17 | -DZLIB_ENABLE_TESTS=OFF 18 | env: 19 | CC: clang 20 | CFLAGS: -fPIC 21 | CI: true 22 | 23 | - name: Compile source code (zlib-ng) 24 | run: cmake --build . --config Release 25 | 26 | - name: Checkout repository (libpng) 27 | uses: actions/checkout@v3 28 | with: 29 | repository: glennrp/libpng 30 | path: libpng 31 | 32 | - name: Generate project files (libpng) 33 | run: | 34 | cmake . \ 35 | -DCMAKE_BUILD_TYPE=Release \ 36 | -DPNG_TESTS=ON \ 37 | -DPNG_STATIC=OFF \ 38 | -DZLIB_INCLUDE_DIR=.. \ 39 | -DZLIB_LIBRARY=$PWD/../libz.a 40 | working-directory: libpng 41 | env: 42 | CC: clang 43 | CI: true 44 | 45 | - name: Compile source code (libpng) 46 | run: cmake --build . --config Release 47 | working-directory: libpng 48 | 49 | - name: Run test cases (libpng) 50 | run: ctest -C Release --output-on-failure --max-width 120 51 | working-directory: libpng 52 | -------------------------------------------------------------------------------- /ext/zlib-ng/.github/workflows/link.yml: -------------------------------------------------------------------------------- 1 | name: Link 2 | on: [push, pull_request] 3 | jobs: 4 | zlib: 5 | name: Link zlib 6 | runs-on: ubuntu-latest 7 | steps: 8 | - name: Checkout repository 9 | uses: actions/checkout@v3 10 | 11 | - name: Checkout zlib repository 12 | uses: actions/checkout@v3 13 | with: 14 | repository: madler/zlib 15 | path: zlib 16 | 17 | - name: Generate project files (zlib) 18 | run: cmake -S zlib -B zlib/build -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF 19 | 20 | - name: Compile source code (zlib) 21 | run: cmake --build zlib/build --config Release 22 | 23 | - name: Generate project files (native) 24 | run: cmake -S . -B native -DZLIB_COMPAT=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DZLIB_LIBRARIES=../zlib/build/libz.a -DZLIB_INCLUDE_DIR="../zlib/build;../zlib" 25 | 26 | - name: Compile source code (native) 27 | run: cmake --build native --config Release 28 | 29 | - name: Upload build errors 30 | uses: actions/upload-artifact@v2 31 | if: failure() 32 | with: 33 | name: Link zlib (CMake Logs) 34 | path: | 35 | **/CMakeFiles/CMakeOutput.log 36 | **/CMakeFiles/CMakeError.log 37 | retention-days: 30 38 | 39 | zlib-ng-compat: 40 | name: Link zlib-ng compat 41 | runs-on: ubuntu-latest 42 | steps: 43 | - name: Checkout repository 44 | uses: actions/checkout@v3 45 | 46 | - name: Generate project files (compat) 47 | run: cmake -S . -B compat -DZLIB_COMPAT=ON -DZLIB_ENABLE_TESTS=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DWITH_MAINTAINER_WARNINGS=ON 48 | 49 | - name: Compile source code (compat) 50 | run: cmake --build compat --config Release 51 | 52 | - name: Generate project files (native) 53 | run: cmake -S . -B native -DZLIB_COMPAT=OFF -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=OFF -DZLIB_LIBRARIES=../compat/libz.a -DZLIB_INCLUDE_DIR=../compat 54 | 55 | - name: Compile source code (native) 56 | run: cmake --build native --config Release 57 | 58 | - name: Upload build errors 59 | uses: actions/upload-artifact@v2 60 | if: failure() 61 | with: 62 | name: Link zlib-ng compat (CMake Logs) 63 | path: | 64 | **/CMakeFiles/CMakeOutput.log 65 | **/CMakeFiles/CMakeError.log 66 | retention-days: 30 67 | -------------------------------------------------------------------------------- /ext/zlib-ng/.github/workflows/nmake.yml: -------------------------------------------------------------------------------- 1 | name: NMake 2 | on: [push, pull_request] 3 | jobs: 4 | nmake: 5 | name: ${{ matrix.name }} 6 | runs-on: ${{ matrix.os }} 7 | strategy: 8 | fail-fast: false 9 | matrix: 10 | include: 11 | - name: Windows NMake x86 12 | os: windows-2022 13 | makefile: win32/Makefile.msc 14 | arch: x86 15 | 16 | - name: Windows NMake x64 compat 17 | os: windows-2022 18 | makefile: win32/Makefile.msc 19 | arch: x86_amd64 20 | additional-args: ZLIB_COMPAT=yes 21 | 22 | - name: Windows NMake x64 Symbol Prefix 23 | os: windows-2022 24 | makefile: win32/Makefile.msc 25 | arch: x86_amd64 26 | additional-args: SYMBOL_PREFIX=zTest_ 27 | 28 | - name: Windows NMake x64 Symbol Prefix Compat 29 | os: windows-2022 30 | makefile: win32/Makefile.msc 31 | arch: x86_amd64 32 | additional-args: ZLIB_COMPAT=yes SYMBOL_PREFIX=zTest_ 33 | 34 | - name: Windows NMake x64 35 | os: windows-2022 36 | makefile: win32/Makefile.msc 37 | arch: x86_amd64 38 | 39 | - name: Windows NMake ARM No Test 40 | os: windows-2022 41 | makefile: win32/Makefile.arm 42 | arch: x86_arm 43 | 44 | - name: Windows NMake ARM64 No Test 45 | os: windows-2022 46 | makefile: win32/Makefile.a64 47 | arch: x86_arm64 48 | 49 | steps: 50 | - name: Checkout repository 51 | uses: actions/checkout@v3 52 | 53 | - name: Setup development environment 54 | uses: ilammy/msvc-dev-cmd@v1.10.0 55 | with: 56 | arch: ${{ matrix.arch }} 57 | 58 | - name: Compile source code 59 | shell: cmd 60 | run: nmake -f ${{ matrix.makefile }} ${{ matrix.additional-args }} 61 | 62 | - name: Run test cases 63 | shell: cmd 64 | # Don't run tests on Windows ARM 65 | if: contains(matrix.arch, 'arm') == false 66 | run: | 67 | nmake -f ${{ matrix.makefile }} ${{ matrix.additional-args }} test 68 | nmake -f ${{ matrix.makefile }} ${{ matrix.additional-args }} testdll 69 | -------------------------------------------------------------------------------- /ext/zlib-ng/.gitignore: -------------------------------------------------------------------------------- 1 | *.diff 2 | *.patch 3 | *.orig 4 | *.rej 5 | 6 | *~ 7 | *.a 8 | *.lo 9 | *.o 10 | *.dylib 11 | 12 | *.gcda 13 | *.gcno 14 | *.gcov 15 | 16 | /benchmark_zlib 17 | /example 18 | /example64 19 | /examplesh 20 | /gtest_zlib 21 | /libz.so* 22 | /libz-ng.so* 23 | /makefixed 24 | /minigzip 25 | /minigzip64 26 | /minigzipsh 27 | /switchlevels 28 | /zlib.pc 29 | /zlib-ng.pc 30 | 31 | .DS_Store 32 | *_fuzzer 33 | *.obj 34 | *.exe 35 | *.pdb 36 | *.exp 37 | *.lib 38 | *.dll 39 | *.res 40 | foo.gz 41 | *.manifest 42 | *.opensdf 43 | *.sln 44 | *.sdf 45 | *.vcxproj 46 | *.vcxproj.filters 47 | .vs 48 | 49 | CMakeCache.txt 50 | CMakeFiles 51 | Testing 52 | /*.cmake 53 | *.stackdump 54 | *._h 55 | zconf.h 56 | zconf.h.cmakein 57 | zconf.h.included 58 | zconf-ng.h 59 | zconf-ng.h.cmakein 60 | ztest* 61 | 62 | configure.log 63 | a.out 64 | 65 | /Makefile 66 | /arch/arm/Makefile 67 | /arch/generic/Makefile 68 | /arch/power/Makefile 69 | /arch/x86/Makefile 70 | .kdev4 71 | *.kdev4 72 | 73 | /Debug 74 | /example.dir 75 | /minigzip.dir 76 | /zlib.dir 77 | /zlibstatic.dir 78 | /win32/Debug 79 | /build/ 80 | /build[.-]*/ 81 | /btmp[12]/ 82 | /pkgtmp[12]/ 83 | 84 | /.idea 85 | /cmake-build-debug 86 | -------------------------------------------------------------------------------- /ext/zlib-ng/.shellcheckrc: -------------------------------------------------------------------------------- 1 | disable=SC2140,SC2086,SC2046,SC2015,SC1097,SC1035,SC1036,SC1007,SC2154,SC2155,SC2000,SC2034,SC2016,SC1091,SC1090,SC2212,SC2143,SC2129,SC2102,SC2069,SC1041,SC1042,SC1044,SC1046,SC1119,SC1110,SC1111,SC1112,SC1102,SC1105,SC1101,SC1004,SC1003,SC1012,SC2068,SC2065,SC2064,SC2063,SC2059,SC2053,SC2048,SC2044,SC2032,SC2031,SC2030,SC2029,SC2025,SC2024,SC2022,SC2018,SC2019,SC2017,SC2014,SC2013,SC2012,SC2009,SC2001,SC2098,SC2096,SC2094,SC2091,SC2092,SC2088,SC2087,SC2076,SC2072,SC2071,SC2223,SC2221,SC2222,SC2217,SC2207,SC2206,SC2205,SC2190,SC2188,SC2187,SC2185,SC2179,SC2178,SC2174,SC2168,SC2167,SC2163,SC2161,SC2160,SC2153,SC2150,SC2148,SC2147,SC2146,SC2142,SC2139,SC2126,SC2123,SC2120,SC2119,SC2117,SC2114,SC1117,SC2164,SC1083,SC2004,SC2125,SC2128,SC2011,SC1008,SC1019,SC2093,SC1132,SC1129,SC2236,SC2237,SC2231,SC2230,SC2229,SC2106,SC2102,SC2243,SC2244,SC2245,SC2247,SC2248,SC2249,SC2250,SC2251,SC2252,SC2181 2 | -------------------------------------------------------------------------------- /ext/zlib-ng/LICENSE.md: -------------------------------------------------------------------------------- 1 | (C) 1995-2013 Jean-loup Gailly and Mark Adler 2 | 3 | This software is provided 'as-is', without any express or implied 4 | warranty. In no event will the authors be held liable for any damages 5 | arising from the use of this software. 6 | 7 | Permission is granted to anyone to use this software for any purpose, 8 | including commercial applications, and to alter it and redistribute it 9 | freely, subject to the following restrictions: 10 | 11 | 1. The origin of this software must not be misrepresented; you must not 12 | claim that you wrote the original software. If you use this software 13 | in a product, an acknowledgment in the product documentation would be 14 | appreciated but is not required. 15 | 16 | 2. Altered source versions must be plainly marked as such, and must not be 17 | misrepresented as being the original software. 18 | 19 | 3. This notice may not be removed or altered from any source distribution. 20 | -------------------------------------------------------------------------------- /ext/zlib-ng/adler32_fold.c: -------------------------------------------------------------------------------- 1 | /* adler32_fold.c -- adler32 folding interface 2 | * Copyright (C) 2022 Adam Stylinski 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "zbuild.h" 7 | #include "functable.h" 8 | #include "adler32_fold.h" 9 | 10 | Z_INTERNAL uint32_t adler32_fold_copy_c(uint32_t adler, uint8_t *dst, const uint8_t *src, uint64_t len) { 11 | adler = functable.adler32(adler, src, len); 12 | while (len > SIZE_MAX) { 13 | memcpy(dst, src, SIZE_MAX); 14 | dst += SIZE_MAX; 15 | src += SIZE_MAX; 16 | len -= SIZE_MAX; 17 | } 18 | if (len) { 19 | memcpy(dst, src, (size_t)len); 20 | } 21 | return adler; 22 | } 23 | -------------------------------------------------------------------------------- /ext/zlib-ng/adler32_fold.h: -------------------------------------------------------------------------------- 1 | /* adler32_fold.h -- adler32 folding interface 2 | * Copyright (C) 2022 Adam Stylinski 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #ifndef ADLER32_FOLD_H_ 7 | #define ADLER32_FOLD_H_ 8 | 9 | Z_INTERNAL uint32_t adler32_fold_copy_c(uint32_t adler, uint8_t *dst, const uint8_t *src, uint64_t len); 10 | 11 | #endif 12 | -------------------------------------------------------------------------------- /ext/zlib-ng/adler32_p.h: -------------------------------------------------------------------------------- 1 | /* adler32_p.h -- Private inline functions and macros shared with 2 | * different computation of the Adler-32 checksum 3 | * of a data stream. 4 | * Copyright (C) 1995-2011, 2016 Mark Adler 5 | * For conditions of distribution and use, see copyright notice in zlib.h 6 | */ 7 | 8 | #ifndef ADLER32_P_H 9 | #define ADLER32_P_H 10 | 11 | #define BASE 65521U /* largest prime smaller than 65536 */ 12 | #define NMAX 5552 13 | /* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */ 14 | 15 | #define DO1(sum1, sum2, buf, i) {(sum1) += buf[(i)]; (sum2) += (sum1);} 16 | #define DO2(sum1, sum2, buf, i) {DO1(sum1, sum2, buf, i); DO1(sum1, sum2, buf, i+1);} 17 | #define DO4(sum1, sum2, buf, i) {DO2(sum1, sum2, buf, i); DO2(sum1, sum2, buf, i+2);} 18 | #define DO8(sum1, sum2, buf, i) {DO4(sum1, sum2, buf, i); DO4(sum1, sum2, buf, i+4);} 19 | #define DO16(sum1, sum2, buf) {DO8(sum1, sum2, buf, 0); DO8(sum1, sum2, buf, 8);} 20 | 21 | static inline uint32_t adler32_len_1(uint32_t adler, const uint8_t *buf, uint32_t sum2) { 22 | adler += buf[0]; 23 | adler %= BASE; 24 | sum2 += adler; 25 | sum2 %= BASE; 26 | return adler | (sum2 << 16); 27 | } 28 | 29 | static inline uint32_t adler32_len_16(uint32_t adler, const uint8_t *buf, uint64_t len, uint32_t sum2) { 30 | while (len) { 31 | --len; 32 | adler += *buf++; 33 | sum2 += adler; 34 | } 35 | adler %= BASE; 36 | sum2 %= BASE; /* only added so many BASE's */ 37 | /* return recombined sums */ 38 | return adler | (sum2 << 16); 39 | } 40 | 41 | static inline uint32_t adler32_copy_len_16(uint32_t adler, const uint8_t *buf, uint8_t *dst, uint64_t len, uint32_t sum2) { 42 | while (len--) { 43 | *dst = *buf++; 44 | adler += *dst++; 45 | sum2 += adler; 46 | } 47 | adler %= BASE; 48 | sum2 %= BASE; /* only added so many BASE's */ 49 | /* return recombined sums */ 50 | return adler | (sum2 << 16); 51 | } 52 | 53 | static inline uint32_t adler32_len_64(uint32_t adler, const uint8_t *buf, uint64_t len, uint32_t sum2) { 54 | #ifdef UNROLL_MORE 55 | while (len >= 16) { 56 | len -= 16; 57 | DO16(adler, sum2, buf); 58 | buf += 16; 59 | #else 60 | while (len >= 8) { 61 | len -= 8; 62 | DO8(adler, sum2, buf, 0); 63 | buf += 8; 64 | #endif 65 | } 66 | /* Process tail (len < 16). */ 67 | return adler32_len_16(adler, buf, len, sum2); 68 | } 69 | 70 | #endif /* ADLER32_P_H */ 71 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore Makefiles; they're all automatically generated 2 | Makefile 3 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/arm/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile for zlib 2 | # Copyright (C) 1995-2013 Jean-loup Gailly, Mark Adler 3 | # For conditions of distribution and use, see copyright notice in zlib.h 4 | 5 | CC= 6 | CFLAGS= 7 | SFLAGS= 8 | INCLUDES= 9 | SUFFIX= 10 | 11 | ACLEFLAG= 12 | NEONFLAG= 13 | NOLTOFLAG= 14 | 15 | SRCDIR=. 16 | SRCTOP=../.. 17 | TOPDIR=$(SRCTOP) 18 | 19 | all: \ 20 | adler32_neon.o adler32_neon.lo \ 21 | arm_features.o arm_features.lo \ 22 | chunkset_neon.o chunkset_neon.lo \ 23 | compare256_neon.o compare256_neon.lo \ 24 | crc32_acle.o crc32_acle.lo \ 25 | slide_hash_neon.o slide_hash_neon.lo \ 26 | insert_string_acle.o insert_string_acle.lo 27 | 28 | adler32_neon.o: 29 | $(CC) $(CFLAGS) $(NEONFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_neon.c 30 | 31 | adler32_neon.lo: 32 | $(CC) $(SFLAGS) $(NEONFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/adler32_neon.c 33 | 34 | arm_features.o: 35 | $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/arm_features.c 36 | 37 | arm_features.lo: 38 | $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/arm_features.c 39 | 40 | chunkset_neon.o: 41 | $(CC) $(CFLAGS) $(NEONFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/chunkset_neon.c 42 | 43 | chunkset_neon.lo: 44 | $(CC) $(SFLAGS) $(NEONFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/chunkset_neon.c 45 | 46 | compare256_neon.o: 47 | $(CC) $(CFLAGS) $(NEONFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/compare256_neon.c 48 | 49 | compare256_neon.lo: 50 | $(CC) $(SFLAGS) $(NEONFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/compare256_neon.c 51 | 52 | crc32_acle.o: 53 | $(CC) $(CFLAGS) $(ACLEFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_acle.c 54 | 55 | crc32_acle.lo: 56 | $(CC) $(SFLAGS) $(ACLEFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32_acle.c 57 | 58 | slide_hash_neon.o: 59 | $(CC) $(CFLAGS) $(NEONFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/slide_hash_neon.c 60 | 61 | slide_hash_neon.lo: 62 | $(CC) $(SFLAGS) $(NEONFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/slide_hash_neon.c 63 | 64 | insert_string_acle.o: 65 | $(CC) $(CFLAGS) $(ACLEFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/insert_string_acle.c 66 | 67 | insert_string_acle.lo: 68 | $(CC) $(SFLAGS) $(ACLEFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/insert_string_acle.c 69 | 70 | mostlyclean: clean 71 | clean: 72 | rm -f *.o *.lo *~ 73 | rm -rf objs 74 | rm -f *.gcda *.gcno *.gcov 75 | 76 | distclean: 77 | rm -f Makefile 78 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/arm/arm_features.h: -------------------------------------------------------------------------------- 1 | /* arm_features.h -- check for ARM features. 2 | * For conditions of distribution and use, see copyright notice in zlib.h 3 | */ 4 | 5 | #ifndef ARM_H_ 6 | #define ARM_H_ 7 | 8 | extern int arm_cpu_has_neon; 9 | extern int arm_cpu_has_crc32; 10 | 11 | void Z_INTERNAL arm_check_features(void); 12 | 13 | #endif /* ARM_H_ */ 14 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/arm/compare256_neon.c: -------------------------------------------------------------------------------- 1 | /* compare256_neon.c - NEON version of compare256 2 | * Copyright (C) 2022 Nathan Moinvaziri 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #if defined(ARM_NEON) && defined(HAVE_BUILTIN_CTZLL) 7 | #ifdef _M_ARM64 8 | # include 9 | #else 10 | # include 11 | #endif 12 | #include "../../zbuild.h" 13 | 14 | static inline uint32_t compare256_neon_static(const uint8_t *src0, const uint8_t *src1) { 15 | uint32_t len = 0; 16 | 17 | do { 18 | uint8x16_t a, b, cmp; 19 | uint64_t lane; 20 | 21 | a = vld1q_u8(src0); 22 | b = vld1q_u8(src1); 23 | 24 | cmp = veorq_u8(a, b); 25 | 26 | lane = vgetq_lane_u64(vreinterpretq_u64_u8(cmp), 0); 27 | if (lane) { 28 | uint32_t match_byte = (uint32_t)__builtin_ctzll(lane) / 8; 29 | return len + match_byte; 30 | } 31 | len += 8; 32 | lane = vgetq_lane_u64(vreinterpretq_u64_u8(cmp), 1); 33 | if (lane) { 34 | uint32_t match_byte = (uint32_t)__builtin_ctzll(lane) / 8; 35 | return len + match_byte; 36 | } 37 | len += 8; 38 | 39 | src0 += 16, src1 += 16; 40 | } while (len < 256); 41 | 42 | return 256; 43 | } 44 | 45 | Z_INTERNAL uint32_t compare256_neon(const uint8_t *src0, const uint8_t *src1) { 46 | return compare256_neon_static(src0, src1); 47 | } 48 | 49 | #define LONGEST_MATCH longest_match_neon 50 | #define COMPARE256 compare256_neon_static 51 | 52 | #include "match_tpl.h" 53 | 54 | #define LONGEST_MATCH_SLOW 55 | #define LONGEST_MATCH longest_match_slow_neon 56 | #define COMPARE256 compare256_neon_static 57 | 58 | #include "match_tpl.h" 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/arm/ctzl.h: -------------------------------------------------------------------------------- 1 | #ifndef ARM_CTZL_H 2 | #define ARM_CTZL_H 3 | 4 | #include 5 | 6 | #if defined(_MSC_VER) && !defined(__clang__) 7 | static __forceinline unsigned long __builtin_ctzl(unsigned long value) { 8 | return _arm_clz(_arm_rbit(value)); 9 | } 10 | #endif 11 | 12 | #endif 13 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/arm/insert_string_acle.c: -------------------------------------------------------------------------------- 1 | /* insert_string_acle.c -- insert_string integer hash variant using ACLE's CRC instructions 2 | * 3 | * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler 4 | * For conditions of distribution and use, see copyright notice in zlib.h 5 | * 6 | */ 7 | 8 | #ifdef ARM_ACLE_CRC_HASH 9 | #ifndef _MSC_VER 10 | # include 11 | #endif 12 | #include "../../zbuild.h" 13 | #include "../../deflate.h" 14 | 15 | #define HASH_CALC(s, h, val) \ 16 | h = __crc32w(0, val) 17 | 18 | #define HASH_CALC_VAR h 19 | #define HASH_CALC_VAR_INIT uint32_t h = 0 20 | 21 | #define UPDATE_HASH update_hash_acle 22 | #define INSERT_STRING insert_string_acle 23 | #define QUICK_INSERT_STRING quick_insert_string_acle 24 | 25 | #include "../../insert_string_tpl.h" 26 | #endif 27 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/arm/slide_hash_neon.c: -------------------------------------------------------------------------------- 1 | /* slide_hash_neon.c -- Optimized hash table shifting for ARM with support for NEON instructions 2 | * Copyright (C) 2017-2020 Mika T. Lindqvist 3 | * 4 | * Authors: 5 | * Mika T. Lindqvist 6 | * Jun He 7 | * 8 | * For conditions of distribution and use, see copyright notice in zlib.h 9 | */ 10 | 11 | #if defined(ARM_NEON_SLIDEHASH) 12 | #ifdef _M_ARM64 13 | # include 14 | #else 15 | # include 16 | #endif 17 | #include "../../zbuild.h" 18 | #include "../../deflate.h" 19 | #include "../../fallback_builtins.h" 20 | 21 | /* SIMD version of hash_chain rebase */ 22 | static inline void slide_hash_chain(Pos *table, uint32_t entries, uint16_t wsize) { 23 | Z_REGISTER uint16x8_t v; 24 | uint16x8x4_t p0, p1; 25 | Z_REGISTER size_t n; 26 | 27 | size_t size = entries*sizeof(table[0]); 28 | Assert((size % sizeof(uint16x8_t) * 8 == 0), "hash table size err"); 29 | 30 | Assert(sizeof(Pos) == 2, "Wrong Pos size"); 31 | v = vdupq_n_u16(wsize); 32 | 33 | n = size / (sizeof(uint16x8_t) * 8); 34 | do { 35 | p0 = vld1q_u16_x4(table); 36 | p1 = vld1q_u16_x4(table+32); 37 | vqsubq_u16_x4_x1(p0, p0, v); 38 | vqsubq_u16_x4_x1(p1, p1, v); 39 | vst1q_u16_x4(table, p0); 40 | vst1q_u16_x4(table+32, p1); 41 | table += 64; 42 | } while (--n); 43 | } 44 | 45 | Z_INTERNAL void slide_hash_neon(deflate_state *s) { 46 | unsigned int wsize = s->w_size; 47 | 48 | slide_hash_chain(s->head, HASH_SIZE, wsize); 49 | slide_hash_chain(s->prev, wsize, wsize); 50 | } 51 | #endif 52 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/generic/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile for zlib 2 | # Copyright (C) 1995-2013 Jean-loup Gailly, Mark Adler 3 | # For conditions of distribution and use, see copyright notice in zlib.h 4 | 5 | CC= 6 | CFLAGS= 7 | SFLAGS= 8 | INCLUDES= 9 | 10 | SRCDIR=. 11 | SRCTOP=../.. 12 | TOPDIR=$(SRCTOP) 13 | 14 | all: 15 | 16 | 17 | mostlyclean: clean 18 | clean: 19 | rm -f *.o *.lo *~ \ 20 | rm -rf objs 21 | rm -f *.gcda *.gcno *.gcov 22 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/power/chunkset_power8.c: -------------------------------------------------------------------------------- 1 | /* chunkset_power8.c -- VSX inline functions to copy small data chunks. 2 | * For conditions of distribution and use, see copyright notice in zlib.h 3 | */ 4 | 5 | #ifdef POWER8_VSX_CHUNKSET 6 | #include 7 | #include "../../zbuild.h" 8 | 9 | typedef vector unsigned char chunk_t; 10 | 11 | #define CHUNK_SIZE 16 12 | 13 | #define HAVE_CHUNKMEMSET_2 14 | #define HAVE_CHUNKMEMSET_4 15 | #define HAVE_CHUNKMEMSET_8 16 | 17 | static inline void chunkmemset_2(uint8_t *from, chunk_t *chunk) { 18 | uint16_t tmp; 19 | memcpy(&tmp, from, sizeof(tmp)); 20 | *chunk = (vector unsigned char)vec_splats(tmp); 21 | } 22 | 23 | static inline void chunkmemset_4(uint8_t *from, chunk_t *chunk) { 24 | uint32_t tmp; 25 | memcpy(&tmp, from, sizeof(tmp)); 26 | *chunk = (vector unsigned char)vec_splats(tmp); 27 | } 28 | 29 | static inline void chunkmemset_8(uint8_t *from, chunk_t *chunk) { 30 | uint64_t tmp; 31 | memcpy(&tmp, from, sizeof(tmp)); 32 | *chunk = (vector unsigned char)vec_splats(tmp); 33 | } 34 | 35 | #define CHUNKSIZE chunksize_power8 36 | #define CHUNKCOPY chunkcopy_power8 37 | #define CHUNKUNROLL chunkunroll_power8 38 | #define CHUNKMEMSET chunkmemset_power8 39 | #define CHUNKMEMSET_SAFE chunkmemset_safe_power8 40 | 41 | static inline void loadchunk(uint8_t const *s, chunk_t *chunk) { 42 | *chunk = vec_xl(0, s); 43 | } 44 | 45 | static inline void storechunk(uint8_t *out, chunk_t *chunk) { 46 | vec_xst(*chunk, 0, out); 47 | } 48 | 49 | #include "chunkset_tpl.h" 50 | 51 | #endif 52 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/power/compare256_power9.c: -------------------------------------------------------------------------------- 1 | /* compare256_power9.c - Power9 version of compare256 2 | * Copyright (C) 2019 Matheus Castanho , IBM 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #ifdef POWER9 7 | #include 8 | #include "../../zbuild.h" 9 | #include "../../zendian.h" 10 | 11 | /* Older versions of GCC misimplemented semantics for these bit counting builtins. 12 | * https://gcc.gnu.org/git/gitweb.cgi?p=gcc.git;h=3f30f2d1dbb3228b8468b26239fe60c2974ce2ac */ 13 | #if defined(__GNUC__) && (__GNUC__ < 12) 14 | # define zng_vec_vctzlsbb(vc, len) __asm__ volatile("vctzlsbb %0, %1\n\t" : "=r" (len) : "v" (vc)) 15 | # define zng_vec_vclzlsbb(vc, len) __asm__ volatile("vclzlsbb %0, %1\n\t" : "=r" (len) : "v" (vc)) 16 | #else 17 | # define zng_vec_vctzlsbb(vc, len) len = __builtin_vec_vctzlsbb(vc) 18 | # define zng_vec_vclzlsbb(vc, len) len = __builtin_vec_vclzlsbb(vc) 19 | #endif 20 | 21 | static inline uint32_t compare256_power9_static(const uint8_t *src0, const uint8_t *src1) { 22 | uint32_t len = 0, cmplen; 23 | 24 | do { 25 | vector unsigned char vsrc0, vsrc1, vc; 26 | 27 | vsrc0 = *((vector unsigned char *)src0); 28 | vsrc1 = *((vector unsigned char *)src1); 29 | 30 | /* Compare 16 bytes at a time. Each byte of vc will be either 31 | * all ones or all zeroes, depending on the result of the comparison. */ 32 | vc = (vector unsigned char)vec_cmpne(vsrc0, vsrc1); 33 | 34 | /* Since the index of matching bytes will contain only zeroes 35 | * on vc (since we used cmpne), counting the number of consecutive 36 | * bytes where LSB == 0 is the same as counting the length of the match. */ 37 | #if BYTE_ORDER == LITTLE_ENDIAN 38 | zng_vec_vctzlsbb(vc, cmplen); 39 | #else 40 | zng_vec_vclzlsbb(vc, cmplen); 41 | #endif 42 | if (cmplen != 16) 43 | return len + cmplen; 44 | 45 | src0 += 16, src1 += 16, len += 16; 46 | } while (len < 256); 47 | 48 | return 256; 49 | } 50 | 51 | Z_INTERNAL uint32_t compare256_power9(const uint8_t *src0, const uint8_t *src1) { 52 | return compare256_power9_static(src0, src1); 53 | } 54 | 55 | #define LONGEST_MATCH longest_match_power9 56 | #define COMPARE256 compare256_power9_static 57 | 58 | #include "match_tpl.h" 59 | 60 | #define LONGEST_MATCH_SLOW 61 | #define LONGEST_MATCH longest_match_slow_power9 62 | #define COMPARE256 compare256_power9_static 63 | 64 | #include "match_tpl.h" 65 | 66 | #endif 67 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/power/fallback_builtins.h: -------------------------------------------------------------------------------- 1 | /* Helper functions to work around issues with clang builtins 2 | * Copyright (C) 2021 IBM Corporation 3 | * 4 | * Authors: 5 | * Daniel Black 6 | * Rogerio Alves 7 | * Tulio Magno Quites Machado Filho 8 | * 9 | * For conditions of distribution and use, see copyright notice in zlib.h 10 | */ 11 | 12 | #ifndef POWER_BUILTINS_H 13 | #define POWER_BUILTINS_H 14 | 15 | /* 16 | * These stubs fix clang incompatibilities with GCC builtins. 17 | */ 18 | 19 | #ifndef __builtin_crypto_vpmsumw 20 | #define __builtin_crypto_vpmsumw __builtin_crypto_vpmsumb 21 | #endif 22 | #ifndef __builtin_crypto_vpmsumd 23 | #define __builtin_crypto_vpmsumd __builtin_crypto_vpmsumb 24 | #endif 25 | 26 | static inline __vector unsigned long long __attribute__((overloadable)) 27 | vec_ld(int __a, const __vector unsigned long long* __b) { 28 | return (__vector unsigned long long)__builtin_altivec_lvx(__a, __b); 29 | } 30 | 31 | #endif 32 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/power/power_features.c: -------------------------------------------------------------------------------- 1 | /* power_features.c - POWER feature check 2 | * Copyright (C) 2020 Matheus Castanho , IBM 3 | * Copyright (C) 2021-2022 Mika T. Lindqvist 4 | * For conditions of distribution and use, see copyright notice in zlib.h 5 | */ 6 | 7 | #ifdef HAVE_SYS_AUXV_H 8 | # include 9 | #endif 10 | #include "../../zbuild.h" 11 | #include "power_features.h" 12 | 13 | Z_INTERNAL int power_cpu_has_altivec = 0; 14 | Z_INTERNAL int power_cpu_has_arch_2_07 = 0; 15 | Z_INTERNAL int power_cpu_has_arch_3_00 = 0; 16 | 17 | void Z_INTERNAL power_check_features(void) { 18 | #ifdef PPC_FEATURES 19 | unsigned long hwcap; 20 | hwcap = getauxval(AT_HWCAP); 21 | 22 | if (hwcap & PPC_FEATURE_HAS_ALTIVEC) 23 | power_cpu_has_altivec = 1; 24 | #endif 25 | 26 | #ifdef POWER_FEATURES 27 | unsigned long hwcap2; 28 | hwcap2 = getauxval(AT_HWCAP2); 29 | 30 | if (hwcap2 & PPC_FEATURE2_ARCH_2_07) 31 | power_cpu_has_arch_2_07 = 1; 32 | if (hwcap2 & PPC_FEATURE2_ARCH_3_00) 33 | power_cpu_has_arch_3_00 = 1; 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/power/power_features.h: -------------------------------------------------------------------------------- 1 | /* power_features.h -- check for POWER CPU features 2 | * Copyright (C) 2020 Matheus Castanho , IBM 3 | * Copyright (C) 2021 Mika T. Lindqvist 4 | * For conditions of distribution and use, see copyright notice in zlib.h 5 | */ 6 | 7 | #ifndef POWER_H_ 8 | #define POWER_H_ 9 | 10 | extern int power_cpu_has_altivec; 11 | extern int power_cpu_has_arch_2_07; 12 | extern int power_cpu_has_arch_3_00; 13 | 14 | void Z_INTERNAL power_check_features(void); 15 | 16 | #endif /* POWER_H_ */ 17 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/power/slide_hash_power8.c: -------------------------------------------------------------------------------- 1 | /* Optimized slide_hash for POWER processors 2 | * Copyright (C) 2019-2020 IBM Corporation 3 | * Author: Matheus Castanho 4 | * For conditions of distribution and use, see copyright notice in zlib.h 5 | */ 6 | 7 | #ifdef POWER8_VSX_SLIDEHASH 8 | 9 | #define SLIDE_PPC slide_hash_power8 10 | #include "slide_ppc_tpl.h" 11 | 12 | #endif /* POWER8_VSX_SLIDEHASH */ 13 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/power/slide_hash_vmx.c: -------------------------------------------------------------------------------- 1 | /* Optimized slide_hash for PowerPC processors with VMX instructions 2 | * Copyright (C) 2017-2021 Mika T. Lindqvist 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | #ifdef PPC_VMX_SLIDEHASH 6 | 7 | #define SLIDE_PPC slide_hash_vmx 8 | #include "slide_ppc_tpl.h" 9 | 10 | #endif /* PPC_VMX_SLIDEHASH */ 11 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/power/slide_ppc_tpl.h: -------------------------------------------------------------------------------- 1 | /* Optimized slide_hash for PowerPC processors 2 | * Copyright (C) 2017-2021 Mika T. Lindqvist 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include 7 | #include "zbuild.h" 8 | #include "deflate.h" 9 | 10 | static inline void slide_hash_chain(Pos *table, uint32_t entries, uint16_t wsize) { 11 | const vector unsigned short vmx_wsize = vec_splats(wsize); 12 | Pos *p = table; 13 | 14 | do { 15 | vector unsigned short value, result; 16 | 17 | value = vec_ld(0, p); 18 | result = vec_subs(value, vmx_wsize); 19 | vec_st(result, 0, p); 20 | 21 | p += 8; 22 | entries -= 8; 23 | } while (entries > 0); 24 | } 25 | 26 | void Z_INTERNAL SLIDE_PPC(deflate_state *s) { 27 | uint16_t wsize = s->w_size; 28 | 29 | slide_hash_chain(s->head, HASH_SIZE, wsize); 30 | slide_hash_chain(s->prev, wsize, wsize); 31 | } 32 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/s390/Makefile.in: -------------------------------------------------------------------------------- 1 | # Makefile for zlib-ng 2 | # Copyright (C) 1995-2013 Jean-loup Gailly, Mark Adler 3 | # For conditions of distribution and use, see copyright notice in zlib.h 4 | 5 | CC= 6 | CFLAGS= 7 | SFLAGS= 8 | INCLUDES= 9 | SUFFIX= 10 | VGFMAFLAG= 11 | NOLTOFLAG= 12 | 13 | SRCDIR=. 14 | SRCTOP=../.. 15 | TOPDIR=$(SRCTOP) 16 | 17 | s390_features.o: 18 | $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/s390_features.c 19 | 20 | s390_features.lo: 21 | $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/s390_features.c 22 | 23 | dfltcc_common.o: 24 | $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/dfltcc_common.c 25 | 26 | dfltcc_common.lo: 27 | $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/dfltcc_common.c 28 | 29 | dfltcc_deflate.o: 30 | $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/dfltcc_deflate.c 31 | 32 | dfltcc_deflate.lo: 33 | $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/dfltcc_deflate.c 34 | 35 | dfltcc_inflate.o: 36 | $(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/dfltcc_inflate.c 37 | 38 | dfltcc_inflate.lo: 39 | $(CC) $(SFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/dfltcc_inflate.c 40 | 41 | crc32-vx.o: 42 | $(CC) $(CFLAGS) $(VGFMAFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32-vx.c 43 | 44 | crc32-vx.lo: 45 | $(CC) $(SFLAGS) $(VGFMAFLAG) $(NOLTOFLAG) $(INCLUDES) -c -o $@ $(SRCDIR)/crc32-vx.c 46 | 47 | mostlyclean: clean 48 | clean: 49 | rm -f *.o *.lo *~ 50 | rm -rf objs 51 | rm -f *.gcda *.gcno *.gcov 52 | 53 | distclean: 54 | rm -f Makefile 55 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/s390/dfltcc_common.c: -------------------------------------------------------------------------------- 1 | /* dfltcc_deflate.c - IBM Z DEFLATE CONVERSION CALL general support. */ 2 | 3 | #include "zbuild.h" 4 | #include "dfltcc_common.h" 5 | #include "dfltcc_detail.h" 6 | 7 | /* 8 | Memory management. 9 | 10 | DFLTCC requires parameter blocks and window to be aligned. zlib-ng allows 11 | users to specify their own allocation functions, so using e.g. 12 | `posix_memalign' is not an option. Thus, we overallocate and take the 13 | aligned portion of the buffer. 14 | */ 15 | 16 | static const int PAGE_ALIGN = 0x1000; 17 | 18 | void Z_INTERNAL *PREFIX(dfltcc_alloc_window)(PREFIX3(streamp) strm, uInt items, uInt size) { 19 | void *p; 20 | void *w; 21 | 22 | /* To simplify freeing, we store the pointer to the allocated buffer right 23 | * before the window. 24 | */ 25 | p = ZALLOC(strm, sizeof(void *) + items * size + PAGE_ALIGN, sizeof(unsigned char)); 26 | if (p == NULL) 27 | return NULL; 28 | w = ALIGN_UP((char *)p + sizeof(void *), PAGE_ALIGN); 29 | *(void **)((char *)w - sizeof(void *)) = p; 30 | return w; 31 | } 32 | 33 | void Z_INTERNAL PREFIX(dfltcc_free_window)(PREFIX3(streamp) strm, void *w) { 34 | if (w) 35 | ZFREE(strm, *(void **)((unsigned char *)w - sizeof(void *))); 36 | } 37 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/s390/dfltcc_common.h: -------------------------------------------------------------------------------- 1 | #ifndef DFLTCC_COMMON_H 2 | #define DFLTCC_COMMON_H 3 | 4 | #include "zutil.h" 5 | 6 | void Z_INTERNAL *PREFIX(dfltcc_alloc_window)(PREFIX3(streamp) strm, uInt items, uInt size); 7 | void Z_INTERNAL PREFIX(dfltcc_free_window)(PREFIX3(streamp) strm, void *w); 8 | 9 | #define ZFREE_STATE ZFREE 10 | 11 | #define ZALLOC_WINDOW PREFIX(dfltcc_alloc_window) 12 | 13 | #define ZFREE_WINDOW PREFIX(dfltcc_free_window) 14 | 15 | #define TRY_FREE_WINDOW PREFIX(dfltcc_free_window) 16 | 17 | #define DFLTCC_BLOCK_HEADER_BITS 3 18 | #define DFLTCC_HLITS_COUNT_BITS 5 19 | #define DFLTCC_HDISTS_COUNT_BITS 5 20 | #define DFLTCC_HCLENS_COUNT_BITS 4 21 | #define DFLTCC_MAX_HCLENS 19 22 | #define DFLTCC_HCLEN_BITS 3 23 | #define DFLTCC_MAX_HLITS 286 24 | #define DFLTCC_MAX_HDISTS 30 25 | #define DFLTCC_MAX_HLIT_HDIST_BITS 7 26 | #define DFLTCC_MAX_SYMBOL_BITS 16 27 | #define DFLTCC_MAX_EOBS_BITS 15 28 | #define DFLTCC_MAX_PADDING_BITS 7 29 | 30 | #define DEFLATE_BOUND_COMPLEN(source_len) \ 31 | ((DFLTCC_BLOCK_HEADER_BITS + \ 32 | DFLTCC_HLITS_COUNT_BITS + \ 33 | DFLTCC_HDISTS_COUNT_BITS + \ 34 | DFLTCC_HCLENS_COUNT_BITS + \ 35 | DFLTCC_MAX_HCLENS * DFLTCC_HCLEN_BITS + \ 36 | (DFLTCC_MAX_HLITS + DFLTCC_MAX_HDISTS) * DFLTCC_MAX_HLIT_HDIST_BITS + \ 37 | (source_len) * DFLTCC_MAX_SYMBOL_BITS + \ 38 | DFLTCC_MAX_EOBS_BITS + \ 39 | DFLTCC_MAX_PADDING_BITS) >> 3) 40 | 41 | #endif 42 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/s390/dfltcc_inflate.h: -------------------------------------------------------------------------------- 1 | #ifndef DFLTCC_INFLATE_H 2 | #define DFLTCC_INFLATE_H 3 | 4 | #include "dfltcc_common.h" 5 | 6 | struct inflate_state Z_INTERNAL *PREFIX(dfltcc_alloc_inflate_state)(PREFIX3(streamp) strm); 7 | void Z_INTERNAL PREFIX(dfltcc_reset_inflate_state)(PREFIX3(streamp) strm); 8 | void Z_INTERNAL PREFIX(dfltcc_copy_inflate_state)(struct inflate_state *dst, const struct inflate_state *src); 9 | int Z_INTERNAL PREFIX(dfltcc_can_inflate)(PREFIX3(streamp) strm); 10 | typedef enum { 11 | DFLTCC_INFLATE_CONTINUE, 12 | DFLTCC_INFLATE_BREAK, 13 | DFLTCC_INFLATE_SOFTWARE, 14 | } dfltcc_inflate_action; 15 | dfltcc_inflate_action Z_INTERNAL PREFIX(dfltcc_inflate)(PREFIX3(streamp) strm, int flush, int *ret); 16 | int Z_INTERNAL PREFIX(dfltcc_was_inflate_used)(PREFIX3(streamp) strm); 17 | int Z_INTERNAL PREFIX(dfltcc_inflate_disable)(PREFIX3(streamp) strm); 18 | 19 | #define ZALLOC_INFLATE_STATE PREFIX(dfltcc_alloc_inflate_state) 20 | #define ZCOPY_INFLATE_STATE PREFIX(dfltcc_copy_inflate_state) 21 | 22 | #define INFLATE_RESET_KEEP_HOOK PREFIX(dfltcc_reset_inflate_state) 23 | 24 | #define INFLATE_PRIME_HOOK(strm, bits, value) \ 25 | do { if (PREFIX(dfltcc_inflate_disable)((strm))) return Z_STREAM_ERROR; } while (0) 26 | 27 | #define INFLATE_TYPEDO_HOOK(strm, flush) \ 28 | if (PREFIX(dfltcc_can_inflate)((strm))) { \ 29 | dfltcc_inflate_action action; \ 30 | \ 31 | RESTORE(); \ 32 | action = PREFIX(dfltcc_inflate)((strm), (flush), &ret); \ 33 | LOAD(); \ 34 | if (action == DFLTCC_INFLATE_CONTINUE) \ 35 | break; \ 36 | else if (action == DFLTCC_INFLATE_BREAK) \ 37 | goto inf_leave; \ 38 | } 39 | 40 | #define INFLATE_NEED_CHECKSUM(strm) (!PREFIX(dfltcc_can_inflate)((strm))) 41 | 42 | #define INFLATE_NEED_UPDATEWINDOW(strm) (!PREFIX(dfltcc_can_inflate)((strm))) 43 | 44 | #define INFLATE_MARK_HOOK(strm) \ 45 | do { \ 46 | if (PREFIX(dfltcc_was_inflate_used)((strm))) return -(1L << 16); \ 47 | } while (0) 48 | 49 | #define INFLATE_SYNC_POINT_HOOK(strm) \ 50 | do { \ 51 | if (PREFIX(dfltcc_was_inflate_used)((strm))) return Z_STREAM_ERROR; \ 52 | } while (0) 53 | 54 | #endif 55 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/s390/s390_features.c: -------------------------------------------------------------------------------- 1 | #include "../../zbuild.h" 2 | #include "s390_features.h" 3 | 4 | #ifdef HAVE_SYS_AUXV_H 5 | # include 6 | #endif 7 | 8 | Z_INTERNAL int PREFIX(s390_cpu_has_vx) = 0; 9 | 10 | void Z_INTERNAL PREFIX(s390_check_features)(void) { 11 | #ifdef S390_FEATURES 12 | PREFIX(s390_cpu_has_vx) = getauxval(AT_HWCAP) & HWCAP_S390_VX; 13 | #endif 14 | } 15 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/s390/s390_features.h: -------------------------------------------------------------------------------- 1 | #ifndef S390_FEATURES_H_ 2 | #define S390_FEATURES_H_ 3 | 4 | extern int PREFIX(s390_cpu_has_vx); 5 | 6 | void Z_INTERNAL PREFIX(s390_check_features)(void); 7 | 8 | #endif 9 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/s390/self-hosted-builder/actions-runner.Dockerfile: -------------------------------------------------------------------------------- 1 | # Self-Hosted IBM Z Github Actions Runner. 2 | 3 | # Temporary image: amd64 dependencies. 4 | FROM amd64/ubuntu:20.04 as ld-prefix 5 | ENV DEBIAN_FRONTEND=noninteractive 6 | RUN apt-get update && apt-get -y install ca-certificates libicu66 libssl1.1 7 | 8 | # Main image. 9 | FROM s390x/ubuntu:20.04 10 | 11 | # Packages for zlib-ng testing. 12 | ENV DEBIAN_FRONTEND=noninteractive 13 | RUN apt-get update && apt-get -y install \ 14 | clang-11 \ 15 | cmake \ 16 | curl \ 17 | gcc \ 18 | git \ 19 | jq \ 20 | libxml2-dev \ 21 | libxslt-dev \ 22 | llvm-11-tools \ 23 | ninja-build \ 24 | python-is-python3 \ 25 | python3 \ 26 | python3-dev \ 27 | python3-pip 28 | 29 | # amd64 dependencies. 30 | COPY --from=ld-prefix / /usr/x86_64-linux-gnu/ 31 | RUN ln -fs ../lib/x86_64-linux-gnu/ld-linux-x86-64.so.2 /usr/x86_64-linux-gnu/lib64/ 32 | RUN ln -fs /etc/resolv.conf /usr/x86_64-linux-gnu/etc/ 33 | ENV QEMU_LD_PREFIX=/usr/x86_64-linux-gnu 34 | 35 | # amd64 Github Actions Runner. 36 | RUN useradd -m actions-runner 37 | USER actions-runner 38 | WORKDIR /home/actions-runner 39 | RUN curl -L https://github.com/actions/runner/releases/download/v2.287.1/actions-runner-linux-x64-2.287.1.tar.gz | tar -xz 40 | VOLUME /home/actions-runner 41 | 42 | # Scripts. 43 | COPY fs/ / 44 | ENTRYPOINT ["/usr/bin/entrypoint"] 45 | CMD ["/usr/bin/actions-runner"] 46 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/s390/self-hosted-builder/actions-runner.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Self-Hosted IBM Z Github Actions Runner 3 | Wants=qemu-user-static 4 | After=qemu-user-static 5 | StartLimitIntervalSec=0 6 | 7 | [Service] 8 | Type=simple 9 | Restart=always 10 | ExecStartPre=-/usr/bin/docker rm --force actions-runner 11 | ExecStart=/usr/bin/docker run \ 12 | --env-file=/etc/actions-runner \ 13 | --init \ 14 | --interactive \ 15 | --name=actions-runner \ 16 | --rm \ 17 | --volume=actions-runner:/home/actions-runner \ 18 | iiilinuxibmcom/actions-runner 19 | ExecStop=/bin/sh -c "docker exec actions-runner kill -INT -- -1" 20 | ExecStop=/bin/sh -c "docker wait actions-runner" 21 | ExecStop=/bin/sh -c "docker rm actions-runner" 22 | 23 | [Install] 24 | WantedBy=multi-user.target 25 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/s390/self-hosted-builder/fs/usr/bin/actions-runner: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Ephemeral runner startup script. 5 | # 6 | # Expects the following environment variables: 7 | # 8 | # - repo=/ 9 | # - access_token= 10 | # 11 | 12 | set -e -u 13 | 14 | # Check the cached registration token. 15 | token_file=registration-token.json 16 | set +e 17 | expires_at=$(jq --raw-output .expires_at "$token_file" 2>/dev/null) 18 | status=$? 19 | set -e 20 | if [[ $status -ne 0 || $(date +%s) -ge $(date -d "$expires_at" +%s) ]]; then 21 | # Refresh the cached registration token. 22 | curl \ 23 | -X POST \ 24 | -H "Accept: application/vnd.github.v3+json" \ 25 | -H "Authorization: token $access_token" \ 26 | "https://api.github.com/repos/$repo/actions/runners/registration-token" \ 27 | -o "$token_file" 28 | fi 29 | 30 | # (Re-)register the runner. 31 | registration_token=$(jq --raw-output .token "$token_file") 32 | ./config.sh remove --token "$registration_token" || true 33 | ./config.sh \ 34 | --url "https://github.com/$repo" \ 35 | --token "$registration_token" \ 36 | --labels z15 \ 37 | --ephemeral 38 | 39 | # Run one job. 40 | ./run.sh 41 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/s390/self-hosted-builder/fs/usr/bin/entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # 4 | # Container entrypoint that waits for all spawned processes. 5 | # 6 | 7 | set -e -u 8 | 9 | # Create a FIFO and start reading from its read end. 10 | tempdir=$(mktemp -d "/tmp/done.XXXXXXXXXX") 11 | trap 'rm -r "$tempdir"' EXIT 12 | done="$tempdir/pipe" 13 | mkfifo "$done" 14 | cat "$done" & waiter=$! 15 | 16 | # Start the workload. Its descendants will inherit the FIFO's write end. 17 | status=0 18 | if [ "$#" -eq 0 ]; then 19 | bash 9>"$done" || status=$? 20 | else 21 | "$@" 9>"$done" || status=$? 22 | fi 23 | 24 | # When the workload and all of its descendants exit, the FIFO's write end will 25 | # be closed and `cat "$done"` will exit. Wait until it happens. This is needed 26 | # in order to handle SelfUpdater, which the workload may start in background 27 | # before exiting. 28 | wait "$waiter" 29 | 30 | exit "$status" 31 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/s390/self-hosted-builder/qemu-user-static.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=Support for transparent execution of non-native binaries with QEMU user emulation 3 | 4 | [Service] 5 | Type=oneshot 6 | # The source code for iiilinuxibmcom/qemu-user-static is at https://github.com/iii-i/qemu-user-static/tree/v6.1.0-1 7 | # TODO: replace it with multiarch/qemu-user-static once version >6.1 is available 8 | ExecStart=/usr/bin/docker run --rm --interactive --privileged iiilinuxibmcom/qemu-user-static --reset -p yes 9 | 10 | [Install] 11 | WantedBy=multi-user.target 12 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/x86/adler32_avx2.c: -------------------------------------------------------------------------------- 1 | /* adler32_avx2.c -- compute the Adler-32 checksum of a data stream 2 | * Copyright (C) 1995-2011 Mark Adler 3 | * Authors: 4 | * Brian Bockelman 5 | * For conditions of distribution and use, see copyright notice in zlib.h 6 | */ 7 | 8 | #include 9 | 10 | #ifdef X86_AVX2_ADLER32 11 | 12 | #include "adler32_avx2_tpl.h" 13 | 14 | #define COPY 15 | #include "adler32_avx2_tpl.h" 16 | 17 | #endif 18 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/x86/adler32_avx2_p.h: -------------------------------------------------------------------------------- 1 | /* adler32_avx2_p.h -- adler32 avx2 utility functions 2 | * Copyright (C) 2022 Adam Stylinski 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #ifndef ADLER32_AVX2_P_H_ 7 | #define ADLER32_AVX2_P_H_ 8 | 9 | #if defined(X86_AVX2_ADLER32) || defined(X86_AVX512VNNI_ADLER32) 10 | 11 | /* 32 bit horizontal sum, adapted from Agner Fog's vector library. */ 12 | static inline uint32_t hsum256(__m256i x) { 13 | __m128i sum1 = _mm_add_epi32(_mm256_extracti128_si256(x, 1), 14 | _mm256_castsi256_si128(x)); 15 | __m128i sum2 = _mm_add_epi32(sum1, _mm_unpackhi_epi64(sum1, sum1)); 16 | __m128i sum3 = _mm_add_epi32(sum2, _mm_shuffle_epi32(sum2, 1)); 17 | return (uint32_t)_mm_cvtsi128_si32(sum3); 18 | } 19 | 20 | static inline uint32_t partial_hsum256(__m256i x) { 21 | /* We need a permutation vector to extract every other integer. The 22 | * rest are going to be zeros */ 23 | const __m256i perm_vec = _mm256_setr_epi32(0, 2, 4, 6, 1, 1, 1, 1); 24 | __m256i non_zero = _mm256_permutevar8x32_epi32(x, perm_vec); 25 | __m128i non_zero_sse = _mm256_castsi256_si128(non_zero); 26 | __m128i sum2 = _mm_add_epi32(non_zero_sse,_mm_unpackhi_epi64(non_zero_sse, non_zero_sse)); 27 | __m128i sum3 = _mm_add_epi32(sum2, _mm_shuffle_epi32(sum2, 1)); 28 | return (uint32_t)_mm_cvtsi128_si32(sum3); 29 | } 30 | #endif 31 | 32 | #endif 33 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/x86/adler32_avx512.c: -------------------------------------------------------------------------------- 1 | /* adler32_avx512.c -- compute the Adler-32 checksum of a data stream 2 | * Copyright (C) 1995-2011 Mark Adler 3 | * Authors: 4 | * Adam Stylinski 5 | * Brian Bockelman 6 | * For conditions of distribution and use, see copyright notice in zlib.h 7 | */ 8 | 9 | #ifdef X86_AVX512_ADLER32 10 | 11 | #include "adler32_avx512_tpl.h" 12 | 13 | #define COPY 14 | #include "adler32_avx512_tpl.h" 15 | 16 | #endif 17 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/x86/adler32_avx512_p.h: -------------------------------------------------------------------------------- 1 | #ifndef AVX512_FUNCS_H 2 | #define AVX512_FUNCS_H 3 | 4 | #include 5 | #include 6 | /* Written because *_add_epi32(a) sets off ubsan */ 7 | static inline uint32_t _mm512_reduce_add_epu32(__m512i x) { 8 | __m256i a = _mm512_extracti64x4_epi64(x, 1); 9 | __m256i b = _mm512_extracti64x4_epi64(x, 0); 10 | 11 | __m256i a_plus_b = _mm256_add_epi32(a, b); 12 | __m128i c = _mm256_extracti128_si256(a_plus_b, 1); 13 | __m128i d = _mm256_extracti128_si256(a_plus_b, 0); 14 | __m128i c_plus_d = _mm_add_epi32(c, d); 15 | 16 | __m128i sum1 = _mm_unpackhi_epi64(c_plus_d, c_plus_d); 17 | __m128i sum2 = _mm_add_epi32(sum1, c_plus_d); 18 | __m128i sum3 = _mm_shuffle_epi32(sum2, 0x01); 19 | __m128i sum4 = _mm_add_epi32(sum2, sum3); 20 | 21 | return _mm_cvtsi128_si32(sum4); 22 | } 23 | 24 | static inline uint32_t partial_hsum(__m512i x) { 25 | /* We need a permutation vector to extract every other integer. The 26 | * rest are going to be zeros. Marking this const so the compiler stands 27 | * a better chance of keeping this resident in a register through entire 28 | * loop execution. We certainly have enough zmm registers (32) */ 29 | const __m512i perm_vec = _mm512_setr_epi32(0, 2, 4, 6, 8, 10, 12, 14, 30 | 1, 1, 1, 1, 1, 1, 1, 1); 31 | 32 | __m512i non_zero = _mm512_permutexvar_epi32(perm_vec, x); 33 | 34 | /* From here, it's a simple 256 bit wide reduction sum */ 35 | __m256i non_zero_avx = _mm512_castsi512_si256(non_zero); 36 | 37 | /* See Agner Fog's vectorclass for a decent reference. Essentially, phadd is 38 | * pretty slow, much slower than the longer instruction sequence below */ 39 | __m128i sum1 = _mm_add_epi32(_mm256_extracti128_si256(non_zero_avx, 1), 40 | _mm256_castsi256_si128(non_zero_avx)); 41 | __m128i sum2 = _mm_add_epi32(sum1,_mm_unpackhi_epi64(sum1, sum1)); 42 | __m128i sum3 = _mm_add_epi32(sum2,_mm_shuffle_epi32(sum2, 1)); 43 | return (uint32_t)_mm_cvtsi128_si32(sum3); 44 | } 45 | 46 | #endif 47 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/x86/adler32_ssse3_p.h: -------------------------------------------------------------------------------- 1 | /* adler32_ssse3_p.h -- adler32 ssse3 utility functions 2 | * Copyright (C) 2022 Adam Stylinski 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #ifndef ADLER32_SSSE3_P_H_ 7 | #define ADLER32_SSSE3_P_H_ 8 | 9 | #ifdef X86_SSSE3_ADLER32 10 | 11 | #include 12 | #include 13 | 14 | static inline uint32_t partial_hsum(__m128i x) { 15 | __m128i second_int = _mm_bsrli_si128(x, 8); 16 | __m128i sum = _mm_add_epi32(x, second_int); 17 | return _mm_cvtsi128_si32(sum); 18 | } 19 | 20 | static inline uint32_t hsum(__m128i x) { 21 | __m128i sum1 = _mm_unpackhi_epi64(x, x); 22 | __m128i sum2 = _mm_add_epi32(x, sum1); 23 | __m128i sum3 = _mm_shuffle_epi32(sum2, 0x01); 24 | __m128i sum4 = _mm_add_epi32(sum2, sum3); 25 | return _mm_cvtsi128_si32(sum4); 26 | } 27 | #endif 28 | 29 | #endif 30 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/x86/chunkset_sse2.c: -------------------------------------------------------------------------------- 1 | /* chunkset_sse2.c -- SSE2 inline functions to copy small data chunks. 2 | * For conditions of distribution and use, see copyright notice in zlib.h 3 | */ 4 | 5 | #include "zbuild.h" 6 | 7 | #ifdef X86_SSE2 8 | #include 9 | 10 | typedef __m128i chunk_t; 11 | 12 | #define CHUNK_SIZE 16 13 | 14 | #define HAVE_CHUNKMEMSET_2 15 | #define HAVE_CHUNKMEMSET_4 16 | #define HAVE_CHUNKMEMSET_8 17 | 18 | static inline void chunkmemset_2(uint8_t *from, chunk_t *chunk) { 19 | int16_t tmp; 20 | memcpy(&tmp, from, sizeof(tmp)); 21 | *chunk = _mm_set1_epi16(tmp); 22 | } 23 | 24 | static inline void chunkmemset_4(uint8_t *from, chunk_t *chunk) { 25 | int32_t tmp; 26 | memcpy(&tmp, from, sizeof(tmp)); 27 | *chunk = _mm_set1_epi32(tmp); 28 | } 29 | 30 | static inline void chunkmemset_8(uint8_t *from, chunk_t *chunk) { 31 | int64_t tmp; 32 | memcpy(&tmp, from, sizeof(tmp)); 33 | *chunk = _mm_set1_epi64x(tmp); 34 | } 35 | 36 | static inline void loadchunk(uint8_t const *s, chunk_t *chunk) { 37 | *chunk = _mm_loadu_si128((__m128i *)s); 38 | } 39 | 40 | static inline void storechunk(uint8_t *out, chunk_t *chunk) { 41 | _mm_storeu_si128((__m128i *)out, *chunk); 42 | } 43 | 44 | #define CHUNKSIZE chunksize_sse2 45 | #define CHUNKCOPY chunkcopy_sse2 46 | #define CHUNKUNROLL chunkunroll_sse2 47 | #define CHUNKMEMSET chunkmemset_sse2 48 | #define CHUNKMEMSET_SAFE chunkmemset_safe_sse2 49 | 50 | #include "chunkset_tpl.h" 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/x86/compare256_avx2.c: -------------------------------------------------------------------------------- 1 | /* compare256_avx2.c -- AVX2 version of compare256 2 | * Copyright Mika T. Lindqvist 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "../../zbuild.h" 7 | 8 | #include "fallback_builtins.h" 9 | 10 | #if defined(X86_AVX2) && defined(HAVE_BUILTIN_CTZ) 11 | 12 | #include 13 | #ifdef _MSC_VER 14 | # include 15 | #endif 16 | 17 | static inline uint32_t compare256_avx2_static(const uint8_t *src0, const uint8_t *src1) { 18 | uint32_t len = 0; 19 | 20 | do { 21 | __m256i ymm_src0, ymm_src1, ymm_cmp; 22 | ymm_src0 = _mm256_loadu_si256((__m256i*)src0); 23 | ymm_src1 = _mm256_loadu_si256((__m256i*)src1); 24 | ymm_cmp = _mm256_cmpeq_epi8(ymm_src0, ymm_src1); /* non-identical bytes = 00, identical bytes = FF */ 25 | unsigned mask = (unsigned)_mm256_movemask_epi8(ymm_cmp); 26 | if (mask != 0xFFFFFFFF) { 27 | uint32_t match_byte = (uint32_t)__builtin_ctz(~mask); /* Invert bits so identical = 0 */ 28 | return len + match_byte; 29 | } 30 | 31 | src0 += 32, src1 += 32, len += 32; 32 | 33 | ymm_src0 = _mm256_loadu_si256((__m256i*)src0); 34 | ymm_src1 = _mm256_loadu_si256((__m256i*)src1); 35 | ymm_cmp = _mm256_cmpeq_epi8(ymm_src0, ymm_src1); 36 | mask = (unsigned)_mm256_movemask_epi8(ymm_cmp); 37 | if (mask != 0xFFFFFFFF) { 38 | uint32_t match_byte = (uint32_t)__builtin_ctz(~mask); 39 | return len + match_byte; 40 | } 41 | 42 | src0 += 32, src1 += 32, len += 32; 43 | } while (len < 256); 44 | 45 | return 256; 46 | } 47 | 48 | Z_INTERNAL uint32_t compare256_avx2(const uint8_t *src0, const uint8_t *src1) { 49 | return compare256_avx2_static(src0, src1); 50 | } 51 | 52 | #define LONGEST_MATCH longest_match_avx2 53 | #define COMPARE256 compare256_avx2_static 54 | 55 | #include "match_tpl.h" 56 | 57 | #define LONGEST_MATCH_SLOW 58 | #define LONGEST_MATCH longest_match_slow_avx2 59 | #define COMPARE256 compare256_avx2_static 60 | 61 | #include "match_tpl.h" 62 | 63 | #endif 64 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/x86/crc32_fold_vpclmulqdq.c: -------------------------------------------------------------------------------- 1 | /* crc32_fold_vpclmulqdq.c -- VPCMULQDQ-based CRC32 folding implementation. 2 | * Copyright Wangyang Guo (wangyang.guo@intel.com) 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #ifdef X86_VPCLMULQDQ_CRC 7 | #include "../../zbuild.h" 8 | #include "../../fallback_builtins.h" 9 | 10 | #include 11 | 12 | #define ONCE(op) if (first) { first = 0; op; } 13 | #define XOR_INITIAL(where) ONCE(where = _mm512_xor_si512(where, zmm_initial)) 14 | 15 | #include "crc32_fold_vpclmulqdq_tpl.h" 16 | #define COPY 17 | #include "crc32_fold_vpclmulqdq_tpl.h" 18 | 19 | #endif 20 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/x86/insert_string_sse42.c: -------------------------------------------------------------------------------- 1 | /* insert_string_sse42.c -- insert_string integer hash variant using SSE4.2's CRC instructions 2 | * 3 | * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler 4 | * For conditions of distribution and use, see copyright notice in zlib.h 5 | * 6 | */ 7 | 8 | #include "../../zbuild.h" 9 | #include 10 | #ifdef _MSC_VER 11 | # include 12 | #endif 13 | #include "../../deflate.h" 14 | 15 | #ifdef X86_SSE42_CRC_INTRIN 16 | # ifdef _MSC_VER 17 | # define HASH_CALC(s, h, val)\ 18 | h = _mm_crc32_u32(h, val) 19 | # else 20 | # define HASH_CALC(s, h, val)\ 21 | h = __builtin_ia32_crc32si(h, val) 22 | # endif 23 | #else 24 | # ifdef _MSC_VER 25 | # define HASH_CALC(s, h, val) {\ 26 | __asm mov edx, h\ 27 | __asm mov eax, val\ 28 | __asm crc32 eax, edx\ 29 | __asm mov h, eax\ 30 | } 31 | # else 32 | # define HASH_CALC(s, h, val) \ 33 | __asm__ __volatile__ (\ 34 | "crc32 %1,%0\n\t"\ 35 | : "+r" (h)\ 36 | : "r" (val)\ 37 | ); 38 | # endif 39 | #endif 40 | 41 | #define HASH_CALC_VAR h 42 | #define HASH_CALC_VAR_INIT uint32_t h = 0 43 | 44 | #define UPDATE_HASH update_hash_sse4 45 | #define INSERT_STRING insert_string_sse4 46 | #define QUICK_INSERT_STRING quick_insert_string_sse4 47 | 48 | #ifdef X86_SSE42_CRC_HASH 49 | # include "../../insert_string_tpl.h" 50 | #endif 51 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/x86/slide_hash_avx2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * AVX2 optimized hash slide, based on Intel's slide_sse implementation 3 | * 4 | * Copyright (C) 2017 Intel Corporation 5 | * Authors: 6 | * Arjan van de Ven 7 | * Jim Kukunas 8 | * Mika T. Lindqvist 9 | * 10 | * For conditions of distribution and use, see copyright notice in zlib.h 11 | */ 12 | #include "../../zbuild.h" 13 | #include "../../deflate.h" 14 | 15 | #include 16 | 17 | static inline void slide_hash_chain(Pos *table, uint32_t entries, const __m256i wsize) { 18 | table += entries; 19 | table -= 16; 20 | 21 | do { 22 | __m256i value, result; 23 | 24 | value = _mm256_loadu_si256((__m256i *)table); 25 | result = _mm256_subs_epu16(value, wsize); 26 | _mm256_storeu_si256((__m256i *)table, result); 27 | 28 | table -= 16; 29 | entries -= 16; 30 | } while (entries > 0); 31 | } 32 | 33 | Z_INTERNAL void slide_hash_avx2(deflate_state *s) { 34 | uint16_t wsize = (uint16_t)s->w_size; 35 | const __m256i ymm_wsize = _mm256_set1_epi16((short)wsize); 36 | 37 | slide_hash_chain(s->head, HASH_SIZE, ymm_wsize); 38 | slide_hash_chain(s->prev, wsize, ymm_wsize); 39 | } 40 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/x86/slide_hash_sse2.c: -------------------------------------------------------------------------------- 1 | /* 2 | * SSE optimized hash slide 3 | * 4 | * Copyright (C) 2017 Intel Corporation 5 | * Authors: 6 | * Arjan van de Ven 7 | * Jim Kukunas 8 | * 9 | * For conditions of distribution and use, see copyright notice in zlib.h 10 | */ 11 | #include "../../zbuild.h" 12 | #include "../../deflate.h" 13 | 14 | #include 15 | #include 16 | 17 | static inline void slide_hash_chain(Pos *table0, Pos *table1, uint32_t entries0, 18 | uint32_t entries1, const __m128i wsize) { 19 | uint32_t entries; 20 | Pos *table; 21 | __m128i value0, value1, result0, result1; 22 | 23 | int on_chain = 0; 24 | 25 | next_chain: 26 | table = (on_chain) ? table1 : table0; 27 | entries = (on_chain) ? entries1 : entries0; 28 | 29 | table += entries; 30 | table -= 16; 31 | 32 | /* ZALLOC allocates this pointer unless the user chose a custom allocator. 33 | * Our alloc function is aligned to 64 byte boundaries */ 34 | do { 35 | value0 = _mm_load_si128((__m128i *)table); 36 | value1 = _mm_load_si128((__m128i *)(table + 8)); 37 | result0 = _mm_subs_epu16(value0, wsize); 38 | result1 = _mm_subs_epu16(value1, wsize); 39 | _mm_store_si128((__m128i *)table, result0); 40 | _mm_store_si128((__m128i *)(table + 8), result1); 41 | 42 | table -= 16; 43 | entries -= 16; 44 | } while (entries > 0); 45 | 46 | ++on_chain; 47 | if (on_chain > 1) { 48 | return; 49 | } else { 50 | goto next_chain; 51 | } 52 | } 53 | 54 | Z_INTERNAL void slide_hash_sse2(deflate_state *s) { 55 | uint16_t wsize = (uint16_t)s->w_size; 56 | const __m128i xmm_wsize = _mm_set1_epi16((short)wsize); 57 | 58 | assert(((uintptr_t)s->head & 15) == 0); 59 | assert(((uintptr_t)s->prev & 15) == 0); 60 | 61 | slide_hash_chain(s->head, s->prev, HASH_SIZE, wsize, xmm_wsize); 62 | } 63 | -------------------------------------------------------------------------------- /ext/zlib-ng/arch/x86/x86_features.h: -------------------------------------------------------------------------------- 1 | /* x86_features.h -- check for CPU features 2 | * Copyright (C) 2013 Intel Corporation Jim Kukunas 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #ifndef X86_FEATURES_H_ 7 | #define X86_FEATURES_H_ 8 | 9 | extern int x86_cpu_has_avx2; 10 | extern int x86_cpu_has_avx512; 11 | extern int x86_cpu_has_avx512vnni; 12 | extern int x86_cpu_has_sse2; 13 | extern int x86_cpu_has_ssse3; 14 | extern int x86_cpu_has_sse41; 15 | extern int x86_cpu_has_sse42; 16 | extern int x86_cpu_has_pclmulqdq; 17 | extern int x86_cpu_has_vpclmulqdq; 18 | extern int x86_cpu_has_tzcnt; 19 | 20 | void Z_INTERNAL x86_check_features(void); 21 | 22 | #endif /* CPU_H_ */ 23 | -------------------------------------------------------------------------------- /ext/zlib-ng/chunkset.c: -------------------------------------------------------------------------------- 1 | /* chunkset.c -- inline functions to copy small data chunks. 2 | * For conditions of distribution and use, see copyright notice in zlib.h 3 | */ 4 | 5 | #include "zbuild.h" 6 | 7 | typedef uint64_t chunk_t; 8 | 9 | #define CHUNK_SIZE 8 10 | 11 | #define HAVE_CHUNKMEMSET_4 12 | #define HAVE_CHUNKMEMSET_8 13 | 14 | static inline void chunkmemset_4(uint8_t *from, chunk_t *chunk) { 15 | uint8_t *dest = (uint8_t *)chunk; 16 | memcpy(dest, from, sizeof(uint32_t)); 17 | memcpy(dest+4, from, sizeof(uint32_t)); 18 | } 19 | 20 | static inline void chunkmemset_8(uint8_t *from, chunk_t *chunk) { 21 | memcpy(chunk, from, sizeof(uint64_t)); 22 | } 23 | 24 | static inline void loadchunk(uint8_t const *s, chunk_t *chunk) { 25 | memcpy(chunk, (uint8_t *)s, sizeof(uint64_t)); 26 | } 27 | 28 | static inline void storechunk(uint8_t *out, chunk_t *chunk) { 29 | memcpy(out, chunk, sizeof(uint64_t)); 30 | } 31 | 32 | #define CHUNKSIZE chunksize_c 33 | #define CHUNKCOPY chunkcopy_c 34 | #define CHUNKUNROLL chunkunroll_c 35 | #define CHUNKMEMSET chunkmemset_c 36 | #define CHUNKMEMSET_SAFE chunkmemset_safe_c 37 | 38 | #include "chunkset_tpl.h" 39 | -------------------------------------------------------------------------------- /ext/zlib-ng/cmake/detect-coverage.cmake: -------------------------------------------------------------------------------- 1 | # detect-coverage.cmake -- Detect supported compiler coverage flags 2 | # Licensed under the Zlib license, see LICENSE.md for details 3 | 4 | macro(add_code_coverage) 5 | # Check for -coverage flag support for Clang/GCC 6 | if(CMAKE_VERSION VERSION_LESS 3.14) 7 | set(CMAKE_REQUIRED_LIBRARIES -lgcov) 8 | else() 9 | set(CMAKE_REQUIRED_LINK_OPTIONS -coverage) 10 | endif() 11 | check_c_compiler_flag(-coverage HAVE_COVERAGE) 12 | set(CMAKE_REQUIRED_LIBRARIES) 13 | set(CMAKE_REQUIRED_LINK_OPTIONS) 14 | 15 | if(HAVE_COVERAGE) 16 | add_compile_options(-coverage) 17 | add_link_options(-coverage) 18 | message(STATUS "Code coverage enabled using: -coverage") 19 | else() 20 | # Some versions of GCC don't support -coverage shorthand 21 | if(CMAKE_VERSION VERSION_LESS 3.14) 22 | set(CMAKE_REQUIRED_LIBRARIES -lgcov) 23 | else() 24 | set(CMAKE_REQUIRED_LINK_OPTIONS -lgcov -fprofile-arcs) 25 | endif() 26 | check_c_compiler_flag("-ftest-coverage -fprofile-arcs -fprofile-values" HAVE_TEST_COVERAGE) 27 | set(CMAKE_REQUIRED_LIBRARIES) 28 | set(CMAKE_REQUIRED_LINK_OPTIONS) 29 | 30 | if(HAVE_TEST_COVERAGE) 31 | add_compile_options(-ftest-coverage -fprofile-arcs -fprofile-values) 32 | add_link_options(-lgcov -fprofile-arcs) 33 | message(STATUS "Code coverage enabled using: -ftest-coverage") 34 | else() 35 | message(WARNING "Compiler does not support code coverage") 36 | set(WITH_CODE_COVERAGE OFF) 37 | endif() 38 | endif() 39 | 40 | # Set optimization level to zero for code coverage builds 41 | if (WITH_CODE_COVERAGE) 42 | # Use CMake compiler flag variables due to add_compile_options failure on Windows GCC 43 | set(CMAKE_C_FLAGS "-O0 ${CMAKE_C_FLAGS}") 44 | set(CMAKE_CXX_FLAGS "-O0 ${CMAKE_CXX_FLAGS}") 45 | endif() 46 | endmacro() 47 | -------------------------------------------------------------------------------- /ext/zlib-ng/cmake/fallback-macros.cmake: -------------------------------------------------------------------------------- 1 | # fallback-macros.cmake -- CMake fallback macros 2 | # Copyright (C) 2022 Nathan Moinvaziri 3 | # Licensed under the Zlib license, see LICENSE.md for details 4 | 5 | # CMake less than version 3.5.2 6 | if(NOT COMMAND add_compile_options) 7 | macro(add_compile_options options) 8 | string(APPEND CMAKE_C_FLAGS ${options}) 9 | string(APPEND CMAKE_CXX_FLAGS ${options}) 10 | endmacro() 11 | endif() 12 | 13 | # CMake less than version 3.14 14 | if(NOT COMMAND add_link_options) 15 | macro(add_link_options options) 16 | string(APPEND CMAKE_EXE_LINKER_FLAGS ${options}) 17 | string(APPEND CMAKE_SHARED_LINKER_FLAGS ${options}) 18 | endmacro() 19 | endif() 20 | -------------------------------------------------------------------------------- /ext/zlib-ng/cmake/toolchain-aarch64.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR aarch64) 3 | set(CMAKE_SYSTEM_VERSION 1) 4 | 5 | set(CMAKE_C_COMPILER_TARGET "aarch64-linux-gnu") 6 | set(CMAKE_CXX_COMPILER_TARGET "aarch64-linux-gnu") 7 | 8 | set(CMAKE_CROSSCOMPILING TRUE) 9 | set(CMAKE_CROSSCOMPILING_EMULATOR qemu-aarch64 -L /usr/${CMAKE_C_COMPILER_TARGET}/) 10 | 11 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | 15 | find_program(C_COMPILER_FULL_PATH NAMES ${CMAKE_C_COMPILER_TARGET}-gcc) 16 | if(NOT C_COMPILER_FULL_PATH) 17 | message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") 18 | endif() 19 | set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) 20 | 21 | find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++) 22 | if(CXX_COMPILER_FULL_PATH) 23 | set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) 24 | endif() 25 | -------------------------------------------------------------------------------- /ext/zlib-ng/cmake/toolchain-arm.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR arm) 3 | set(CMAKE_SYSTEM_VERSION 1) 4 | 5 | if(NOT DEFINED CMAKE_C_COMPILER_TARGET) 6 | set(CMAKE_C_COMPILER_TARGET arm-linux-gnueabi) 7 | endif() 8 | if(NOT DEFINED CMAKE_CXX_COMPILER_TARGET) 9 | set(CMAKE_CXX_COMPILER_TARGET arm-linux-gnueabi) 10 | endif() 11 | 12 | set(CMAKE_CROSSCOMPILING TRUE) 13 | set(CMAKE_CROSSCOMPILING_EMULATOR qemu-arm -L /usr/${CMAKE_C_COMPILER_TARGET}/) 14 | 15 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 16 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 17 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 18 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 19 | 20 | find_program(C_COMPILER_FULL_PATH NAMES ${CMAKE_C_COMPILER_TARGET}-gcc) 21 | if(NOT C_COMPILER_FULL_PATH) 22 | message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") 23 | endif() 24 | set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) 25 | 26 | find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++) 27 | if(CXX_COMPILER_FULL_PATH) 28 | set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) 29 | endif() 30 | -------------------------------------------------------------------------------- /ext/zlib-ng/cmake/toolchain-armhf.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR arm) 3 | set(CMAKE_SYSTEM_VERSION 1) 4 | 5 | set(CMAKE_C_COMPILER_TARGET arm-linux-gnueabihf) 6 | set(CMAKE_CXX_COMPILER_TARGET arm-linux-gnueabihf) 7 | 8 | set(CMAKE_CROSSCOMPILING TRUE) 9 | set(CMAKE_CROSSCOMPILING_EMULATOR qemu-arm -L /usr/${CMAKE_C_COMPILER_TARGET}/) 10 | 11 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 15 | 16 | find_program(C_COMPILER_FULL_PATH NAMES ${CMAKE_C_COMPILER_TARGET}-gcc) 17 | if(NOT C_COMPILER_FULL_PATH) 18 | message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") 19 | endif() 20 | set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) 21 | 22 | find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++) 23 | if(CXX_COMPILER_FULL_PATH) 24 | set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) 25 | endif() 26 | -------------------------------------------------------------------------------- /ext/zlib-ng/cmake/toolchain-mingw-i686.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Windows) 2 | 3 | set(CMAKE_C_COMPILER_TARGET i686-w64-mingw32) 4 | set(CMAKE_CXX_COMPILER_TARGET i686-w64-mingw32) 5 | set(CMAKE_RC_COMPILER_TARGET i686-w64-mingw32) 6 | 7 | set(CMAKE_CROSSCOMPILING TRUE) 8 | set(CMAKE_CROSSCOMPILING_EMULATOR wine) 9 | 10 | set(CMAKE_FIND_ROOT_PATH /usr/i686-w64-mingw32) 11 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | 15 | # Prefer posix gcc variant for gtest pthread support 16 | find_program(C_COMPILER_FULL_PATH NAMES 17 | ${CMAKE_C_COMPILER_TARGET}-gcc-posix 18 | ${CMAKE_C_COMPILER_TARGET}-gcc) 19 | if(NOT C_COMPILER_FULL_PATH) 20 | message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") 21 | endif() 22 | set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) 23 | 24 | find_program(CXX_COMPILER_FULL_PATH NAMES 25 | ${CMAKE_CXX_COMPILER_TARGET}-g++-posix 26 | ${CMAKE_CXX_COMPILER_TARGET}-g++) 27 | if(CXX_COMPILER_FULL_PATH) 28 | set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) 29 | endif() 30 | 31 | find_program(RC_COMPILER_FULL_PATH NAMES 32 | ${CMAKE_RC_COMPILER_TARGET}-windres) 33 | if(RC_COMPILER_FULL_PATH) 34 | set(CMAKE_RC_COMPILER ${RC_COMPILER_FULL_PATH}) 35 | endif() 36 | -------------------------------------------------------------------------------- /ext/zlib-ng/cmake/toolchain-mingw-x86_64.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Windows) 2 | 3 | set(CMAKE_C_COMPILER_TARGET x86_64-w64-mingw32) 4 | set(CMAKE_CXX_COMPILER_TARGET x86_64-w64-mingw32) 5 | set(CMAKE_RC_COMPILER_TARGET x86_64-w64-mingw32) 6 | 7 | set(CMAKE_CROSSCOMPILING TRUE) 8 | set(CMAKE_CROSSCOMPILING_EMULATOR wine) 9 | 10 | set(CMAKE_FIND_ROOT_PATH /usr/x86_64-w64-mingw32) 11 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | 15 | # Prefer posix gcc variant for gtest pthread support 16 | find_program(C_COMPILER_FULL_PATH NAMES 17 | ${CMAKE_C_COMPILER_TARGET}-gcc-posix 18 | ${CMAKE_C_COMPILER_TARGET}-gcc) 19 | if(NOT C_COMPILER_FULL_PATH) 20 | message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") 21 | endif() 22 | set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) 23 | 24 | find_program(CXX_COMPILER_FULL_PATH NAMES 25 | ${CMAKE_CXX_COMPILER_TARGET}-g++-posix 26 | ${CMAKE_CXX_COMPILER_TARGET}-g++) 27 | if(CXX_COMPILER_FULL_PATH) 28 | set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) 29 | endif() 30 | 31 | find_program(RC_COMPILER_FULL_PATH NAMES ${CMAKE_RC_COMPILER_TARGET}-windres) 32 | if(RC_COMPILER_FULL_PATH) 33 | set(CMAKE_RC_COMPILER ${RC_COMPILER_FULL_PATH}) 34 | endif() 35 | -------------------------------------------------------------------------------- /ext/zlib-ng/cmake/toolchain-powerpc.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR powerpc) 3 | set(CMAKE_SYSTEM_VERSION 1) 4 | 5 | set(CMAKE_C_COMPILER_TARGET powerpc-linux-gnu) 6 | set(CMAKE_CXX_COMPILER_TARGET powerpc-linux-gnu) 7 | 8 | set(CMAKE_CROSSCOMPILING TRUE) 9 | set(CMAKE_CROSSCOMPILING_EMULATOR qemu-ppc -cpu 7400 -L /usr/${CMAKE_C_COMPILER_TARGET}/) 10 | 11 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 15 | 16 | find_program(C_COMPILER_FULL_PATH NAMES ${CMAKE_C_COMPILER_TARGET}-gcc) 17 | if(NOT C_COMPILER_FULL_PATH) 18 | message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") 19 | endif() 20 | set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) 21 | 22 | find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++) 23 | if(CXX_COMPILER_FULL_PATH) 24 | set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) 25 | endif() 26 | -------------------------------------------------------------------------------- /ext/zlib-ng/cmake/toolchain-powerpc64.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR ppc64) 3 | set(CMAKE_SYSTEM_VERSION 1) 4 | 5 | set(CMAKE_C_COMPILER_TARGET powerpc64-linux-gnu) 6 | set(CMAKE_CXX_COMPILER_TARGET powerpc64-linux-gnu) 7 | 8 | set(CMAKE_CROSSCOMPILING TRUE) 9 | set(CMAKE_CROSSCOMPILING_EMULATOR qemu-ppc64 -cpu power8 -L /usr/${CMAKE_C_COMPILER_TARGET}/) 10 | 11 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 15 | 16 | find_program(C_COMPILER_FULL_PATH NAMES ${CMAKE_C_COMPILER_TARGET}-gcc) 17 | if(NOT C_COMPILER_FULL_PATH) 18 | message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") 19 | endif() 20 | set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) 21 | 22 | find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++) 23 | if(CXX_COMPILER_FULL_PATH) 24 | set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) 25 | endif() 26 | -------------------------------------------------------------------------------- /ext/zlib-ng/cmake/toolchain-powerpc64le.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR ppc64le) 3 | set(CMAKE_SYSTEM_VERSION 1) 4 | 5 | set(CMAKE_C_COMPILER_TARGET powerpc64le-linux-gnu) 6 | set(CMAKE_CXX_COMPILER_TARGET powerpc64le-linux-gnu) 7 | 8 | set(CMAKE_CROSSCOMPILING TRUE) 9 | set(CMAKE_CROSSCOMPILING_EMULATOR qemu-ppc64le -cpu power8 -L /usr/${CMAKE_C_COMPILER_TARGET}/) 10 | 11 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 15 | 16 | find_program(C_COMPILER_FULL_PATH NAMES ${CMAKE_C_COMPILER_TARGET}-gcc) 17 | if(NOT C_COMPILER_FULL_PATH) 18 | message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") 19 | endif() 20 | set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) 21 | 22 | find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++) 23 | if(CXX_COMPILER_FULL_PATH) 24 | set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) 25 | endif() 26 | -------------------------------------------------------------------------------- /ext/zlib-ng/cmake/toolchain-s390x.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR s390x) 3 | set(CMAKE_SYSTEM_VERSION 1) 4 | 5 | set(CMAKE_C_COMPILER_TARGET s390x-linux-gnu) 6 | set(CMAKE_CXX_COMPILER_TARGET s390x-linux-gnu) 7 | 8 | set(CMAKE_CROSSCOMPILING TRUE) 9 | set(CMAKE_CROSSCOMPILING_EMULATOR qemu-s390x -L /usr/${CMAKE_C_COMPILER_TARGET}/) 10 | 11 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 15 | 16 | find_program(C_COMPILER_FULL_PATH NAMES ${CMAKE_C_COMPILER_TARGET}-gcc) 17 | if(NOT C_COMPILER_FULL_PATH) 18 | message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") 19 | endif() 20 | set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) 21 | 22 | find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++) 23 | if(CXX_COMPILER_FULL_PATH) 24 | set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) 25 | endif() 26 | -------------------------------------------------------------------------------- /ext/zlib-ng/cmake/toolchain-sparc64.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_SYSTEM_NAME Linux) 2 | set(CMAKE_SYSTEM_PROCESSOR sparc64) 3 | set(CMAKE_SYSTEM_VERSION 1) 4 | 5 | set(CMAKE_C_COMPILER_TARGET sparc64-linux-gnu) 6 | set(CMAKE_CXX_COMPILER_TARGET sparc64-linux-gnu) 7 | 8 | set(CMAKE_CROSSCOMPILING TRUE) 9 | set(CMAKE_CROSSCOMPILING_EMULATOR qemu-sparc64 -L /usr/${CMAKE_C_COMPILER_TARGET}/) 10 | 11 | set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 12 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 13 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 14 | set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY) 15 | 16 | find_program(C_COMPILER_FULL_PATH NAMES ${CMAKE_C_COMPILER_TARGET}-gcc) 17 | if(NOT C_COMPILER_FULL_PATH) 18 | message(FATAL_ERROR "Cross-compiler for ${CMAKE_C_COMPILER_TARGET} not found") 19 | endif() 20 | set(CMAKE_C_COMPILER ${C_COMPILER_FULL_PATH}) 21 | 22 | find_program(CXX_COMPILER_FULL_PATH NAMES g++-${CMAKE_CXX_COMPILER_TARGET} ${CMAKE_CXX_COMPILER_TARGET}-g++) 23 | if(CXX_COMPILER_FULL_PATH) 24 | set(CMAKE_CXX_COMPILER ${CXX_COMPILER_FULL_PATH}) 25 | endif() 26 | -------------------------------------------------------------------------------- /ext/zlib-ng/cpu_features.c: -------------------------------------------------------------------------------- 1 | /* cpu_features.c -- CPU architecture feature check 2 | * Copyright (C) 2017 Hans Kristian Rosbach 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include "zbuild.h" 7 | 8 | #include "cpu_features.h" 9 | 10 | Z_INTERNAL void cpu_check_features(void) { 11 | static int features_checked = 0; 12 | if (features_checked) 13 | return; 14 | #if defined(X86_FEATURES) 15 | x86_check_features(); 16 | #elif defined(ARM_FEATURES) 17 | arm_check_features(); 18 | #elif defined(PPC_FEATURES) || defined(POWER_FEATURES) 19 | power_check_features(); 20 | #elif defined(S390_FEATURES) 21 | PREFIX(s390_check_features)(); 22 | #endif 23 | features_checked = 1; 24 | } 25 | -------------------------------------------------------------------------------- /ext/zlib-ng/crc32_braid_comb.c: -------------------------------------------------------------------------------- 1 | /* crc32_braid_comb.c -- compute the CRC-32 of a data stream 2 | * Copyright (C) 1995-2022 Mark Adler 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | * 5 | * This interleaved implementation of a CRC makes use of pipelined multiple 6 | * arithmetic-logic units, commonly found in modern CPU cores. It is due to 7 | * Kadatch and Jenkins (2010). See doc/crc-doc.1.0.pdf in this distribution. 8 | */ 9 | 10 | #include "zbuild.h" 11 | #include "zutil.h" 12 | #include "crc32_braid_p.h" 13 | #include "crc32_braid_tbl.h" 14 | #include "crc32_braid_comb_p.h" 15 | 16 | /* ========================================================================= */ 17 | static uint32_t crc32_combine_(uint32_t crc1, uint32_t crc2, z_off64_t len2) { 18 | return multmodp(x2nmodp(len2, 3), crc1) ^ crc2; 19 | } 20 | static uint32_t crc32_combine_gen_(z_off64_t len2) { 21 | return x2nmodp(len2, 3); 22 | } 23 | static uint32_t crc32_combine_op_(uint32_t crc1, uint32_t crc2, const uint32_t op) { 24 | return multmodp(op, crc1) ^ crc2; 25 | } 26 | 27 | /* ========================================================================= */ 28 | 29 | #ifdef ZLIB_COMPAT 30 | unsigned long Z_EXPORT PREFIX(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off_t len2) { 31 | return (unsigned long)crc32_combine_((uint32_t)crc1, (uint32_t)crc2, len2); 32 | } 33 | unsigned long Z_EXPORT PREFIX4(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off64_t len2) { 34 | return (unsigned long)crc32_combine_((uint32_t)crc1, (uint32_t)crc2, len2); 35 | } 36 | unsigned long Z_EXPORT PREFIX(crc32_combine_gen)(z_off_t len2) { 37 | return crc32_combine_gen_(len2); 38 | } 39 | unsigned long Z_EXPORT PREFIX4(crc32_combine_gen)(z_off64_t len2) { 40 | return crc32_combine_gen_(len2); 41 | } 42 | unsigned long Z_EXPORT PREFIX(crc32_combine_op)(unsigned long crc1, unsigned long crc2, const unsigned long op) { 43 | return (unsigned long)crc32_combine_op_((uint32_t)crc1, (uint32_t)crc2, (uint32_t)op); 44 | } 45 | #else 46 | uint32_t Z_EXPORT PREFIX4(crc32_combine)(uint32_t crc1, uint32_t crc2, z_off64_t len2) { 47 | return crc32_combine_(crc1, crc2, len2); 48 | } 49 | uint32_t Z_EXPORT PREFIX(crc32_combine_gen)(z_off64_t len2) { 50 | return crc32_combine_gen_(len2); 51 | } 52 | uint32_t Z_EXPORT PREFIX(crc32_combine_op)(uint32_t crc1, uint32_t crc2, const uint32_t op) { 53 | return crc32_combine_op_(crc1, crc2, op); 54 | } 55 | #endif 56 | 57 | /* ========================================================================= */ 58 | -------------------------------------------------------------------------------- /ext/zlib-ng/crc32_braid_comb_p.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC32_BRAID_COMB_P_H_ 2 | #define CRC32_BRAID_COMB_P_H_ 3 | 4 | /* 5 | Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial, 6 | reflected. For speed, this requires that a not be zero. 7 | */ 8 | static uint32_t multmodp(uint32_t a, uint32_t b) { 9 | uint32_t m, p; 10 | 11 | m = (uint32_t)1 << 31; 12 | p = 0; 13 | for (;;) { 14 | if (a & m) { 15 | p ^= b; 16 | if ((a & (m - 1)) == 0) 17 | break; 18 | } 19 | m >>= 1; 20 | b = b & 1 ? (b >> 1) ^ POLY : b >> 1; 21 | } 22 | return p; 23 | } 24 | 25 | /* 26 | Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been 27 | initialized. 28 | */ 29 | static uint32_t x2nmodp(z_off64_t n, unsigned k) { 30 | uint32_t p; 31 | 32 | p = (uint32_t)1 << 31; /* x^0 == 1 */ 33 | while (n) { 34 | if (n & 1) 35 | p = multmodp(x2n_table[k & 31], p); 36 | n >>= 1; 37 | k++; 38 | } 39 | return p; 40 | } 41 | 42 | #endif /* CRC32_BRAID_COMB_P_H_ */ 43 | -------------------------------------------------------------------------------- /ext/zlib-ng/crc32_braid_p.h: -------------------------------------------------------------------------------- 1 | #ifndef CRC32_BRAID_P_H_ 2 | #define CRC32_BRAID_P_H_ 3 | 4 | #include "zbuild.h" 5 | #include "zendian.h" 6 | 7 | /* Define N */ 8 | #ifdef Z_TESTN 9 | # define N Z_TESTN 10 | #else 11 | # define N 5 12 | #endif 13 | #if N < 1 || N > 6 14 | # error N must be in 1..6 15 | #endif 16 | 17 | /* 18 | Define W and the associated z_word_t type. If W is not defined, then a 19 | braided calculation is not used, and the associated tables and code are not 20 | compiled. 21 | */ 22 | #ifdef Z_TESTW 23 | # if Z_TESTW-1 != -1 24 | # define W Z_TESTW 25 | # endif 26 | #else 27 | # ifndef W 28 | # if defined(__x86_64__) || defined(__aarch64__) || defined(__powerpc64__) 29 | # define W 8 30 | # else 31 | # define W 4 32 | # endif 33 | # endif 34 | #endif 35 | #ifdef W 36 | # if W == 8 37 | typedef uint64_t z_word_t; 38 | # else 39 | # undef W 40 | # define W 4 41 | typedef uint32_t z_word_t; 42 | # endif 43 | #endif 44 | 45 | /* CRC polynomial. */ 46 | #define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */ 47 | 48 | extern uint32_t crc32_braid(uint32_t crc, const uint8_t *buf, uint64_t len); 49 | 50 | #endif /* CRC32_BRAID_P_H_ */ 51 | -------------------------------------------------------------------------------- /ext/zlib-ng/crc32_fold.c: -------------------------------------------------------------------------------- 1 | /* crc32_fold.c -- crc32 folding interface 2 | * Copyright (C) 2021 Nathan Moinvaziri 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | #include "zbuild.h" 6 | #include "functable.h" 7 | 8 | #include "crc32_fold.h" 9 | 10 | Z_INTERNAL uint32_t crc32_fold_reset_c(crc32_fold *crc) { 11 | crc->value = CRC32_INITIAL_VALUE; 12 | return crc->value; 13 | } 14 | 15 | Z_INTERNAL void crc32_fold_copy_c(crc32_fold *crc, uint8_t *dst, const uint8_t *src, uint64_t len) { 16 | crc->value = functable.crc32(crc->value, src, len); 17 | while (len > SIZE_MAX) { 18 | memcpy(dst, src, SIZE_MAX); 19 | dst += SIZE_MAX; 20 | src += SIZE_MAX; 21 | len -= SIZE_MAX; 22 | } 23 | if (len) { 24 | memcpy(dst, src, (size_t)len); 25 | } 26 | } 27 | 28 | Z_INTERNAL void crc32_fold_c(crc32_fold *crc, const uint8_t *src, uint64_t len, uint32_t init_crc) { 29 | /* Note: while this is basically the same thing as the vanilla CRC function, we still need 30 | * a functable entry for it so that we can generically dispatch to this function with the 31 | * same arguments for the versions that _do_ do a folding CRC but we don't want a copy. The 32 | * init_crc is an unused argument in this context */ 33 | Z_UNUSED(init_crc); 34 | crc->value = functable.crc32(crc->value, src, len); 35 | } 36 | 37 | Z_INTERNAL uint32_t crc32_fold_final_c(crc32_fold *crc) { 38 | return crc->value; 39 | } 40 | -------------------------------------------------------------------------------- /ext/zlib-ng/crc32_fold.h: -------------------------------------------------------------------------------- 1 | /* crc32_fold.h -- crc32 folding interface 2 | * Copyright (C) 2021 Nathan Moinvaziri 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | #ifndef CRC32_FOLD_H_ 6 | #define CRC32_FOLD_H_ 7 | 8 | #define CRC32_FOLD_BUFFER_SIZE (16 * 4) 9 | /* sizeof(__m128i) * (4 folds) */ 10 | 11 | typedef struct crc32_fold_s { 12 | uint8_t fold[CRC32_FOLD_BUFFER_SIZE]; 13 | uint32_t value; 14 | } crc32_fold; 15 | 16 | Z_INTERNAL uint32_t crc32_fold_reset_c(crc32_fold *crc); 17 | Z_INTERNAL void crc32_fold_copy_c(crc32_fold *crc, uint8_t *dst, const uint8_t *src, uint64_t len); 18 | Z_INTERNAL void crc32_fold_c(crc32_fold *crc, const uint8_t *src, uint64_t len, uint32_t init_crc); 19 | Z_INTERNAL uint32_t crc32_fold_final_c(crc32_fold *crc); 20 | 21 | #endif 22 | -------------------------------------------------------------------------------- /ext/zlib-ng/deflate_huff.c: -------------------------------------------------------------------------------- 1 | /* deflate_huff.c -- compress data using huffman encoding only strategy 2 | * 3 | * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler 4 | * For conditions of distribution and use, see copyright notice in zlib.h 5 | */ 6 | 7 | #include "zbuild.h" 8 | #include "deflate.h" 9 | #include "deflate_p.h" 10 | #include "functable.h" 11 | 12 | /* =========================================================================== 13 | * For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table. 14 | * (It will be regenerated if this run of deflate switches away from Huffman.) 15 | */ 16 | Z_INTERNAL block_state deflate_huff(deflate_state *s, int flush) { 17 | int bflush = 0; /* set if current block must be flushed */ 18 | 19 | for (;;) { 20 | /* Make sure that we have a literal to write. */ 21 | if (s->lookahead == 0) { 22 | fill_window(s); 23 | if (s->lookahead == 0) { 24 | if (flush == Z_NO_FLUSH) 25 | return need_more; 26 | break; /* flush the current block */ 27 | } 28 | } 29 | 30 | /* Output a literal byte */ 31 | bflush = zng_tr_tally_lit(s, s->window[s->strstart]); 32 | s->lookahead--; 33 | s->strstart++; 34 | if (bflush) 35 | FLUSH_BLOCK(s, 0); 36 | } 37 | s->insert = 0; 38 | if (flush == Z_FINISH) { 39 | FLUSH_BLOCK(s, 1); 40 | return finish_done; 41 | } 42 | if (s->sym_next) 43 | FLUSH_BLOCK(s, 0); 44 | return block_done; 45 | } 46 | -------------------------------------------------------------------------------- /ext/zlib-ng/doc/crc-doc.1.0.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/ext/zlib-ng/doc/crc-doc.1.0.pdf -------------------------------------------------------------------------------- /ext/zlib-ng/doc/crc-pclmulqdq.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/ext/zlib-ng/doc/crc-pclmulqdq.pdf -------------------------------------------------------------------------------- /ext/zlib-ng/functable.h: -------------------------------------------------------------------------------- 1 | /* functable.h -- Struct containing function pointers to optimized functions 2 | * Copyright (C) 2017 Hans Kristian Rosbach 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #ifndef FUNCTABLE_H_ 7 | #define FUNCTABLE_H_ 8 | 9 | #include "deflate.h" 10 | #include "crc32_fold.h" 11 | #include "adler32_fold.h" 12 | 13 | struct functable_s { 14 | uint32_t (* adler32) (uint32_t adler, const uint8_t *buf, uint64_t len); 15 | uint32_t (* adler32_fold_copy) (uint32_t adler, uint8_t *dst, const uint8_t *src, uint64_t len); 16 | uint32_t (* crc32) (uint32_t crc, const uint8_t *buf, uint64_t len); 17 | uint32_t (* crc32_fold_reset) (crc32_fold *crc); 18 | void (* crc32_fold_copy) (crc32_fold *crc, uint8_t *dst, const uint8_t *src, uint64_t len); 19 | void (* crc32_fold) (crc32_fold *crc, const uint8_t *src, uint64_t len, uint32_t init_crc); 20 | uint32_t (* crc32_fold_final) (crc32_fold *crc); 21 | uint32_t (* compare256) (const uint8_t *src0, const uint8_t *src1); 22 | uint32_t (* chunksize) (void); 23 | uint8_t* (* chunkcopy) (uint8_t *out, uint8_t const *from, unsigned len); 24 | uint8_t* (* chunkunroll) (uint8_t *out, unsigned *dist, unsigned *len); 25 | uint8_t* (* chunkmemset) (uint8_t *out, unsigned dist, unsigned len); 26 | uint8_t* (* chunkmemset_safe) (uint8_t *out, unsigned dist, unsigned len, unsigned left); 27 | void (* insert_string) (deflate_state *const s, uint32_t str, uint32_t count); 28 | uint32_t (* longest_match) (deflate_state *const s, Pos cur_match); 29 | uint32_t (* longest_match_slow) (deflate_state *const s, Pos cur_match); 30 | Pos (* quick_insert_string)(deflate_state *const s, uint32_t str); 31 | void (* slide_hash) (deflate_state *s); 32 | uint32_t (* update_hash) (deflate_state *const s, uint32_t h, uint32_t val); 33 | }; 34 | 35 | Z_INTERNAL extern Z_TLS struct functable_s functable; 36 | 37 | #endif 38 | -------------------------------------------------------------------------------- /ext/zlib-ng/inffast.h: -------------------------------------------------------------------------------- 1 | #ifndef INFFAST_H_ 2 | #define INFFAST_H_ 3 | /* inffast.h -- header to use inffast.c 4 | * Copyright (C) 1995-2003, 2010 Mark Adler 5 | * For conditions of distribution and use, see copyright notice in zlib.h 6 | */ 7 | 8 | /* WARNING: this file should *not* be used by applications. It is 9 | part of the implementation of the compression library and is 10 | subject to change. Applications should only use zlib.h. 11 | */ 12 | 13 | void Z_INTERNAL zng_inflate_fast(PREFIX3(stream) *strm, unsigned long start); 14 | 15 | #define INFLATE_FAST_MIN_HAVE 8 16 | #define INFLATE_FAST_MIN_LEFT 258 17 | 18 | #endif /* INFFAST_H_ */ 19 | -------------------------------------------------------------------------------- /ext/zlib-ng/insert_string.c: -------------------------------------------------------------------------------- 1 | /* insert_string.c -- insert_string integer hash variant 2 | * 3 | * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler 4 | * For conditions of distribution and use, see copyright notice in zlib.h 5 | * 6 | */ 7 | 8 | #include "zbuild.h" 9 | #include "deflate.h" 10 | 11 | #define HASH_SLIDE 16 12 | 13 | #define HASH_CALC(s, h, val) h = ((val * 2654435761U) >> HASH_SLIDE); 14 | #define HASH_CALC_VAR h 15 | #define HASH_CALC_VAR_INIT uint32_t h = 0 16 | 17 | #define UPDATE_HASH update_hash_c 18 | #define INSERT_STRING insert_string_c 19 | #define QUICK_INSERT_STRING quick_insert_string_c 20 | 21 | #include "insert_string_tpl.h" 22 | -------------------------------------------------------------------------------- /ext/zlib-ng/insert_string_roll.c: -------------------------------------------------------------------------------- 1 | /* insert_string_roll.c -- insert_string rolling hash variant 2 | * 3 | * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler 4 | * For conditions of distribution and use, see copyright notice in zlib.h 5 | * 6 | */ 7 | 8 | #include "zbuild.h" 9 | #include "deflate.h" 10 | 11 | #define HASH_SLIDE 5 12 | 13 | #define HASH_CALC(s, h, val) h = ((h << HASH_SLIDE) ^ ((uint8_t)val)) 14 | #define HASH_CALC_VAR s->ins_h 15 | #define HASH_CALC_VAR_INIT 16 | #define HASH_CALC_READ val = strstart[0] 17 | #define HASH_CALC_MASK (32768u - 1u) 18 | #define HASH_CALC_OFFSET (STD_MIN_MATCH-1) 19 | 20 | #define UPDATE_HASH update_hash_roll 21 | #define INSERT_STRING insert_string_roll 22 | #define QUICK_INSERT_STRING quick_insert_string_roll 23 | 24 | #include "insert_string_tpl.h" 25 | -------------------------------------------------------------------------------- /ext/zlib-ng/slide_hash.c: -------------------------------------------------------------------------------- 1 | /* slide_hash.c -- slide hash table C implementation 2 | * 3 | * Copyright (C) 1995-2013 Jean-loup Gailly and Mark Adler 4 | * For conditions of distribution and use, see copyright notice in zlib.h 5 | */ 6 | 7 | #include "zbuild.h" 8 | #include "deflate.h" 9 | 10 | /* =========================================================================== 11 | * Slide the hash table when sliding the window down (could be avoided with 32 12 | * bit values at the expense of memory usage). We slide even when level == 0 to 13 | * keep the hash table consistent if we switch back to level > 0 later. 14 | */ 15 | static inline void slide_hash_c_chain(Pos *table, uint32_t entries, uint16_t wsize) { 16 | #ifdef NOT_TWEAK_COMPILER 17 | table += entries; 18 | do { 19 | unsigned m; 20 | m = *--table; 21 | *table = (Pos)(m >= wsize ? m-wsize : 0); 22 | /* If entries is not on any hash chain, prev[entries] is garbage but 23 | * its value will never be used. 24 | */ 25 | } while (--entries); 26 | #else 27 | { 28 | /* As of I make this change, gcc (4.8.*) isn't able to vectorize 29 | * this hot loop using saturated-subtraction on x86-64 architecture. 30 | * To avoid this defect, we can change the loop such that 31 | * o. the pointer advance forward, and 32 | * o. demote the variable 'm' to be local to the loop, and 33 | * choose type "Pos" (instead of 'unsigned int') for the 34 | * variable to avoid unnecessary zero-extension. 35 | */ 36 | unsigned int i; 37 | Pos *q = table; 38 | for (i = 0; i < entries; i++) { 39 | Pos m = *q; 40 | Pos t = (Pos)wsize; 41 | *q++ = (Pos)(m >= t ? m-t: 0); 42 | } 43 | } 44 | #endif /* NOT_TWEAK_COMPILER */ 45 | } 46 | 47 | Z_INTERNAL void slide_hash_c(deflate_state *s) { 48 | uint16_t wsize = (uint16_t)s->w_size; 49 | 50 | slide_hash_c_chain(s->head, HASH_SIZE, wsize); 51 | slide_hash_c_chain(s->prev, wsize, wsize); 52 | } 53 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/.gitignore: -------------------------------------------------------------------------------- 1 | # ignore Makefiles; they're all automatically generated 2 | Makefile 3 | /switchlevels 4 | /switchlevels.dSYM/ 5 | /switchlevels.exe 6 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/CVE-2002-0059/test.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/ext/zlib-ng/test/CVE-2002-0059/test.gz -------------------------------------------------------------------------------- /ext/zlib-ng/test/CVE-2004-0797/test.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/ext/zlib-ng/test/CVE-2004-0797/test.gz -------------------------------------------------------------------------------- /ext/zlib-ng/test/CVE-2005-1849/test.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/ext/zlib-ng/test/CVE-2005-1849/test.gz -------------------------------------------------------------------------------- /ext/zlib-ng/test/CVE-2005-2096/test.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/ext/zlib-ng/test/CVE-2005-2096/test.gz -------------------------------------------------------------------------------- /ext/zlib-ng/test/GH-361/test.txt: -------------------------------------------------------------------------------- 1 | .....-.u..|u....-...!..A.#?)9.._B..F..| 2 | 00000650 fa 13 88 89 2c 1f 81 0f e4 e9 ce 39 a0 87 2e 2e |....,......9....| 3 | 00000660 a5 0c 08 9c ec fc 88 6d 16 02 0a a0 3d fc 36 29 |.......m....=.6)| 4 | 00000670 8d f5 c3 ba 1d 07 f4 78 e1 a0 41 f9 89 15 a5 69 |.......x..A.... -------------------------------------------------------------------------------- /ext/zlib-ng/test/GH-364/test.bin: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/GH-382/defneg3.dat: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/ext/zlib-ng/test/GH-382/defneg3.dat -------------------------------------------------------------------------------- /ext/zlib-ng/test/GH-979/pigz-2.6.tar.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/ext/zlib-ng/test/GH-979/pigz-2.6.tar.gz -------------------------------------------------------------------------------- /ext/zlib-ng/test/README.md: -------------------------------------------------------------------------------- 1 | Contents 2 | -------- 3 | 4 | |Name|Description| 5 | |-|-| 6 | |[CVE-2003-0107](https://nvd.nist.gov/vuln/detail/CVE-2003-0107)|Buffer overflow in the gzprintf function, requires ZLIB_COMPAT| 7 | |[CVE-2002-0059](https://nvd.nist.gov/vuln/detail/CVE-2002-0059)|inflateEnd to release memory more than once| 8 | |[CVE-2004-0797](https://nvd.nist.gov/vuln/detail/CVE-2004-0797)|Error handling in inflate and inflateBack causes crash| 9 | |[CVE-2005-1849](https://nvd.nist.gov/vuln/detail/CVE-2005-1849)|inftrees.h bug causes crash| 10 | |[CVE-2005-2096](https://nvd.nist.gov/vuln/detail/CVE-2005-2096)|Buffer overflow when incomplete code description| 11 | |[CVE-2018-25032](https://nvd.nist.gov/vuln/detail/CVE-2018-25032)|Memory corruption when compressing if the input has many distant matches.| 12 | |[GH-361](https://github.com/zlib-ng/zlib-ng/issues/361)|Test case for overlapping matches| 13 | |[GH-364](https://github.com/zlib-ng/zlib-ng/issues/364)|Test case for switching compression levels| 14 | |[GH-382](https://github.com/zlib-ng/zlib-ng/issues/382)|Test case for deflateEnd returning -3 in deflate quick| 15 | 16 | Copying 17 | ------- 18 | 19 | Some of the files in _test_ are licensed differently: 20 | 21 | - test/data/fireworks.jpeg is Copyright 2013 Steinar H. Gunderson, and 22 | is licensed under the Creative Commons Attribution 3.0 license 23 | (CC-BY-3.0). See https://creativecommons.org/licenses/by/3.0/ 24 | for more information. 25 | 26 | - test/data/paper-100k.pdf is an excerpt (bytes 92160 to 194560) from the paper 27 | “Combinatorial Modeling of Chromatin Features Quantitatively Predicts DNA 28 | Replication Timing in _Drosophila_” by Federico Comoglio and Renato Paro, 29 | which is licensed under the CC-BY license. See 30 | https://www.ploscompbiol.org/static/license for more information. 31 | 32 | - test/data/lcet10.txt is from Project Gutenberg. It does not have expired 33 | copyright, but is still in the public domain according to the license information. 34 | (https://www.gutenberg.org/ebooks/53). 35 | 36 | - test/GH-382/defneg3.dat was the smallest file generated by Nathan Moinvaziri 37 | that reproduced GH-382. It is licensed under the terms of the zlib license. 38 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/abi/ignore: -------------------------------------------------------------------------------- 1 | # See https://sourceware.org/libabigail/manual/libabigail-concepts.html#suppression-specifications 2 | 3 | [suppress_type] 4 | name = internal_state 5 | 6 | [suppress_type] 7 | name_regexp = z_stream.* 8 | 9 | # Size varies with version number 10 | [suppress_variable] 11 | name = zlibng_string 12 | 13 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/abicheck.md: -------------------------------------------------------------------------------- 1 | ABI Compatibility test 2 | ---------------------- 3 | 4 | abicheck.sh uses libabigail to check ABI stability. 5 | It will abort if the current source 6 | tree has a change that breaks binary compatibility. 7 | 8 | This protects against the common scenario where: 9 | - an app is compiled against the current zlib-ng 10 | - the system package manager updates the zlib-ng shared library 11 | - the app now crashes because some symbol is 12 | missing or some public structure or parameter 13 | has changed type or size 14 | 15 | If run with --zlib-compat, it verifies that the 16 | current source tree generates a library that 17 | is ABI-compatible with the reference release 18 | of classic zlib. This ensures that building 19 | zlib-ng with --zlib-compat does what it says on the tin. 20 | 21 | abicheck.sh is not perfect, but it can catch 22 | many common compatibility issues. 23 | 24 | Cached files test/abi/*.abi 25 | --------------------------- 26 | 27 | Comparing to the old version of zlib (or zlib-ng) 28 | means someone has to check out and build 29 | the previous source tree and extract its .abi 30 | using abidw. This can be slow. 31 | 32 | If you don't mind the slowness, run abicheck.sh --refresh-if, 33 | and it will download and build the reference version 34 | and extract the .abi on the spot if needed. 35 | (FIXME: should this be the default?) 36 | 37 | On the next run, the reference .abi file will already be 38 | present, and that step will be skipped. 39 | It's stored in the tests/abi directory, 40 | in a file with the architecture and git hash in the name. 41 | 42 | If you're running continuous integration 43 | which clear out the source tree on each run, 44 | and you don't want your build machines 45 | constantly downloading and building the old 46 | version, you can check the .abi file into git. 47 | 48 | To make this easier, a helper script could be written to automatically build 49 | all the configurations tested by .github/workflows/abicheck.yml 50 | Then they could be checked into git en masse by a maintainer 51 | when a new platform is added or a new major version (which 52 | intentionally breaks backwards compatibility) is being prepared. 53 | 54 | Further reading 55 | --------------- 56 | 57 | - https://sourceware.org/libabigail/manual/ 58 | - https://developers.redhat.com/blog/2014/10/23/comparing-abis-for-compatibility-with-libabigail-part-1/ 59 | - https://developers.redhat.com/blog/2020/04/02/how-to-write-an-abi-compliance-checker-using-libabigail/ 60 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/add-subdirectory-project/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5.1) 2 | 3 | project(zlib-ng-add-subdirecory-test C) 4 | 5 | include(CTest) 6 | 7 | set(BUILD_SHARED_LIBS OFF) 8 | set(ZLIB_ENABLE_TESTS ON CACHE BOOL "Build test binaries" FORCE) 9 | 10 | add_subdirectory(../.. zlib-ng) 11 | 12 | add_executable(app main.c) 13 | target_link_libraries(app zlibstatic) 14 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/add-subdirectory-project/main.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include "zlib-ng.h" 3 | 4 | int main(void) { 5 | printf("zlib-ng: %s\n", ZLIBNG_VERSION); 6 | return 0; 7 | } 8 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/benchmarks/README.md: -------------------------------------------------------------------------------- 1 | ## Benchmarks 2 | These benchmarks are written using [Google Benchmark](https://github.com/google/benchmark). 3 | 4 | *Repetitions* 5 | 6 | To increase the number of times each benchmark iteration is run use: 7 | 8 | ``` 9 | --benchmark_repetitions=20 10 | ``` 11 | 12 | *Filters* 13 | 14 | To filter out which benchmarks are performed use: 15 | 16 | ``` 17 | --benchmark_filter="adler32*" 18 | ``` 19 | 20 | There are two different benchmarks, micro and macro. 21 | 22 | ### Benchmark benchmark_zlib 23 | These are microbenchmarks intended to test lower level subfunctions of the library. 24 | 25 | Benchmarks include impelementations of: 26 | - Adler32 27 | - CRC 28 | - 256 byte comparisons 29 | - SIMD accelerated "slide hash" routine 30 | 31 | By default these benchmarks report things on the nanosecond scale and are small enough 32 | to measure very minute diferences. 33 | 34 | ### Benchmark benchmark_zlib_apps 35 | These benchmarks measure applications of zlib as a whole. Currently the only examples 36 | are PNG encoding and decoding. The PNG encode and decode tests leveraging procedurally 37 | generated and highly compressible image data. 38 | 39 | Additionally, a test called `png_decode_realistic` that will decode any RGB 8 BPP encoded 40 | set of PNGs in the working directory under a directory named "test_pngs" with files named 41 | {0..1}.png. If these images do not exist, they will error out and the benchmark will move 42 | on to the next set of benchmarks. 43 | 44 | *benchmark_zlib_apps_alt* 45 | 46 | The user can compile a comparison benchmark application linking to any zlib-compatible 47 | implementation of his or her choosing. 48 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/benchmarks/benchmark_crc32.cc: -------------------------------------------------------------------------------- 1 | /* benchmark_crc32.cc -- benchmark crc32 variants 2 | * Copyright (C) 2022 Nathan Moinvaziri 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include 7 | #include 8 | 9 | #include 10 | 11 | extern "C" { 12 | # include "zbuild.h" 13 | # include "zutil_p.h" 14 | # include "cpu_features.h" 15 | } 16 | 17 | #define MAX_RANDOM_INTS (1024 * 1024) 18 | #define MAX_RANDOM_INTS_SIZE (MAX_RANDOM_INTS * sizeof(uint32_t)) 19 | 20 | class crc32: public benchmark::Fixture { 21 | private: 22 | uint32_t *random_ints; 23 | 24 | public: 25 | void SetUp(const ::benchmark::State& state) { 26 | random_ints = (uint32_t *)zng_alloc(MAX_RANDOM_INTS_SIZE); 27 | assert(random_ints != NULL); 28 | 29 | for (int32_t i = 0; i < MAX_RANDOM_INTS; i++) { 30 | random_ints[i] = rand(); 31 | } 32 | } 33 | 34 | void Bench(benchmark::State& state, crc32_func crc32) { 35 | uint32_t hash = 0; 36 | 37 | for (auto _ : state) { 38 | hash = crc32(hash, (const unsigned char *)random_ints, state.range(0)); 39 | } 40 | 41 | benchmark::DoNotOptimize(hash); 42 | } 43 | 44 | void TearDown(const ::benchmark::State& state) { 45 | zng_free(random_ints); 46 | } 47 | }; 48 | 49 | #define BENCHMARK_CRC32(name, fptr, support_flag) \ 50 | BENCHMARK_DEFINE_F(crc32, name)(benchmark::State& state) { \ 51 | if (!support_flag) { \ 52 | state.SkipWithError("CPU does not support " #name); \ 53 | } \ 54 | Bench(state, fptr); \ 55 | } \ 56 | BENCHMARK_REGISTER_F(crc32, name)->Range(1, MAX_RANDOM_INTS_SIZE); 57 | 58 | BENCHMARK_CRC32(braid, crc32_braid, 1); 59 | 60 | #ifdef ARM_ACLE_CRC_HASH 61 | BENCHMARK_CRC32(acle, crc32_acle, arm_cpu_has_crc32); 62 | #elif defined(POWER8_VSX_CRC32) 63 | BENCHMARK_CRC32(power8, crc32_power8, power_cpu_has_arch_2_07); 64 | #elif defined(S390_CRC32_VX) 65 | BENCHMARK_CRC32(vx, PREFIX(s390_crc32_vx), PREFIX(s390_cpu_has_vx)); 66 | #elif defined(X86_PCLMULQDQ_CRC) 67 | /* CRC32 fold does a memory copy while hashing */ 68 | BENCHMARK_CRC32(pclmulqdq, crc32_pclmulqdq, x86_cpu_has_pclmulqdq); 69 | #endif 70 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/benchmarks/benchmark_main.cc: -------------------------------------------------------------------------------- 1 | /* benchmark_main.cc -- benchmark suite main entry point 2 | * Copyright (C) 2022 Nathan Moinvaziri 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include 7 | 8 | #include 9 | 10 | #ifndef BUILD_ALT 11 | extern "C" { 12 | # include "zbuild.h" 13 | # include "cpu_features.h" 14 | } 15 | #endif 16 | 17 | int main(int argc, char** argv) { 18 | #ifndef BUILD_ALT 19 | cpu_check_features(); 20 | #endif 21 | 22 | ::benchmark::Initialize(&argc, argv); 23 | ::benchmark::RunSpecifiedBenchmarks(); 24 | 25 | return EXIT_SUCCESS; 26 | } 27 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/benchmarks/benchmark_png_encode.cc: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "benchmark_png_shared.h" 5 | 6 | #define IMWIDTH 1024 7 | #define IMHEIGHT 1024 8 | 9 | class png_encode: public benchmark::Fixture { 10 | private: 11 | png_dat outpng; 12 | 13 | /* Backing this on the heap is a more realistic benchmark */ 14 | uint8_t *input_img_buf = NULL; 15 | 16 | public: 17 | /* Let's make the vanilla version have something extremely compressible */ 18 | virtual void init_img(png_bytep img_bytes, size_t width, size_t height) { 19 | init_compressible(img_bytes, width * height); 20 | } 21 | 22 | void SetUp(const ::benchmark::State& state) { 23 | input_img_buf = (uint8_t*)malloc(IMWIDTH * IMHEIGHT * 3); 24 | outpng.buf = (uint8_t*)malloc(IMWIDTH * IMHEIGHT * 3); 25 | /* Using malloc rather than zng_alloc so that we can call realloc. 26 | * IMWIDTH * IMHEIGHT is likely to be more than enough bytes, though, 27 | * given that a simple run length encoding already pretty much can 28 | * reduce to this */ 29 | outpng.len = 0; 30 | outpng.buf_rem = IMWIDTH * IMHEIGHT * 3; 31 | assert(input_img_buf != NULL); 32 | assert(outpng.buf != NULL); 33 | init_img(input_img_buf, IMWIDTH, IMHEIGHT); 34 | } 35 | 36 | /* State in this circumstance will convey the compression level */ 37 | void Bench(benchmark::State &state) { 38 | for (auto _ : state) { 39 | encode_png((png_bytep)input_img_buf, &outpng, state.range(0), IMWIDTH, IMHEIGHT); 40 | outpng.buf_rem = outpng.len; 41 | outpng.len = 0; 42 | } 43 | } 44 | 45 | void TearDown(const ::benchmark::State &state) { 46 | free(input_img_buf); 47 | free(outpng.buf); 48 | } 49 | }; 50 | 51 | BENCHMARK_DEFINE_F(png_encode, encode_compressible)(benchmark::State &state) { 52 | Bench(state); 53 | } 54 | BENCHMARK_REGISTER_F(png_encode, encode_compressible)->DenseRange(0, 9, 1)->Unit(benchmark::kMicrosecond); 55 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/cmake/run-and-redirect.cmake: -------------------------------------------------------------------------------- 1 | # run-and-redirect.cmake -- Runs a command and validates exit code 2 | 3 | # Copyright (C) 2021 Nathan Moinvaziri 4 | # Licensed under the Zlib license, see LICENSE.md for details 5 | 6 | # Normally ctest will always fail with non-zero exit code, but we have tests 7 | # that need to check specific exit codes. 8 | 9 | # Required Variables 10 | # COMMAND - Command to run 11 | 12 | # Optional Variables 13 | # INPUT - Standard input 14 | # OUTPUT - Standard output (default: /dev/null) 15 | # SUCCESS_EXIT - List of successful exit codes (default: 0, ie: 0;1) 16 | 17 | # If no output is specified, discard output 18 | if(NOT DEFINED OUTPUT) 19 | if(WIN32) 20 | set(OUTPUT NUL) 21 | else() 22 | set(OUTPUT /dev/null) 23 | endif() 24 | endif() 25 | 26 | if(INPUT) 27 | # Check to see that input file exists 28 | if(NOT EXISTS ${INPUT}) 29 | message(FATAL_ERROR "Cannot find input: ${INPUT}") 30 | endif() 31 | # Execute with both stdin and stdout file 32 | execute_process(COMMAND ${COMMAND} 33 | RESULT_VARIABLE CMD_RESULT 34 | INPUT_FILE ${INPUT} 35 | OUTPUT_FILE ${OUTPUT}) 36 | else() 37 | # Execute with only stdout file 38 | execute_process(COMMAND ${COMMAND} 39 | RESULT_VARIABLE CMD_RESULT 40 | OUTPUT_FILE ${OUTPUT}) 41 | endif() 42 | 43 | # Check if exit code is in list of successful exit codes 44 | if(SUCCESS_EXIT) 45 | list(FIND SUCCESS_EXIT ${CMD_RESULT} _INDEX) 46 | if (${_INDEX} GREATER -1) 47 | set(CMD_RESULT 0) 48 | endif() 49 | endif() 50 | 51 | # Check to see if successful 52 | if(CMD_RESULT) 53 | message(FATAL_ERROR "${COMMAND} failed: ${CMD_RESULT}") 54 | endif() 55 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/cmake/test-cves.cmake: -------------------------------------------------------------------------------- 1 | # test-cves.cmake -- Tests targeting common vulnerabilities and exposures 2 | 3 | set(CVES CVE-2002-0059 CVE-2004-0797 CVE-2005-1849 CVE-2005-2096) 4 | foreach(cve ${CVES}) 5 | set(CVE_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ -d) 6 | add_test(NAME ${cve} 7 | COMMAND ${CMAKE_COMMAND} 8 | "-DCOMMAND=${CVE_COMMAND}" 9 | -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/${cve}/test.gz 10 | "-DSUCCESS_EXIT=0;1" 11 | -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-redirect.cmake) 12 | endforeach() 13 | 14 | set(CVE_COMPRESS_LEVELS 6 1 2) 15 | foreach(cve_compress_level ${CVE_COMPRESS_LEVELS}) 16 | add_test(NAME CVE-2018-25032-fixed-level-${cve_compress_level} 17 | COMMAND ${CMAKE_COMMAND} 18 | "-DTARGET=${MINIDEFLATE_COMMAND}" 19 | "-DCOMPRESS_ARGS=-c;-k;-m;1;-w;-15;-s;4;-F;-${cve_compress_level}" 20 | "-DDECOMPRESS_ARGS=-c;-k;-d;-m;1;-w;-15;-${cve_compress_level}" 21 | -DGZIP_VERIFY=OFF 22 | -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/CVE-2018-25032/fixed.txt 23 | -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/compress-and-verify.cmake) 24 | 25 | add_test(NAME CVE-2018-25032-default-level-${cve_compress_level} 26 | COMMAND ${CMAKE_COMMAND} 27 | "-DTARGET=${MINIDEFLATE_COMMAND}" 28 | "-DCOMPRESS_ARGS=-c;-k;-m;1;-w;-15;-s;4;-${cve_compress_level}" 29 | "-DDECOMPRESS_ARGS=-c;-k;-d;-m;1;-w;-15;-${cve_compress_level}" 30 | -DGZIP_VERIFY=OFF 31 | -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/CVE-2018-25032/default.txt 32 | -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/compress-and-verify.cmake) 33 | endforeach() 34 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/cmake/test-tools.cmake: -------------------------------------------------------------------------------- 1 | # test-tools.cmake -- Tests targeting tool coverage 2 | 3 | # Test --help and invalid parameters for our tools 4 | set(TEST_COMMAND ${MINIGZIP_COMMAND} "--help") 5 | add_test(NAME minigzip-help 6 | COMMAND ${CMAKE_COMMAND} 7 | "-DCOMMAND=${TEST_COMMAND}" 8 | -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-redirect.cmake) 9 | 10 | set(TEST_COMMAND ${MINIGZIP_COMMAND} "--invalid") 11 | add_test(NAME minigzip-invalid 12 | COMMAND ${CMAKE_COMMAND} 13 | "-DCOMMAND=${TEST_COMMAND}" 14 | -DSUCCESS_EXIT=64 15 | -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-redirect.cmake) 16 | 17 | set(TEST_COMMAND ${MINIDEFLATE_COMMAND} "--help") 18 | add_test(NAME minideflate-help 19 | COMMAND ${CMAKE_COMMAND} 20 | "-DCOMMAND=${TEST_COMMAND}" 21 | -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-redirect.cmake) 22 | 23 | set(TEST_COMMAND ${MINIDEFLATE_COMMAND} "--invalid") 24 | add_test(NAME minideflate-invalid 25 | COMMAND ${CMAKE_COMMAND} 26 | "-DCOMMAND=${TEST_COMMAND}" 27 | -DSUCCESS_EXIT=64 28 | -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-redirect.cmake) 29 | 30 | set(TEST_COMMAND ${SWITCHLEVELS_COMMAND} "--help") 31 | add_test(NAME switchlevels-help 32 | COMMAND ${CMAKE_COMMAND} 33 | "-DCOMMAND=${TEST_COMMAND}" 34 | -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-redirect.cmake) 35 | 36 | # Test generated crc32 tables match tables in source directory 37 | add_test(NAME makecrct 38 | COMMAND ${CMAKE_COMMAND} 39 | "-DCOMMAND=${MAKECRCT_COMMAND}" 40 | -DOUTPUT=${PROJECT_BINARY_DIR}/Testing/Temporary/crc32_braid_tbl._h 41 | -DCOMPARE=${PROJECT_SOURCE_DIR}/crc32_braid_tbl.h 42 | -DIGNORE_LINE_ENDINGS=ON 43 | -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-compare.cmake) 44 | 45 | # Test generated inflate tables match tables in source directory 46 | add_test(NAME makefixed 47 | COMMAND ${CMAKE_COMMAND} 48 | "-DCOMMAND=${MAKEFIXED_COMMAND}" 49 | -DOUTPUT=${PROJECT_BINARY_DIR}/Testing/Temporary/inffixed_tbl._h 50 | -DCOMPARE=${PROJECT_SOURCE_DIR}/inffixed_tbl.h 51 | -DIGNORE_LINE_ENDINGS=ON 52 | -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-compare.cmake) 53 | 54 | # Test generated tree tables match tables in source directory 55 | add_test(NAME maketrees 56 | COMMAND ${CMAKE_COMMAND} 57 | "-DCOMMAND=${MAKETREES_COMMAND}" 58 | -DOUTPUT=${PROJECT_BINARY_DIR}/Testing/Temporary/trees_tbl._h 59 | -DCOMPARE=${PROJECT_SOURCE_DIR}/trees_tbl.h 60 | -DIGNORE_LINE_ENDINGS=ON 61 | -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/run-and-compare.cmake) 62 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/data/fireworks.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/ext/zlib-ng/test/data/fireworks.jpg -------------------------------------------------------------------------------- /ext/zlib-ng/test/data/paper-100k.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/ext/zlib-ng/test/data/paper-100k.pdf -------------------------------------------------------------------------------- /ext/zlib-ng/test/fuzz/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.5.1) 2 | 3 | if(CMAKE_C_COMPILER_ID MATCHES "Clang") 4 | enable_language(CXX) 5 | 6 | if(DEFINED ENV{LIB_FUZZING_ENGINE}) 7 | set(FUZZING_ENGINE $ENV{LIB_FUZZING_ENGINE}) 8 | set(FUZZING_ENGINE_FOUND ON) 9 | else() 10 | find_library(FUZZING_ENGINE "FuzzingEngine") 11 | endif() 12 | endif() 13 | 14 | set(FUZZERS 15 | fuzzer_checksum 16 | fuzzer_compress 17 | fuzzer_example_small 18 | fuzzer_example_large 19 | fuzzer_example_flush 20 | fuzzer_example_dict 21 | ) 22 | 23 | if(WITH_GZFILEOP) 24 | list(APPEND FUZZERS fuzzer_minigzip) 25 | endif() 26 | 27 | foreach(FUZZER ${FUZZERS}) 28 | add_executable(${FUZZER} ${FUZZER}.c) 29 | 30 | if(NOT FUZZING_ENGINE_FOUND) 31 | target_sources(${FUZZER} PRIVATE standalone_fuzz_target_runner.c) 32 | endif() 33 | 34 | target_link_libraries(${FUZZER} zlibstatic) 35 | if(FUZZING_ENGINE_FOUND) 36 | target_link_libraries(${FUZZER} ${FUZZING_ENGINE}) 37 | endif() 38 | 39 | if(ZLIB_ENABLE_TESTS) 40 | file(GLOB FUZZER_TEST_FILES ${PROJECT_SOURCE_DIR}/*) 41 | set(FUZZER_COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR} $ ${FUZZER_TEST_FILES}) 42 | add_test(NAME ${FUZZER} COMMAND ${FUZZER_COMMAND}) 43 | endif() 44 | endforeach() 45 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/fuzz/standalone_fuzz_target_runner.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | 4 | #include "zbuild.h" 5 | 6 | extern int LLVMFuzzerTestOneInput(const unsigned char *data, size_t size); 7 | 8 | int main(int argc, char **argv) { 9 | int i; 10 | fprintf(stderr, "StandaloneFuzzTargetMain: running %d inputs\n", argc - 1); 11 | 12 | for (i = 1; i < argc; i++) { 13 | size_t len, n_read, err; 14 | unsigned char *buf; 15 | FILE *f = fopen(argv[i], "rb+"); 16 | if (!f) { 17 | /* Failed to open this file: it may be a directory. */ 18 | fprintf(stderr, "Skipping: %s\n", argv[i]); 19 | continue; 20 | } 21 | fprintf(stderr, "Running: %s %s\n", argv[0], argv[i]); 22 | fseek(f, 0, SEEK_END); 23 | len = ftell(f); 24 | fseek(f, 0, SEEK_SET); 25 | buf = (unsigned char *)malloc(len); 26 | n_read = fread(buf, 1, len, f); 27 | assert(n_read == len); 28 | LLVMFuzzerTestOneInput(buf, len); 29 | free(buf); 30 | err = fclose(f); 31 | assert(err == 0); 32 | Z_UNUSED(err); 33 | fprintf(stderr, "Done: %s: (%d bytes)\n", argv[i], (int)n_read); 34 | } 35 | 36 | return 0; 37 | } 38 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/gh1235.c: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | #include 4 | #include "zutil.h" 5 | 6 | int main(void) { 7 | unsigned char plain[32]; 8 | unsigned char compressed[130]; 9 | PREFIX3(stream) strm; 10 | int bound; 11 | z_size_t bytes; 12 | 13 | for (int i = 0; i <= 32; i++) { 14 | memset(plain, 6, i); 15 | memset(&strm, 0, sizeof(strm)); 16 | PREFIX(deflateInit2)(&strm, 0, 8, 31, 1, Z_DEFAULT_STRATEGY); 17 | bound = PREFIX(deflateBound)(&strm, i); 18 | strm.next_in = plain; 19 | strm.next_out = compressed; 20 | strm.avail_in = i; 21 | strm.avail_out = sizeof(compressed); 22 | if (PREFIX(deflate)(&strm, Z_FINISH) != Z_STREAM_END) return -1; 23 | if (strm.avail_in != 0) return -1; 24 | printf("bytes = %2i, deflateBound = %2i, total_out = %2zi\n", i, bound, strm.total_out); 25 | if (bound < strm.total_out) return -1; 26 | if (PREFIX(deflateEnd)(&strm) != Z_OK) return -1; 27 | } 28 | for (int i = 0; i <= 32; i++) { 29 | bytes = sizeof(compressed); 30 | for (int j = 0; j < i; j++) { 31 | plain[j] = j; 32 | } 33 | bound = PREFIX(compressBound)(i); 34 | if (PREFIX(compress2)(compressed, &bytes, plain, i, 1) != Z_OK) return -1; 35 | printf("bytes = %2i, compressBound = %2i, total_out = %2zi\n", i, bound, (size_t)bytes); 36 | if (bytes > bound) return -1; 37 | } 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_aligned_alloc.cc: -------------------------------------------------------------------------------- 1 | /* test_aligned_alloc.cc - Test zng_alloc_aligned and zng_free_aligned */ 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | extern "C" { 8 | # include "zbuild.h" 9 | # include "zutil.h" 10 | } 11 | 12 | #include 13 | 14 | void *zng_calloc_unaligned(void *opaque, unsigned items, unsigned size) { 15 | uint8_t *pointer = (uint8_t *)calloc(1, (items * size) + 2); 16 | Z_UNUSED(opaque); 17 | if (pointer == NULL) 18 | return pointer; 19 | /* Store whether or not our allocation is aligned */ 20 | *pointer = ((uint64_t)(intptr_t)pointer + 1) % 2 == 0; 21 | pointer++; 22 | if (*pointer) { 23 | /* Return pointer that is off by one */ 24 | pointer++; 25 | } 26 | return (void *)pointer; 27 | } 28 | 29 | void zng_cfree_unaligned(void *opaque, void *ptr) { 30 | uint8_t *pointer = (uint8_t *)ptr; 31 | Z_UNUSED(opaque); 32 | pointer--; 33 | /* Get whether or not our original memory pointer was aligned */ 34 | if (*pointer) { 35 | /* Return original aligned pointer to free() */ 36 | pointer--; 37 | } 38 | free(pointer); 39 | } 40 | 41 | TEST(zalloc, aligned_64) { 42 | void *return_ptr = zng_alloc_aligned(zng_calloc_unaligned, 0, 1, 100, 64); 43 | ASSERT_TRUE(return_ptr != NULL); 44 | EXPECT_EQ((intptr_t)return_ptr % 64, 0); 45 | zng_free_aligned(zng_cfree_unaligned, 0, return_ptr); 46 | } 47 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_compare256.cc: -------------------------------------------------------------------------------- 1 | /* test_compare256.cc -- compare256 unit tests 2 | * Copyright (C) 2022 Nathan Moinvaziri 3 | * For conditions of distribution and use, see copyright notice in zlib.h 4 | */ 5 | 6 | #include 7 | #include 8 | #include 9 | 10 | extern "C" { 11 | # include "zbuild.h" 12 | # include "zutil_p.h" 13 | # include "cpu_features.h" 14 | } 15 | 16 | #include 17 | 18 | #define MAX_COMPARE_SIZE (256) 19 | 20 | /* Ensure that compare256 returns the correct match length */ 21 | static inline void compare256_match_check(compare256_func compare256) { 22 | int32_t match_len, i; 23 | uint8_t *str1; 24 | uint8_t *str2; 25 | 26 | str1 = (uint8_t *)zng_alloc(MAX_COMPARE_SIZE); 27 | ASSERT_TRUE(str1 != NULL); 28 | memset(str1, 'a', MAX_COMPARE_SIZE); 29 | 30 | str2 = (uint8_t *)zng_alloc(MAX_COMPARE_SIZE); 31 | ASSERT_TRUE(str2 != NULL); 32 | memset(str2, 'a', MAX_COMPARE_SIZE); 33 | 34 | for (i = 0; i <= MAX_COMPARE_SIZE; i++) { 35 | if (i < MAX_COMPARE_SIZE) 36 | str2[i] = 0; 37 | 38 | match_len = compare256(str1, str2); 39 | EXPECT_EQ(match_len, i); 40 | 41 | if (i < MAX_COMPARE_SIZE) 42 | str2[i] = 'a'; 43 | } 44 | 45 | zng_free(str1); 46 | zng_free(str2); 47 | } 48 | 49 | #define TEST_COMPARE256(name, func, support_flag) \ 50 | TEST(compare256, name) { \ 51 | if (!support_flag) { \ 52 | GTEST_SKIP(); \ 53 | return; \ 54 | } \ 55 | compare256_match_check(func); \ 56 | } 57 | 58 | TEST_COMPARE256(c, compare256_c, 1) 59 | 60 | #ifdef UNALIGNED_OK 61 | TEST_COMPARE256(unaligned_16, compare256_unaligned_16, 1) 62 | #ifdef HAVE_BUILTIN_CTZ 63 | TEST_COMPARE256(unaligned_32, compare256_unaligned_32, 1) 64 | #endif 65 | #if defined(UNALIGNED64_OK) && defined(HAVE_BUILTIN_CTZLL) 66 | TEST_COMPARE256(unaligned_64, compare256_unaligned_64, 1) 67 | #endif 68 | #endif 69 | #if defined(X86_SSE2) && defined(HAVE_BUILTIN_CTZ) 70 | TEST_COMPARE256(sse2, compare256_sse2, x86_cpu_has_sse2) 71 | #endif 72 | #if defined(X86_AVX2) && defined(HAVE_BUILTIN_CTZ) 73 | TEST_COMPARE256(avx2, compare256_avx2, x86_cpu_has_avx2) 74 | #endif 75 | #if defined(ARM_NEON) && defined(HAVE_BUILTIN_CTZLL) 76 | TEST_COMPARE256(neon, compare256_neon, arm_cpu_has_neon) 77 | #endif 78 | #ifdef POWER9 79 | TEST_COMPARE256(power9, compare256_power9, power_cpu_has_arch_3_00) 80 | #endif 81 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_compress.cc: -------------------------------------------------------------------------------- 1 | /* test_compress.cc - Test compress() and uncompress() using hello world string */ 2 | 3 | #include "zbuild.h" 4 | #ifdef ZLIB_COMPAT 5 | # include "zlib.h" 6 | #else 7 | # include "zlib-ng.h" 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "test_shared.h" 16 | 17 | #include 18 | 19 | TEST(compress, basic) { 20 | uint8_t compr[128], uncompr[128]; 21 | z_size_t compr_len = sizeof(compr), uncompr_len = sizeof(uncompr); 22 | int err; 23 | 24 | err = PREFIX(compress)(compr, &compr_len, (const unsigned char *)hello, hello_len); 25 | EXPECT_EQ(err, Z_OK); 26 | 27 | strcpy((char*)uncompr, "garbage"); 28 | 29 | err = PREFIX(uncompress)(uncompr, &uncompr_len, compr, compr_len); 30 | EXPECT_EQ(err, Z_OK); 31 | 32 | EXPECT_STREQ((char *)uncompr, (char *)hello); 33 | } 34 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_compress_bound.cc: -------------------------------------------------------------------------------- 1 | /* test_compress_bound.cc - Test compressBound() with small buffers */ 2 | 3 | #include "zbuild.h" 4 | #ifdef ZLIB_COMPAT 5 | # include "zlib.h" 6 | #else 7 | # include "zlib-ng.h" 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "test_shared.h" 16 | 17 | #include 18 | 19 | #define MAX_LENGTH (32) 20 | 21 | class compress_bound_variant : public testing::TestWithParam { 22 | public: 23 | void estimate(int32_t level) { 24 | z_size_t estimate_len = 0; 25 | uint8_t *uncompressed = NULL; 26 | uint8_t dest[128]; 27 | int err; 28 | 29 | uncompressed = (uint8_t *)malloc(MAX_LENGTH); 30 | ASSERT_TRUE(uncompressed != NULL); 31 | 32 | /* buffer with values for worst case compression */ 33 | for (int32_t j = 0; j < MAX_LENGTH; j++) { 34 | uncompressed[j] = (uint8_t)j; 35 | } 36 | 37 | for (z_size_t i = 0; i < MAX_LENGTH; i++) { 38 | z_size_t dest_len = sizeof(dest); 39 | 40 | /* calculate actual output length */ 41 | estimate_len = PREFIX(compressBound)(i); 42 | 43 | err = PREFIX(compress2)(dest, &dest_len, uncompressed, i, level); 44 | EXPECT_EQ(err, Z_OK); 45 | EXPECT_GE(estimate_len, dest_len) << 46 | "level: " << level << "\n" << 47 | "length: " << i; 48 | } 49 | 50 | free(uncompressed); 51 | } 52 | }; 53 | 54 | TEST_P(compress_bound_variant, estimate) { 55 | estimate(GetParam()); 56 | } 57 | 58 | INSTANTIATE_TEST_SUITE_P(compress_bound, compress_bound_variant, 59 | testing::Values(0, 1, 2, 3, 4, 5, 6, 7, 8, 9)); 60 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_compress_dual.cc: -------------------------------------------------------------------------------- 1 | /* test_compress_dual.cc - Test linking against both zlib and zlib-ng */ 2 | 3 | #include "zlib.h" 4 | 5 | #include 6 | #include 7 | #include 8 | #include 9 | 10 | #include "test_shared.h" 11 | 12 | #include 13 | 14 | TEST(compress, basic_zlib) { 15 | Byte compr[128], uncompr[128]; 16 | uLong compr_len = sizeof(compr), uncompr_len = sizeof(uncompr); 17 | int err; 18 | 19 | err = compress(compr, &compr_len, (const unsigned char *)hello, hello_len); 20 | EXPECT_EQ(err, Z_OK); 21 | 22 | strcpy((char*)uncompr, "garbage"); 23 | 24 | err = uncompress(uncompr, &uncompr_len, compr, compr_len); 25 | EXPECT_EQ(err, Z_OK); 26 | 27 | EXPECT_STREQ((char *)uncompr, (char *)hello); 28 | } 29 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_cve-2003-0107.cc: -------------------------------------------------------------------------------- 1 | // https://www.securityfocus.com/archive/1/312869 --- originally by Richard Kettlewell 2 | #include 3 | #include 4 | #include 5 | 6 | #include "zbuild.h" 7 | #ifdef ZLIB_COMPAT 8 | # include "zlib.h" 9 | #else 10 | # include "zlib-ng.h" 11 | #endif 12 | 13 | #include 14 | 15 | #if !defined(_WIN32) && defined(ZLIB_COMPAT) 16 | TEST(gzip, cve_2003_0107) { 17 | gzFile f; 18 | int ret; 19 | 20 | f = gzopen("/dev/null", "w"); 21 | EXPECT_TRUE(f != NULL); 22 | 23 | ret = gzprintf(f, "%10240s", ""); 24 | printf("gzprintf -> %d\n", ret); 25 | ret = gzclose(f); 26 | printf("gzclose -> %d [%d]\n", ret, errno); 27 | } 28 | #endif 29 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_deflate_copy.cc: -------------------------------------------------------------------------------- 1 | /* test_deflate_copy.cc - Test deflateCopy() with small buffers */ 2 | 3 | #include "zbuild.h" 4 | #ifdef ZLIB_COMPAT 5 | # include "zlib.h" 6 | #else 7 | # include "zlib-ng.h" 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "deflate.h" 16 | 17 | #include "test_shared.h" 18 | 19 | #include 20 | 21 | TEST(deflate, copy) { 22 | PREFIX3(stream) c_stream, c_stream_copy; 23 | uint8_t compr[128]; 24 | z_size_t compr_len = sizeof(compr); 25 | int err; 26 | 27 | memset(&c_stream, 0, sizeof(c_stream)); 28 | memset(&c_stream_copy, 0, sizeof(c_stream_copy)); 29 | 30 | err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); 31 | EXPECT_EQ(err, Z_OK); 32 | 33 | c_stream.next_in = (z_const unsigned char *)hello; 34 | c_stream.next_out = compr; 35 | 36 | while (c_stream.total_in != hello_len && c_stream.total_out < compr_len) { 37 | c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ 38 | err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); 39 | EXPECT_EQ(err, Z_OK); 40 | } 41 | 42 | /* Finish the stream, still forcing small buffers: */ 43 | for (;;) { 44 | c_stream.avail_out = 1; 45 | err = PREFIX(deflate)(&c_stream, Z_FINISH); 46 | if (err == Z_STREAM_END) break; 47 | EXPECT_EQ(err, Z_OK); 48 | } 49 | 50 | err = PREFIX(deflateCopy)(&c_stream_copy, &c_stream); 51 | EXPECT_EQ(err, Z_OK); 52 | 53 | EXPECT_EQ(c_stream.state->status, c_stream_copy.state->status); 54 | 55 | err = PREFIX(deflateEnd)(&c_stream); 56 | EXPECT_EQ(err, Z_OK); 57 | 58 | err = PREFIX(deflateEnd)(&c_stream_copy); 59 | EXPECT_EQ(err, Z_OK); 60 | } 61 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_deflate_dict.cc: -------------------------------------------------------------------------------- 1 | /* test_deflate_dict.cc - Test deflateGetDictionary() with small buffers */ 2 | 3 | #include "zbuild.h" 4 | #ifdef ZLIB_COMPAT 5 | # include "zlib.h" 6 | #else 7 | # include "zlib-ng.h" 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "test_shared.h" 16 | 17 | #include 18 | 19 | TEST(deflate, dictionary) { 20 | PREFIX3(stream) c_stream; 21 | uint8_t compr[128]; 22 | uint32_t compr_len = sizeof(compr); 23 | uint8_t *dict_new = NULL; 24 | uint32_t *dict_len; 25 | int err; 26 | 27 | memset(&c_stream, 0, sizeof(c_stream)); 28 | 29 | err = PREFIX(deflateInit)(&c_stream, Z_BEST_COMPRESSION); 30 | EXPECT_EQ(err, Z_OK); 31 | 32 | c_stream.next_out = compr; 33 | c_stream.avail_out = compr_len; 34 | 35 | c_stream.next_in = (z_const unsigned char *)hello; 36 | c_stream.avail_in = (uint32_t)hello_len; 37 | 38 | err = PREFIX(deflate)(&c_stream, Z_FINISH); 39 | EXPECT_EQ(err, Z_STREAM_END); 40 | 41 | dict_new = (uint8_t *)calloc(256, 1); 42 | ASSERT_TRUE(dict_new != NULL); 43 | dict_len = (uint32_t *)calloc(4, 1); 44 | ASSERT_TRUE(dict_len != NULL); 45 | 46 | err = PREFIX(deflateGetDictionary)(&c_stream, dict_new, dict_len); 47 | EXPECT_EQ(err, Z_OK); 48 | 49 | err = PREFIX(deflateEnd)(&c_stream); 50 | EXPECT_EQ(err, Z_OK); 51 | 52 | free(dict_new); 53 | free(dict_len); 54 | } 55 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_deflate_hash_head_0.cc: -------------------------------------------------------------------------------- 1 | /* Generated by fuzzing - test hash_head == 0 handling. */ 2 | 3 | #include "zbuild.h" 4 | #ifdef ZLIB_COMPAT 5 | # include "zlib.h" 6 | #else 7 | # include "zlib-ng.h" 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "test_shared.h" 15 | 16 | #include 17 | 18 | TEST(deflate, hash_head_0) { 19 | PREFIX3(stream) strm; 20 | int err; 21 | 22 | memset(&strm, 0, sizeof(strm)); 23 | err = PREFIX(deflateInit2)(&strm, 1, Z_DEFLATED, -15, 4, Z_HUFFMAN_ONLY); 24 | EXPECT_EQ(err, Z_OK); 25 | 26 | unsigned char next_in[9698]; 27 | memset(next_in, 0x30, sizeof(next_in)); 28 | next_in[8193] = 0x00; 29 | next_in[8194] = 0x00; 30 | next_in[8195] = 0x00; 31 | next_in[8199] = 0x8a; 32 | strm.next_in = next_in; 33 | unsigned char next_out[21572]; 34 | strm.next_out = next_out; 35 | 36 | strm.avail_in = 0; 37 | strm.avail_out = 1348; 38 | err = PREFIX(deflateParams(&strm, 3, Z_FILTERED)); 39 | EXPECT_EQ(err, Z_OK); 40 | 41 | strm.avail_in = 6728; 42 | strm.avail_out = 2696; 43 | err = PREFIX(deflate(&strm, Z_SYNC_FLUSH)); 44 | EXPECT_EQ(err, Z_OK); 45 | 46 | strm.avail_in = 15; 47 | strm.avail_out = 1348; 48 | err = PREFIX(deflateParams(&strm, 9, Z_FILTERED)); 49 | EXPECT_EQ(err, Z_OK); 50 | 51 | strm.avail_in = 1453; 52 | strm.avail_out = 1348; 53 | err = PREFIX(deflate(&strm, Z_FULL_FLUSH)); 54 | EXPECT_EQ(err, Z_OK); 55 | 56 | strm.avail_in = (uint32_t)(next_in + sizeof(next_in) - strm.next_in); 57 | strm.avail_out = (uint32_t)(next_out + sizeof(next_out) - strm.next_out); 58 | err = PREFIX(deflate)(&strm, Z_FINISH); 59 | EXPECT_EQ(err, Z_STREAM_END); 60 | 61 | uint32_t compressed_size = (uint32_t)(strm.next_out - next_out); 62 | 63 | err = PREFIX(deflateEnd)(&strm); 64 | EXPECT_EQ(err, Z_OK); 65 | 66 | memset(&strm, 0, sizeof(strm)); 67 | err = PREFIX(inflateInit2)(&strm, -15); 68 | EXPECT_EQ(err, Z_OK); 69 | 70 | strm.next_in = next_out; 71 | strm.avail_in = compressed_size; 72 | unsigned char uncompressed[sizeof(next_in)]; 73 | strm.next_out = uncompressed; 74 | strm.avail_out = sizeof(uncompressed); 75 | 76 | err = PREFIX(inflate)(&strm, Z_NO_FLUSH); 77 | EXPECT_EQ(err, Z_STREAM_END); 78 | 79 | err = PREFIX(inflateEnd)(&strm); 80 | EXPECT_EQ(err, Z_OK); 81 | 82 | EXPECT_TRUE(memcmp(uncompressed, next_in, sizeof(uncompressed)) == 0); 83 | } 84 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_deflate_header.cc: -------------------------------------------------------------------------------- 1 | /* test_deflate_header.cc - Test deflateSetHeader() with small buffers */ 2 | 3 | #include "zbuild.h" 4 | #ifdef ZLIB_COMPAT 5 | # include "zlib.h" 6 | #else 7 | # include "zlib-ng.h" 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "test_shared.h" 16 | 17 | #include 18 | 19 | TEST(deflate, header) { 20 | PREFIX3(stream) c_stream; 21 | PREFIX(gz_header) *head; 22 | uint8_t compr[128]; 23 | z_size_t compr_len = sizeof(compr); 24 | int err; 25 | 26 | head = (PREFIX(gz_header) *)calloc(1, sizeof(PREFIX(gz_header))); 27 | ASSERT_TRUE(head != NULL); 28 | 29 | memset(&c_stream, 0, sizeof(c_stream)); 30 | 31 | /* gzip */ 32 | err = PREFIX(deflateInit2)(&c_stream, Z_DEFAULT_COMPRESSION, Z_DEFLATED, MAX_WBITS + 16, 8, Z_DEFAULT_STRATEGY); 33 | EXPECT_EQ(err, Z_OK); 34 | 35 | head->text = 1; 36 | head->comment = (uint8_t *)"comment"; 37 | head->name = (uint8_t *)"name"; 38 | head->hcrc = 1; 39 | head->extra = (uint8_t *)"extra"; 40 | head->extra_len = (uint32_t)strlen((const char *)head->extra); 41 | 42 | err = PREFIX(deflateSetHeader)(&c_stream, head); 43 | EXPECT_EQ(err, Z_OK); 44 | 45 | PREFIX(deflateBound)(&c_stream, (unsigned long)compr_len); 46 | 47 | c_stream.next_in = (unsigned char *)hello; 48 | c_stream.next_out = compr; 49 | 50 | while (c_stream.total_in != hello_len && c_stream.total_out < compr_len) { 51 | c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ 52 | err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); 53 | EXPECT_EQ(err, Z_OK); 54 | } 55 | 56 | /* Finish the stream, still forcing small buffers: */ 57 | for (;;) { 58 | c_stream.avail_out = 1; 59 | err = PREFIX(deflate)(&c_stream, Z_FINISH); 60 | if (err == Z_STREAM_END) break; 61 | EXPECT_EQ(err, Z_OK); 62 | } 63 | 64 | err = PREFIX(deflateEnd)(&c_stream); 65 | EXPECT_EQ(err, Z_OK); 66 | 67 | free(head); 68 | } 69 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_deflate_pending.cc: -------------------------------------------------------------------------------- 1 | /* test_deflate_pending.cc - Test deflatePending() with small buffers */ 2 | 3 | #include "zbuild.h" 4 | #ifdef ZLIB_COMPAT 5 | # include "zlib.h" 6 | #else 7 | # include "zlib-ng.h" 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "test_shared.h" 16 | 17 | #include 18 | 19 | TEST(deflate, pending) { 20 | PREFIX3(stream) c_stream; 21 | uint8_t compr[128]; 22 | z_size_t compr_len = sizeof(compr); 23 | int *bits; 24 | unsigned *ped; 25 | int err; 26 | 27 | 28 | bits = (int *)calloc(256, 1); 29 | ASSERT_TRUE(bits != NULL); 30 | ped = (unsigned *)calloc(256, 1); 31 | ASSERT_TRUE(ped != NULL); 32 | 33 | memset(&c_stream, 0, sizeof(c_stream)); 34 | 35 | err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); 36 | EXPECT_EQ(err, Z_OK); 37 | 38 | c_stream.next_in = (z_const unsigned char *)hello; 39 | c_stream.next_out = compr; 40 | 41 | while (c_stream.total_in != hello_len && c_stream.total_out < compr_len) { 42 | c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ 43 | err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); 44 | EXPECT_EQ(err, Z_OK); 45 | } 46 | 47 | err = PREFIX(deflatePending)(&c_stream, ped, bits); 48 | EXPECT_EQ(err, Z_OK); 49 | 50 | EXPECT_GE(*bits, 0); 51 | EXPECT_LE(*bits, 7); 52 | 53 | /* Finish the stream, still forcing small buffers: */ 54 | for (;;) { 55 | c_stream.avail_out = 1; 56 | err = PREFIX(deflate)(&c_stream, Z_FINISH); 57 | if (err == Z_STREAM_END) break; 58 | EXPECT_EQ(err, Z_OK); 59 | } 60 | 61 | err = PREFIX(deflateEnd)(&c_stream); 62 | EXPECT_EQ(err, Z_OK); 63 | 64 | free(bits); 65 | free(ped); 66 | } 67 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_deflate_tune.cc: -------------------------------------------------------------------------------- 1 | /* test_deflate_tune.cc - Test deflateTune() with small buffers */ 2 | 3 | #include "zbuild.h" 4 | #ifdef ZLIB_COMPAT 5 | # include "zlib.h" 6 | #else 7 | # include "zlib-ng.h" 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "test_shared.h" 16 | 17 | #include 18 | 19 | TEST(deflate, tune) { 20 | PREFIX3(stream) c_stream; 21 | uint8_t compr[128]; 22 | z_size_t compr_len = sizeof(compr); 23 | int err; 24 | int good_length = 3; 25 | int max_lazy = 5; 26 | int nice_length = 18; 27 | int max_chain = 6; 28 | 29 | memset(&c_stream, 0, sizeof(c_stream)); 30 | 31 | err = PREFIX(deflateInit)(&c_stream, Z_BEST_COMPRESSION); 32 | EXPECT_EQ(err, Z_OK); 33 | 34 | err = PREFIX(deflateTune)(&c_stream, good_length, max_lazy,nice_length, max_chain); 35 | EXPECT_EQ(err, Z_OK); 36 | 37 | c_stream.next_in = (z_const unsigned char *)hello; 38 | c_stream.next_out = compr; 39 | 40 | while (c_stream.total_in != hello_len && c_stream.total_out < compr_len) { 41 | c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ 42 | err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); 43 | EXPECT_EQ(err, Z_OK); 44 | } 45 | 46 | /* Finish the stream, still forcing small buffers: */ 47 | for (;;) { 48 | c_stream.avail_out = 1; 49 | err = PREFIX(deflate)(&c_stream, Z_FINISH); 50 | if (err == Z_STREAM_END) break; 51 | EXPECT_EQ(err, Z_OK); 52 | } 53 | 54 | err = PREFIX(deflateEnd)(&c_stream); 55 | EXPECT_EQ(err, Z_OK); 56 | } 57 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_inflate_adler32.cc: -------------------------------------------------------------------------------- 1 | /* GH-1066 - inflate small amount of data and validate with adler32 checksum. */ 2 | 3 | #include "zbuild.h" 4 | #ifdef ZLIB_COMPAT 5 | # include "zlib.h" 6 | #else 7 | # include "zlib-ng.h" 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | 14 | #include "test_shared.h" 15 | 16 | #include 17 | 18 | const char* original = "The quick brown fox jumped over the lazy dog"; 19 | 20 | z_const unsigned char compressed[] = { 21 | 0x78, 0x9c, 0x0b, 0xc9, 0x48, 0x55, 0x28, 0x2c, 0xcd, 0x4c, 0xce, 0x56, 0x48, 22 | 0x2a, 0xca, 0x2f, 0xcf, 0x53, 0x48, 0xcb, 0xaf, 0x50, 0xc8, 0x2a, 0xcd, 0x2d, 23 | 0x48, 0x4d, 0x51, 0xc8, 0x2f, 0x4b, 0x2d, 0x52, 0x28, 0xc9, 0x48, 0x55, 0xc8, 24 | 0x49, 0xac, 0xaa, 0x54, 0x48, 0xc9, 0x4f, 0x07, 0x00, 0x6b, 0x93, 0x10, 0x30 25 | }; 26 | 27 | TEST(inflate, adler32) { 28 | unsigned char uncompressed[1024]; 29 | PREFIX3(stream) strm; 30 | 31 | memset(&strm, 0, sizeof(strm)); 32 | 33 | int err = PREFIX(inflateInit2)(&strm, 32 + MAX_WBITS); 34 | EXPECT_EQ(err, Z_OK); 35 | 36 | strm.next_in = compressed; 37 | strm.avail_in = sizeof(compressed); 38 | strm.next_out = uncompressed; 39 | strm.avail_out = sizeof(uncompressed); 40 | 41 | err = PREFIX(inflate)(&strm, Z_NO_FLUSH); 42 | EXPECT_EQ(err, Z_STREAM_END); 43 | 44 | EXPECT_EQ(strm.adler, 0x6b931030); 45 | 46 | err = PREFIX(inflateEnd)(&strm); 47 | EXPECT_EQ(err, Z_OK); 48 | 49 | EXPECT_TRUE(memcmp(uncompressed, original, MIN(strm.total_out, strlen(original))) == 0); 50 | } 51 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_inflate_sync.cc: -------------------------------------------------------------------------------- 1 | /* test_inflate_sync.cc - Test inflateSync using full flush deflate and corrupted data */ 2 | 3 | #include "zbuild.h" 4 | #ifdef ZLIB_COMPAT 5 | # include "zlib.h" 6 | #else 7 | # include "zlib-ng.h" 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "test_shared.h" 16 | 17 | #include 18 | 19 | TEST(inflate, sync) { 20 | PREFIX3(stream) c_stream, d_stream; 21 | uint8_t compr[128], uncompr[128]; 22 | z_size_t compr_len = sizeof(compr), uncompr_len = sizeof(uncompr); 23 | int err; 24 | 25 | memset(&c_stream, 0, sizeof(c_stream)); 26 | 27 | /* build compressed stream with full flush */ 28 | err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); 29 | EXPECT_EQ(err, Z_OK); 30 | 31 | c_stream.next_in = (z_const unsigned char *)hello; 32 | c_stream.next_out = compr; 33 | c_stream.avail_in = 3; 34 | c_stream.avail_out = (uint32_t)compr_len; 35 | 36 | err = PREFIX(deflate)(&c_stream, Z_FULL_FLUSH); 37 | EXPECT_EQ(err, Z_OK); 38 | 39 | /* force an error in first compressed block */ 40 | compr[3]++; 41 | c_stream.avail_in = hello_len-3; 42 | 43 | err = PREFIX(deflate)(&c_stream, Z_FINISH); 44 | EXPECT_EQ(err, Z_STREAM_END); 45 | 46 | err = PREFIX(deflateEnd)(&c_stream); 47 | EXPECT_EQ(err, Z_OK); 48 | 49 | compr_len = (z_size_t)c_stream.total_out; 50 | 51 | memset(&d_stream, 0, sizeof(d_stream)); 52 | /* just read the zlib header */ 53 | d_stream.next_in = compr; 54 | d_stream.avail_in = 2; 55 | 56 | err = PREFIX(inflateInit)(&d_stream); 57 | EXPECT_EQ(err, Z_OK); 58 | 59 | d_stream.next_out = uncompr; 60 | d_stream.avail_out = (uint32_t)uncompr_len; 61 | 62 | err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); 63 | EXPECT_EQ(err, Z_OK); 64 | 65 | /* read all compressed data, but skip damaged part */ 66 | d_stream.avail_in = (uint32_t)compr_len-2; 67 | err = PREFIX(inflateSync)(&d_stream); 68 | EXPECT_EQ(err, Z_OK); 69 | 70 | err = PREFIX(inflate)(&d_stream, Z_FINISH); 71 | EXPECT_EQ(err, Z_STREAM_END); 72 | 73 | err = PREFIX(inflateEnd)(&d_stream); 74 | EXPECT_EQ(err, Z_OK); 75 | } 76 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_large_buffers.cc: -------------------------------------------------------------------------------- 1 | /* test_large_buffers.cc - Test deflate() and inflate() with large buffers */ 2 | 3 | #include "zbuild.h" 4 | #ifdef ZLIB_COMPAT 5 | # include "zlib.h" 6 | #else 7 | # include "zlib-ng.h" 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | 16 | #include "test_shared.h" 17 | 18 | #include 19 | 20 | #define COMPR_BUFFER_SIZE (48 * 1024) 21 | #define UNCOMPR_BUFFER_SIZE (32 * 1024) 22 | #define UNCOMPR_RAND_SIZE (8 * 1024) 23 | 24 | TEST(deflate, large_buffers) { 25 | PREFIX3(stream) c_stream, d_stream; 26 | uint8_t *compr, *uncompr; 27 | uint32_t compr_len, uncompr_len; 28 | int32_t i; 29 | time_t now; 30 | int err; 31 | 32 | memset(&c_stream, 0, sizeof(c_stream)); 33 | memset(&d_stream, 0, sizeof(d_stream)); 34 | 35 | compr = (uint8_t *)calloc(1, COMPR_BUFFER_SIZE); 36 | ASSERT_TRUE(compr != NULL); 37 | uncompr = (uint8_t *)calloc(1, UNCOMPR_BUFFER_SIZE); 38 | ASSERT_TRUE(uncompr != NULL); 39 | 40 | compr_len = COMPR_BUFFER_SIZE; 41 | uncompr_len = UNCOMPR_BUFFER_SIZE; 42 | 43 | srand((unsigned)time(&now)); 44 | for (i = 0; i < UNCOMPR_RAND_SIZE; i++) 45 | uncompr[i] = (uint8_t)(rand() % 256); 46 | 47 | err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); 48 | EXPECT_EQ(err, Z_OK); 49 | 50 | c_stream.next_out = compr; 51 | c_stream.avail_out = compr_len; 52 | c_stream.next_in = uncompr; 53 | c_stream.avail_in = uncompr_len; 54 | 55 | err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); 56 | EXPECT_EQ(err, Z_OK); 57 | EXPECT_EQ(c_stream.avail_in, 0); 58 | 59 | err = PREFIX(deflate)(&c_stream, Z_FINISH); 60 | EXPECT_EQ(err, Z_STREAM_END); 61 | 62 | err = PREFIX(deflateEnd)(&c_stream); 63 | EXPECT_EQ(err, Z_OK); 64 | 65 | d_stream.next_in = compr; 66 | d_stream.avail_in = compr_len; 67 | d_stream.next_out = uncompr; 68 | 69 | err = PREFIX(inflateInit)(&d_stream); 70 | EXPECT_EQ(err, Z_OK); 71 | 72 | for (;;) { 73 | d_stream.next_out = uncompr; /* discard the output */ 74 | d_stream.avail_out = uncompr_len; 75 | err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); 76 | if (err == Z_STREAM_END) break; 77 | EXPECT_EQ(err, Z_OK); 78 | } 79 | 80 | err = PREFIX(inflateEnd)(&d_stream); 81 | EXPECT_EQ(err, Z_OK); 82 | 83 | EXPECT_EQ(d_stream.total_out, uncompr_len); 84 | 85 | free(compr); 86 | free(uncompr); 87 | } 88 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_main.cc: -------------------------------------------------------------------------------- 1 | /* test_test.cc - Main entry point for test framework */ 2 | 3 | #include 4 | 5 | #include "gtest/gtest.h" 6 | 7 | extern "C" { 8 | # include "zbuild.h" 9 | # include "cpu_features.h" 10 | } 11 | 12 | GTEST_API_ int main(int argc, char **argv) { 13 | printf("Running main() from %s\n", __FILE__); 14 | cpu_check_features(); 15 | testing::InitGoogleTest(&argc, argv); 16 | return RUN_ALL_TESTS(); 17 | } -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_shared.h: -------------------------------------------------------------------------------- 1 | static const char hello[] = "hello, hello!"; 2 | static const int hello_len = sizeof(hello); 3 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_small_buffers.cc: -------------------------------------------------------------------------------- 1 | /* test_small_buffers.cc - Test deflate() and inflate() with small buffers */ 2 | 3 | #include "zbuild.h" 4 | #ifdef ZLIB_COMPAT 5 | # include "zlib.h" 6 | #else 7 | # include "zlib-ng.h" 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "test_shared.h" 16 | 17 | #include 18 | 19 | TEST(deflate, small_buffers) { 20 | PREFIX3(stream) c_stream, d_stream; 21 | uint8_t compr[128], uncompr[128]; 22 | z_size_t compr_len = sizeof(compr), uncompr_len = sizeof(uncompr); 23 | int err; 24 | 25 | memset(&c_stream, 0, sizeof(c_stream)); 26 | memset(&d_stream, 0, sizeof(d_stream)); 27 | 28 | err = PREFIX(deflateInit)(&c_stream, Z_DEFAULT_COMPRESSION); 29 | EXPECT_EQ(err, Z_OK); 30 | 31 | c_stream.next_in = (z_const unsigned char *)hello; 32 | c_stream.next_out = compr; 33 | 34 | while (c_stream.total_in != hello_len && c_stream.total_out < compr_len) { 35 | c_stream.avail_in = c_stream.avail_out = 1; /* force small buffers */ 36 | err = PREFIX(deflate)(&c_stream, Z_NO_FLUSH); 37 | EXPECT_EQ(err, Z_OK); 38 | } 39 | /* Finish the stream, still forcing small buffers */ 40 | for (;;) { 41 | c_stream.avail_out = 1; 42 | err = PREFIX(deflate)(&c_stream, Z_FINISH); 43 | if (err == Z_STREAM_END) break; 44 | EXPECT_EQ(err, Z_OK); 45 | } 46 | 47 | err = PREFIX(deflateEnd)(&c_stream); 48 | EXPECT_EQ(err, Z_OK); 49 | 50 | strcpy((char*)uncompr, "garbage"); 51 | 52 | d_stream.next_in = compr; 53 | d_stream.next_out = uncompr; 54 | 55 | err = PREFIX(inflateInit)(&d_stream); 56 | EXPECT_EQ(err, Z_OK); 57 | 58 | while (d_stream.total_out < uncompr_len && d_stream.total_in < compr_len) { 59 | d_stream.avail_in = d_stream.avail_out = 1; /* force small buffers */ 60 | err = PREFIX(inflate)(&d_stream, Z_NO_FLUSH); 61 | if (err == Z_STREAM_END) break; 62 | EXPECT_EQ(err, Z_OK); 63 | } 64 | 65 | err = PREFIX(inflateEnd)(&d_stream); 66 | EXPECT_EQ(err, Z_OK); 67 | 68 | EXPECT_STREQ((char*)uncompr, hello); 69 | } 70 | -------------------------------------------------------------------------------- /ext/zlib-ng/test/test_version.cc: -------------------------------------------------------------------------------- 1 | /* test_version.cc - Test zVersion() and zlibCompileFlags() */ 2 | 3 | #include "zbuild.h" 4 | #ifdef ZLIB_COMPAT 5 | # include "zlib.h" 6 | #else 7 | # include "zlib-ng.h" 8 | #endif 9 | 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | #include "test_shared.h" 16 | 17 | #include 18 | 19 | TEST(version, basic) { 20 | static const char *my_version = PREFIX2(VERSION); 21 | 22 | EXPECT_EQ(zVersion()[0], my_version[0]); 23 | EXPECT_STREQ(zVersion(), PREFIX2(VERSION)); 24 | 25 | printf("zlib-ng version %s = 0x%08lx, compile flags = 0x%lx\n", 26 | ZLIBNG_VERSION, ZLIBNG_VERNUM, PREFIX(zlibCompileFlags)()); 27 | } 28 | -------------------------------------------------------------------------------- /ext/zlib-ng/tools/config.sub: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | # Canonicalize CHOST. 3 | # In particular, converts Debian multiarch tuples into GNU triplets. 4 | # See also 5 | # https://wiki.debian.org/Multiarch/Tuples 6 | # https://wiki.gentoo.org/wiki/CHOST 7 | # If you need an architecture not listed here, file a bug at github.com/zlib-ng/zlib-ng 8 | # and work around the problem by dropping libtool's much more comprehensive config.sub 9 | # on top of this file, see 10 | # https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub 11 | 12 | case "$1" in 13 | *-*-linux-gnu*) echo $1;; 14 | i686-linux-gnu*|x86_64-linux-gnu*) echo $1 | sed 's/-linux-gnu/-pc-linux-gnu/';; 15 | *-linux-gnu*) echo $1 | sed 's/-linux-gnu/-unknown-linux-gnu/';; 16 | *) echo $1;; 17 | esac 18 | -------------------------------------------------------------------------------- /ext/zlib-ng/trees.h: -------------------------------------------------------------------------------- 1 | #ifndef TREES_H_ 2 | #define TREES_H_ 3 | 4 | /* Constants */ 5 | 6 | #define DIST_CODE_LEN 512 7 | /* see definition of array dist_code in trees.c */ 8 | 9 | #define MAX_BL_BITS 7 10 | /* Bit length codes must not exceed MAX_BL_BITS bits */ 11 | 12 | #define REP_3_6 16 13 | /* repeat previous bit length 3-6 times (2 bits of repeat count) */ 14 | 15 | #define REPZ_3_10 17 16 | /* repeat a zero length 3-10 times (3 bits of repeat count) */ 17 | 18 | #define REPZ_11_138 18 19 | /* repeat a zero length 11-138 times (7 bits of repeat count) */ 20 | 21 | static const int extra_lbits[LENGTH_CODES] /* extra bits for each length code */ 22 | = {0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0}; 23 | 24 | static const int extra_dbits[D_CODES] /* extra bits for each distance code */ 25 | = {0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13}; 26 | 27 | static const int extra_blbits[BL_CODES] /* extra bits for each bit length code */ 28 | = {0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7}; 29 | 30 | static const unsigned char bl_order[BL_CODES] 31 | = {16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15}; 32 | /* The lengths of the bit length codes are sent in order of decreasing 33 | * probability, to avoid transmitting the lengths for unused bit length codes. 34 | */ 35 | 36 | 37 | /* Function definitions */ 38 | void gen_codes (ct_data *tree, int max_code, uint16_t *bl_count); 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /ext/zlib-ng/win32/replace.vbs: -------------------------------------------------------------------------------- 1 | strInputFileName = Wscript.Arguments(0) 2 | strOutputFileName = Wscript.Arguments(1) 3 | strOldText = Wscript.Arguments(2) 4 | strNewText = Wscript.Arguments(3) 5 | 6 | Set objFSO = CreateObject("Scripting.FileSystemObject") 7 | Set objFile = objFSO.OpenTextFile(strInputFileName, 1) 8 | 9 | strText = objFile.ReadAll 10 | objFile.Close 11 | strNewText = Replace(strText, strOldText, strNewText) 12 | 13 | Set objFile = objFSO.OpenTextFile(strOutputFileName, 2, True) 14 | objFile.Write strNewText 15 | objFile.Close 16 | -------------------------------------------------------------------------------- /ext/zlib-ng/win32/zlib-ng.def.in: -------------------------------------------------------------------------------- 1 | ; zlib-ng data compression library 2 | EXPORTS 3 | ; basic functions 4 | @ZLIB_SYMBOL_PREFIX@zlibng_version 5 | @ZLIB_SYMBOL_PREFIX@zng_deflate 6 | @ZLIB_SYMBOL_PREFIX@zng_deflateEnd 7 | @ZLIB_SYMBOL_PREFIX@zng_deflateInit 8 | @ZLIB_SYMBOL_PREFIX@zng_deflateInit2 9 | @ZLIB_SYMBOL_PREFIX@zng_inflate 10 | @ZLIB_SYMBOL_PREFIX@zng_inflateEnd 11 | @ZLIB_SYMBOL_PREFIX@zng_inflateInit 12 | @ZLIB_SYMBOL_PREFIX@zng_inflateInit2 13 | @ZLIB_SYMBOL_PREFIX@zng_inflateBackInit 14 | ; advanced functions 15 | @ZLIB_SYMBOL_PREFIX@zng_deflateSetDictionary 16 | @ZLIB_SYMBOL_PREFIX@zng_deflateGetDictionary 17 | @ZLIB_SYMBOL_PREFIX@zng_deflateCopy 18 | @ZLIB_SYMBOL_PREFIX@zng_deflateReset 19 | @ZLIB_SYMBOL_PREFIX@zng_deflateParams 20 | @ZLIB_SYMBOL_PREFIX@zng_deflateTune 21 | @ZLIB_SYMBOL_PREFIX@zng_deflateBound 22 | @ZLIB_SYMBOL_PREFIX@zng_deflatePending 23 | @ZLIB_SYMBOL_PREFIX@zng_deflatePrime 24 | @ZLIB_SYMBOL_PREFIX@zng_deflateSetHeader 25 | @ZLIB_SYMBOL_PREFIX@zng_deflateSetParams 26 | @ZLIB_SYMBOL_PREFIX@zng_deflateGetParams 27 | @ZLIB_SYMBOL_PREFIX@zng_inflateSetDictionary 28 | @ZLIB_SYMBOL_PREFIX@zng_inflateGetDictionary 29 | @ZLIB_SYMBOL_PREFIX@zng_inflateSync 30 | @ZLIB_SYMBOL_PREFIX@zng_inflateCopy 31 | @ZLIB_SYMBOL_PREFIX@zng_inflateReset 32 | @ZLIB_SYMBOL_PREFIX@zng_inflateReset2 33 | @ZLIB_SYMBOL_PREFIX@zng_inflatePrime 34 | @ZLIB_SYMBOL_PREFIX@zng_inflateMark 35 | @ZLIB_SYMBOL_PREFIX@zng_inflateGetHeader 36 | @ZLIB_SYMBOL_PREFIX@zng_inflateBack 37 | @ZLIB_SYMBOL_PREFIX@zng_inflateBackEnd 38 | @ZLIB_SYMBOL_PREFIX@zng_zlibCompileFlags 39 | ; utility functions 40 | @ZLIB_SYMBOL_PREFIX@zng_compress 41 | @ZLIB_SYMBOL_PREFIX@zng_compress2 42 | @ZLIB_SYMBOL_PREFIX@zng_compressBound 43 | @ZLIB_SYMBOL_PREFIX@zng_uncompress 44 | @ZLIB_SYMBOL_PREFIX@zng_uncompress2 45 | ; checksum functions 46 | @ZLIB_SYMBOL_PREFIX@zng_adler32 47 | @ZLIB_SYMBOL_PREFIX@zng_adler32_z 48 | @ZLIB_SYMBOL_PREFIX@zng_crc32 49 | @ZLIB_SYMBOL_PREFIX@zng_crc32_z 50 | @ZLIB_SYMBOL_PREFIX@zng_adler32_combine 51 | @ZLIB_SYMBOL_PREFIX@zng_crc32_combine 52 | ; various hacks, don't look :) 53 | @ZLIB_SYMBOL_PREFIX@zng_zError 54 | @ZLIB_SYMBOL_PREFIX@zng_inflateSyncPoint 55 | @ZLIB_SYMBOL_PREFIX@zng_get_crc_table 56 | @ZLIB_SYMBOL_PREFIX@zng_inflateUndermine 57 | @ZLIB_SYMBOL_PREFIX@zng_inflateValidate 58 | @ZLIB_SYMBOL_PREFIX@zng_inflateCodesUsed 59 | @ZLIB_SYMBOL_PREFIX@zng_inflateResetKeep 60 | @ZLIB_SYMBOL_PREFIX@zng_deflateResetKeep 61 | -------------------------------------------------------------------------------- /ext/zlib-ng/win32/zlib-ng1.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "zlib-ng.h" 3 | 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION ZLIBNG_VER_MAJOR,ZLIBNG_VER_MINOR,ZLIBNG_VER_REVISION,0 6 | PRODUCTVERSION ZLIBNG_VER_MAJOR,ZLIBNG_VER_MINOR,ZLIBNG_VER_REVISION,0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | #ifdef _DEBUG 9 | FILEFLAGS 1 10 | #else 11 | FILEFLAGS 0 12 | #endif 13 | FILEOS VOS__WINDOWS32 14 | FILETYPE VFT_DLL 15 | FILESUBTYPE 0 // not used 16 | BEGIN 17 | BLOCK "StringFileInfo" 18 | BEGIN 19 | BLOCK "040904E4" 20 | //language ID = U.S. English, char set = Windows, Multilingual 21 | BEGIN 22 | VALUE "FileDescription", "zlib data compression library\0" 23 | VALUE "FileVersion", ZLIBNG_VERSION "\0" 24 | VALUE "InternalName", "zlib-ng1.dll\0" 25 | VALUE "LegalCopyright", "(C) 1995-2013 Jean-loup Gailly & Mark Adler\0" 26 | VALUE "OriginalFilename", "zlib-ng1.dll\0" 27 | VALUE "ProductName", "zlib\0" 28 | VALUE "ProductVersion", ZLIBNG_VERSION "\0" 29 | VALUE "Comments", "For more information visit https://www.zlib.net/\0" 30 | END 31 | END 32 | BLOCK "VarFileInfo" 33 | BEGIN 34 | VALUE "Translation", 0x0409, 1252 35 | END 36 | END 37 | -------------------------------------------------------------------------------- /ext/zlib-ng/win32/zlib.def.in: -------------------------------------------------------------------------------- 1 | ; zlib data compression library 2 | EXPORTS 3 | ; basic functions 4 | @ZLIB_SYMBOL_PREFIX@zlibVersion 5 | @ZLIB_SYMBOL_PREFIX@deflate 6 | @ZLIB_SYMBOL_PREFIX@deflateEnd 7 | @ZLIB_SYMBOL_PREFIX@inflate 8 | @ZLIB_SYMBOL_PREFIX@inflateEnd 9 | ; advanced functions 10 | @ZLIB_SYMBOL_PREFIX@deflateSetDictionary 11 | @ZLIB_SYMBOL_PREFIX@deflateGetDictionary 12 | @ZLIB_SYMBOL_PREFIX@deflateCopy 13 | @ZLIB_SYMBOL_PREFIX@deflateReset 14 | @ZLIB_SYMBOL_PREFIX@deflateParams 15 | @ZLIB_SYMBOL_PREFIX@deflateTune 16 | @ZLIB_SYMBOL_PREFIX@deflateBound 17 | @ZLIB_SYMBOL_PREFIX@deflatePending 18 | @ZLIB_SYMBOL_PREFIX@deflatePrime 19 | @ZLIB_SYMBOL_PREFIX@deflateSetHeader 20 | @ZLIB_SYMBOL_PREFIX@inflateSetDictionary 21 | @ZLIB_SYMBOL_PREFIX@inflateGetDictionary 22 | @ZLIB_SYMBOL_PREFIX@inflateSync 23 | @ZLIB_SYMBOL_PREFIX@inflateCopy 24 | @ZLIB_SYMBOL_PREFIX@inflateReset 25 | @ZLIB_SYMBOL_PREFIX@inflateReset2 26 | @ZLIB_SYMBOL_PREFIX@inflatePrime 27 | @ZLIB_SYMBOL_PREFIX@inflateMark 28 | @ZLIB_SYMBOL_PREFIX@inflateGetHeader 29 | @ZLIB_SYMBOL_PREFIX@inflateBack 30 | @ZLIB_SYMBOL_PREFIX@inflateBackEnd 31 | @ZLIB_SYMBOL_PREFIX@zlibCompileFlags 32 | ; utility functions 33 | @ZLIB_SYMBOL_PREFIX@compress 34 | @ZLIB_SYMBOL_PREFIX@compress2 35 | @ZLIB_SYMBOL_PREFIX@compressBound 36 | @ZLIB_SYMBOL_PREFIX@uncompress 37 | @ZLIB_SYMBOL_PREFIX@uncompress2 38 | ; large file functions 39 | @ZLIB_SYMBOL_PREFIX@adler32_combine64 40 | @ZLIB_SYMBOL_PREFIX@crc32_combine64 41 | @ZLIB_SYMBOL_PREFIX@crc32_combine_gen64 42 | ; checksum functions 43 | @ZLIB_SYMBOL_PREFIX@adler32 44 | @ZLIB_SYMBOL_PREFIX@adler32_z 45 | @ZLIB_SYMBOL_PREFIX@crc32 46 | @ZLIB_SYMBOL_PREFIX@crc32_z 47 | @ZLIB_SYMBOL_PREFIX@adler32_combine 48 | @ZLIB_SYMBOL_PREFIX@crc32_combine 49 | @ZLIB_SYMBOL_PREFIX@crc32_combine_gen 50 | @ZLIB_SYMBOL_PREFIX@crc32_combine_op 51 | ; various hacks, don't look :) 52 | @ZLIB_SYMBOL_PREFIX@deflateInit_ 53 | @ZLIB_SYMBOL_PREFIX@deflateInit2_ 54 | @ZLIB_SYMBOL_PREFIX@inflateInit_ 55 | @ZLIB_SYMBOL_PREFIX@inflateInit2_ 56 | @ZLIB_SYMBOL_PREFIX@inflateBackInit_ 57 | @ZLIB_SYMBOL_PREFIX@zError 58 | @ZLIB_SYMBOL_PREFIX@inflateSyncPoint 59 | @ZLIB_SYMBOL_PREFIX@get_crc_table 60 | @ZLIB_SYMBOL_PREFIX@inflateUndermine 61 | @ZLIB_SYMBOL_PREFIX@inflateValidate 62 | @ZLIB_SYMBOL_PREFIX@inflateCodesUsed 63 | @ZLIB_SYMBOL_PREFIX@inflateResetKeep 64 | @ZLIB_SYMBOL_PREFIX@deflateResetKeep 65 | -------------------------------------------------------------------------------- /ext/zlib-ng/win32/zlib1.rc: -------------------------------------------------------------------------------- 1 | #include 2 | #include "zlib.h" 3 | 4 | VS_VERSION_INFO VERSIONINFO 5 | FILEVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0 6 | PRODUCTVERSION ZLIB_VER_MAJOR,ZLIB_VER_MINOR,ZLIB_VER_REVISION,0 7 | FILEFLAGSMASK VS_FFI_FILEFLAGSMASK 8 | #ifdef _DEBUG 9 | FILEFLAGS 1 10 | #else 11 | FILEFLAGS 0 12 | #endif 13 | FILEOS VOS__WINDOWS32 14 | FILETYPE VFT_DLL 15 | FILESUBTYPE 0 // not used 16 | BEGIN 17 | BLOCK "StringFileInfo" 18 | BEGIN 19 | BLOCK "040904E4" 20 | //language ID = U.S. English, char set = Windows, Multilingual 21 | BEGIN 22 | VALUE "FileDescription", "zlib data compression library\0" 23 | VALUE "FileVersion", ZLIB_VERSION "\0" 24 | VALUE "InternalName", "zlib1.dll\0" 25 | VALUE "LegalCopyright", "(C) 1995-2013 Jean-loup Gailly & Mark Adler\0" 26 | VALUE "OriginalFilename", "zlib1.dll\0" 27 | VALUE "ProductName", "zlib\0" 28 | VALUE "ProductVersion", ZLIB_VERSION "\0" 29 | VALUE "Comments", "For more information visit https://www.zlib.net/\0" 30 | END 31 | END 32 | BLOCK "VarFileInfo" 33 | BEGIN 34 | VALUE "Translation", 0x0409, 1252 35 | END 36 | END 37 | -------------------------------------------------------------------------------- /ext/zlib-ng/zendian.h: -------------------------------------------------------------------------------- 1 | /* zendian.h -- define BYTE_ORDER for endian tests 2 | * For conditions of distribution and use, see copyright notice in zlib.h 3 | */ 4 | 5 | #ifndef ENDIAN_H_ 6 | #define ENDIAN_H_ 7 | 8 | /* First check whether the compiler knows the target __BYTE_ORDER__. */ 9 | #if defined(__BYTE_ORDER__) 10 | # if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ 11 | # if !defined(LITTLE_ENDIAN) 12 | # define LITTLE_ENDIAN __ORDER_LITTLE_ENDIAN__ 13 | # endif 14 | # if !defined(BYTE_ORDER) 15 | # define BYTE_ORDER LITTLE_ENDIAN 16 | # endif 17 | # elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ 18 | # if !defined(BIG_ENDIAN) 19 | # define BIG_ENDIAN __ORDER_BIG_ENDIAN__ 20 | # endif 21 | # if !defined(BYTE_ORDER) 22 | # define BYTE_ORDER BIG_ENDIAN 23 | # endif 24 | # endif 25 | #elif defined(__MINGW32__) 26 | # include 27 | #elif defined(_WIN32) 28 | # define LITTLE_ENDIAN 1234 29 | # define BIG_ENDIAN 4321 30 | # if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined (_M_ARM) || defined (_M_ARM64) 31 | # define BYTE_ORDER LITTLE_ENDIAN 32 | # else 33 | # error Unknown endianness! 34 | # endif 35 | #elif defined(__linux__) 36 | # include 37 | #elif defined(__APPLE__) || defined(__arm__) || defined(__aarch64__) 38 | # include 39 | #elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__bsdi__) || defined(__DragonFly__) 40 | # include 41 | #elif defined(__sun) || defined(sun) 42 | # include 43 | # if !defined(LITTLE_ENDIAN) 44 | # define LITTLE_ENDIAN 4321 45 | # endif 46 | # if !defined(BIG_ENDIAN) 47 | # define BIG_ENDIAN 1234 48 | # endif 49 | # if !defined(BYTE_ORDER) 50 | # if defined(_BIG_ENDIAN) 51 | # define BYTE_ORDER BIG_ENDIAN 52 | # else 53 | # define BYTE_ORDER LITTLE_ENDIAN 54 | # endif 55 | # endif 56 | #else 57 | # include 58 | #endif 59 | 60 | #endif 61 | -------------------------------------------------------------------------------- /ext/zlib-ng/zlib.map: -------------------------------------------------------------------------------- 1 | ZLIB_1.2.0 { 2 | global: 3 | compressBound; 4 | deflateBound; 5 | inflateBack; 6 | inflateBackEnd; 7 | inflateBackInit_; 8 | inflateCopy; 9 | local: 10 | deflate_copyright; 11 | inflate_copyright; 12 | inflate_fast; 13 | inflate_table; 14 | zcalloc; 15 | zcfree; 16 | z_errmsg; 17 | gz_error; 18 | _*; 19 | }; 20 | 21 | ZLIB_1.2.0.2 { 22 | gzclearerr; 23 | gzungetc; 24 | zlibCompileFlags; 25 | } ZLIB_1.2.0; 26 | 27 | ZLIB_1.2.0.8 { 28 | deflatePrime; 29 | } ZLIB_1.2.0.2; 30 | 31 | ZLIB_1.2.2 { 32 | adler32_combine; 33 | crc32_combine; 34 | deflateSetHeader; 35 | inflateGetHeader; 36 | } ZLIB_1.2.0.8; 37 | 38 | ZLIB_1.2.2.3 { 39 | deflateTune; 40 | gzdirect; 41 | } ZLIB_1.2.2; 42 | 43 | ZLIB_1.2.2.4 { 44 | inflatePrime; 45 | } ZLIB_1.2.2.3; 46 | 47 | ZLIB_1.2.3.3 { 48 | adler32_combine64; 49 | crc32_combine64; 50 | gzopen64; 51 | gzseek64; 52 | gztell64; 53 | inflateUndermine; 54 | } ZLIB_1.2.2.4; 55 | 56 | ZLIB_1.2.3.4 { 57 | inflateReset2; 58 | inflateMark; 59 | } ZLIB_1.2.3.3; 60 | 61 | ZLIB_1.2.3.5 { 62 | gzbuffer; 63 | gzoffset; 64 | gzoffset64; 65 | gzclose_r; 66 | gzclose_w; 67 | } ZLIB_1.2.3.4; 68 | 69 | ZLIB_1.2.5.1 { 70 | deflatePending; 71 | } ZLIB_1.2.3.5; 72 | 73 | ZLIB_1.2.5.2 { 74 | deflateResetKeep; 75 | gzgetc_; 76 | inflateResetKeep; 77 | } ZLIB_1.2.5.1; 78 | 79 | ZLIB_1.2.7.1 { 80 | inflateGetDictionary; 81 | gzvprintf; 82 | } ZLIB_1.2.5.2; 83 | 84 | ZLIB_1.2.9 { 85 | inflateCodesUsed; 86 | inflateValidate; 87 | uncompress2; 88 | gzfread; 89 | gzfwrite; 90 | deflateGetDictionary; 91 | adler32_z; 92 | crc32_z; 93 | } ZLIB_1.2.7.1; 94 | 95 | ZLIB_1.2.12 { 96 | crc32_combine_gen; 97 | crc32_combine_gen64; 98 | crc32_combine_op; 99 | } ZLIB_1.2.9; 100 | -------------------------------------------------------------------------------- /ext/zlib-ng/zlib.pc.cmakein: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | symbol_prefix=@ZLIB_SYMBOL_PREFIX@ 4 | libdir=@PC_LIB_INSTALL_DIR@ 5 | sharedlibdir=${libdir} 6 | includedir=@PC_INC_INSTALL_DIR@ 7 | 8 | Name: zlib@SUFFIX@ 9 | Description: zlib-ng compression library 10 | Version: @ZLIB_FULL_VERSION@ 11 | 12 | Requires: 13 | Libs: -L${libdir} -L${sharedlibdir} -lz@SUFFIX@ 14 | Cflags: -I${includedir} 15 | -------------------------------------------------------------------------------- /ext/zlib-ng/zlib.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@prefix@ 2 | exec_prefix=@exec_prefix@ 3 | symbol_prefix=@symbol_prefix@ 4 | libdir=@libdir@ 5 | sharedlibdir=@sharedlibdir@ 6 | includedir=@includedir@ 7 | 8 | Name: zlib@SUFFIX@ 9 | Description: zlib-ng compression library 10 | Version: @VERSION@ 11 | 12 | Requires: 13 | Libs: -L${libdir} -L${sharedlibdir} -lz@SUFFIX@ 14 | Cflags: -I${includedir} 15 | -------------------------------------------------------------------------------- /ext/zlib-ng/zlib_name_mangling.h.empty: -------------------------------------------------------------------------------- 1 | /* zlib_name_mangling.h has been automatically generated from 2 | * zlib_name_mangling.h.empty because ZLIB_SYMBOL_PREFIX was NOT set. 3 | */ 4 | 5 | #ifndef ZLIB_NAME_MANGLING_H 6 | #define ZLIB_NAME_MANGLING_H 7 | 8 | #endif /* ZLIB_NAME_MANGLING_H */ 9 | -------------------------------------------------------------------------------- /ext/zlib-ng/zutil_p.h: -------------------------------------------------------------------------------- 1 | /* zutil_p.h -- Private inline functions used internally in zlib-ng 2 | * For conditions of distribution and use, see copyright notice in zlib.h 3 | */ 4 | 5 | #ifndef ZUTIL_P_H 6 | #define ZUTIL_P_H 7 | 8 | #if defined(__APPLE__) || defined(HAVE_POSIX_MEMALIGN) 9 | # include 10 | #elif defined(__FreeBSD__) 11 | # include 12 | # include 13 | #else 14 | # include 15 | #endif 16 | 17 | /* Function to allocate 16 or 64-byte aligned memory */ 18 | static inline void *zng_alloc(size_t size) { 19 | #ifdef HAVE_POSIX_MEMALIGN 20 | void *ptr; 21 | return posix_memalign(&ptr, 64, size) ? NULL : ptr; 22 | #elif defined(_WIN32) 23 | return (void *)_aligned_malloc(size, 64); 24 | #elif defined(__APPLE__) 25 | return (void *)malloc(size); /* MacOS always aligns to 16 bytes */ 26 | #else 27 | return (void *)memalign(64, size); 28 | #endif 29 | } 30 | 31 | /* Function that can free aligned memory */ 32 | static inline void zng_free(void *ptr) { 33 | #if defined(_WIN32) 34 | _aligned_free(ptr); 35 | #else 36 | free(ptr); 37 | #endif 38 | } 39 | 40 | #endif 41 | -------------------------------------------------------------------------------- /figures/splitcode_example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/figures/splitcode_example.png -------------------------------------------------------------------------------- /figures/splitcode_figure.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/figures/splitcode_figure.png -------------------------------------------------------------------------------- /figures/splitcode_logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/figures/splitcode_logo.png -------------------------------------------------------------------------------- /func_tests/A_1.fastq.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/func_tests/A_1.fastq.gz -------------------------------------------------------------------------------- /func_tests/A_2.fastq.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/func_tests/A_2.fastq.gz -------------------------------------------------------------------------------- /func_tests/B_1.fastq.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/func_tests/B_1.fastq.gz -------------------------------------------------------------------------------- /func_tests/B_2.fastq.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/func_tests/B_2.fastq.gz -------------------------------------------------------------------------------- /func_tests/b.fastq: -------------------------------------------------------------------------------- 1 | @90bcac51-a76b-476e-9518-2de3598af948 2 | CTGCATCTCGTTCAGTTGCGTATTGCTGAGATATCCGACAGTGACTGGAGTTCAGACGTGTGCTCTTCCGATCTAGCCGGGACTGAGGTCCGCGATTCGTCTAGGATGCTGGCAAAATGGTCGTAAGCGGCCCGTCTTGAAACACGGACCAAGGAGTCTAACATCTAGATCGGAAGAGCGTCGTGTAGGGAAAGAGTGTAAGCCTGAG 3 | + 4 | (((&#####$&446555..//-1111B@@ABDEJEGGDECBAAABADEEBBC84333599;951101245<=::989;9;BEEGA;1111A@@@@?ABABBDEDDEHI{KG{KDDEDDJGLGDEAA?>944432232222=EFCDCDBEDDABBCCEED???@AA@@CCCBAACDFHHEDEECFFB>>>??AA@@BBCA@@A@?>,(& 5 | -------------------------------------------------------------------------------- /func_tests/config_fastassign.txt: -------------------------------------------------------------------------------- 1 | tags groups 2 | ATATATA A 3 | GTGTGTG B 4 | CCCCCC C 5 | AAAAAAAA D 6 | TTTTTTTT E 7 | GGGGGGG F 8 | -------------------------------------------------------------------------------- /func_tests/config_fastassign_2.txt: -------------------------------------------------------------------------------- 1 | tags groups 2 | ATATATA A 3 | GTGTGTG B 4 | CCCCCC D 5 | AAAAAAAA D 6 | TTTTTTTT E 7 | GGGGGGG F 8 | -------------------------------------------------------------------------------- /func_tests/configb.txt: -------------------------------------------------------------------------------- 1 | groups ids tags distances locations previous minFindsG 2 | xx xxx AAAAAAAAAAAAAAAAA 0 0:-90:0 - 3 | 2Pbc 2Pbc_3prime_1 GTGACTGGAGTTCAGAC 0 0:30:120 - 4 | 2Pbc 2Pbc_3prime_2 GTGTGCTCTTCCGATCT 0 0:43:145 - 5 | 2Puni 2Puni_3prime_2_rc GATCGGAAGAGCGTCG 0 - {2Pbc_3prime_2} 6 | -------------------------------------------------------------------------------- /func_tests/even.txt: -------------------------------------------------------------------------------- 1 | # Even 2 | 3 | ATACTGCGGCTGACG 4 | CTAGGTGGCGGTCTG 5 | GTGACATTAAGGTTG 6 | TATCAATGATGGTGC 7 | CCTCACGTCTAGGCG 8 | ATTCCTCTGCGATGC 9 | GATTACGTTCCACGG 10 | GTAGCTTACGTCATC 11 | GTAGGTTCTGGAATC 12 | AATCACGAGTTCGTC 13 | CAAGCTAGACGGTTC 14 | TAACCATATTGCCGT 15 | AGTCCTGCCACTACG 16 | GAGGATTGGAGAATC 17 | CCAACAAGATAGTGC 18 | AATGCGTGTGTTCGG 19 | TGCCGTGACTCCATC 20 | CCTTCGTTAAGGCTG 21 | AGAAGTGCTCCAGGT 22 | CGGAGGATCTAGTGG 23 | GCTGAGCTGGTCTAG 24 | GCTTCATTAACTAGG 25 | GATTAGTGCGAGAGG 26 | ACGCTCTATACACCG 27 | GTAGTCCAGGTCGTC 28 | GACGACTGACTAGGT 29 | GCATAGGACAGGCAG 30 | TCGCACCACAACCAT 31 | ACTCAAGCACCTCTC 32 | GGTCGCATGATAAGG 33 | GTATCGTATAGGTCG 34 | CGCTTGGCTAATAGG 35 | GAAGATCGCAATTAG 36 | TCTACACCGCTGAAG 37 | CGCTCCTAGATGTTC 38 | TCCGTGGCTTACTGG 39 | GACTACTGCTCACCG 40 | GTGAAGTGACTGAGG 41 | TAGATTGTTGCGTGC 42 | CCGACATCCGCTGTG 43 | TCAAGCCTTGCGGAG 44 | CCTGCTTCCGTGATG 45 | TTATTGCCACCAGTG 46 | CACGTTCAACTGGCG 47 | CCAGTTAGCAAGACG 48 | GCTGGAACTCATAAG 49 | TGCTCGTTGGTCCAG 50 | AGTCTTCGGATACCG 51 | TGGACCTCTAATTGC 52 | CATCGACTCACCTTC 53 | GCGGATTCTCAGTGG 54 | GAACACGCACATGGC 55 | GTTGCTGTGTGGATC 56 | CCAGCAATCCTACAG 57 | ACCGCAGAGAGGTAG 58 | ACGCTTATGGCAGTG 59 | GTTGCGTAGTGATGC 60 | TGATTCCTGAGTCCG 61 | GCACGAGATCCTTGC 62 | CTAGCACCTCGTAAT 63 | TCAATGGACGGATGC 64 | CGTATACCGAGTTGG 65 | TCCGTTGCTATAATC 66 | GGTTGATTCAAGAAT 67 | GCATGGATACCAGCG 68 | GTCCAGGCATTCGTC 69 | TCGTGTGAGTCTCGT 70 | ACAACGGTGCGACTG 71 | ATTCTCTGCCGAGAG 72 | CGTATCGAGGTGCCG 73 | GTTGTTCGTGTGTCG 74 | GTCCTGTCTAGTCCG 75 | GATGACCTGTCCATG 76 | AGCGTGCAGTGGAAG 77 | GGCTCTGAACCTATC 78 | GAGCTGGACAGGTGG 79 | CACAGTCCTCCATGC 80 | CCGCACTCTGATAAT 81 | TTGATAAGCCGACGG 82 | GCCTATTGTACTGCG 83 | CACACCATCGTATTC 84 | TATCCTGTCAACGGC 85 | ATGCTTCACACGGTG 86 | GCTTGCCGTAGCGTG 87 | TGTCCGCCTGCATGG 88 | GTCGATATTGATCCG 89 | GGAACACTCTACTGC 90 | AAGCGGAAGGTATAG 91 | CTACTTCCGAATCAG 92 | CCACGGAGCCTTCTC 93 | GCACACGATCATCTG 94 | CTGTTACGTCCGCTG 95 | CTGGTGTCACGTCTC 96 | ACGCTGTGGCGATTC 97 | ACTGTTCGACACGTC 98 | GCTCCAGTCGTAATC 99 | -------------------------------------------------------------------------------- /func_tests/example.SJ.tab: -------------------------------------------------------------------------------- 1 | MT 3 5 + 2 | MT 3 5 + 3 | MT 2 5 - 4 | MT 31 60 + 5 | 1 2 5 - 6 | 1 3094999 3096284 + 7 | -------------------------------------------------------------------------------- /func_tests/from_name.fq: -------------------------------------------------------------------------------- 1 | @aaa 1:N:ATCCC+ATCG 2 | GGGGAGAGAGCGATAGACATA 3 | + 4 | JJJJJJJJJJJJJJJJJJJJJ 5 | -------------------------------------------------------------------------------- /func_tests/nest.test.1.R1.fa: -------------------------------------------------------------------------------- 1 | >a 2 | ATCGTTTCGCGCC 3 | -------------------------------------------------------------------------------- /func_tests/nest.test.1.R1.fq: -------------------------------------------------------------------------------- 1 | @a 2 | ATCGTTTCGCGCG 3 | + 4 | AAAAAAAAAAAAA 5 | -------------------------------------------------------------------------------- /func_tests/nest.test.1.R2.fq: -------------------------------------------------------------------------------- 1 | @a 2 | CCCCCCCCCCCCC 3 | + 4 | AAAAAAAAAAAAA 5 | -------------------------------------------------------------------------------- /func_tests/nest.test.2.R1.fq: -------------------------------------------------------------------------------- 1 | @b 2 | CGCGAAAAAAAAAAAAA 3 | + 4 | KKKKKKKKKKKKKKKKK 5 | @c 6 | ATCGTTTCGCGCG 7 | + 8 | AAAAAAAAAAAAA 9 | -------------------------------------------------------------------------------- /func_tests/nest.test.2.R2.fq: -------------------------------------------------------------------------------- 1 | @b 2 | ATCGGGAAAAAAAAAAA 3 | + 4 | KKKKKKKKKKKKKKKKK 5 | @c 6 | ATCGTTTCGCGCG 7 | + 8 | AAAAAAAAAAAAA 9 | -------------------------------------------------------------------------------- /func_tests/nest.test.3.R1.fq: -------------------------------------------------------------------------------- 1 | @a 2 | GTGTGTGTCCCCCCCCTTTTTTTT 3 | + 4 | KKKKKKKKKKKKKKKKKKKKKKKK 5 | @b 6 | GTGTGTGTAAAAAAAATTTTTTTT 7 | + 8 | KKKKKKKKKKKKKKKKKKKKKKKK 9 | @c 10 | GTGTGTGTCCCCCCCCTTTTTTTT 11 | + 12 | KKKKKKKKKKKKKKKKKKKKKKKK 13 | @d 14 | GTGTGTGTAAAAAAAATTTTTTTT 15 | + 16 | KKKKKKKKKKKKKKKKKKKKKKKK 17 | -------------------------------------------------------------------------------- /func_tests/nest.test.3.R2.fq: -------------------------------------------------------------------------------- 1 | @a 2 | AAAAAAAAGGGGGGGGG 3 | + 4 | KKKKKKKKKKKKKKKKK 5 | @b 6 | AAAAAAAAGGGGGGGGG 7 | + 8 | KKKKKKKKKKKKKKKKK 9 | @c 10 | ACCCCAAAGGGGGGGGG 11 | + 12 | KKKKKKKKKKKKKKKKK 13 | @d 14 | ACCCCAAAGGGGGGGGG 15 | + 16 | KKKKKKKKKKKKKKKKK 17 | -------------------------------------------------------------------------------- /func_tests/nest_config.txt: -------------------------------------------------------------------------------- 1 | ids tags subs 2 | X ATCG GGGGG 3 | Y CGCG 4 | Z TTT 5 | 6 | @nest 7 | 8 | ids tags subs 9 | B GTTT AAA 10 | Y CCCC 11 | Z CGCGCG 12 | -------------------------------------------------------------------------------- /func_tests/nest_config_2.txt: -------------------------------------------------------------------------------- 1 | @extract {X}<./func_tests/xxx[5]> 2 | 3 | ids tags subs 4 | X ATCG GGGGG 5 | Y CGCG 6 | Z TTT 7 | 8 | @nest 9 | 10 | ids tags subs 11 | B GTTT AAA 12 | Y CCCC 13 | Z CGCGCG 14 | 15 | 16 | -------------------------------------------------------------------------------- /func_tests/nest_config_3.txt: -------------------------------------------------------------------------------- 1 | @extract {X} 2 | 3 | ids tags subs 4 | X ATCG GGGGG 5 | Y CGCG 6 | Z TTT 7 | 8 | @nest 9 | 10 | ids tags subs 11 | B GTTT AAA 12 | Y CCCC 13 | Z CGCGCG 14 | 15 | @nest 16 | 17 | @x-only 18 | @extract {GGA}<./func_tests/xx>1:-1 19 | 20 | tags locations 21 | GGA 1 22 | 23 | 24 | -------------------------------------------------------------------------------- /func_tests/nest_config_4.txt: -------------------------------------------------------------------------------- 1 | 2 | @assign 3 | 4 | @keep: 5 | R,R2 6 | 7 | ids tags locations 8 | R AAAAAA 1:0:10 9 | R2 GGGGGG 1:10 10 | 11 | 12 | @nest 13 | 14 | @x-only 15 | @no-tags 16 | @filter-len 0,24,17 17 | 18 | -------------------------------------------------------------------------------- /func_tests/nest_config_5.txt: -------------------------------------------------------------------------------- 1 | @extract {X} 2 | 3 | ids tags subs 4 | X ATCG GGGGG 5 | Y CGCG 6 | Z TTT 7 | 8 | @nest 9 | 10 | ids tags subs 11 | B GTTT AAA 12 | Y CCCC 13 | Z CGCGCG 14 | 15 | @nest 16 | 17 | @extract {GGA}<./func_tests/xx>1:-1 18 | 19 | tags locations 20 | GGA 1 21 | 22 | 23 | -------------------------------------------------------------------------------- /func_tests/odd.txt: -------------------------------------------------------------------------------- 1 | # Odd 2 | 3 | TTCGTGGAATCTAGC 4 | CCTCTAACTAAGGAT 5 | CCTACAGAAGTATCT 6 | GTGTCAAGCACCGCT 7 | GTATTACTCATAGGC 8 | ACCGCAATATAATTG 9 | GACAAGCCACCTTAT 10 | CTGTGTCTGTCACCT 11 | CCTGTGCGTTAGAGT 12 | ATCAATCGCAGCGGT 13 | TCGGCAACAGACCAT 14 | CTAGGTCGAATGCCT 15 | CGGTCACGCCTGAGC 16 | ATCAATGAACGAGGC 17 | GCCGTGCCTCTAACT 18 | TGGCTAGGTTGTGTG 19 | ACTAGAGGTGTCCGT 20 | GCCATGCAGTTACGC 21 | GTGCTATAATCTTGT 22 | AGTTCGTCACCGTGT 23 | TCGAGTGGAGCAATT 24 | GCGTCATCGGACTCT 25 | GGTTGCTTGCATTGT 26 | CGGTTCGTTAGGCGT 27 | TACTCGGTTAGTCCT 28 | TGCCTACGACGTAGC 29 | GTAGAACGCTAGGTT 30 | GTCACACGTTGAACT 31 | CCGCCTAGTGAGGCT 32 | AGGACGCAGTGAGAT 33 | AGCAACGTCCTATTG 34 | ATACGGCACCTACTT 35 | TCGTTCTCATTCTGT 36 | ACAATCACCGTGTAT 37 | ATCATACCACGCCGC 38 | ATACTCTGGTGCCAT 39 | TGATGTGATAAGGCT 40 | TTGAACACTTCCGTT 41 | GGTTGCAGCCTCCGC 42 | CACACGTCGAGCGAT 43 | ACGCCGATAAGGACT 44 | GCTCTTCATAAGCCT 45 | TCCTGGACAGTGAGC 46 | GTCACCAAGAGACGC 47 | TTCTTGTCTTGGAGC 48 | TGTGTAGGAGCAAGT 49 | GTTCATTACGTCAGT 50 | CTCAATCTGGATCGC 51 | CTGGAAGCCTCTAGC 52 | GAATATAGGCACTTG 53 | GTTCTCCTTAGAGAT 54 | CCTTCCGCCTCGTAT 55 | TCAAGGTGTCCGAGT 56 | TTGCTTAACGGATTG 57 | TATGAATATGTGGCT 58 | TTCCAACACACGGAT 59 | CGTGAGGATCAACGC 60 | TATCTGTGAGCCGAT 61 | CGTTCCATGCTATCT 62 | AGACAGACGGTCTAT 63 | TCTCTTGCATCACGC 64 | TATCGCACTCATTGT 65 | TCACTCGGTGCGACT 66 | CTACATCTGTCGAGT 67 | GATACCGTAGCAGAT 68 | AATTGAATACACCGT 69 | GATAGCACCGTTCAT 70 | GCCATTCCACTTAGC 71 | TGAGTGCCGCAGACT 72 | CTCCAGTGTCGTCGC 73 | CCTAGTAGAAGACGT 74 | GAGTGCGTGTTAGCT 75 | TCTAACACACAGCCT 76 | ATATCTCGAATAGGC 77 | ACCAAGCACCAGACT 78 | ACGAACTCCATGCGT 79 | CTATTGCATCTTCAT 80 | TCCGATGGACGCCGT 81 | TGCTAACCTACACAT 82 | AACGAGGTCAGTCGC 83 | AGTGGCACTTCACCT 84 | GGCAACGGCTCATGT 85 | CCTTCCTATGCTACT 86 | GGCAAGACTGCCTAT 87 | TCGAGGATAGCCTGT 88 | AACGCAGGATACTAT 89 | CTCAGGAAGGCTGAT 90 | CTCTTGGAGGTATCT 91 | GAAGTGGTTCGGTCT 92 | GAGAGGATGAATGCT 93 | TAACGCTGTGAAGGC 94 | AGACTCAATTAGGCT 95 | TCCGAGATGATGTGT 96 | CGTGTCATCGCTAGT 97 | GCTGACATAAGACCT 98 | GAAGCCTCGGATTGT 99 | -------------------------------------------------------------------------------- /func_tests/test_1.vcf.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/func_tests/test_1.vcf.gz -------------------------------------------------------------------------------- /func_tests/test_2.vcf.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/func_tests/test_2.vcf.gz -------------------------------------------------------------------------------- /func_tests/vcf_validation.fa.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pachterlab/splitcode/dc7b14f32d3753c9448c2f3b8465c82e93817913/func_tests/vcf_validation.fa.gz -------------------------------------------------------------------------------- /src/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | file(GLOB sources *.cpp) 2 | file(GLOB headers *.h *.hpp) 3 | 4 | list(REMOVE_ITEM sources main.cpp) 5 | 6 | add_library(splitcode_core ${sources} ${headers}) 7 | target_include_directories(splitcode_core PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) 8 | 9 | add_executable(splitcode main.cpp) 10 | 11 | find_package( Threads REQUIRED ) 12 | target_link_libraries(splitcode splitcode_core pthread) 13 | 14 | if(LINK MATCHES static) 15 | set(BUILD_SHARED_LIBS OFF) 16 | 17 | if (UNIX AND NOT APPLE) 18 | set(CMAKE_EXE_LINKER_FLAGS "-static -static-libstdc++") 19 | SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") 20 | set(CMAKE_EXE_LINKER_FLAGS "-static -static-libgcc -static-libstdc++") 21 | endif(UNIX AND NOT APPLE) 22 | 23 | SET_TARGET_PROPERTIES(splitcode splitcode_core PROPERTIES LINK_SEARCH_END_STATIC 1) 24 | endif(LINK MATCHES static) 25 | 26 | if (NOT ZLIBNG) 27 | find_package( ZLIB REQUIRED ) 28 | 29 | if ( ZLIB_FOUND ) 30 | include_directories( ${ZLIB_INCLUDE_DIRS} ) 31 | target_link_libraries(splitcode splitcode_core ${ZLIB_LIBRARIES}) 32 | else() 33 | message(FATAL_ERROR "zlib not found. Required for reading FASTQ files" ) 34 | endif( ZLIB_FOUND ) 35 | endif(NOT ZLIBNG) 36 | 37 | if (ZLIBNG) 38 | add_definitions(-DSPLITCODE_USE_ZLIB_NG) 39 | include_directories(../ext/zlib-ng/zlib-ng) 40 | include_directories(../ext/zlib-ng) 41 | if(WIN32) 42 | target_link_libraries(splitcode ${CMAKE_CURRENT_SOURCE_DIR}/../ext/zlib-ng/zlib-ng/libz.lib) 43 | else() 44 | target_link_libraries(splitcode ${CMAKE_CURRENT_SOURCE_DIR}/../ext/zlib-ng/zlib-ng/libz.a) 45 | endif(WIN32) 46 | endif(ZLIBNG) 47 | 48 | if (USE_HTSLIB) 49 | include_directories(../ext/htslib) 50 | if(WIN32) 51 | target_link_libraries(splitcode ${CMAKE_CURRENT_SOURCE_DIR}/../ext/htslib/libhts.lib) 52 | else() 53 | if(ZLIBNG) 54 | target_link_libraries(splitcode ${CMAKE_CURRENT_SOURCE_DIR}/../ext/htslib/libhts.a ${CMAKE_CURRENT_SOURCE_DIR}/../ext/zlib-ng/zlib-ng/libz.a) 55 | else() 56 | target_link_libraries(splitcode ${CMAKE_CURRENT_SOURCE_DIR}/../ext/htslib/libhts.a) 57 | endif(ZLIBNG) 58 | endif(WIN32) 59 | else() 60 | add_definitions(-DNO_HTSLIB) 61 | endif() 62 | 63 | if(LINK MATCHES static) 64 | if (UNIX AND NOT APPLE) 65 | target_link_libraries(splitcode librt.a) 66 | endif() 67 | else() 68 | if (UNIX AND NOT APPLE) 69 | target_link_libraries(splitcode rt) 70 | endif() 71 | endif(LINK MATCHES static) 72 | 73 | 74 | install(TARGETS splitcode DESTINATION "${CMAKE_INSTALL_BINDIR}") 75 | --------------------------------------------------------------------------------