Compare commits
21
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
33554dc14e | ||
|
|
c7d4c28f01 | ||
|
|
c8929b8c77 | ||
|
|
7ee0fe1c1f | ||
|
|
ce11589f84 | ||
|
|
c34ec52159 | ||
|
|
50d9826e74 | ||
|
|
4444d35985 | ||
|
|
78a597543c | ||
|
|
78999ebcfa | ||
|
|
b049475dd6 | ||
|
|
477b6567e7 | ||
|
|
ba67d870a2 | ||
|
|
f4019ad5ea | ||
|
|
098779c924 | ||
|
|
54b9c86d9d | ||
|
|
744dc87c16 | ||
|
|
b400655f3c | ||
|
|
314ab9e9f0 | ||
|
|
0fbc448013 | ||
|
|
eb9d1982fa |
No files matched your search
@@ -0,0 +1,73 @@
|
||||
version: 2
|
||||
jobs:
|
||||
build:
|
||||
working_directory: /root/SRB2
|
||||
docker:
|
||||
- image: debian:stretch
|
||||
environment:
|
||||
CC: ccache gcc -m32
|
||||
PKG_CONFIG_LIBDIR: /usr/lib/i386-linux-gnu/pkgconfig
|
||||
LIBGME_CFLAGS: -I/usr/include
|
||||
LIBGME_LDFLAGS: -lgme
|
||||
CCACHE_COMPRESS: true
|
||||
WFLAGS: -Wno-unsuffixed-float-constants
|
||||
GCC49: true
|
||||
#- image: ubuntu:trusty
|
||||
# environment:
|
||||
# CC: ccache gcc -m32
|
||||
# PKG_CONFIG_LIBDIR: /usr/lib/i386-linux-gnu/pkgconfig
|
||||
# LIBGME_CFLAGS: -I/usr/include
|
||||
# LIBGME_LDFLAGS: -lgme
|
||||
# CCACHE_COMPRESS: true
|
||||
# WFLAGS: -Wno-unsuffixed-float-constants
|
||||
# GCC48: true
|
||||
steps:
|
||||
- run:
|
||||
name: Add i386 arch
|
||||
command: dpkg --add-architecture i386
|
||||
- run:
|
||||
name: Add STJr PPA
|
||||
command: |
|
||||
apt-get -qq update
|
||||
apt-get -qq -y install dirmngr
|
||||
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys 0B1702D71499D9C25F986507F240F4449D3B0EC6
|
||||
echo "deb http://ppa.launchpad.net/stjr/srb2/ubuntu trusty main" >> /etc/apt/sources.list
|
||||
- run:
|
||||
name: Update APT listing
|
||||
command: apt-get -qq update
|
||||
- run:
|
||||
name: Support S3 upload
|
||||
command: apt-get -qq -y install ca-certificates
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-SRB2-APT
|
||||
- run:
|
||||
name: Install SDK
|
||||
command: apt-get -qq -y --no-install-recommends install git build-essential libpng-dev:i386 libsdl2-mixer-dev:i386 libgme-dev:i386 libcurl4-openssl-dev:i386 libopenmpt-dev:i386 gettext ccache wget gcc-multilib upx openssh-client
|
||||
- save_cache:
|
||||
key: v1-SRB2-APT
|
||||
paths:
|
||||
- /var/cache/apt/archives
|
||||
- checkout
|
||||
#- run:
|
||||
# name: Compile without network support and BLUA
|
||||
# command: make -C src LINUX=1 ERRORMODE=1 -k NONET=1 NO_LUA=1
|
||||
#- run:
|
||||
# name: wipe build
|
||||
# command: make -C src LINUX=1 cleandep
|
||||
- run:
|
||||
name: rebuild depend
|
||||
command: make -C src LINUX=1 clean
|
||||
- restore_cache:
|
||||
keys:
|
||||
- v1-SRB2-{{ .Branch }}-{{ checksum "objs/Linux/SDL/Release/depend.dep" }}
|
||||
- run:
|
||||
name: Compile
|
||||
command: make -C src LINUX=1 ERRORMODE=1 -k
|
||||
- store_artifacts:
|
||||
path: /root/SRB2/bin/Linux/Release/
|
||||
destination: bin
|
||||
- save_cache:
|
||||
key: v1-SRB2-{{ .Branch }}-{{ checksum "objs/Linux/SDL/Release/depend.dep" }}
|
||||
paths:
|
||||
- /root/.ccache
|
||||
@@ -4,7 +4,6 @@
|
||||
*.plg
|
||||
*.suo
|
||||
*.vcproj.*.*.user
|
||||
*.kate-swp
|
||||
Win32_LIB_ASM_Debug
|
||||
Win32_LIB_ASM_Release
|
||||
*.bsc
|
||||
|
||||
+436
@@ -0,0 +1,436 @@
|
||||
default:
|
||||
image: debian:stable-slim
|
||||
|
||||
stages: # List of stages for jobs, and their order of execution
|
||||
- build
|
||||
|
||||
variables:
|
||||
GIT_STRATEGY: clone
|
||||
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_CONCURRENT_ID/$CI_PROJECT_PATH
|
||||
|
||||
.job_template: &job_build # This job runs in the build stage, which runs first.
|
||||
|
||||
stage: build
|
||||
|
||||
cache:
|
||||
- key: ccache-$CI_PROJECT_PATH_SLUG-$CI_JOB_NAME_SLUG
|
||||
fallback_keys:
|
||||
- cache-$CI_PROJECT_PATH_SLUG-$CI_DEFAULT_BRANCH
|
||||
- cache-$CI_PROJECT_PATH_SLUG-default
|
||||
paths:
|
||||
- ccache
|
||||
- ccache_statslog
|
||||
|
||||
- key: apt-$CI_JOB_IMAGE
|
||||
paths:
|
||||
- apt-cache
|
||||
unprotect: true
|
||||
|
||||
before_script:
|
||||
- - |
|
||||
# debconf
|
||||
echo -e "\e[0Ksection_start:`date +%s`:debconf[collapsed=true]\r\e[0KSetup debconf's environment"
|
||||
- export DEBIAN_FRONTEND="noninteractive"
|
||||
- export DEBIAN_PRIORITY="low"
|
||||
- export DEBCONF_NONINTERACTIVE_SEEN="true"
|
||||
- |
|
||||
# debconf
|
||||
echo -e "\e[0Ksection_end:`date +%s`:debconf\r\e[0K"
|
||||
- - |
|
||||
# dpkg_aa
|
||||
echo -e "\e[0Ksection_start:`date +%s`:dpkg_aa[collapsed=true]\r\e[0KAdding architectures to dpkg"
|
||||
- dpkg --add-architecture i386
|
||||
- dpkg --add-architecture amd64
|
||||
- dpkg --add-architecture arm64
|
||||
- |
|
||||
# dpkg_aa
|
||||
echo -e "\e[0Ksection_end:`date +%s`:dpkg_aa\r\e[0K"
|
||||
- - |
|
||||
# apt_conf
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_conf[collapsed=true]\r\e[0KSetting up APT conf"
|
||||
- export APT_CACHE_DIR=`pwd`/apt-cache
|
||||
- mkdir --parents --verbose $APT_CACHE_DIR/partial/
|
||||
- touch /etc/apt/apt.conf.d/99build
|
||||
- |
|
||||
# apt.conf
|
||||
echo Adding options to apt.conf':'
|
||||
- |
|
||||
# APT::Install-Recommends
|
||||
echo APT::Install-Recommends "false"\; | tee --append /etc/apt/apt.conf.d/99build
|
||||
- |
|
||||
# quit
|
||||
echo quiet "1"\; | tee --append /etc/apt/apt.conf.d/99build
|
||||
- |
|
||||
# APT::Get::Assume-Yes
|
||||
echo APT::Get::Assume-Yes "true"\; | tee --append /etc/apt/apt.conf.d/99build
|
||||
- |
|
||||
# Dir::Cache::Archives
|
||||
echo Dir::Cache::Archives "$APT_CACHE_DIR"\; | tee --append /etc/apt/apt.conf.d/99build
|
||||
- |
|
||||
# apt_conf
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_conf\r\e[0K"
|
||||
- - |
|
||||
# apt_update
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_update[collapsed=true]\r\e[0KUpdating APT listing"
|
||||
- apt-get update
|
||||
- |
|
||||
# apt_update
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_update\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_pre
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_pre[collapsed=true]\r\e[0KInstalling pre packages"
|
||||
- apt-get install apt-utils
|
||||
- |
|
||||
# apt_pre
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_pre\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_upgrade
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_upgrade[collapsed=true]\r\e[0KUpdating existing packages"
|
||||
- apt-get upgrade
|
||||
- |
|
||||
# apt_update
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_upgrade\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_common
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_common[collapsed=true]\r\e[0KInstalling common packages"
|
||||
- apt-get install make git ccache
|
||||
- |
|
||||
# apt_common
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_common\r\e[0K"
|
||||
|
||||
- - |
|
||||
# ccache_config
|
||||
echo -e "\e[0Ksection_start:`date +%s`:ccache_config[collapsed=true]\r\e[0KSetting up ccache config"
|
||||
- mkdir --parents --verbose ~/.ccache/
|
||||
- touch ~/.ccache/ccache.conf
|
||||
- |
|
||||
# cache.conf
|
||||
echo Adding ccache configution option
|
||||
- |
|
||||
# base_dir
|
||||
echo base_dir = $PWD | tee --append ~/.ccache/ccache.conf
|
||||
- |
|
||||
# cache_dir
|
||||
echo cache_dir = $PWD/ccache | tee --append ~/.ccache/ccache.conf
|
||||
- |
|
||||
# compiler_check
|
||||
echo compiler_check = content | tee --append ~/.ccache/ccache.conf
|
||||
- |
|
||||
# stats_log
|
||||
echo stats_log = $PWD/ccache_statslog | tee --append ~/.ccache/ccache.conf
|
||||
- |
|
||||
# max_size
|
||||
echo max_size = 50M | tee --append ~/.ccache/ccache.conf
|
||||
- |
|
||||
# ccache_config
|
||||
echo -e "\e[0Ksection_end:`date +%s`:ccache_config\r\e[0K"
|
||||
|
||||
- - |
|
||||
# cache_reset
|
||||
echo -e "\e[0Ksection_start:`date +%s`:ccache_reset[collapsed=true]\r\e[0KResetting ccache statistics"
|
||||
- ccache --zero-stats
|
||||
- ccache --show-stats
|
||||
- |
|
||||
# ccache_reset
|
||||
echo -e "\e[0Ksection_end:`date +%s`:ccache_reset\r\e[0K"
|
||||
|
||||
after_script:
|
||||
- - |
|
||||
# apt_clean
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_clean[collapsed=true]\r\e[0KCleaning of unneeded APT packages"
|
||||
- apt-get autoclean
|
||||
- |
|
||||
# apt_clean
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_clean\r\e[0K"
|
||||
|
||||
- - |
|
||||
# ccache_stats
|
||||
echo -e "\e[0Ksection_start:`date +%s`:ccache_stats[collapsed=true]\r\e[0Kccache statistics:"
|
||||
- ccache --show-stats --verbose
|
||||
- ccache --show-log-stats --verbose
|
||||
- |
|
||||
# ccahe_stats
|
||||
echo -e "\e[0Ksection_end:`date +%s`:ccache_stats\r\e[0K"
|
||||
|
||||
Debian testing GCC:
|
||||
<<: *job_build
|
||||
image: debian:testing-slim
|
||||
|
||||
allow_failure: true
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
expose_as: "Debian GCC testing"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-testing-gcc"
|
||||
|
||||
variables:
|
||||
CC: gcc
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install gcc
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
|
||||
- apt-get install libsdl2-mixer-dev libpng-dev libcurl4-openssl-dev libgme-dev libopenmpt-dev
|
||||
- |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Windows x86:
|
||||
<<: *job_build
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-Win32"
|
||||
|
||||
variables:
|
||||
PREFIX: i686-w64-mingw32
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install gcc-mingw-w64-i686-win32
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 MINGW=1 SDL=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 MINGW=1 SDL=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Debian stable:amd64:
|
||||
<<: *job_build
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
expose_as: "Debian amd64"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-x86-64"
|
||||
|
||||
variables:
|
||||
CC: x86_64-linux-gnu-gcc
|
||||
OBJCOPY: x86_64-linux-gnu-objcopy
|
||||
OBJDUMP: x86_64-linux-gnu-objdump
|
||||
PKG_CONFIG_PATH: /usr/lib/x86_64-linux-gnu/pkgconfig
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install gcc-x86-64-linux-gnu || apt-get install gcc
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
|
||||
- apt-get install libsdl2-mixer-dev:amd64 libpng-dev:amd64 libcurl4-openssl-dev:amd64 libgme-dev:amd64 libopenmpt-dev:amd64
|
||||
- |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX64=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX64=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Debian stable:i386:
|
||||
<<: *job_build
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
expose_as: "Debian i386"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-i686"
|
||||
|
||||
variables:
|
||||
CC: i686-linux-gnu-gcc
|
||||
OBJCOPY: i686-linux-gnu-objcopy
|
||||
OBJDUMP: i686-linux-gnu-objdump
|
||||
PKG_CONFIG_PATH: /usr/lib/i386-linux-gnu/pkgconfig
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install gcc-i686-linux-gnu || apt-get install gcc
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
|
||||
- apt-get install libsdl2-mixer-dev:i386 libpng-dev:i386 libcurl4-openssl-dev:i386 libgme-dev:i386 libopenmpt-dev:i386
|
||||
- |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Debian stable:arm64:
|
||||
<<: *job_build
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
expose_as: "Debian arm64"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-aarch64"
|
||||
|
||||
variables:
|
||||
CC: aarch64-linux-gnu-gcc
|
||||
OBJCOPY: aarch64-linux-gnu-objcopy
|
||||
OBJDUMP: aarch64-linux-gnu-objdump
|
||||
PKG_CONFIG_PATH: /usr/lib/aarch64-linux-gnu/pkgconfig
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install gcc-aarch64-linux-gnu || apt-get install gcc
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
|
||||
- apt-get install libsdl2-mixer-dev:arm64 libpng-dev:arm64 libcurl4-openssl-dev:arm64 libgme-dev:arm64 libopenmpt-dev:arm64
|
||||
- |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX64=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 LINUX64=1 NONX86=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Windows x64:
|
||||
<<: *job_build
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
expose_as: "Win64"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-Win64"
|
||||
|
||||
variables:
|
||||
PREFIX: x86_64-w64-mingw32
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install gcc-mingw-w64-x86-64-win32
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 MINGW64=1 SDL=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 MINGW64=1 SDL=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Debian stable Clang:
|
||||
<<: *job_build
|
||||
|
||||
allow_failure: true
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
expose_as: "Debian Clang"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-clang"
|
||||
|
||||
variables:
|
||||
CC: clang
|
||||
WFLAGS: -Wno-cast-align
|
||||
|
||||
script:
|
||||
- - |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_toolchain[collapsed=true]\r\e[0KInstalling toolchain packages"
|
||||
- apt-get install clang
|
||||
- |
|
||||
# apt_toolchain
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_toolchain\r\e[0K"
|
||||
|
||||
- - |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_start:`date +%s`:apt_development[collapsed=true]\r\e[0KInstalling development packages"
|
||||
- apt-get install libsdl2-mixer-dev libpng-dev libcurl4-openssl-dev libgme-dev libopenmpt-dev
|
||||
- |
|
||||
# apt_development
|
||||
echo -e "\e[0Ksection_end:`date +%s`:apt_development\r\e[0K"
|
||||
|
||||
- - |
|
||||
# make
|
||||
echo -e "\e[0Ksection_start:`date +%s`:make[collapsed=false]\r\e[0KCompiling SRB2"
|
||||
- make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1 || make --directory=src --keep-going CCACHE=1 ERRORMODE=1 NONX86=1
|
||||
- |
|
||||
# make
|
||||
echo -e "\e[0Ksection_end:`date +%s`:make\r\e[0K"
|
||||
|
||||
Debian testing Clang:
|
||||
extends: Debian stable Clang
|
||||
|
||||
image: debian:testing-slim
|
||||
|
||||
artifacts:
|
||||
paths:
|
||||
- "bin/"
|
||||
- "src/comptime.h"
|
||||
expose_as: "Debina Clang testing"
|
||||
name: "$CI_PROJECT_PATH_SLUG-$CI_COMMIT_REF_SLUG-$CI_COMMIT_SHORT_SHA-testing-clang"
|
||||
|
||||
variables:
|
||||
CC: clang
|
||||
WFLAGS: -Wno-cast-align -Wno-deprecated-non-prototype
|
||||
@@ -0,0 +1,5 @@
|
||||
[submodule "libs/bluajit"]
|
||||
path = libs/bluajit
|
||||
url = https://github.com/Indev450/bluajit
|
||||
[submodule "libs/bluajit/"]
|
||||
branch = bluajit-install
|
||||
+712
@@ -0,0 +1,712 @@
|
||||
# Travis-CI Config
|
||||
#
|
||||
# You may use the Deployer to upload packages and builds to external servers.
|
||||
# See deployer/travis/deployer_defaults.sh for environment variables to configure.
|
||||
|
||||
language: c
|
||||
sudo: required
|
||||
dist: trusty
|
||||
|
||||
matrix:
|
||||
include:
|
||||
################################
|
||||
# Test Buildbots
|
||||
# Deployer does not operate on these. See Deployer Buildbots, below.
|
||||
# These bots are disabled when a deployment is triggered by 'deployer' branch name AND DPL_TERMINATE_TESTS=1.
|
||||
# These bots remain enabled when a deployment is triggered by release tag.
|
||||
################################
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.4
|
||||
compiler: gcc-4.4
|
||||
env: GCC44=1
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#gcc-4.4 (Ubuntu/Linaro 4.4.7-8ubuntu1) 4.4.7
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.6
|
||||
compiler: gcc-4.6
|
||||
env: GCC46=1
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#gcc-4.6 (Ubuntu/Linaro 4.6.4-6ubuntu2) 4.6.4
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.7
|
||||
compiler: gcc-4.7
|
||||
env: GCC47=1
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#gcc-4.7
|
||||
- os: linux
|
||||
compiler: gcc
|
||||
env: GCC48=1
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#gcc (Ubuntu 4.8.4-2ubuntu1~14.04) 4.8.4
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
env: GCC48=1
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-7
|
||||
compiler: gcc-7
|
||||
env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough" GCC72=1
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#gcc-7 (Ubuntu 7.2.0-1ubuntu1~14.04) 7.2.0 20170802
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-8
|
||||
compiler: gcc-8
|
||||
env: WFLAGS="-Wno-tautological-compare -Wno-error=implicit-fallthrough -Wno-implicit-fallthrough -Wno-error=format-overflow -Wno-error=format-truncation" GCC81=1
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#gcc-8 (Ubuntu 7.2.0-1ubuntu1~14.04) 8.1.0
|
||||
- os: linux
|
||||
compiler: clang
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#clang version 3.5.0 (tags/RELEASE_350/final)
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-precise-3.5
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- clang-3.5
|
||||
compiler: clang-3.5
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#Ubuntu clang version 3.5.0-4ubuntu2~trusty2 (tags/RELEASE_350/final) (based on LLVM 3.5.0)
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-precise-3.6
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- clang-3.6
|
||||
compiler: clang-3.6
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#Ubuntu clang version 3.6.2-svn240577-1~exp1 (branches/release_36) (based on LLVM 3.6.2)
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-precise-3.7
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- clang-3.7
|
||||
compiler: clang-3.7
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#Ubuntu clang version 3.7.1-svn253571-1~exp1 (branches/release_37) (based on LLVM 3.7.1)
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-precise-3.8
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- clang-3.8
|
||||
compiler: clang-3.8
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#clang version 3.8.1-svn271127-1~exp1 (branches/release_38)
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
sources:
|
||||
- llvm-toolchain-precise-3.9
|
||||
- ubuntu-toolchain-r-test
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- clang-3.9
|
||||
compiler: clang-3.9
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#clang version 3.9.X
|
||||
# - os: linux
|
||||
# addons:
|
||||
# apt:
|
||||
# sources:
|
||||
# - llvm-toolchain-precise-4.0
|
||||
# - ubuntu-toolchain-r-test
|
||||
# packages:
|
||||
# - libsdl2-mixer-dev
|
||||
# - libpng-dev
|
||||
# - libgl1-mesa-dev
|
||||
# - libgme-dev
|
||||
# - p7zip-full
|
||||
# - clang-4.0
|
||||
# compiler: clang-4.0
|
||||
# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
# #clang version 4.0.X
|
||||
# - os: linux
|
||||
# addons:
|
||||
# apt:
|
||||
# sources:
|
||||
# - llvm-toolchain-precise-5.0
|
||||
# - ubuntu-toolchain-r-test
|
||||
# packages:
|
||||
# - libsdl2-mixer-dev
|
||||
# - libpng-dev
|
||||
# - libgl1-mesa-dev
|
||||
# - libgme-dev
|
||||
# - p7zip-full
|
||||
# - clang-5.0
|
||||
# compiler: clang-5.0
|
||||
# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
# #clang version 5.0.X
|
||||
# - os: osx
|
||||
# osx_image: beta-xcode6.1
|
||||
# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
# #Apple LLVM version 6.0 (clang-600.0.54) (based on LLVM 3.5svn)
|
||||
# - os: osx
|
||||
# osx_image: beta-xcode6.2
|
||||
# compiler: gcc
|
||||
# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
# #Apple LLVM version 6.0 (clang-600.0.57) (based on LLVM 3.5svn)
|
||||
## - os: osx
|
||||
## osx_image: beta-xcode6.3
|
||||
## if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
## #I think xcode.6.3 VM is broken, it does not boot
|
||||
# - os: osx
|
||||
# osx_image: xcode6.4
|
||||
# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
# #Apple LLVM version 6.1.0 (clang-602.0.53) (based on LLVM 3.6.0svn)
|
||||
# - os: osx
|
||||
# osx_image: xcode7
|
||||
# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
# #Apple LLVM version 7.0.0 (clang-700.0.72)
|
||||
# - os: osx
|
||||
# osx_image: xcode7.1
|
||||
# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
# #Apple LLVM version 7.0.0 (clang-700.1.76)
|
||||
# - os: osx
|
||||
# osx_image: xcode7.2
|
||||
# if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
# #Apple LLVM version 7.0.2 (clang-700.1.81)
|
||||
# - os: osx
|
||||
# osx_image: xcode7.3
|
||||
# #Apple LLVM version 7.3.0 (clang-703.0.31)
|
||||
# - os: osx
|
||||
# osx_image: xcode7.3
|
||||
# #Apple LLVM version 7.3.0 (clang-703.0.31)
|
||||
- os: osx
|
||||
if: env(DPL_ENABLED) != "1" OR env(DPL_TERMINATE_TESTS) != "1" OR NOT branch =~ /^.*deployer.*$/
|
||||
#Default: macOS 10.13 and Xcode 9.4.1
|
||||
|
||||
|
||||
################################
|
||||
# Deployer Buildbots - OSX
|
||||
################################
|
||||
- os: osx
|
||||
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
AND env(DPL_TERMINATE_MAIN) != "1"
|
||||
env:
|
||||
- _DPL_JOB_ENABLED=1
|
||||
- _DPL_JOB_NAME=osx
|
||||
- _DPL_FTP_TARGET=1
|
||||
- _DPL_PACKAGE_BINARY=1
|
||||
#Apple LLVM version 7.3.0 (clang-703.0.31)
|
||||
|
||||
|
||||
################################
|
||||
# Deployer Buildbots - Linux assets
|
||||
# Set DPL_TERMINATE_ASSETS to disable all of these
|
||||
# List Ubuntu LTS next, newest to oldest
|
||||
# Then list non-LTS, newest to oldest
|
||||
################################
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
dist: xenial
|
||||
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
AND env(DPL_TERMINATE_ASSETS) != "1"
|
||||
env:
|
||||
- _DPL_JOB_ENABLED=1
|
||||
- _DPL_JOB_NAME=bionic-asset
|
||||
- _DPL_DPUT_TARGET=1
|
||||
- _DPL_PACKAGE_SOURCE=1
|
||||
- _DPL_PACKAGE_MAIN=0
|
||||
- _DPL_PACKAGE_ASSET=1
|
||||
- PACKAGE_DISTRO=bionic
|
||||
#- PACKAGE_SUBVERSION=~18.04bionic
|
||||
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
|
||||
################################
|
||||
# The below asset bots produce packages that occupy too much space.
|
||||
# It would be nice if the asset files were not included in the source package itself,
|
||||
# so these can deploy to each Ubuntu target without manual intervention.
|
||||
#
|
||||
# Currently, to get around Launchpad's space limitation,
|
||||
# copy the packages from *one* bot and the space usage is not increased.
|
||||
################################
|
||||
# - os: linux
|
||||
# addons:
|
||||
# apt:
|
||||
# packages:
|
||||
# - libsdl2-mixer-dev
|
||||
# - libpng-dev
|
||||
# - libgl1-mesa-dev
|
||||
# - libgme-dev
|
||||
# - p7zip-full
|
||||
# - gcc-4.8
|
||||
# compiler: gcc-4.8
|
||||
# dist: trusty
|
||||
# if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
# AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
# AND env(DPL_TERMINATE_ASSETS) != "1"
|
||||
# env:
|
||||
# - _DPL_JOB_ENABLED=1
|
||||
# - _DPL_JOB_NAME=trusty-asset
|
||||
# - _DPL_DPUT_TARGET=1
|
||||
# - _DPL_PACKAGE_SOURCE=1
|
||||
# - _DPL_PACKAGE_MAIN=0
|
||||
# - _DPL_PACKAGE_ASSET=1
|
||||
# - PACKAGE_DISTRO=trusty
|
||||
# #- PACKAGE_SUBVERSION=~14.04trusty
|
||||
# #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
# - os: linux
|
||||
# addons:
|
||||
# apt:
|
||||
# packages:
|
||||
# - libsdl2-mixer-dev
|
||||
# - libpng-dev
|
||||
# - libgl1-mesa-dev
|
||||
# - libgme-dev
|
||||
# - p7zip-full
|
||||
# - gcc-4.8
|
||||
# compiler: gcc-4.8
|
||||
# dist: xenial
|
||||
# if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
# AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
# AND env(DPL_TERMINATE_ASSETS) != "1"
|
||||
# env:
|
||||
# - _DPL_JOB_ENABLED=1
|
||||
# - _DPL_JOB_NAME=disco-asset
|
||||
# - _DPL_DPUT_TARGET=1
|
||||
# - _DPL_PACKAGE_SOURCE=1
|
||||
# - _DPL_PACKAGE_MAIN=0
|
||||
# - _DPL_PACKAGE_ASSET=1
|
||||
# - PACKAGE_DISTRO=disco
|
||||
# #- PACKAGE_SUBVERSION=~19.04disco
|
||||
# #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
# - os: linux
|
||||
# addons:
|
||||
# apt:
|
||||
# packages:
|
||||
# - libsdl2-mixer-dev
|
||||
# - libpng-dev
|
||||
# - libgl1-mesa-dev
|
||||
# - libgme-dev
|
||||
# - p7zip-full
|
||||
# - gcc-4.8
|
||||
# compiler: gcc-4.8
|
||||
# dist: xenial
|
||||
# if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
# AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
# AND env(DPL_TERMINATE_ASSETS) != "1"
|
||||
# env:
|
||||
# - _DPL_JOB_ENABLED=1
|
||||
# - _DPL_JOB_NAME=cosmic-asset
|
||||
# - _DPL_DPUT_TARGET=1
|
||||
# - _DPL_PACKAGE_SOURCE=1
|
||||
# - _DPL_PACKAGE_MAIN=0
|
||||
# - _DPL_PACKAGE_ASSET=1
|
||||
# - PACKAGE_DISTRO=cosmic
|
||||
# #- PACKAGE_SUBVERSION=~18.10cosmic
|
||||
# #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
# - os: linux
|
||||
# addons:
|
||||
# apt:
|
||||
# packages:
|
||||
# - libsdl2-mixer-dev
|
||||
# - libpng-dev
|
||||
# - libgl1-mesa-dev
|
||||
# - libgme-dev
|
||||
# - p7zip-full
|
||||
# - gcc-4.8
|
||||
# compiler: gcc-4.8
|
||||
# dist: xenial
|
||||
# if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
# AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
# AND env(DPL_TERMINATE_ASSETS) != "1"
|
||||
# env:
|
||||
# - _DPL_JOB_ENABLED=1
|
||||
# - _DPL_JOB_NAME=xenial-asset
|
||||
# - _DPL_DPUT_TARGET=1
|
||||
# - _DPL_PACKAGE_SOURCE=1
|
||||
# - _DPL_PACKAGE_MAIN=0
|
||||
# - _DPL_PACKAGE_ASSET=1
|
||||
# - PACKAGE_DISTRO=xenial
|
||||
# #- PACKAGE_SUBVERSION=~16.04xenial
|
||||
# #gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
|
||||
|
||||
################################
|
||||
# Deployer Buildbots - Linux binaries
|
||||
# List Ubuntu LTS, newest to oldest
|
||||
# Then list non-LTS, newest to oldest
|
||||
################################
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
dist: xenial
|
||||
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
AND env(DPL_TERMINATE_MAIN) != "1"
|
||||
env:
|
||||
- _DPL_JOB_ENABLED=1
|
||||
- _DPL_JOB_NAME=focal
|
||||
- _DPL_DPUT_TARGET=1
|
||||
- _DPL_PACKAGE_SOURCE=1
|
||||
- PACKAGE_DISTRO=focal
|
||||
- PACKAGE_SUBVERSION=~20.04focal
|
||||
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
dist: xenial
|
||||
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
AND env(DPL_TERMINATE_MAIN) != "1"
|
||||
env:
|
||||
- _DPL_JOB_ENABLED=1
|
||||
- _DPL_JOB_NAME=bionic
|
||||
- _DPL_DPUT_TARGET=1
|
||||
- _DPL_PACKAGE_SOURCE=1
|
||||
- PACKAGE_DISTRO=bionic
|
||||
- PACKAGE_SUBVERSION=~18.04bionic
|
||||
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
dist: xenial
|
||||
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
AND env(DPL_TERMINATE_MAIN) != "1"
|
||||
env:
|
||||
- _DPL_JOB_ENABLED=1
|
||||
- _DPL_JOB_NAME=xenial
|
||||
- _DPL_DPUT_TARGET=1
|
||||
- _DPL_PACKAGE_SOURCE=1
|
||||
- PACKAGE_DISTRO=xenial
|
||||
- PACKAGE_SUBVERSION=~16.04xenial
|
||||
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
dist: trusty
|
||||
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
AND env(DPL_TERMINATE_MAIN) != "1"
|
||||
env:
|
||||
- _DPL_JOB_ENABLED=1
|
||||
- _DPL_JOB_NAME=trusty
|
||||
- _DPL_DPUT_TARGET=1
|
||||
- _DPL_PACKAGE_SOURCE=1
|
||||
- PACKAGE_DISTRO=trusty
|
||||
- PACKAGE_SUBVERSION=~14.04trusty
|
||||
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
- os: linux
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
- gcc-4.8
|
||||
compiler: gcc-4.8
|
||||
dist: xenial
|
||||
if: env(DPL_ENABLED) = "1" AND (env(_DPL_JOB_ENABLED) = "1" OR env(DPL_JOB_ENABLE_ALL) = "1")
|
||||
AND (branch =~ /^.*deployer.*$/ OR (tag IS present AND env(DPL_TAG_ENABLED) = "1"))
|
||||
AND env(DPL_TERMINATE_MAIN) != "1"
|
||||
env:
|
||||
- _DPL_JOB_ENABLED=1
|
||||
- _DPL_JOB_NAME=eoan
|
||||
- _DPL_DPUT_TARGET=1
|
||||
- _DPL_PACKAGE_SOURCE=1
|
||||
- PACKAGE_DISTRO=eoan
|
||||
- PACKAGE_SUBVERSION=~19.10eoan
|
||||
#gcc-4.8 (Ubuntu 4.8.5-2ubuntu1~14.04.1) 4.8.5
|
||||
allow_failures:
|
||||
- compiler: clang-3.5
|
||||
- compiler: clang-3.6
|
||||
- compiler: clang-3.7
|
||||
- compiler: clang-3.8
|
||||
- compiler: clang-3.9
|
||||
- compiler: clang-4.0
|
||||
- compiler: clang-5.0
|
||||
|
||||
|
||||
cache:
|
||||
apt: true
|
||||
ccache: true
|
||||
directories:
|
||||
- $HOME/srb2_cache
|
||||
|
||||
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
- libsdl2-mixer-dev
|
||||
- libpng-dev
|
||||
- libgl1-mesa-dev
|
||||
- libgme-dev
|
||||
- zlib1g-dev
|
||||
- libcurl4-openssl-dev
|
||||
- p7zip-full
|
||||
homebrew:
|
||||
taps:
|
||||
- mazmazz/srb2
|
||||
packages:
|
||||
- sdl2_mixer
|
||||
- game-music-emu
|
||||
- p7zip
|
||||
- cmake
|
||||
- curl
|
||||
update: true
|
||||
|
||||
|
||||
|
||||
before_install:
|
||||
# Initialize Deployer defaults
|
||||
- . ./deployer/travis/deployer_defaults.sh
|
||||
|
||||
# Initialize Deployer; check if Deployer is enabled
|
||||
# This needs to be run in the current shell so that $__DPL_ACTIVE is set for this session
|
||||
- . ./deployer/travis/deployer.sh
|
||||
|
||||
# Also check if we should now terminate -- see `deployer.sh` for conditions.
|
||||
# This should never happen on non-release buildbots when Deployer is not triggered.
|
||||
- if [[ "$__DPL_TRY_TERMINATE_EARLY" == "1" ]]; then
|
||||
if [[ "$__DPL_ACTIVE" != "1" ]]; then
|
||||
echo "Exiting early because this job is not deploying.";
|
||||
exit;
|
||||
fi;
|
||||
fi
|
||||
|
||||
# If we're triggered by release tag, force ASSET_FILES_OPTIONAL_GET=1
|
||||
- if [[ "$__DPL_TAG_ELIGIBLE" = "1" ]]; then
|
||||
ASSET_FILES_OPTIONAL_GET=1;
|
||||
fi;
|
||||
|
||||
|
||||
install:
|
||||
# Install OS X library dependencies via Homebrew
|
||||
# Do this differently for release buildbots:
|
||||
# * `brew install --build-bottle` builds libraries for x86_64's lowest common denominator CPU, core2
|
||||
# * `sdl2_mixer` requires options from the formula tap https://github.com/mazmazz/homebrew-srb2
|
||||
# * `brew postinstall` runs post-install scripts after building a bottle
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
if [[ "$__DPL_ACTIVE" == "1" ]]; then
|
||||
brew install --build-bottle sdl2 game-music-emu;
|
||||
brew install --build-bottle mazmazz/srb2/sdl2_mixer --with-flac --with-mpg123;
|
||||
brew postinstall sdl2 game-music-emu mazmazz/srb2/sdl2_mixer;
|
||||
fi;
|
||||
fi
|
||||
- mkdir -p $HOME/srb2_cache
|
||||
|
||||
|
||||
before_script:
|
||||
# OLDPWD is root repo folder
|
||||
- OLDPWD=$PWD
|
||||
- __ASSET_DIRECTORY="$OLDPWD/assets/installer"
|
||||
- mkdir -p "$__ASSET_DIRECTORY"
|
||||
- cd "$HOME/srb2_cache"
|
||||
|
||||
# Get stat command so we know what the cached archive date is.
|
||||
# stat is different for OSX
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
STATCMD="stat -f %m";
|
||||
else
|
||||
STATCMD="stat -c %y";
|
||||
fi
|
||||
|
||||
# Get asset files (required for MD5)
|
||||
# See `deployer_defaults.sh` for asset download path
|
||||
- if [[ "$ASSET_ARCHIVE_PATH" != "" ]]; then
|
||||
if [ -f "$(basename $ASSET_ARCHIVE_PATH)" ]; then
|
||||
echo "$(basename $ASSET_ARCHIVE_PATH) cache date -- $($STATCMD $(basename $ASSET_ARCHIVE_PATH))";
|
||||
fi;
|
||||
wget --verbose --server-response -N "$ASSET_ARCHIVE_PATH";
|
||||
7z x "$(basename $ASSET_ARCHIVE_PATH)" -o"$__ASSET_DIRECTORY" -aos;
|
||||
fi;
|
||||
|
||||
# Get optional files too
|
||||
- if [[ "$__DPL_ACTIVE" == "1" ]] && [[ "$ASSET_FILES_OPTIONAL_GET" == "1" ]] && [[ "$ASSET_ARCHIVE_OPTIONAL_PATH" != "" ]]; then
|
||||
if [ -f "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH)" ]; then
|
||||
echo "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH) cache date -- $($STATCMD $(basename $ASSET_ARCHIVE_OPTIONAL_PATH))";
|
||||
fi;
|
||||
wget --verbose --server-response -N "$ASSET_ARCHIVE_OPTIONAL_PATH";
|
||||
7z x "$(basename $ASSET_ARCHIVE_OPTIONAL_PATH)" -o"$__ASSET_DIRECTORY" -aos;
|
||||
fi;
|
||||
|
||||
# Go back to root repo folder
|
||||
- cd "$OLDPWD"
|
||||
|
||||
# Prepare CMake asset lists
|
||||
- SRB2_ASSET_HASHED=$(echo ${ASSET_FILES_HASHED// /\;})
|
||||
- SRB2_ASSET_DOCS=$(echo ${ASSET_FILES_DOCS// /\;})
|
||||
- SRB2_ASSET_DIRECTORY="$__ASSET_DIRECTORY"
|
||||
|
||||
# Prepare CMake
|
||||
- mkdir build
|
||||
- cd build
|
||||
- mkdir package
|
||||
- export CFLAGS="-Wall -W -Werror $WFLAGS"
|
||||
- export CCACHE_COMPRESS=true
|
||||
# If OS X, set -march=core2 to build compatible binaries with old Macs
|
||||
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
export CFLAGS="${CFLAGS} -march=core2";
|
||||
fi;
|
||||
- cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/bin -DCPACK_PACKAGE_DIRECTORY=$PWD/package
|
||||
-DSRB2_ASSET_HASHED="${SRB2_ASSET_HASHED}" -DSRB2_ASSET_DOCS="${SRB2_ASSET_DOCS}"
|
||||
-DSRB2_ASSET_DIRECTORY="${SRB2_ASSET_DIRECTORY}"
|
||||
-DCPACK_PACKAGE_DESCRIPTION_SUMMARY="${PROGRAM_NAME}"
|
||||
-DCPACK_PACKAGE_VENDOR="${PROGRAM_VENDOR}"
|
||||
-DSRB2_SDL2_EXE_NAME="${PROGRAM_FILENAME}"
|
||||
|
||||
script:
|
||||
# Build our Makefile from Cmake!
|
||||
- if [[ "$__DPL_ACTIVE" == "1" ]]; then
|
||||
. ../deployer/travis/deployer_build.sh;
|
||||
else
|
||||
make -k;
|
||||
fi;
|
||||
|
||||
after_success:
|
||||
# Run the upload scripts
|
||||
# These do nothing if Deployer is not triggered
|
||||
- . ../deployer/travis/deployer_ftp.sh
|
||||
- . ../deployer/travis/deployer_dput.sh
|
||||
@@ -0,0 +1,269 @@
|
||||
# Doxyfile 1.4.3
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
PROJECT_NAME = SRB2
|
||||
PROJECT_NUMBER = 1.09
|
||||
OUTPUT_DIRECTORY = ./doc/SRB2
|
||||
CREATE_SUBDIRS = YES
|
||||
OUTPUT_LANGUAGE = English
|
||||
USE_WINDOWS_ENCODING = YES
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF = "The $name class" \
|
||||
"The $name widget" \
|
||||
"The $name file" \
|
||||
is \
|
||||
provides \
|
||||
specifies \
|
||||
contains \
|
||||
represents \
|
||||
a \
|
||||
an \
|
||||
the
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
DETAILS_AT_TOP = NO
|
||||
INHERIT_DOCS = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 8
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = YES
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
SUBGROUPING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = YES
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = NO
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ./src
|
||||
FILE_PATTERNS = *.c \
|
||||
*.cc \
|
||||
*.cxx \
|
||||
*.cpp \
|
||||
*.c++ \
|
||||
*.d \
|
||||
*.java \
|
||||
*.ii \
|
||||
*.ixx \
|
||||
*.ipp \
|
||||
*.i++ \
|
||||
*.inl \
|
||||
*.h \
|
||||
*.hh \
|
||||
*.hxx \
|
||||
*.hpp \
|
||||
*.h++ \
|
||||
*.idl \
|
||||
*.odl \
|
||||
*.cs \
|
||||
*.php \
|
||||
*.php3 \
|
||||
*.inc \
|
||||
*.m \
|
||||
*.mm \
|
||||
*.dox
|
||||
RECURSIVE = YES
|
||||
EXCLUDE = ./src/sdl/IMG_xpm.c \
|
||||
./src/sdl/SRB2DC/scramble.c
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS = */src/hardware/*/* \
|
||||
*/src/sdl/SDL_main/* \
|
||||
*/src/*/*_private.h \
|
||||
*/src/sdl/*/*help.? \
|
||||
*/src/md5.? \
|
||||
*/src/sdl/filter/*
|
||||
EXAMPLE_PATH =
|
||||
EXAMPLE_PATTERNS = *
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = NO
|
||||
REFERENCES_RELATION = NO
|
||||
#USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = YES
|
||||
TREEVIEW_WIDTH = 250
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = NO
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = NO
|
||||
USE_PDFLATEX = NO
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = NO
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH =
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED = DOXYGEN \
|
||||
HWRENDER \
|
||||
DIRECTFULLSCREEN \
|
||||
HW3SOUND \
|
||||
LOGMESSAGES \
|
||||
WALLSPLATS \
|
||||
FLOORSPLATS
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
MAX_DOT_GRAPH_WIDTH = 1024
|
||||
MAX_DOT_GRAPH_HEIGHT = 1024
|
||||
MAX_DOT_GRAPH_DEPTH = 1000
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
||||
-12
@@ -192,18 +192,6 @@ from `0` to `#musicdefs-1`, or string indices (which is equal to calling `S_Find
|
||||
Hook is called whenever `S_ShowMusicCredit` (either from game or mod) is called. Takes musicdef as only argument, returning true
|
||||
will overwrite vanilla behavior (not show music credit), can be used to implement custom music credit pop-ups.
|
||||
|
||||
## addHook("SetupVote", function(result, gt, secondgt, prevmap))
|
||||
|
||||
Hook is called whenever server sets up options for vote screen. `result` is table where lua can store options to,
|
||||
(for example, `result[1] = 1` will force green hills as first option), gt is current gametype, secondgt is
|
||||
alternative gametype picked for 3rd entry (for example, gt can be `GT_RACE`, and secondgt can be `GT_MATCH`)
|
||||
prevmap is the previous map that was played (small note - in game code, it is offset by -1, but for lua its offset back,
|
||||
so if previous gamemap was 1, prevmap would also be 1. Which means you can safely do mapheaderinfo[prevmap] to get info on previous map)
|
||||
|
||||
Limitations: currently, game can only change gametype for 3rd option in map (meaning for example, if current gametype is race, and you
|
||||
put battle map in first option, when it gets picked that map will be still run in race gametype). That means, game will only handle maps with
|
||||
different gametype if it is put in 3rd vote option.
|
||||
|
||||
# Other changes
|
||||
|
||||
## P_PlayRinglossSound(source, damager)
|
||||
|
||||
@@ -1,35 +1,103 @@
|
||||
# SRB2Kart-Saturn
|
||||
|
||||
SRB2Kart-Saturn is a modification of SRB2Kart with a focus on new Features, Fixes, Optimizations and general Improvements, all while retaining 100% compatibility with vanilla SRB2Kart.
|
||||
# SRB2Kart: Saturn
|
||||
|
||||
[SRB2Kart](https://srb2.org/mods/) is a kart racing mod based on the 3D Sonic the Hedgehog fangame [Sonic Robo Blast 2](https://srb2.org/), based on a modified version of [Doom Legacy](http://doomlegacy.sourceforge.net/).
|
||||
|
||||
For more information on Saturn´s features check out the changelogs on the [Releases](https://github.com/Indev450/SRB2Kart-Saturn/releases) page and the ingame "Saturn Options" menu.
|
||||
## Saturn Features (Take a look at the "Saturn Options" menu c;)
|
||||
|
||||
Also be sure to check the LUASTUFF file for more information on all the extra lua features Saturn has.
|
||||
- Sprites player rotation on slopes; going on hills, levitate, going down, and so on alters your sprites (configurable)
|
||||
- You can alter all the base kart HUD element offsets on the fly in the Saturn Options settings menu
|
||||
- `addfilelocal` Command, for those who want to use things like their custom hud in netgames (Same as addfile but completely client sided)
|
||||
- Palette rendering, make the OpenGL renderer (almost) look like software mode!
|
||||
- OpenMPT for Tracker module playback instead of GME
|
||||
- Fixes looping and sounds better
|
||||
- Allows filter configuration
|
||||
- Colourize your Kart HUD, to either your player color or whichever colour you like! (optional / requieres extra2.kart file)
|
||||
- The minimal brightness with Shaders can be configured, now you can seeeee in dark areas (0-255 , uses Sector brightness values)
|
||||
- Lua HUD hooks for Intermission (ex: You can make hostmod votes still visible during intermission!)
|
||||
- Lua HUD hooks for Vote Screen (ex: You can make hostmod votes still visible during map vote screen!)
|
||||
- Saltyhop! do a funny hop
|
||||
- Smaller Speedometer (optional / requieres extra.kart file)
|
||||
- Record Attack input display can now be used everywhere
|
||||
- Smaller minimap icons and also show player names on the minimap (toggable)
|
||||
- Support for animated votescreens!
|
||||
- `showmusiccredit` command, shows you the current music track again
|
||||
- `listskins` show a list of all skins currently loaded
|
||||
- Visual Portals from Haya's HEP Client
|
||||
- Horizonline effect in OpenGL (watch the endless bricks on SNES Bowsers Castle!)
|
||||
- Localskins! use whatever skin you like!
|
||||
- Toggable lowercase menu's also from Haya's HEP client
|
||||
- Everything that Galaxy has
|
||||
|
||||
We also have a Flatpak available on [Flathub](https://flathub.org/en/apps/org.srb2.SRB2Kart-Saturn)! (many thanks to riomccloud!)
|
||||
## Improvements / Bug fixes
|
||||
|
||||
- Replay size has been increased to 10MiB minimum, to make replay overflows very unlikely to happen
|
||||
- can be set to 100MiB max with `maxdemosize` command in console
|
||||
- Music changes now properly show the music credits (ex: Kart maps with easter eggs that alter the music)
|
||||
- The mapper still has to provide a MusicDEF for this to work.
|
||||
- Configurable chatlog length (yay can read those messages from 30 mins ago without opening log.txt)
|
||||
- Configurable timeout for waiting to join a full server (in vanilla this is capped to 5 minutes before it boots you out)
|
||||
- Characters now spin in skin selection menu (configurable)
|
||||
- HTTP Addon download speed has been raised dramatically
|
||||
- configurable with `downloadspeed` command
|
||||
- HWR Drawnodes have been refactored, this should fix a few rare crashes esp in regards to OpenGL Visportals
|
||||
- The Position Number in the corner is alot smaller now (half the size!)
|
||||
- Toggable Lap animation
|
||||
- Main menu shows the current renderer being used
|
||||
- MSAA and A2C Antialiasing support (Configurable in renderer.txt file)
|
||||
- A simple button to rejoin your last visited server
|
||||
- Ability to show ALL maps in the mapselect screen, this includes hidden or hellmaps "showallmaps yes/no"
|
||||
- Ability to toggle the Stagetitlecard "maptitles on/off"
|
||||
|
||||
## Performance / Debugging
|
||||
|
||||
- Access for `mobj_t` and `player_t` fields from Lua has been completely rewritten, for much better performance with many Lua scripts
|
||||
- Lua shows Tracebacks whenever an error occurs
|
||||
- The Lua Perfstats page now has multiple pages and is more organized (ps_thinkframe_page X in console)
|
||||
- People with lower end hardware can disable "screen textures" with "gr_screentextures" command, huge performance gain with minimal visual loss
|
||||
- Intermission backgrounds, heat wave effects and etc are broken with this
|
||||
- `ffloorclip`, exclusive to Software, which boosts performance on maps with many Floor over Floor sectors
|
||||
|
||||
## Technical fixes
|
||||
|
||||
- ZFigthing Textures in Opengl mode have been fixed in engine (well almost all of it)
|
||||
- FOFs intersecting with slopes have less issues and now render correctly in Opengl
|
||||
- Midtextures on slopes in Opengl are fixed, many weird guardrails and fences, aswell as some of those sticking out textures from the ground on some maps should be gone
|
||||
- The annoying depraction messages for `P_TeleportMove` and `P_AproxDistance` have been silenced
|
||||
- Silenced the annoying "cant find next map..." messages as theyre super useless and annoying anyways
|
||||
- Added a small cooldown on `map` command due to spamming causing a SIGSEGV
|
||||
- Many bugfixes to the Software renderer, so its much less prone to crashing
|
||||
- Many bugfixes to the OpenGL renderer (too many too list all of them here; check the changelogs for more information)
|
||||
- Bugfixes to the soundsystem, mainly regarding Sound muting
|
||||
- Refactored Zone Memory Allocations (helps a bit with large maps)
|
||||
- Many many more crash fixes and other bugfixes to the basegame (too many too list all of them here; check the changelogs for more information)
|
||||
|
||||
- Crash Backtraces have been replaced by libbacktrace (except for 32bit Windows builds)
|
||||
Crashlogs now contain alot more informations. and even more if your build has debug symbols
|
||||
Also allows 64bit Windows builds to produce Crashlogs!
|
||||
|
||||
## MISC
|
||||
- Bird's Camera Tilting feature is no longer turned on by default
|
||||
- Bird's warning on the title screen has been removed
|
||||
|
||||
## Bugs
|
||||
- On maps which change the song multiple times on map start (exp: Wandering Falls) may show multiple music credits appearing
|
||||
- A2C antialiasing makes transparent surfaces even more transparent
|
||||
- You tell us! c:
|
||||
|
||||
## Note
|
||||
Check the LUASTUFF file for more information on all the lua things Saturn has.
|
||||
|
||||
## Dependencies
|
||||
- SDL2 (Linux/OS X only)
|
||||
- SDL2-Mixer (Linux/OS X only)
|
||||
- libupnp (Linux/OS X only)
|
||||
- libgme (Linux/OS X only)
|
||||
- libopenmpt (Linux/OS X only)
|
||||
- libbacktrace (Linux/OS X only, optional, disable support with NOLIBBACKTRACE)
|
||||
- libupnp (Linux/OS X only, optional, enable support with HAVE_MINIUPNPC)
|
||||
- libbacktrace (Linux/OS X only)
|
||||
|
||||
## Compiling
|
||||
|
||||
See [SRB2 Wiki/Source code compiling](http://wiki.srb2.org/wiki/Source_code_compiling). The compiling process for SRB2Kart is largely identical to SRB2.
|
||||
|
||||
Currently only the Makefile build system with GCC or Clang compiler is supported.
|
||||
|
||||
Visual C++ (MSVC) is unsupported.
|
||||
|
||||
64-bit Windows builds are supported and recommended over 32-bit builds, they will build automatically when using the MSYS2 MinGW 64-bit executable (requires the mingw-w64-x86_64-gcc package), no extra flags needed!
|
||||
The specific DLLs can be found under /libs/dll-binaries/(i686 for 32bit/x86_64 for 64-bit)/ or in the Release packages
|
||||
|
||||
Alternatively the [srb2bld](https://github.com/Bijman/srb2bld) script by Bijman can be used aswell!
|
||||
|
||||
## Disclaimer
|
||||
Kart Krew is in no way affiliated with SEGA or Sonic Team. We do not claim ownership of any of SEGA's intellectual property used in SRB2.
|
||||
+133
@@ -0,0 +1,133 @@
|
||||
version: 1.3.{branch}-{build}
|
||||
os: MinGW
|
||||
|
||||
environment:
|
||||
CC: ccache
|
||||
CCACHE_CC: i686-w64-mingw32-gcc
|
||||
CCACHE_CC_64: x86_64-w64-mingw32-gcc
|
||||
WINDRES: windres
|
||||
# c:\mingw-w64 i686 has gcc 6.3.0, so use c:\msys64 7.3.0 instead
|
||||
MINGW_SDK: c:\msys64\mingw32
|
||||
# c:\msys64 x86_64 has gcc 8.2.0, so use c:\mingw-w64 7.3.0 instead
|
||||
MINGW_SDK_64: C:\mingw-w64\x86_64-8.1.0-posix-seh-rt_v6-rev0\mingw64
|
||||
CFLAGS: -Wall -W -Werror -Wno-error=implicit-fallthrough -Wimplicit-fallthrough=3 -Wno-tautological-compare -Wno-error=suggest-attribute=noreturn
|
||||
UPX_ZIP: upx391w
|
||||
UPX_URL: http://upx.sourceforge.net/download/upx391w.zip
|
||||
CCACHE_EXE: ccache.exe
|
||||
CCACHE_URL: http://alam.srb2.org/ccache.exe
|
||||
CCACHE_COMPRESS: true
|
||||
CCACHE_DIR: C:\Users\appveyor\.ccache
|
||||
# Disable UPX by default. The user can override this in their Appveyor project settings
|
||||
NOUPX: 1
|
||||
##############################
|
||||
# DEPLOYER VARIABLES
|
||||
# DPL_ENABLED=1 builds installers for branch names starting with `deployer`.
|
||||
# DPL_TAG_ENABLED=1 will also build installers for release tags. DPL_ENABLED=1 must also be set.
|
||||
# Set these in the Appveyor project settings
|
||||
##############################
|
||||
DPL_ENABLED: 0
|
||||
DPL_TAG_ENABLED: 0
|
||||
DPL_INSTALLER_NAME: srb2kart-v13
|
||||
# Asset handling is barebones vs. Travis Deployer. We operate on 7z only.
|
||||
# Include the README files and the OpenGL batch in the main and patch archives.
|
||||
# The x86/x64 archives contain the DLL binaries.
|
||||
ASSET_ARCHIVE_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-assets.7z
|
||||
ASSET_ARCHIVE_PATCH_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-patch-assets.7z
|
||||
ASSET_ARCHIVE_X86_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-x86-assets.7z
|
||||
ASSET_ARCHIVE_X64_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-x64-assets.7z
|
||||
ASSET_ARCHIVE_OPTIONAL_PATH: https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-optional-assets.7z
|
||||
# This is overridden to 1 for release tag builds
|
||||
ASSET_FILES_OPTIONAL_GET: 0
|
||||
# For patches, also include the X86/X64 DLLs.
|
||||
PACKAGE_PATCH_DLL_GET: 0
|
||||
# Delete all asset downloads so they can be redownloaded
|
||||
ASSET_CLEAN: 0
|
||||
|
||||
cache:
|
||||
- upx391w.zip
|
||||
- ccache.exe
|
||||
- C:\Users\appveyor\.ccache
|
||||
- C:\Users\appveyor\srb2_cache
|
||||
|
||||
install:
|
||||
- if [%CONFIGURATION%] == [SDL64] ( set "X86_64=1" )
|
||||
- if [%CONFIGURATION%] == [SDL64] ( set "CONFIGURATION=SDL" )
|
||||
- if [%X86_64%] == [1] ( set "MINGW_SDK=%MINGW_SDK_64%" )
|
||||
- if [%X86_64%] == [1] ( set "CCACHE_CC=%CCACHE_CC_64%" )
|
||||
|
||||
- if not exist "%UPX_ZIP%.zip" appveyor DownloadFile "%UPX_URL%" -FileName "%UPX_ZIP%.zip"
|
||||
- 7z x -y "%UPX_ZIP%.zip" -o%TMP% >null
|
||||
- robocopy /S /xx /ns /nc /nfl /ndl /np /njh /njs "%TMP%\%UPX_ZIP%" "%MINGW_SDK%\bin" upx.exe || exit 0
|
||||
|
||||
- if not exist "%CCACHE_EXE%" appveyor DownloadFile "%CCACHE_URL%" -FileName "%CCACHE_EXE%"
|
||||
- ccache -M 99M
|
||||
- xcopy /Y /V /I ccache.exe "%MINGW_SDK%\bin"
|
||||
|
||||
configuration:
|
||||
- SDL
|
||||
#- SDL64
|
||||
|
||||
before_build:
|
||||
- set "Path=%MINGW_SDK%\bin;%Path%"
|
||||
- if [%X86_64%] == [1] ( x86_64-w64-mingw32-gcc --version ) else ( i686-w64-mingw32-gcc --version )
|
||||
- mingw32-make --version
|
||||
- if not [%NOUPX%] == [1] ( upx -V )
|
||||
- ccache -V
|
||||
- ccache -s
|
||||
- if [%NOUPX%] == [1] ( set "NOUPX=NOUPX=1" ) else ( set "NOUPX=" )
|
||||
- if defined [%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%] ( set "COMMIT=%APPVEYOR_PULL_REQUEST_HEAD_COMMIT%" ) else ( set "COMMIT=%APPVEYOR_REPO_COMMIT%" )
|
||||
- cmd: git rev-parse --short %COMMIT%>%TMP%/gitshort.txt
|
||||
- cmd: set /P GITSHORT=<%TMP%/gitshort.txt
|
||||
# for pull requests, take the owner's name only, if this isn't the same repo of course
|
||||
- set "REPO=%APPVEYOR_REPO_BRANCH%"
|
||||
- if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [] ( if not [%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%] == [%APPVEYOR_REPO_NAME%] ( for /f "delims=/" %%a in ("%APPVEYOR_PULL_REQUEST_HEAD_REPO_NAME%") do set "REPO=%%a-%APPVEYOR_PULL_REQUEST_HEAD_REPO_BRANCH%" ) )
|
||||
- set "EXENAME=EXENAME=srb2win-%REPO%-%GITSHORT%.exe"
|
||||
- set "SRB2_MFLAGS=-C src WARNINGMODE=1 CCACHE=1 NOOBJDUMP=1 %NOUPX% %EXENAME%"
|
||||
- if [%X86_64%] == [1] ( set "MINGW_FLAGS=MINGW64=1 X86_64=1 GCC81=1" ) else ( set "MINGW_FLAGS=MINGW=1 GCC91=1" )
|
||||
- set "SRB2_MFLAGS=%SRB2_MFLAGS% %MINGW_FLAGS% %CONFIGURATION%=1"
|
||||
|
||||
build_script:
|
||||
- cmd: mingw32-make.exe %SRB2_MFLAGS% clean
|
||||
- cmd: mingw32-make.exe %SRB2_MFLAGS% ERRORMODE=1 -k
|
||||
|
||||
after_build:
|
||||
- if [%X86_64%] == [1] (
|
||||
set "BUILD_PATH=bin\Mingw64\Release"
|
||||
) else (
|
||||
set "BUILD_PATH=bin\Mingw\Release"
|
||||
)
|
||||
- if [%X86_64%] == [1] ( set "CONFIGURATION=%CONFIGURATION%64" )
|
||||
- ccache -s
|
||||
- set BUILD_ARCHIVE=%REPO%-%GITSHORT%-%CONFIGURATION%.7z
|
||||
- set BUILDSARCHIVE=%REPO%-%CONFIGURATION%.7z
|
||||
- cmd: 7z a %BUILD_ARCHIVE% %BUILD_PATH% -xr!.gitignore
|
||||
- appveyor PushArtifact %BUILD_ARCHIVE%
|
||||
- cmd: copy %BUILD_ARCHIVE% %BUILDSARCHIVE%
|
||||
- appveyor PushArtifact %BUILDSARCHIVE%
|
||||
##############################
|
||||
# DEPLOYER SCRIPT
|
||||
##############################
|
||||
- if [%DPL_ENABLED%] == [1] ( call "deployer\appveyor\deployer.bat" )
|
||||
|
||||
test: off
|
||||
|
||||
#deploy:
|
||||
# - provider: FTP
|
||||
# protocol: ftps
|
||||
# host:
|
||||
# secure: NsLJEPIBvmwCOj8Tg8RoRQ==
|
||||
# username:
|
||||
# secure: ejxi5mvk7oLYu7QtbYojajEPigMy0mokaKhuEVuDZcA=
|
||||
# password:
|
||||
# secure: Hbn6Uy3lT0YZ88yFJ3aW4w==
|
||||
# folder: appveyor
|
||||
# application:
|
||||
# active_mode: false
|
||||
# on:
|
||||
# branch: master
|
||||
# appveyor_repo_tag: true
|
||||
|
||||
|
||||
on_finish:
|
||||
#- cmd: echo xfreerdp /u:appveyor /cert-ignore +clipboard /v:<ip>:<port>
|
||||
#- ps: $blockRdp = $true; iex ((new-object net.webclient).DownloadString('https://raw.githubusercontent.com/appveyor/ci/master/scripts/enable-rdp.ps1'))
|
||||
@@ -30,24 +30,6 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
0-Clause BSD License
|
||||
applies to:
|
||||
- qs22k
|
||||
Copyright (c) 2022, Raymond Gardner
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
Permission to use, copy, modify, and/or distribute this software for any
|
||||
purpose with or without fee is hereby granted.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY
|
||||
SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR
|
||||
IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
curl License
|
||||
applies to:
|
||||
|
||||
@@ -0,0 +1,70 @@
|
||||
srb2 for Debian
|
||||
---------------
|
||||
|
||||
SRB2 Debian package!
|
||||
Hi there, to rebuild these packages just use debuild in the root source directory (not /src!).
|
||||
You can build these with or without a key if you want, but if you want to put these on a repo,
|
||||
generate your own GnuPG key as per the https://help.ubuntu.com/community/GnuPrivacyGuardHowto
|
||||
instructions and pass the -k<keyid> command to debuild. Make sure you export the key footprint
|
||||
and give them to your users to install with apt-key add. Thanks!
|
||||
|
||||
-- Callum Dickinson <gcfreak_ag20@hotmail.com> Fri, 26 Nov 2010 18:25:31 +1300
|
||||
|
||||
---------------
|
||||
|
||||
|
||||
Templating
|
||||
|
||||
Note that you MUST run [repo-root]/debian_template.sh before running debuild
|
||||
on these scripts! debian_template.sh fills these template files with working values.
|
||||
|
||||
You should also set PACKAGE_NAME_EMAIL="John Doe <jdoe@example.com>" to match
|
||||
the identity of the key you will use to sign the package.
|
||||
|
||||
|
||||
Building for Launchpad PPA
|
||||
|
||||
Use these steps to prepare building a source package for Launchpad:
|
||||
|
||||
1. cd [repo-root]
|
||||
2. git reset --hard; git clean -fd; git clean -fx;
|
||||
* Resets your repo folder to a committed state and removes untracked files
|
||||
* If you built srb2-data in the assets/ folder, MAKE SURE THAT FOLDER DOES NOT HAVE ASSETS,
|
||||
OR THEY MAY BE INCLUDED IN THE MAIN SOURCE PACKAGE!
|
||||
|
||||
Build the source package:
|
||||
|
||||
1. source [repo-root]/debian_template.sh
|
||||
* Initializes defaults for the package variables and fills in templates.
|
||||
2. debuild -S (builds the source package for Launchpad)
|
||||
|
||||
|
||||
Signing for Launchpad PPA
|
||||
|
||||
First, follow Callum's instructions to generate a GnuPG key with your identity. You will need
|
||||
to publish the fingerprint of that key to Ubuntu's key server.
|
||||
|
||||
https://help.ubuntu.com/community/GnuPrivacyGuardHowto#Uploading_the_key_to_Ubuntu_keyserver
|
||||
|
||||
Next, you will have to add that key fingerprint to your Launchpad account. Go to your Launchpad
|
||||
profile and click the yellow Edit button next to "OpenPGP keys". Once you add the key, you can
|
||||
upload signed source packages and publish them onto your PPA.
|
||||
|
||||
IF YOU UPLOAD A PACKAGE and Launchpad does NOT send you a confirmation or rejection email, that
|
||||
means your key is not set up correctly with your Launchpad account.
|
||||
|
||||
Finally, if your packages have not already been signed, follow these steps:
|
||||
|
||||
1. cd ..
|
||||
* Packages are located in the parent folder of where debuild was called
|
||||
2. debsign "srb2_[version]_source.changes"
|
||||
* You may need to specify -k [key-fingerprint]
|
||||
|
||||
|
||||
Uploading for Launchpad PPA
|
||||
|
||||
Follow the instructions at <https://help.launchpad.net/Packaging/PPA/Uploading> to upload
|
||||
to your PPA and have Launchpad build your binary deb packages.
|
||||
|
||||
|
||||
-- Marco Zafra <marco.a.zafra@gmail.com> Mon, 26 Nov 2018 21:13:00 -0500
|
||||
@@ -0,0 +1,46 @@
|
||||
srb2 for Debian
|
||||
---------------
|
||||
|
||||
Here it is! SRB2 v2.1.2 source code!
|
||||
|
||||
GNU/Linux
|
||||
~~~
|
||||
|
||||
Dependencies:
|
||||
SDL 1.2.7 or better (from libsdl.org)
|
||||
SDL_Mixer 1.2.2(.7 for file-less music playback) (from libsdl.org)
|
||||
Nasm (use NOASM=1 if you don't have it or have an non-i386 system, I think)
|
||||
libPNG 1.2.7
|
||||
Zlib 1.2.3
|
||||
The Xiph.org libogg and libvorbis libraries
|
||||
The OpenGL headers (from Mesa, usually shipped with your X.org or XFree
|
||||
installation, so you needn't worry, most likely)
|
||||
GCC 3.x toolchain and binutils
|
||||
GNU Make
|
||||
|
||||
Build instructions:
|
||||
|
||||
make -C src LINUX=1
|
||||
|
||||
Build instructions for non-X86 devices (such as X64):
|
||||
|
||||
make -C src LINUX=1 NONX86=1
|
||||
|
||||
Build instructions to build for Wii Linux/SRB2Wii on a PowerPC system,
|
||||
follow cross-compiling instructions for cross-compiling on a x86 system:
|
||||
|
||||
make -C src LINUX=1 WIILINUX=1
|
||||
|
||||
Build instructions to build for Pandora (Linux) on a ARM system,
|
||||
follow cross-compiling instructions for cross-compiling on a x86 system:
|
||||
|
||||
make -C src PANDORA=1
|
||||
|
||||
-------------------------------------------------------------------------------
|
||||
|
||||
binaries will turn in up in bin/
|
||||
|
||||
note: read the src/makefile for more options
|
||||
|
||||
- Sonic Team Junior
|
||||
http://www.srb2.org
|
||||
@@ -0,0 +1,5 @@
|
||||
${PACKAGE_NAME} (${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION}) ${PACKAGE_DISTRO}; urgency=${PACKAGE_URGENCY}
|
||||
|
||||
* ${PROGRAM_NAME} v${PROGRAM_VERSION} program build
|
||||
|
||||
-- ${PACKAGE_NAME_EMAIL} ${__PACKAGE_DATETIME}
|
||||
@@ -0,0 +1 @@
|
||||
7
|
||||
@@ -0,0 +1,51 @@
|
||||
# SRB2 Debian package control file.
|
||||
|
||||
Source: ${PACKAGE_NAME}
|
||||
Section: games
|
||||
Priority: extra
|
||||
Maintainer: ${PACKAGE_GROUP_NAME_EMAIL}
|
||||
Build-Depends: debhelper (>= 7.0.50~),
|
||||
libsdl2-dev,
|
||||
libsdl2-mixer-dev,
|
||||
libpng-dev | libpng16-dev | libpng12-dev (>= 1.2.7),
|
||||
zlib1g-dev,
|
||||
libgme-dev,
|
||||
libcurl4-openssl-dev,
|
||||
libglu1-dev | libglu-dev,
|
||||
libosmesa6-dev | libgl-dev,
|
||||
nasm [i386]
|
||||
Standards-Version: 3.8.4
|
||||
Homepage: ${PACKAGE_WEBSITE}
|
||||
|
||||
Package: ${PACKAGE_NAME}
|
||||
Architecture: any
|
||||
Depends: ${SHLIBS_DEPENDS}, ${MISC_DEPENDS},
|
||||
${PACKAGE_NAME}-data (>> ${PACKAGE_ASSET_MINVERSION}), ${PACKAGE_NAME}-data (<< ${PACKAGE_ASSET_MAXVERSION}),
|
||||
libsdl2-2.0-0,
|
||||
libsdl2-mixer-2.0-0,
|
||||
zlib1g,
|
||||
libgme0,
|
||||
libcurl4,
|
||||
libpng | libpng16-16 | libpng12-0
|
||||
Description: A cross-platform 3D Sonic fangame
|
||||
Sonic Robo Blast 2 is a 3D open-source Sonic the Hedgehog
|
||||
fangame built using a modified version of the Doom Legacy
|
||||
port of Doom. SRB2 is closely inspired by the original
|
||||
Sonic games from the Sega Genesis, and attempts to recreate
|
||||
the design in 3D. It features tons of levels, enemies, speed,
|
||||
and quite a lot of the fun that the original Sonic games provided.
|
||||
|
||||
|
||||
Package: ${PACKAGE_NAME}-dbg
|
||||
Architecture: any
|
||||
# FIXME: should be Depends: ${SHLIBS_DEPENDS}, ${MISC_DEPENDS}, srb2-data (= 2.1.14), srb2 but dh_shlibdeps is being an asshat
|
||||
Depends: libc6, ${MISC_DEPENDS}, ${PACKAGE_NAME}-data (>> ${PACKAGE_ASSET_MINVERSION}), ${PACKAGE_NAME}-data (<< ${PACKAGE_ASSET_MAXVERSION}), ${PACKAGE_NAME}
|
||||
Description: A cross-platform 3D Sonic fangame
|
||||
Sonic Robo Blast 2 is a 3D open-source Sonic the Hedgehog
|
||||
fangame built using a modified version of the Doom Legacy
|
||||
port of Doom. SRB2 is closely inspired by the original
|
||||
Sonic games from the Sega Genesis, and attempts to recreate
|
||||
the design in 3D. It features tons of levels, enemies, speed,
|
||||
and quite a lot of the fun that the original Sonic games provided.
|
||||
This is a debug binary; its symbols will be loaded by gdb
|
||||
when the user starts the game with gdb for debugging.
|
||||
@@ -0,0 +1,27 @@
|
||||
This work was packaged for Debian by:
|
||||
|
||||
${PACKAGE_NAME_EMAIL} ${__PACKAGE_DATETIME}
|
||||
|
||||
It was downloaded from:
|
||||
|
||||
${PACKAGE_WEBSITE}
|
||||
|
||||
Upstream Author(s):
|
||||
|
||||
${PACKAGE_GROUP_NAME_EMAIL}
|
||||
|
||||
Copyright:
|
||||
|
||||
Copyright (C) 1998-2018 by Sonic Team Junior
|
||||
|
||||
License:
|
||||
|
||||
GNU General Public License, version 2
|
||||
|
||||
The Debian packaging is:
|
||||
|
||||
Copyright (C) 2010 Callum Dickinson <gcfreak_ag20@hotmail.com>
|
||||
Copyright (C) 2010-2018 by Sonic Team Junior <stjr@srb2.org>
|
||||
|
||||
and is licensed under the GPL version 2,
|
||||
see "/usr/share/common-licenses/GPL-2".
|
||||
@@ -0,0 +1,4 @@
|
||||
README.md
|
||||
assets/README.txt
|
||||
assets/LICENSE.txt
|
||||
assets/LICENSE-3RD-PARTY.txt
|
||||
@@ -0,0 +1,172 @@
|
||||
#!/usr/bin/make -f
|
||||
# -*- makefile -*-
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
# GNU Make Debian package makefile for SRB2
|
||||
#
|
||||
# Copyright (C) 1998-2010 by Callum Dickinson
|
||||
#
|
||||
# This program is free software; you can redistribute it and/or
|
||||
# modify it under the terms of the GNU General Public License
|
||||
# as published by the Free Software Foundation; either version 2
|
||||
# of the License, or (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# This file most likely will not need to be modified to make
|
||||
# branches of SRB2 capable of making their own Debian packages,
|
||||
# instead look at the /debian/control file for configuration.
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
#############################################################################
|
||||
#
|
||||
# !!!!!!!!!! DEPLOYER NOTE !!!!!!!!!!
|
||||
#
|
||||
# Variables to be templated are curly-braced ${PACKAGE_INSTALL_PATH}
|
||||
# Variables used by the rules script are parenthese'd $(PKGDIR)
|
||||
# See [repo-root]/debian_template.sh
|
||||
#
|
||||
#############################################################################
|
||||
|
||||
# Uncomment this to turn on verbose mode.
|
||||
#export DH_VERBOSE=1
|
||||
|
||||
# user/group of to-be-installed files
|
||||
ROOT_USER := 0
|
||||
ROOT_GROUP := 0
|
||||
|
||||
# determine cross-compile (may need some work)
|
||||
CROSS_COMPILE_BUILD := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE)
|
||||
CROSS_COMPILE_HOST := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE)
|
||||
CROSS_COMPILE := $(shell test "$(CROSS_COMPILE_BUILD)" != "$(CROSS_COMPILE_HOST)" && echo "$(CROSS_COMPILE_HOST)")
|
||||
|
||||
MKDIR = mkdir -p
|
||||
MAKE = make
|
||||
INSTALL = install -o $(ROOT_USER) -g $(ROOT_GROUP) -m 644
|
||||
MV = mv
|
||||
RM = rm -rf
|
||||
STRIPARGS = --strip-unneeded
|
||||
ifdef CROSS_COMPILE
|
||||
STRIP = $(CROSS_COMPILE_HOST)-strip $(STRIPARGS)
|
||||
else
|
||||
STRIP = strip $(STRIPARGS)
|
||||
endif
|
||||
DIR := $(shell pwd)
|
||||
|
||||
# FIXME: hate hate hate head/tail hack :(
|
||||
CONTROLF = $(DIR)/debian/control
|
||||
PACKAGE = ${PACKAGE_NAME}
|
||||
DBGPKG = ${PACKAGE}-dbg
|
||||
TITLE = ${PROGRAM_NAME}
|
||||
SECTION = Games/Action
|
||||
EXENAME = ${PROGRAM_FILENAME}
|
||||
DBGNAME = debug/$(EXENAME)
|
||||
|
||||
PKGDIR = $(shell echo "${PACKAGE_INSTALL_PATH}" | sed -e 's/^\///')
|
||||
DBGDIR = usr/lib/debug/$(PKGDIR)
|
||||
LINKDIR = $(shell echo "${PACKAGE_LINK_PATH}" | sed -e 's/^\///')
|
||||
PIXMAPS_DIR = usr/share/pixmaps
|
||||
DESKTOP_DIR = usr/share/applications
|
||||
PREFIX = $(shell test "$(CROSS_COMPILE_BUILD)" != "$(CROSS_COMPILE_HOST)" && echo "PREFIX=$(CROSS_COMPILE_HOST)")
|
||||
OS = LINUX=1
|
||||
NONX86 = $(shell test "`echo $(CROSS_COMPILE_HOST) | grep 'i[3-6]86'`" || echo "NONX86=1")
|
||||
MAKEARGS = $(OS) $(NONX86) $(PREFIX) EXENAME=$(EXENAME) DBGNAME=$(DBGNAME) NOOBJDUMP=1 # SDL_PKGCONFIG=sdl2 PNG_PKGCONFIG=libpng
|
||||
MENUFILE1 = ?package($(PACKAGE)):needs="X11" section="$(SECTION)"
|
||||
MENUFILE2 = title="$(TITLE)" command="/$(PKGDIR)/$(PACKAGE)"
|
||||
BINDIR := $(DIR)/bin/Linux/Release
|
||||
|
||||
# FIXME pkg-config dir hacks
|
||||
# Launchpad doesn't need this; it actually makes i386 builds fail due to cross-compile
|
||||
# export PKG_CONFIG_LIBDIR = /usr/lib/$(CROSS_COMPILE_HOST)/pkgconfig
|
||||
LDFLAGS += "-Wl,-rpath=/usr/lib/$(CROSS_COMPILE_HOST)"
|
||||
|
||||
# Some libgme-dev packages don't use pkg-config yet, so include the linker flag ourselves
|
||||
PKG_CONFIG?=pkg-config
|
||||
LIBGME_PKGCONFIG?=libgme
|
||||
LIBGME_LDFLAGS?=$(shell $(PKG_CONFIG) $(LIBGME_PKGCONFIG) --libs)
|
||||
|
||||
ifeq ($(LIBGME_LDFLAGS),)
|
||||
MAKEARGS += LIBGME_LDFLAGS=-lgme
|
||||
endif
|
||||
|
||||
build:
|
||||
$(MKDIR) $(BINDIR)/debug
|
||||
$(MAKE) -C $(DIR)/src $(MAKEARGS)
|
||||
$(STRIP) $(BINDIR)/$(EXENAME)
|
||||
|
||||
binary-indep:
|
||||
# only here to kill Lintian warning
|
||||
echo "no need to do any arch-independent stuff"
|
||||
|
||||
binary-arch:
|
||||
# create ddirs
|
||||
$(MKDIR) $(DIR)/debian/tmp/$(PKGDIR) $(DIR)/debian/tmp/$(DBGDIR)
|
||||
$(MKDIR) $(DIR)/debian/tmp/$(PKGDIR) $(DIR)/debian/tmp/$(DESKTOP_DIR)
|
||||
$(MKDIR) $(DIR)/debian/tmp/$(PKGDIR) $(DIR)/debian/tmp/$(PIXMAPS_DIR)
|
||||
# install main binaries
|
||||
$(INSTALL) $(BINDIR)/$(EXENAME) $(DIR)/debian/tmp/$(PKGDIR)/$(PACKAGE)
|
||||
$(INSTALL) $(BINDIR)/$(DBGNAME) $(DIR)/debian/tmp/$(DBGDIR)/$(PACKAGE)
|
||||
# Install desktop file and banner image
|
||||
$(INSTALL) $(DIR)/srb2.png $(DIR)/debian/tmp/usr/share/pixmaps/${PROGRAM_FILENAME}.png
|
||||
$(INSTALL) $(DIR)/debian/srb2.desktop $(DIR)/debian/tmp/usr/share/applications/${PROGRAM_FILENAME}.desktop
|
||||
# add compiled binaries to include-binaries
|
||||
echo $(BINDIR)/$(EXENAME) >> $(DIR)/debian/source/include-binaries
|
||||
echo $(BINDIR)/$(EXENAME) >> $(DIR)/debian/source/include-binaries
|
||||
# Generate install folder files
|
||||
echo $(PKGDIR) > $(DIR)/debian/$(PACKAGE).install
|
||||
echo $(DESKTOP_DIR) >> $(DIR)/debian/$(PACKAGE).install
|
||||
echo $(PIXMAPS_DIR) >> $(DIR)/debian/$(PACKAGE).install
|
||||
echo $(DBGDIR) > $(DIR)/debian/$(DBGPKG).install
|
||||
# Launchpad only calls binary-arch, so just move everything up
|
||||
#binary: binary-arch
|
||||
# Generate .desktop specifications
|
||||
echo "`echo '$(MENUFILE1)\\'`" > $(DIR)/debian/menu
|
||||
echo " `echo '$(MENUFILE2)'`" >> $(DIR)/debian/menu
|
||||
dh_testdir
|
||||
dh_testroot
|
||||
dh_installchangelogs
|
||||
dh_installdocs
|
||||
# dh_installexamples
|
||||
dh_install --sourcedir=$(DIR)/debian/tmp
|
||||
dh_installmenu
|
||||
# dh_installdebconf
|
||||
# dh_installlogrotate
|
||||
# dh_installemacsen
|
||||
# dh_installpam
|
||||
# dh_installmime
|
||||
# dh_python
|
||||
# dh_installinit
|
||||
# dh_installcron
|
||||
# dh_installinfo
|
||||
# dh_installman
|
||||
dh_link $(PKGDIR)/$(EXENAME) $(LINKDIR)/$(EXENAME)
|
||||
dh_compress
|
||||
dh_fixperms
|
||||
# dh_perl
|
||||
# dh_makeshlibs
|
||||
dh_installdeb
|
||||
-dh_shlibdeps
|
||||
dh_gencontrol
|
||||
dh_md5sums
|
||||
dh_builddeb
|
||||
|
||||
binary: binary-arch
|
||||
|
||||
clean:
|
||||
$(MAKE) -C $(DIR)/src $(MAKEARGS) clean cleandep
|
||||
$(RM) $(BINDIR)/*
|
||||
$(RM) $(DIR)/debian/$(PACKAGE)/*
|
||||
$(RM) $(DIR)/debian/$(DBGPKG)/*
|
||||
$(RM) $(DIR)/debian/tmp/*
|
||||
$(RM) $(DIR)/debian/$(PACKAGE).install
|
||||
$(RM) $(DIR)/debian/$(DBGPKG).install
|
||||
$(RM) $(DIR)/debian/menu
|
||||
$(RM) $(DIR)/debian/files
|
||||
$(RM) $(DIR)/debian/source/include-binaries
|
||||
|
||||
.PHONY: all clean binary binary-indep build
|
||||
@@ -0,0 +1 @@
|
||||
3.0 (native)
|
||||
@@ -0,0 +1,11 @@
|
||||
tar-ignore = "assets/*.srb"
|
||||
tar-ignore = "assets/*.pk3"
|
||||
tar-ignore = "assets/*.dta"
|
||||
tar-ignore = "assets/*.wad"
|
||||
tar-ignore = "assets/*.kart"
|
||||
tar-ignore = "assets/debian/${PACKAGE_NAME}-data/*"
|
||||
tar-ignore = "assets/debian/tmp/*"
|
||||
tar-ignore = "*.obj"
|
||||
tar-ignore = "*.dep"
|
||||
tar-ignore = ".git/*"
|
||||
tar-ignore = ".git*"
|
||||
@@ -0,0 +1,10 @@
|
||||
[Desktop Entry]
|
||||
Name=${PROGRAM_NAME}
|
||||
Comment=${PROGRAM_DESCRIPTION}
|
||||
Encoding=UTF-8
|
||||
Exec=${PACKAGE_INSTALL_PATH}/${PROGRAM_FILENAME}
|
||||
Icon=/usr/share/pixmaps/${PROGRAM_FILENAME}.png
|
||||
Terminal=false
|
||||
Type=Application
|
||||
StartupNotify=false
|
||||
Categories=Application;Game;
|
||||
@@ -0,0 +1,166 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Deployer for Travis-CI
|
||||
# Debian package templating
|
||||
#
|
||||
# Call this script BEFORE running debuild!
|
||||
# source ./debian_template.sh [clean] [main/asset]
|
||||
#
|
||||
# Before running this script,
|
||||
# you should also set PACKAGE_NAME_EMAIL="John Doe <jdoe@example.com>" to match
|
||||
# the identity of the key you will use to sign the package.
|
||||
#
|
||||
|
||||
# Get script's actual path
|
||||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
|
||||
|
||||
# Recursive function for directory crawling
|
||||
# $1 = Directory root to crawl
|
||||
# $2 = Code to eval on file
|
||||
# $3 = Code to eval on directory
|
||||
# Exposes $dirtails, $dirlevel, and $dirtailname
|
||||
dirlevel=0 # initialize
|
||||
dirtails=()
|
||||
|
||||
# Utility function to make dira/dirb/dirc string
|
||||
makedirtailname () {
|
||||
dirtailname=""
|
||||
for tail in $dirtails; do
|
||||
if [[ "$dirtailname" == "" ]]; then
|
||||
dirtailname="/$tail";
|
||||
else
|
||||
dirtailname="$dirtailname/$tail";
|
||||
fi;
|
||||
done;
|
||||
}
|
||||
|
||||
evaldirectory () {
|
||||
if [ -d "$1" ]; then
|
||||
# Set contextual variables
|
||||
# dirtails is an array of directory basenames after the crawl root
|
||||
if (( $dirlevel > 0 )); then
|
||||
dirtails+=( "$(basename $1)" );
|
||||
else
|
||||
dirtails=();
|
||||
fi;
|
||||
dirlevel=$((dirlevel+1));
|
||||
|
||||
# Generate directory path after the crawl root
|
||||
makedirtailname;
|
||||
|
||||
# Eval our directory with the latest contextual info
|
||||
# Don't eval on root
|
||||
if (( $dirlevel > 1 )) && [[ "$3" != "" ]]; then
|
||||
eval "$3";
|
||||
fi;
|
||||
|
||||
# Iterate entries
|
||||
for name in $1/*; do
|
||||
if [ -d "$name" ]; then
|
||||
# Name is a directory, but don't eval yet
|
||||
# Recurse so our vars are updated
|
||||
evaldirectory "$name" "$2" "$3";
|
||||
|
||||
# Decrement our directory level and remove a dirtail
|
||||
unset 'dirtails[ ${#dirtails[@]}-1 ]';
|
||||
dirlevel=$((dirlevel-1));
|
||||
makedirtailname;
|
||||
else
|
||||
# Name is a file
|
||||
if [ -f "$name" ] && [[ "$2" != "" ]]; then
|
||||
eval "$2";
|
||||
fi;
|
||||
fi;
|
||||
done;
|
||||
|
||||
# Reset our variables; we're done iterating
|
||||
if (( $dirlevel == 1 )); then
|
||||
dirlevel=0;
|
||||
fi;
|
||||
fi;
|
||||
}
|
||||
|
||||
#
|
||||
# Initialize package parameter defaults
|
||||
#
|
||||
if [[ "$__DEBIAN_PARAMETERS_INITIALIZED" != "1" ]]; then
|
||||
. ${DIR}/deployer/travis/deployer_defaults.sh;
|
||||
fi;
|
||||
|
||||
# Clean up after ourselves; we only expect to run this script once
|
||||
# during buildboting
|
||||
__DEBIAN_PARAMETERS_INITIALIZED=0
|
||||
|
||||
# for envsubst
|
||||
export __PACKAGE_DATETIME="$(date '+%a, %d %b %Y %H:%M:%S %z')"
|
||||
export __PACKAGE_DATETIME_DIGIT="$(date -u '+%Y%m%d%H%M%S')"
|
||||
|
||||
if [[ "$PACKAGE_REVISION" == "" ]]; then
|
||||
PACKAGE_REVISION="-$__PACKAGE_DATETIME_DIGIT";
|
||||
__PACKAGE_REVISION_BY_DATE=1;
|
||||
export PACKAGE_REVISION=${PACKAGE_REVISION}; # for envsubst
|
||||
fi;
|
||||
|
||||
#
|
||||
# Clean the old debian/ directories
|
||||
#
|
||||
if [[ "$1" == "clean" ]]; then
|
||||
toclean=$2;
|
||||
else
|
||||
toclean=$1;
|
||||
fi;
|
||||
|
||||
if [[ "$toclean" == "" ]] || [[ "$toclean" == "main" ]]; then
|
||||
echo "Cleaning main package scripts";
|
||||
if [[ ! -f ${DIR}/debian ]]; then
|
||||
rm -rf ${DIR}/debian;
|
||||
fi;
|
||||
fi;
|
||||
if [[ "$toclean" == "" ]] || [[ "$toclean" == "asset" ]]; then
|
||||
echo "Cleaning asset package scripts";
|
||||
if [[ ! -f ${DIR}/assets/debian ]]; then
|
||||
rm -rf ${DIR}/assets/debian;
|
||||
fi;
|
||||
fi;
|
||||
|
||||
#
|
||||
# Make new templates
|
||||
#
|
||||
if [[ "$1" != "clean" ]]; then
|
||||
totemplate=$1;
|
||||
|
||||
# HACK: ${shlibs:Depends} in the templates make the templating fail
|
||||
# So just define replacemment variables
|
||||
export SHLIBS_DEPENDS=${SHLIBS_DEPENDS};
|
||||
export MISC_DEPENDS=${MISC_DEPENDS};
|
||||
export DEBFILEVAR='$$file'; # used in assets/debian/rules
|
||||
|
||||
# Package parameters are exported for envsubst in deployer_defaults.sh
|
||||
|
||||
if [[ "$totemplate" == "" ]] || [[ "$totemplate" == "main" ]]; then
|
||||
echo "Generating main package scripts";
|
||||
fromroot=${DIR}/debian-template;
|
||||
toroot=${DIR}/debian;
|
||||
mkdir ${toroot};
|
||||
|
||||
evaldirectory ${fromroot} \
|
||||
"cat \$name | envsubst > ${toroot}\${dirtailname}/\$( basename \$name )" \
|
||||
"mkdir \"${toroot}\${dirtailname}\"";
|
||||
fi;
|
||||
|
||||
if [[ "$totemplate" == "" ]] || [[ "$totemplate" == "asset" ]]; then
|
||||
echo "Generating asset package scripts";
|
||||
fromroot=${DIR}/assets/debian-template;
|
||||
toroot=${DIR}/assets/debian;
|
||||
mkdir ${toroot};
|
||||
|
||||
# Root dir to crawl; file eval; directory eval
|
||||
evaldirectory ${fromroot} \
|
||||
"cat \$name | envsubst > ${toroot}\${dirtailname}/\$( basename \$name )" \
|
||||
"mkdir \"${toroot}\${dirtailname}\"";
|
||||
fi;
|
||||
fi;
|
||||
|
||||
if [[ "$__DPL_ACTIVE" != "1" ]] && [[ "$__PACKAGE_REVISION_BY_DATE" == "1" ]]; then
|
||||
unset PACKAGE_REVISION; # so we can reset the date on subsequent runs
|
||||
fi;
|
||||
@@ -0,0 +1,195 @@
|
||||
@setlocal enableextensions enabledelayedexpansion
|
||||
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
: Appveyor Deployer
|
||||
: See appveyor.yml for default variables
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
: Evaluate whether we should be deploying
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
if not [%DPL_ENABLED%] == [1] (
|
||||
echo Deployer is not enabled...
|
||||
exit /b
|
||||
)
|
||||
|
||||
: Don't do DD installs because fmodex DLL handling is not implemented.
|
||||
if [%CONFIGURATION%] == [DD] (
|
||||
echo Deployer does not support DD builds...
|
||||
exit /b
|
||||
)
|
||||
|
||||
if [%CONFIGURATION%] == [DD64] (
|
||||
echo Deployer does not support DD builds...
|
||||
exit /b
|
||||
)
|
||||
|
||||
: Substring match from https://stackoverflow.com/questions/7005951/batch-file-find-if-substring-is-in-string-not-in-a-file
|
||||
: The below line says "if deployer is NOT in string"
|
||||
: Note that APPVEYOR_REPO_BRANCH for pull request builds is the BASE branch that PR is merging INTO
|
||||
if x%APPVEYOR_REPO_BRANCH:deployer=%==x%APPVEYOR_REPO_BRANCH% (
|
||||
if not [%APPVEYOR_REPO_TAG%] == [true] (
|
||||
echo Deployer is enabled but we are not in a release tag or a 'deployer' branch...
|
||||
exit /b
|
||||
) else (
|
||||
if not [%DPL_TAG_ENABLED%] == [1] (
|
||||
echo Deployer is not enabled for release tags...
|
||||
exit /b
|
||||
)
|
||||
)
|
||||
)
|
||||
|
||||
: Release tags always get optional assets (music.dta)
|
||||
if [%APPVEYOR_REPO_TAG%] == [true] (
|
||||
set "ASSET_FILES_OPTIONAL_GET=1"
|
||||
)
|
||||
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
: Get asset archives
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
if exist "C:\Users\appveyor\srb2_cache\archives\" (
|
||||
if [%ASSET_CLEAN%] == [1] (
|
||||
echo Cleaning asset archives...
|
||||
rmdir /s /q "C:\Users\appveyor\srb2_cache\archives"
|
||||
)
|
||||
)
|
||||
|
||||
if not exist "C:\Users\appveyor\srb2_cache\archives\" mkdir "C:\Users\appveyor\srb2_cache\archives"
|
||||
|
||||
goto EXTRACT_ARCHIVES
|
||||
|
||||
::::::::::::::::::::::::::::::::
|
||||
: ARCHIVE_NAME_PARTS
|
||||
: Call this like a function. %archivepath% is the path to extract parts from.
|
||||
::::::::::::::::::::::::::::::::
|
||||
|
||||
for %%a in (%archivepath%) do (
|
||||
set "file=%%~fa"
|
||||
set "filepath=%%~dpa"
|
||||
set "filename=%%~nxa"
|
||||
)
|
||||
|
||||
set "localarchivepath=C:\Users\appveyor\srb2_cache\archives\%filename%"
|
||||
|
||||
goto EOF
|
||||
|
||||
::::::::::::::::::::::::::::::::
|
||||
: EXTRACT_ARCHIVES
|
||||
::::::::::::::::::::::::::::::::
|
||||
|
||||
set "archivepath=%ASSET_ARCHIVE_PATH%"
|
||||
call :ARCHIVE_NAME_PARTS
|
||||
set "ASSET_ARCHIVE_PATH_LOCAL=%localarchivepath%"
|
||||
if not exist "%localarchivepath%" appveyor DownloadFile "%ASSET_ARCHIVE_PATH%" -FileName "%localarchivepath%"
|
||||
|
||||
set "archivepath=%ASSET_ARCHIVE_PATCH_PATH%"
|
||||
call :ARCHIVE_NAME_PARTS
|
||||
set "ASSET_ARCHIVE_PATCH_PATH_LOCAL=%localarchivepath%"
|
||||
if not exist "%localarchivepath%" appveyor DownloadFile "%ASSET_ARCHIVE_PATCH_PATH%" -FileName "%localarchivepath%"
|
||||
|
||||
if not [%X86_64%] == [1] (
|
||||
set "archivepath=%ASSET_ARCHIVE_X86_PATH%"
|
||||
call :ARCHIVE_NAME_PARTS
|
||||
set "ASSET_ARCHIVE_X86_PATH_LOCAL=!localarchivepath!"
|
||||
if not exist "!localarchivepath!" appveyor DownloadFile "%ASSET_ARCHIVE_X86_PATH%" -FileName "!localarchivepath!"
|
||||
)
|
||||
|
||||
if [%X86_64%] == [1] (
|
||||
set "archivepath=%ASSET_ARCHIVE_X64_PATH%"
|
||||
call :ARCHIVE_NAME_PARTS
|
||||
set "ASSET_ARCHIVE_X64_PATH_LOCAL=!localarchivepath!"
|
||||
if not exist "!localarchivepath!" appveyor DownloadFile "%ASSET_ARCHIVE_X64_PATH%" -FileName "!localarchivepath!"
|
||||
)
|
||||
|
||||
if [%ASSET_FILES_OPTIONAL_GET%] == [1] (
|
||||
set "archivepath=%ASSET_ARCHIVE_OPTIONAL_PATH%"
|
||||
call :ARCHIVE_NAME_PARTS
|
||||
set "ASSET_ARCHIVE_OPTIONAL_PATH_LOCAL=!localarchivepath!"
|
||||
if not exist "!localarchivepath!" appveyor DownloadFile "%ASSET_ARCHIVE_OPTIONAL_PATH%" -FileName "!localarchivepath!"
|
||||
)
|
||||
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
: Build the installers
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
mkdir "assets\installer"
|
||||
mkdir "assets\patch"
|
||||
|
||||
7z x -y "%ASSET_ARCHIVE_PATH_LOCAL%" -o"assets\installer" >null
|
||||
7z x -y "%ASSET_ARCHIVE_PATCH_PATH_LOCAL%" -o"assets\patch" >null
|
||||
|
||||
: Copy optional files to full installer (music.dta)
|
||||
if [%ASSET_FILES_OPTIONAL_GET%] == [1] (
|
||||
7z x -y "%ASSET_ARCHIVE_OPTIONAL_PATH_LOCAL%" -o"assets\installer" >null
|
||||
)
|
||||
|
||||
: Copy EXE -- BUILD_PATH is from appveyor.yml
|
||||
robocopy /S /ns /nc /nfl /ndl /np /njh /njs "%BUILD_PATH%" "assets\installer" /XF "*.debug" ".gitignore"
|
||||
robocopy /S /ns /nc /nfl /ndl /np /njh /njs "%BUILD_PATH%" "assets\patch" /XF "*.debug" ".gitignore"
|
||||
|
||||
: Are we building DD? (we were supposed to exit earlier!)
|
||||
if [%CONFIGURATION%] == [DD] ( set "DPL_INSTALLER_NAME=%DPL_INSTALLER_NAME%-DD" )
|
||||
if [%CONFIGURATION%] == [DD64] ( set "DPL_INSTALLER_NAME=%DPL_INSTALLER_NAME%-DD" )
|
||||
|
||||
: If we are not a release tag, suffix the filename
|
||||
if not [%APPVEYOR_REPO_TAG%] == [true] (
|
||||
set "INSTALLER_SUFFIX=-%APPVEYOR_REPO_BRANCH%-%GITSHORT%-%CONFIGURATION%"
|
||||
) else (
|
||||
set "INSTALLER_SUFFIX="
|
||||
)
|
||||
|
||||
if not [%X86_64%] == [1] ( goto X86_INSTALL )
|
||||
|
||||
::::::::::::::::::::::::::::::::
|
||||
: X64_INSTALL
|
||||
::::::::::::::::::::::::::::::::
|
||||
|
||||
: Extract DLL binaries
|
||||
7z x -y "%ASSET_ARCHIVE_X64_PATH_LOCAL%" -o"assets\installer" >null
|
||||
if [%PACKAGE_PATCH_DLL_GET%] == [1] (
|
||||
7z x -y "!ASSET_ARCHIVE_X64_PATH_LOCAL!" -o"assets\patch" >null
|
||||
)
|
||||
|
||||
: Build the installer
|
||||
7z a -sfx7z.sfx "%DPL_INSTALLER_NAME%-x64-Installer%INSTALLER_SUFFIX%.exe" .\assets\installer\*
|
||||
|
||||
: Build the patch
|
||||
7z a "%DPL_INSTALLER_NAME%-x64-Patch%INSTALLER_SUFFIX%.zip" .\assets\patch\*
|
||||
|
||||
: Upload artifacts
|
||||
appveyor PushArtifact "%DPL_INSTALLER_NAME%-x64-Installer%INSTALLER_SUFFIX%.exe"
|
||||
appveyor PushArtifact "%DPL_INSTALLER_NAME%-x64-Patch%INSTALLER_SUFFIX%.zip"
|
||||
|
||||
: We only do x86 OR x64, one at a time, so exit now.
|
||||
goto EOF
|
||||
|
||||
::::::::::::::::::::::::::::::::
|
||||
: X86_INSTALL
|
||||
::::::::::::::::::::::::::::::::
|
||||
|
||||
: Extract DLL binaries
|
||||
7z x -y "%ASSET_ARCHIVE_X86_PATH_LOCAL%" -o"assets\installer" >null
|
||||
if [%PACKAGE_PATCH_DLL_GET%] == [1] (
|
||||
7z x -y "!ASSET_ARCHIVE_X86_PATH_LOCAL!" -o"assets\patch" >null
|
||||
)
|
||||
|
||||
: Build the installer
|
||||
7z a -sfx7z.sfx "%DPL_INSTALLER_NAME%-Installer%INSTALLER_SUFFIX%.exe" .\assets\installer\*
|
||||
|
||||
: Build the patch
|
||||
7z a "%DPL_INSTALLER_NAME%-Patch%INSTALLER_SUFFIX%.zip" .\assets\patch\*
|
||||
|
||||
: Upload artifacts
|
||||
appveyor PushArtifact "%DPL_INSTALLER_NAME%-Installer%INSTALLER_SUFFIX%.exe"
|
||||
appveyor PushArtifact "%DPL_INSTALLER_NAME%-Patch%INSTALLER_SUFFIX%.zip"
|
||||
|
||||
: We only do x86 OR x64, one at a time, so exit now
|
||||
goto EOF
|
||||
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
: EOF
|
||||
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
|
||||
|
||||
endlocal
|
||||
@@ -0,0 +1,157 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Deployer for Travis-CI
|
||||
# Initialization
|
||||
#
|
||||
# Performs validity checks to ensure that Deployer is allowed to run
|
||||
# e.g., is an FTP hostname specified? Are we whitelisted by OSNAMES and BRANCHES?
|
||||
#
|
||||
# Set these environment variables in your Travis-CI settings, where they are stored securely.
|
||||
# See other shell scripts for more options.
|
||||
#
|
||||
# DPL_ENABLED = 1 (leave blank to disable)
|
||||
# DPL_TAG_ENABLED = 1 (run Deployer on all tags)
|
||||
# DPL_JOB_ENABLE_ALL = 1 (run Deployer on all jobs; leave blank to act on specific jobs, see below)
|
||||
# DPL_JOBNAMES = name1,name2 (whitelist of job names to allow uploading; leave blank to upload from all jobs)
|
||||
# DPL_OSNAMES = osx (whitelist of OS names to allow uploading; leave blank to upload from all OSes)
|
||||
# DPL_BRANCHES = master,branch1,branch2 (whitelist of branches to upload; leave blank to upload all branches)
|
||||
#
|
||||
# To enable Deployer on specific jobs, set _DPL_JOB_ENABLED=1 for that job. Example:
|
||||
# - matrix:
|
||||
# - os: osx
|
||||
# env:
|
||||
# - _DPL_JOB_ENABLED=1
|
||||
#
|
||||
# DO NOT set __DPL_ACTIVE, because that would bypass these validity checks.
|
||||
|
||||
# Validate Deployer state
|
||||
if [[ "$DPL_ENABLED" == "1" ]] && [[ "$TRAVIS_PULL_REQUEST" == "false" ]]; then
|
||||
# Test for base eligibility:
|
||||
# Are we in a deployer branch? Or
|
||||
# Are we in a release tag AND DPL_TAG_ENABLED=1?
|
||||
if [[ $TRAVIS_BRANCH == *"deployer"* ]]; then
|
||||
__DPL_BASE_ELIGIBLE=1;
|
||||
__DPL_TERMINATE_EARLY_ELIGIBLE=1;
|
||||
fi;
|
||||
|
||||
if [[ "$TRAVIS_TAG" != "" ]] && [[ "$DPL_TAG_ENABLED" == "1" ]]; then
|
||||
__DPL_BASE_ELIGIBLE=1;
|
||||
__DPL_TAG_ELIGIBLE=1;
|
||||
__DPL_TERMINATE_EARLY_ELIGIBLE=1;
|
||||
fi;
|
||||
|
||||
# Logging message for trigger word
|
||||
if [[ "$__DPL_TAG_ELIGIBLE" != "1" ]] && [[ "$DPL_TRIGGER" != "" ]]; then
|
||||
echo "Testing for trigger $DPL_TRIGGER, commit message: $TRAVIS_COMMIT_MESSAGE";
|
||||
echo "[${DPL_TRIGGER}]";
|
||||
echo "[${DPL_TRIGGER}-${_DPL_JOB_NAME}]";
|
||||
echo "[${DPL_TRIGGER}-${TRAVIS_OS_NAME}]";
|
||||
fi;
|
||||
|
||||
#
|
||||
# Search for the trigger word
|
||||
# Force enable if release tags are eligible
|
||||
#
|
||||
if [[ "$__DPL_TAG_ELIGIBLE" == "1" ]] || [[ "$DPL_TRIGGER" == "" ]] \
|
||||
|| [[ $TRAVIS_COMMIT_MESSAGE == *"[$DPL_TRIGGER]"* ]] \
|
||||
|| [[ $TRAVIS_COMMIT_MESSAGE == *"[${DPL_TRIGGER}-${_DPL_JOB_NAME}]"* ]] \
|
||||
|| [[ $TRAVIS_COMMIT_MESSAGE == *"[${DPL_TRIGGER}-${TRAVIS_OS_NAME}]"* ]]; then
|
||||
#
|
||||
# Whitelist by branch name
|
||||
# Force enable if release tags are eligible
|
||||
#
|
||||
if [[ "$__DPL_TAG_ELIGIBLE" == "1" ]] || [[ "$DPL_BRANCHES" == "" ]] || [[ $DPL_BRANCHES == *"$TRAVIS_BRANCH"* ]]; then
|
||||
# Set this so we only early-terminate builds when we are specifically deploying
|
||||
# Trigger string and branch are encompassing conditions; the rest are job-specific
|
||||
# This check only matters for deployer branches and when DPL_TERMINATE_TESTS=1,
|
||||
# because we're filtering non-deployer jobs.
|
||||
#
|
||||
# __DPL_TRY_TERMINATE_EARLY is invalidated in .travis.yml if __DPL_ACTIVE=1
|
||||
if [[ "$__DPL_TERMINATE_EARLY_ELIGIBLE" == "1" ]] && [[ "$DPL_TERMINATE_TESTS" == "1" ]]; then
|
||||
__DPL_TRY_TERMINATE_EARLY=1;
|
||||
fi;
|
||||
|
||||
#
|
||||
# Is the job enabled for deployment?
|
||||
#
|
||||
if [[ "$DPL_JOB_ENABLE_ALL" == "1" ]] || [[ "$_DPL_JOB_ENABLED" == "1" ]]; then
|
||||
#
|
||||
# Whitelist by job names
|
||||
#
|
||||
if [[ "$DPL_JOBNAMES" == "" ]] || [[ "$_DPL_JOB_NAME" == "" ]] || [[ $DPL_JOBNAMES == *"$_DPL_JOB_NAME"* ]]; then
|
||||
#
|
||||
# Whitelist by OS names
|
||||
#
|
||||
if [[ "$DPL_OSNAMES" == "" ]] || [[ $DPL_OSNAMES == *"$TRAVIS_OS_NAME"* ]]; then
|
||||
# Base Deployer is eligible for becoming active
|
||||
|
||||
# Are we building for Linux?
|
||||
if [[ "$_DPL_PACKAGE_BINARY" == "1" ]] || [[ "$_DPL_PACKAGE_SOURCE" == "1" ]]; then
|
||||
if [[ "$_DPL_PACKAGE_MAIN" == "1" ]] || [[ "$_DPL_PACKAGE_ASSET" == "1" ]]; then
|
||||
if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
|
||||
__DPL_DEBIAN_ACTIVE=1;
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
|
||||
# Now check for deployment targets
|
||||
if [[ "$_DPL_FTP_TARGET" == "1" ]] && [[ "$DPL_FTP_HOSTNAME" != "" ]]; then
|
||||
if [[ "$TRAVIS_OS_HOST" == "linux" ]] && [[ "$DPL_FTP_PROTOCOL" == "ftp" ]]; then
|
||||
echo "Non-secure FTP will not work on Linux Travis-CI jobs!";
|
||||
echo "Try SFTP or another target. Details:";
|
||||
echo "https://blog.travis-ci.com/2018-07-23-the-tale-of-ftp-at-travis-ci";
|
||||
else
|
||||
if [[ "$__DPL_DEBIAN_ACTIVE" == "1" ]] || [[ "$_DPL_PACKAGE_BINARY" == "1" ]] || [[ "$_DPL_BINARY" == "1" ]]; then
|
||||
echo "Deployer FTP target is enabled";
|
||||
__DPL_FTP_ACTIVE=1;
|
||||
else
|
||||
echo "Deployer FTP target cannot be enabled: You must specify _DPL_PACKAGE_BINARY=1,";
|
||||
echo "and/or _DPL_BINARY=1 in your job's environment variables.";
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
|
||||
if [[ "$_DPL_DPUT_TARGET" == "1" ]] && [[ "$__DPL_DEBIAN_ACTIVE" == "1" ]] \
|
||||
&& [[ "$DPL_DPUT_INCOMING" != "" ]]; then
|
||||
if [[ "$DPL_DPUT_METHOD" == "ftp" ]]; then
|
||||
echo "DPUT will not work with non-secure FTP on Linux Travis-CI jobs!";
|
||||
echo "Try SFTP or another method for DPUT. Details:";
|
||||
echo "https://blog.travis-ci.com/2018-07-23-the-tale-of-ftp-at-travis-ci";
|
||||
else
|
||||
echo "Deployer DPUT target is enabled";
|
||||
__DPL_DPUT_ACTIVE=1;
|
||||
fi;
|
||||
fi;
|
||||
|
||||
# If any deployment targets are active, then so is the Deployer at large
|
||||
if [[ "$__DPL_FTP_ACTIVE" == "1" ]] || [[ "$__DPL_DPUT_ACTIVE" == "1" ]]; then
|
||||
__DPL_ACTIVE=1;
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
else
|
||||
if [[ "$DPL_TRIGGER" != "" ]]; then
|
||||
echo "Testing for global trigger [$DPL_TRIGGER, commit message: $TRAVIS_COMMIT_MESSAGE";
|
||||
fi;
|
||||
if [[ "$DPL_TRIGGER" != "" ]] && [[ $TRAVIS_COMMIT_MESSAGE == *"[$DPL_TRIGGER"* ]]; then
|
||||
if [[ "$__DPL_TAG_ELIGIBLE" == "1" ]] || [[ "$DPL_BRANCHES" == "" ]] || [[ $DPL_BRANCHES == *"$TRAVIS_BRANCH"* ]]; then
|
||||
# This check only matters for deployer branches and when DPL_TERMINATE_TESTS=1,
|
||||
# because we're filtering non-deployer jobs.
|
||||
if [[ "$__DPL_TERMINATE_EARLY_ELIGIBLE" == "1" ]] && [[ "$DPL_TERMINATE_TESTS" == "1" ]]; then
|
||||
# Assume that some job received the trigger, so mark this for early termination
|
||||
__DPL_TRY_TERMINATE_EARLY=1;
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
|
||||
if [[ "$__DPL_TRY_TERMINATE_EARLY" == "1" ]] && [[ "$__DPL_ACTIVE" != "1" ]]; then
|
||||
echo "Deployer is active in another job";
|
||||
fi;
|
||||
|
||||
if [[ "$__DPL_TRY_TERMINATE_EARLY" != "1" ]] && [[ "$__DPL_ACTIVE" != "1" ]]; then
|
||||
echo "Deployer is not active";
|
||||
fi;
|
||||
@@ -0,0 +1,190 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Deployer for Travis-CI
|
||||
# Build Script
|
||||
#
|
||||
# Builds the required targets depending on which sub-modules are enabled
|
||||
|
||||
if [[ "$__DPL_FTP_ACTIVE" == "1" ]] || [[ "$__DPL_DPUT_ACTIVE" == "1" ]]; then
|
||||
if [[ "$__DPL_DEBIAN_ACTIVE" == "1" ]]; then
|
||||
echo "Building Debian package(s)"
|
||||
|
||||
sudo apt-get install devscripts debhelper fakeroot secure-delete expect;
|
||||
|
||||
# Build source packages first, since they zip up the entire source folder,
|
||||
# binaries and all
|
||||
if [[ "$_DPL_PACKAGE_MAIN" == "1" ]]; then
|
||||
. ../debian_template.sh main;
|
||||
OLDPWD=$PWD; # [repo]/build
|
||||
cd ..; # repo root
|
||||
|
||||
if [[ "$_DPL_PACKAGE_SOURCE" == "1" ]]; then
|
||||
echo "Building main source Debian package";
|
||||
expect <(cat <<EOD
|
||||
spawn debuild -S -us -uc;
|
||||
expect "continue anyway? (y/n)"
|
||||
send "y\r"
|
||||
interact
|
||||
EOD
|
||||
);
|
||||
fi;
|
||||
|
||||
if [[ "$_DPL_PACKAGE_BINARY" == "1" ]]; then
|
||||
echo "Building main binary Debian package";
|
||||
expect <(cat <<EOD
|
||||
spawn debuild -us -uc;
|
||||
expect "continue anyway? (y/n)"
|
||||
send "y\r"
|
||||
interact
|
||||
EOD
|
||||
);
|
||||
fi;
|
||||
|
||||
cd $OLDPWD;
|
||||
fi;
|
||||
|
||||
# Also an asset package
|
||||
if [[ "$_DPL_PACKAGE_ASSET" == "1" ]]; then
|
||||
. ../debian_template.sh asset;
|
||||
OLDPWD=$PWD; # [repo]/build
|
||||
cd ../assets;
|
||||
|
||||
# make sure the asset files exist, download them if they don't
|
||||
#echo "Checking asset files for asset Debian package";
|
||||
#debuild -T build;
|
||||
|
||||
if [[ "$_DPL_PACKAGE_SOURCE" == "1" ]]; then
|
||||
echo "Building asset source Debian package";
|
||||
expect <(cat <<EOD
|
||||
spawn debuild -S -us -uc;
|
||||
expect "continue anyway? (y/n)"
|
||||
send "y\r"
|
||||
interact
|
||||
EOD
|
||||
);
|
||||
fi;
|
||||
|
||||
if [[ "$_DPL_PACKAGE_BINARY" == "1" ]]; then
|
||||
echo "Building asset binary Debian package";
|
||||
expect <(cat <<EOD
|
||||
spawn debuild -us -uc;
|
||||
expect "continue anyway? (y/n)"
|
||||
send "y\r"
|
||||
interact
|
||||
EOD
|
||||
);
|
||||
fi;
|
||||
|
||||
cd $OLDPWD;
|
||||
fi;
|
||||
|
||||
# Now sign our packages
|
||||
if [[ "$DPL_PGP_KEY_PRIVATE" != "" ]] && [[ "$DPL_PGP_KEY_PASSPHRASE" != "" ]]; then
|
||||
# Get the key to sign
|
||||
# Do this AFTER debuild so that we can specify the passphrase in command line
|
||||
echo "$DPL_PGP_KEY_PRIVATE" | base64 --decode > key.asc;
|
||||
echo "$DPL_PGP_KEY_PASSPHRASE" > phrase.txt;
|
||||
gpg --import key.asc;
|
||||
|
||||
if [[ "$_DPL_PACKAGE_MAIN" == "1" ]]; then
|
||||
echo "Signing main package(s)";
|
||||
|
||||
PACKAGEFILENAME=${PACKAGE_NAME}_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
PACKAGEDBGFILENAME=${PACKAGE_NAME}-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGENIGHTLYDBGFILENAME=${PACKAGE_NAME}-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHDBGFILENAME=${PACKAGE_NAME}-patch-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHNIGHTLYDBGFILENAME=${PACKAGE_NAME}-patch-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
|
||||
PACKAGEFILENAMES=(
|
||||
$PACKAGEFILENAME
|
||||
$PACKAGEDBGFILENAME
|
||||
#$PACKAGENIGHTLYFILENAME
|
||||
#$PACKAGENIGHTLYDBGFILENAME
|
||||
#$PACKAGEPATCHFILENAME
|
||||
#$PACKAGEPATCHDBGFILENAME
|
||||
#$PACKAGEPATCHNIGHTLYFILENAME
|
||||
#$PACKAGEPATCHNIGHTLYDBGFILENAME
|
||||
);
|
||||
|
||||
# Main packages are in parent of root repo folder
|
||||
OLDPWD=$PWD; # [repo]/build
|
||||
cd ../..; # parent of repo root
|
||||
|
||||
for n in ${PACKAGEFILENAMES}; do
|
||||
for f in ./$n*.changes; do
|
||||
debsign --no-re-sign -p"gpg --passphrase-file $OLDPWD/phrase.txt --batch" "$f";
|
||||
done;
|
||||
done;
|
||||
|
||||
cd $OLDPWD;
|
||||
fi;
|
||||
|
||||
if [[ "$_DPL_PACKAGE_ASSET" == "1" ]]; then
|
||||
echo "Signing asset package(s)";
|
||||
|
||||
PACKAGEFILENAME=${PACKAGE_NAME}-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
|
||||
PACKAGEFILENAMES=(
|
||||
$PACKAGEFILENAME
|
||||
#$PACKAGENIGHTLYFILENAME
|
||||
#$PACKAGEPATCHFILENAME
|
||||
#$PACKAGEPATCHNIGHTLYFILENAME
|
||||
)
|
||||
|
||||
# Asset packages are in root repo folder
|
||||
OLDPWD=$PWD; # [repo]/build
|
||||
cd ..; # repo root
|
||||
|
||||
for n in ${PACKAGEFILENAMES}; do
|
||||
for f in ./$n*.changes; do
|
||||
debsign --no-re-sign -p"gpg --passphrase-file $OLDPWD/phrase.txt --batch" "$f";
|
||||
done;
|
||||
done;
|
||||
|
||||
cd $OLDPWD;
|
||||
fi;
|
||||
|
||||
# Delete the keys :eyes:
|
||||
srm key.asc;
|
||||
srm phrase.txt;
|
||||
fi;
|
||||
fi;
|
||||
|
||||
# all other OSes
|
||||
if [[ "$TRAVIS_OS_NAME" != "linux" ]]; then
|
||||
#
|
||||
# Check for binary building
|
||||
#
|
||||
if [[ "$_DPL_BINARY" == "1" ]]; then
|
||||
echo "Building a Binary";
|
||||
make -k;
|
||||
fi;
|
||||
|
||||
#
|
||||
# Check for package building
|
||||
#
|
||||
if [[ "$_DPL_PACKAGE_BINARY" == "1" ]]; then
|
||||
echo "Building a Package";
|
||||
|
||||
# Make an OSX package; superuser is required for library bundling
|
||||
#
|
||||
# HACK: OSX packaging can't write libraries to .app package unless we're superuser
|
||||
# because the original library files don't have WRITE permission
|
||||
# Bug may be sidestepped by using CHMOD_BUNDLE_ITEMS=TRUE
|
||||
# But I don't know where this is set. Not `cmake -D...` because this var is ignored.
|
||||
# https://cmake.org/Bug/view.php?id=9284
|
||||
if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
|
||||
sudo make -k package;
|
||||
else
|
||||
# Some day, when Windows is supported, we'll just make a standard package
|
||||
make -k package;
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
fi;
|
||||
@@ -0,0 +1,105 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Deployer for Travis-CI
|
||||
# Default Variables
|
||||
#
|
||||
# Here are all of the user-set variables used by Deployer.
|
||||
# See the "Cross-platform deployment" page on SRB2 Wiki for documentation.
|
||||
|
||||
# Core Parameters
|
||||
: ${DPL_ENABLED} # Enable Deployer behavior; must be set for any deployment activity
|
||||
: ${DPL_TAG_ENABLED} # Trigger Deployer for all tag releases
|
||||
: ${DPL_JOB_ENABLE_ALL} # Enable all jobs for deployment
|
||||
: ${DPL_TERMINATE_TESTS} # Terminate all build test jobs (used in .travis.yml)
|
||||
: ${DPL_TRIGGER} # Use a [word] in the commit message to trigger Deployer
|
||||
: ${DPL_JOBNAMES} # Trigger Deployer by job name
|
||||
: ${DPL_OSNAMES} # Trigger Deployer by OS name (osx,linux)
|
||||
: ${DPL_BRANCHES} # Trigger Deployer by git branch name
|
||||
|
||||
# Job Parameters
|
||||
: ${_DPL_JOB_ENABLED} # Enable Deployer for this specific job. DPL_ENABLED must be set too.
|
||||
: ${_DPL_JOB_NAME} # Identifier for the job, used for logging and trigger word matching
|
||||
: ${_DPL_FTP_TARGET} # Deploy to FTP
|
||||
: ${_DPL_DPUT_TARGET} # Deploy to DPUT
|
||||
: ${_DPL_PACKAGE_SOURCE} # Build packages into a Source distribution. Linux only.
|
||||
: ${_DPL_PACKAGE_BINARY} # Build packages into a Binary distribution.
|
||||
: ${_DPL_PACKAGE_MAIN:=1} # Build main installation package. Linux only; OS X assumes this.
|
||||
: ${_DPL_PACKAGE_ASSET} # Build asset installation package. Linux only.
|
||||
|
||||
# Asset File Parameters
|
||||
: ${ASSET_ARCHIVE_PATH:=https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-assets.7z}
|
||||
: ${ASSET_ARCHIVE_OPTIONAL_PATH:=https://github.com/mazmazz/Kart-Public/releases/download/kart_assets/srb2kart-v102-optional-assets.7z}
|
||||
: ${ASSET_FILES_HASHED:=srb2.srb patch.kart gfx.kart textures.kart chars.kart maps.kart}
|
||||
: ${ASSET_FILES_DOCS:=README.txt HISTORY.txt LICENSE.txt LICENSE-3RD-PARTY.txt}
|
||||
: ${ASSET_FILES_OPTIONAL_GET:=0}
|
||||
|
||||
# FTP Parameters
|
||||
: ${DPL_FTP_PROTOCOL}
|
||||
: ${DPL_FTP_USER}
|
||||
: ${DPL_FTP_PASS}
|
||||
: ${DPL_FTP_HOSTNAME}
|
||||
: ${DPL_FTP_PORT}
|
||||
: ${DPL_FTP_PATH}
|
||||
|
||||
# DPUT Parameters
|
||||
: ${DPL_DPUT_DOMAIN:=ppa.launchpad.net}
|
||||
: ${DPL_DPUT_METHOD:=sftp}
|
||||
: ${DPL_DPUT_INCOMING}
|
||||
: ${DPL_DPUT_LOGIN:=anonymous}
|
||||
: ${DPL_SSH_KEY_PRIVATE} # Base64-encoded private key file. Used to sign repository uploads
|
||||
: ${DPL_SSH_KEY_PASSPHRASE} # Decodes the private key file.
|
||||
|
||||
# Package Parameters
|
||||
: ${PACKAGE_NAME:=srb2kart}
|
||||
: ${PACKAGE_VERSION:=1.0.2}
|
||||
: ${PACKAGE_SUBVERSION} # Highly recommended to set this to reflect the distro series target (e.g., ~18.04bionic)
|
||||
: ${PACKAGE_REVISION} # Defaults to UTC timestamp
|
||||
: ${PACKAGE_INSTALL_PATH:=/usr/games/SRB2Kart}
|
||||
: ${PACKAGE_LINK_PATH:=/usr/games}
|
||||
: ${PACKAGE_DISTRO:=trusty}
|
||||
: ${PACKAGE_URGENCY:=high}
|
||||
: ${PACKAGE_NAME_EMAIL:=Kart Krew <stjr@srb2.org>}
|
||||
: ${PACKAGE_GROUP_NAME_EMAIL:=Kart Krew <stjr@srb2.org>}
|
||||
: ${PACKAGE_WEBSITE:=<https://mb.srb2.org/showthread.php?p=802695>}
|
||||
|
||||
: ${PACKAGE_ASSET_MINVERSION:=1.0.1} # Number this the version BEFORE the actual required version, because we do a > check
|
||||
: ${PACKAGE_ASSET_MAXVERSION:=1.0.3} # Number this the version AFTER the actual required version, because we do a < check
|
||||
|
||||
: ${PROGRAM_NAME:=Sonic Robo Blast 2 Kart}
|
||||
: ${PROGRAM_VENDOR:=Kart Krew}
|
||||
: ${PROGRAM_VERSION:=1.0.2}
|
||||
: ${PROGRAM_DESCRIPTION:=A kart racing mod based on the 3D Sonic the Hedgehog fangame Sonic Robo Blast 2.}
|
||||
: ${PROGRAM_FILENAME:=srb2kart}
|
||||
|
||||
: ${DPL_PGP_KEY_PRIVATE} # Base64-encoded private key file. Used to sign Debian packages
|
||||
: ${DPL_PGP_KEY_PASSPHRASE} # Decodes the private key file.
|
||||
|
||||
# Export Asset and Package Parameters for envsubst templating
|
||||
|
||||
export ASSET_ARCHIVE_PATH="${ASSET_ARCHIVE_PATH}"
|
||||
export ASSET_ARCHIVE_OPTIONAL_PATH="${ASSET_ARCHIVE_OPTIONAL_PATH}"
|
||||
export ASSET_FILES_HASHED="${ASSET_FILES_HASHED}"
|
||||
export ASSET_FILES_DOCS="${ASSET_FILES_DOCS}"
|
||||
export ASSET_FILES_OPTIONAL_GET="${ASSET_FILES_OPTIONAL_GET}"
|
||||
|
||||
export PACKAGE_NAME="${PACKAGE_NAME}"
|
||||
export PACKAGE_VERSION="${PACKAGE_VERSION}"
|
||||
export PACKAGE_SUBVERSION="${PACKAGE_SUBVERSION}" # in case we have this
|
||||
export PACKAGE_REVISION="${PACKAGE_REVISION}"
|
||||
export PACKAGE_ASSET_MINVERSION="${PACKAGE_ASSET_MINVERSION}"
|
||||
export PACKAGE_ASSET_MAXVERSION="${PACKAGE_ASSET_MAXVERSION}"
|
||||
export PACKAGE_INSTALL_PATH="${PACKAGE_INSTALL_PATH}"
|
||||
export PACKAGE_LINK_PATH="${PACKAGE_LINK_PATH}"
|
||||
export PACKAGE_DISTRO="${PACKAGE_DISTRO}"
|
||||
export PACKAGE_URGENCY="${PACKAGE_URGENCY}"
|
||||
export PACKAGE_NAME_EMAIL="${PACKAGE_NAME_EMAIL}"
|
||||
export PACKAGE_GROUP_NAME_EMAIL="${PACKAGE_GROUP_NAME_EMAIL}"
|
||||
export PACKAGE_WEBSITE="${PACKAGE_WEBSITE}"
|
||||
|
||||
export PROGRAM_NAME="${PROGRAM_NAME}"
|
||||
export PROGRAM_VERSION="${PROGRAM_VERSION}"
|
||||
export PROGRAM_DESCRIPTION="${PROGRAM_DESCRIPTION}"
|
||||
export PROGRAM_FILENAME="${PROGRAM_FILENAME}"
|
||||
|
||||
# This file is called in debian_template.sh, so mark our completion so we don't run it again
|
||||
__DEBIAN_PARAMETERS_INITIALIZED=1
|
||||
@@ -0,0 +1,133 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Deployer for Travis-CI
|
||||
# DPUT uploader (e.g., Launchpad PPA)
|
||||
#
|
||||
|
||||
if [[ "$__DPL_DPUT_ACTIVE" == "1" ]]; then
|
||||
# Install APT dependencies
|
||||
# paramiko required for ssh
|
||||
sudo apt-get install python-paramiko expect dput; # python-pip
|
||||
#pip install paramiko;
|
||||
|
||||
# Output the DPUT config
|
||||
# Dput only works if you're using secure FTP, so that's what we default to.
|
||||
cat > "./dput.cf" << EOM
|
||||
[deployer]
|
||||
fqdn = ${DPL_DPUT_DOMAIN}
|
||||
method = ${DPL_DPUT_METHOD}
|
||||
incoming = ${DPL_DPUT_INCOMING}
|
||||
login = ${DPL_DPUT_LOGIN}
|
||||
allow_unsigned_uploads = 0
|
||||
EOM
|
||||
|
||||
# Output SSH config
|
||||
# Don't let SSH prompt us for untrusted hosts
|
||||
cat >> "./ssh_config" << EOM
|
||||
|
||||
Host *
|
||||
StrictHostKeyChecking no
|
||||
UserKnownHostsFile=/dev/null
|
||||
PubKeyAuthentication yes
|
||||
IdentityFile ${PWD}/key.private
|
||||
IdentitiesOnly yes
|
||||
EOM
|
||||
sudo sh -c "cat < ${PWD}/ssh_config >> /etc/ssh/ssh_config";
|
||||
|
||||
# Get the private key
|
||||
echo "$DPL_SSH_KEY_PRIVATE" | base64 --decode > key.private;
|
||||
chmod 700 ./key.private;
|
||||
|
||||
if [[ "$_DPL_PACKAGE_MAIN" == "1" ]]; then
|
||||
PACKAGEFILENAME=${PACKAGE_NAME}_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
PACKAGEDBGFILENAME=${PACKAGE_NAME}-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGENIGHTLYDBGFILENAME=${PACKAGE_NAME}-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHDBGFILENAME=${PACKAGE_NAME}-patch-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHNIGHTLYDBGFILENAME=${PACKAGE_NAME}-patch-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
|
||||
PACKAGEFILENAMES=(
|
||||
$PACKAGEFILENAME
|
||||
$PACKAGEDBGFILENAME
|
||||
#$PACKAGENIGHTLYFILENAME
|
||||
#$PACKAGENIGHTLYDBGFILENAME
|
||||
#$PACKAGEPATCHFILENAME
|
||||
#$PACKAGEPATCHDBGFILENAME
|
||||
#$PACKAGEPATCHNIGHTLYFILENAME
|
||||
#$PACKAGEPATCHNIGHTLYDBGFILENAME
|
||||
);
|
||||
|
||||
# Main packages are in parent of root repo folder
|
||||
OLDPWD=$PWD; # [repo]/build
|
||||
cd ../..;
|
||||
|
||||
# Enter passphrase if required
|
||||
for n in ${PACKAGEFILENAMES}; do
|
||||
for f in $n*.changes; do
|
||||
# Binary builds also generate source builds, so exclude the source
|
||||
# builds if desired
|
||||
if [[ "$_DPL_PACKAGE_SOURCE" != "1" ]]; then
|
||||
if [[ "$f" == *"_source"* ]] || [[ "$f" == *".tar.xz"* ]]; then
|
||||
continue;
|
||||
fi;
|
||||
fi;
|
||||
|
||||
expect <(cat <<EOD
|
||||
spawn dput -c "${OLDPWD}/dput.cf" deployer "$f";
|
||||
expect "Enter passphrase for key"
|
||||
send "${DPL_SSH_KEY_PASSPHRASE}\r"
|
||||
interact
|
||||
EOD
|
||||
);
|
||||
done;
|
||||
done;
|
||||
|
||||
# Go back to [repo]/build folder
|
||||
cd $OLDPWD;
|
||||
fi;
|
||||
|
||||
if [[ "$_DPL_PACKAGE_ASSET" == "1" ]]; then
|
||||
PACKAGEFILENAME=${PACKAGE_NAME}-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
|
||||
PACKAGEFILENAMES=(
|
||||
$PACKAGEFILENAME
|
||||
#$PACKAGENIGHTLYFILENAME
|
||||
#$PACKAGEPATCHFILENAME
|
||||
#$PACKAGEPATCHNIGHTLYFILENAME
|
||||
)
|
||||
|
||||
# Asset packages are in root repo folder
|
||||
OLDPWD=$PWD; # [repo]/build
|
||||
cd ..;
|
||||
|
||||
# Enter passphrase if required
|
||||
for n in ${PACKAGEFILENAMES}; do
|
||||
for f in $n*.changes; do
|
||||
# Binary builds also generate source builds, so exclude the source
|
||||
# builds if desired
|
||||
if [[ "$_DPL_PACKAGE_SOURCE" != "1" ]]; then
|
||||
if [[ "$f" == *"_source"* ]] || [[ "$f" == *".tar.xz"* ]]; then
|
||||
continue;
|
||||
fi;
|
||||
fi;
|
||||
expect <(cat <<EOD
|
||||
spawn dput -c "${OLDPWD}/dput.cf" deployer "$f";
|
||||
expect "Enter passphrase for key"
|
||||
send "${DPL_SSH_KEY_PASSPHRASE}\r"
|
||||
interact
|
||||
EOD
|
||||
);
|
||||
done;
|
||||
done;
|
||||
|
||||
# Go back to [repo]/build folder
|
||||
cd $OLDPWD;
|
||||
fi;
|
||||
|
||||
srm ./key.private;
|
||||
fi;
|
||||
@@ -0,0 +1,137 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Deployer for Travis-CI
|
||||
# FTP Uploader
|
||||
#
|
||||
# Package files are uploaded to, e.g., ftp://username:password@example.com:21/path/to/upload/STJr/SRB2/master/460873812-151.1
|
||||
# With file `commit.txt` and folder(s) `bin` and `package`
|
||||
#
|
||||
# Set these environment variables in your Travis-CI settings, where they are stored securely.
|
||||
# See other shell scripts for more options.
|
||||
#
|
||||
# DPL_FTP_PROTOCOL = ftp (ftp or sftp or ftps or however your FTP URI begins)
|
||||
# DPL_FTP_USER = username
|
||||
# DPL_FTP_PASS = password
|
||||
# DPL_FTP_HOSTNAME = example.com
|
||||
# DPL_FTP_PORT = 21
|
||||
# DPL_FTP_PATH = path/to/upload (do not add trailing slash)
|
||||
|
||||
if [[ "$__DPL_FTP_ACTIVE" == "1" ]]; then
|
||||
if [[ "$TRAVIS_JOB_NAME" != "" ]]; then
|
||||
JOBNAME=$TRAVIS_JOB_NAME;
|
||||
else
|
||||
if [[ "$_DPL_JOB_NAME" != "" ]]; then
|
||||
JOBNAME=$_DPL_JOB_NAME;
|
||||
else
|
||||
JOBNAME=$TRAVIS_OS_NAME;
|
||||
fi;
|
||||
fi;
|
||||
|
||||
# Generate commit.txt file
|
||||
echo "Travis-CI Build $TRAVIS_OS_NAME - $TRAVIS_REPO_SLUG/$TRAVIS_BRANCH - $TRAVIS_JOB_NUMBER - $JOBNAME" > "commit.txt";
|
||||
echo "Job ID $TRAVIS_JOB_ID" >> "commit.txt";
|
||||
echo "" >> "commit.txt";
|
||||
echo "Commit $TRAVIS_COMMIT" >> "commit.txt";
|
||||
echo "$TRAVIS_COMMIT_MESSAGE" >> "commit.txt";
|
||||
echo "" >> "commit.txt";
|
||||
|
||||
# Initialize FTP parameters
|
||||
if [[ "$DPL_FTP_PORT" == "" ]]; then
|
||||
DPL_FTP_PORT=21;
|
||||
fi;
|
||||
if [[ "$DPL_FTP_PROTOCOL" == "" ]]; then
|
||||
DPL_FTP_PROTOCOL=ftp;
|
||||
fi;
|
||||
__DPL_FTP_LOCATION=$DPL_FTP_PROTOCOL://$DPL_FTP_HOSTNAME:$DPL_FTP_PORT/$DPL_FTP_PATH/$TRAVIS_REPO_SLUG/$TRAVIS_BRANCH/$TRAVIS_JOB_ID-$TRAVIS_JOB_NUMBER-$JOBNAME;
|
||||
|
||||
# Upload to FTP!
|
||||
echo "Uploading to FTP...";
|
||||
curl --ftp-create-dirs -T "commit.txt" -u $DPL_FTP_USER:$DPL_FTP_PASS "$__DPL_FTP_LOCATION/commit.txt";
|
||||
|
||||
if [[ "$__DPL_DEBIAN_ACTIVE" == "1" ]]; then
|
||||
if [[ "$_DPL_PACKAGE_MAIN" == "1" ]]; then
|
||||
PACKAGEFILENAME=${PACKAGE_NAME}_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
PACKAGEDBGFILENAME=${PACKAGE_NAME}-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGENIGHTLYDBGFILENAME=${PACKAGE_NAME}-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHDBGFILENAME=${PACKAGE_NAME}-patch-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHNIGHTLYDBGFILENAME=${PACKAGE_NAME}-patch-nightly-dbg_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
|
||||
PACKAGEFILENAMES=(
|
||||
$PACKAGEFILENAME
|
||||
$PACKAGEDBGFILENAME
|
||||
#$PACKAGENIGHTLYFILENAME
|
||||
#$PACKAGENIGHTLYDBGFILENAME
|
||||
#$PACKAGEPATCHFILENAME
|
||||
#$PACKAGEPATCHDBGFILENAME
|
||||
#$PACKAGEPATCHNIGHTLYFILENAME
|
||||
#$PACKAGEPATCHNIGHTLYDBGFILENAME
|
||||
);
|
||||
|
||||
# Main packages are in parent of root repo folder
|
||||
OLDPWD=$PWD; # [repo]/build
|
||||
cd ../..;
|
||||
|
||||
for n in ${PACKAGEFILENAMES}; do
|
||||
for f in ./$n*; do
|
||||
# Binary builds also generate source builds, so exclude the source
|
||||
# builds if desired
|
||||
if [[ "$_DPL_PACKAGE_SOURCE" != "1" ]]; then
|
||||
if [[ "$f" == *"_source"* ]] || [[ "$f" == *".tar.xz"* ]]; then
|
||||
continue;
|
||||
fi;
|
||||
fi;
|
||||
curl --ftp-create-dirs -T "$f" -u $DPL_FTP_USER:$DPL_FTP_PASS "$__DPL_FTP_LOCATION/package/main/$f";
|
||||
done;
|
||||
done;
|
||||
|
||||
# Go back to [repo]/build folder
|
||||
cd $OLDPWD;
|
||||
fi;
|
||||
|
||||
if [[ "$_DPL_PACKAGE_ASSET" == "1" ]]; then
|
||||
PACKAGEFILENAME=${PACKAGE_NAME}-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGENIGHTLYFILENAME=${PACKAGE_NAME}-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHFILENAME=${PACKAGE_NAME}-patch-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
#PACKAGEPATCHNIGHTLYFILENAME=${PACKAGE_NAME}-patch-nightly-data_${PACKAGE_VERSION}${PACKAGE_SUBVERSION}${PACKAGE_REVISION};
|
||||
|
||||
PACKAGEFILENAMES=(
|
||||
$PACKAGEFILENAME
|
||||
#$PACKAGENIGHTLYFILENAME
|
||||
#$PACKAGEPATCHFILENAME
|
||||
#$PACKAGEPATCHNIGHTLYFILENAME
|
||||
)
|
||||
|
||||
# Asset packages are in root repo folder
|
||||
OLDPWD=$PWD; # [repo]/build
|
||||
cd ..;
|
||||
|
||||
for n in ${PACKAGEFILENAMES}; do
|
||||
for f in ./$n*; do
|
||||
# Binary builds also generate source builds, so exclude the source
|
||||
# builds if desired
|
||||
if [[ "$_DPL_PACKAGE_SOURCE" != "1" ]]; then
|
||||
if [[ "$f" == *"_source"* ]] || [[ "$f" == *".tar.xz"* ]]; then
|
||||
continue;
|
||||
fi;
|
||||
fi;
|
||||
curl --ftp-create-dirs -T "$f" -u $DPL_FTP_USER:$DPL_FTP_PASS "$__DPL_FTP_LOCATION/package/asset/$f";
|
||||
done;
|
||||
done;
|
||||
|
||||
# Go back to [repo]/build folder
|
||||
cd $OLDPWD;
|
||||
fi;
|
||||
else
|
||||
if [[ "$_DPL_BINARY" == "1" ]]; then
|
||||
find bin -type f -exec curl -u $DPL_FTP_USER:$DPL_FTP_PASS --ftp-create-dirs -T {} $__DPL_FTP_LOCATION/{} \;;
|
||||
fi;
|
||||
|
||||
if [[ "$_DPL_PACKAGE_BINARY" == "1" ]]; then
|
||||
sudo rm -r package/_CPack_Packages
|
||||
find package -type f -exec curl -u $DPL_FTP_USER:$DPL_FTP_PASS --ftp-create-dirs -T {} $__DPL_FTP_LOCATION/{} \;;
|
||||
fi;
|
||||
fi;
|
||||
fi
|
||||
@@ -0,0 +1,93 @@
|
||||
================================================================
|
||||
How to add Low-res modes to your XF86Config under Linux MANUALLY
|
||||
================================================================
|
||||
|
||||
I TAKE NO RESPONSIBILITY FOR ANY DAMAGE DONE TO YOUR EQUIPMENT!!!
|
||||
|
||||
This document explains how to add low-res modes like 320x200 to your
|
||||
X-Server configuration, because some new setup tools for the X-Server
|
||||
do not support this. ONLY RECOMMENDED FOR USERS WHO KNOW WHAT THEY DO!
|
||||
|
||||
I do not take any responsibility for damage done to your monitor, your
|
||||
videocard, your harddisk, your cat, your dog or anything else!!!
|
||||
IMPORTANT IS, THAT YOUR "HorizSync" AND "VertRefresh" VALUES REALLY
|
||||
MATCH YOUR MONITOR! OTHERWISE YOUR MONITOR CAN BLOW UP!!!
|
||||
|
||||
OK, if you have read up to here, you either know what you do or really
|
||||
die-hard want those low-res modes. Here is what to do:
|
||||
Look up your XF86Config. Is is either in /etc or in /etc/X11. Here is
|
||||
what you have to add to the definition of your modeslines:
|
||||
|
||||
# Low-res Doublescan modes
|
||||
# If your chipset does not support doublescan, you get a 'squashed'
|
||||
# resolution like 320x400.
|
||||
|
||||
# 320x200 @ 70 Hz, 31.5 kHz hsync, 8:5 aspect ratio
|
||||
Modeline "320x200" 12.588 320 336 384 400 200 204 205 225 Doublescan
|
||||
# 320x240 @ 60 Hz, 31.5 kHz hsync, 4:3 aspect ratio
|
||||
Modeline "320x240" 12.588 320 336 384 400 240 245 246 262 Doublescan
|
||||
# 320x240 @ 72 Hz, 36.5 kHz hsync
|
||||
Modeline "320x240" 15.750 320 336 384 400 240 244 246 262 Doublescan
|
||||
# 400x300 @ 56 Hz, 35.2 kHz hsync, 4:3 aspect ratio
|
||||
ModeLine "400x300" 18 400 416 448 512 300 301 302 312 Doublescan
|
||||
# 400x300 @ 60 Hz, 37.8 kHz hsync
|
||||
Modeline "400x300" 20 400 416 480 528 300 301 303 314 Doublescan
|
||||
# 400x300 @ 72 Hz, 48.0 kHz hsync
|
||||
Modeline "400x300" 25 400 424 488 520 300 319 322 333 Doublescan
|
||||
|
||||
If your video card only supports a specific set of discrete dotclocks
|
||||
(RAMDAC) you may have to replace the dotclocks given here by one of the
|
||||
specified (e.g in the first modeline the dotclock is 12.588 MHz). I believe
|
||||
that nowadays all cards and monitors should work with these settings, but
|
||||
if you have outdated hardware you better check the frequencies yourself. If
|
||||
there is any uncertainty, please check the "XFree86 Video Timings HOWTO".
|
||||
|
||||
|
||||
Then have a look at the section "Screen" with the appropriate driver
|
||||
(usually either "svga" or "accel"). Under Subsection "Display" there
|
||||
are modes for the given color depth. Add the desired modes. As an
|
||||
example I give you my screens definition here with low-res modes in
|
||||
16 bit color depth:
|
||||
|
||||
Section "Screen"
|
||||
Driver "accel"
|
||||
Device "3D Charger"
|
||||
Monitor "Iiyama Pro 450"
|
||||
DefaultColorDepth 16
|
||||
|
||||
Subsection "Display"
|
||||
Depth 8
|
||||
Modes "1280x1024" "1024x768" "800x600" "640x480"
|
||||
ViewPort 0 0
|
||||
Virtual 1280 1024
|
||||
EndSubsection
|
||||
Subsection "Display"
|
||||
Depth 16
|
||||
Modes "1152x864" "1024x768" "800x600" "640x480" "400x300" "320x200" <- THIS IS ACTUALLY WHAT YOU WANT!!!
|
||||
ViewPort 0 0 ^^^^^^^^^^^^^^^^^^^
|
||||
Virtual 1152 864
|
||||
EndSubsection
|
||||
Subsection "Display"
|
||||
Depth 24
|
||||
Modes "800x600" "640x480"
|
||||
ViewPort 0 0
|
||||
Virtual 800 600
|
||||
EndSubsection
|
||||
Subsection "Display"
|
||||
Depth 32
|
||||
Modes "800x600" "640x480"
|
||||
ViewPort 0 0
|
||||
Virtual 800 600
|
||||
EndSubsection
|
||||
EndSection
|
||||
|
||||
Once again: important is, that you edit the correct Screen section.
|
||||
If you use the SVGA Server and edit the ACCEL Server, you might
|
||||
wonder where your new modes have gone.
|
||||
|
||||
If everything went fine and you want to say thank you, just write
|
||||
to "metzgermeister@users.sourceforge.net". If your monitor blew
|
||||
up and you want to kill me, find me playing Legacy or Q3A on the net
|
||||
and frag me (with your second monitor, hehe).
|
||||
|
||||
- metzgermeister
|
||||
@@ -0,0 +1,212 @@
|
||||
1-99 : Player Starts
|
||||
1 - Player 1 Start 1
|
||||
2 - Player 2 Start 2
|
||||
3 - Player 3 Start 3
|
||||
4 - Player 4 Start 4
|
||||
5 - Player 5 Start 4001
|
||||
6 - Player 6 Start 4002
|
||||
7 - Player 7 Start 4003
|
||||
8 - Player 8 Start 4004
|
||||
9 - Player 9 Start 4005
|
||||
10 - Player 10 Start 4006
|
||||
11 - Player 11 Start 4007
|
||||
12 - Player 12 Start 4008
|
||||
13 - Player 13 Start 4009
|
||||
14 - Player 14 Start 4010
|
||||
15 - Player 15 Start 4011
|
||||
16 - Player 16 Start 4012
|
||||
17 - Player 17 Start 4013
|
||||
18 - Player 18 Start 4014
|
||||
19 - Player 19 Start 4015
|
||||
20 - Player 20 Start 4016
|
||||
21 - Player 21 Start 4017
|
||||
22 - Player 22 Start 4018
|
||||
23 - Player 23 Start 4019
|
||||
24 - Player 24 Start 4020
|
||||
25 - Player 25 Start 4021
|
||||
26 - Player 26 Start 4022
|
||||
27 - Player 27 Start 4023
|
||||
28 - Player 28 Start 4024
|
||||
29 - Player 29 Start 4025
|
||||
30 - Player 30 Start 4026
|
||||
31 - Player 31 Start 4027
|
||||
32 - Player 32 Start 4028
|
||||
33 - Player Match Start 11
|
||||
34 - Red Team Start 87
|
||||
35 - Blue Team Start 89
|
||||
36 - Tag start New
|
||||
|
||||
100 - 199 : Enemies
|
||||
100 - Blue Crawla 3004
|
||||
101 - Red Crawla 9
|
||||
102 - GFZ Fish 58
|
||||
103 - Gold Buzz 5005
|
||||
104 - Red Buzz 5006
|
||||
105 - Jetty-Syn Bomber 3005
|
||||
106 - Jetty-Syn Gunner 22
|
||||
107 - Crawla Commander 21
|
||||
108 - Deton 71
|
||||
109 - Skim 56
|
||||
110 - THZ Turret 2004
|
||||
111 - Pop-up Turret 42
|
||||
|
||||
200 - 299 : Bosses and their associated items (if any)
|
||||
200 - Boss 1 16
|
||||
201 - Boss 2 2008
|
||||
290 - Boss Fly Point 17
|
||||
291 - EggTrap Center 2049
|
||||
|
||||
300 - 399 : Collectibles
|
||||
300 - Ring 2014
|
||||
301 - Homing Ring 69
|
||||
302 - Rail Ring 3003
|
||||
303 - Infinity Ring 80
|
||||
304 - Automatic Ring 26
|
||||
305 - Explosion Ring 54
|
||||
306 - Red CTF Flag 31
|
||||
307 - Blue CTF Flag 34
|
||||
308 - Special Stage Token 2013
|
||||
309 - Emerald 1 420
|
||||
310 - Emerald 2 421
|
||||
311 - Emerald 3 422
|
||||
312 - Emerald 4 423
|
||||
313 - Emerald 5 424
|
||||
314 - Emerald 6 425
|
||||
315 - Emerald 7 426
|
||||
316 - Hunting Emerald 1 64
|
||||
317 - Hunting Emerald 2 3002
|
||||
318 - Hunting Emerald 3 3001
|
||||
|
||||
400 - 499 : Boxes
|
||||
400 - Super Ring Box 2011
|
||||
401 - Grey Ring Box 2012
|
||||
402 - Ring Shield Box 48
|
||||
403 - Fire Shield Box 2002
|
||||
404 - Bomb Shield Box 2018
|
||||
405 - Jump Shield Box 35
|
||||
406 - Water Shield Box 2028
|
||||
407 - Sneaker Box 25
|
||||
408 - Invincibility Box 2022
|
||||
409 - 1-Up Box 41
|
||||
410 - Eggman Box 2005
|
||||
411 - Mixup Box 78
|
||||
412 - Question Box 3000
|
||||
|
||||
500 - 599 : Interactive Objects (friendly or otherwise - includes springs)
|
||||
500 - Bubble Patch 33
|
||||
501 - Level End Sign 86
|
||||
502 - Starpost 3006
|
||||
520 - Spike Ball -1
|
||||
521 - Special Stage Spike Ball 23
|
||||
522 - Ceiling Spike 67
|
||||
523 - Floor Spike 68
|
||||
540 - Fan 32
|
||||
541 - Steam Riser 30
|
||||
550 - Yellow Spring 28
|
||||
551 - Red Spring 79
|
||||
552 - Blue Spring 5004
|
||||
553 - Yellow Spring Down 65
|
||||
554 - Red Spring Down 66
|
||||
555 - Yellow Diagonal Spring 2015
|
||||
556 - Red Diagonal Spring 38
|
||||
557 - Yellow Diag Spring Down 20
|
||||
558 - Red Diag Spring Down 39
|
||||
|
||||
600 - 699 : Special placement patterns
|
||||
600 - Vertical Rigns - Stack of 5 (suitable for Yellow Spring) 84
|
||||
601 - Vertical Rings - Stack of 5 (suitable for Red Spring) 44
|
||||
602 - Diagonal rings (5) 76
|
||||
603 - Diagonal rings (10) 77
|
||||
604 - A ring of rings 47
|
||||
605 - A BIGGER ring of rings 2007
|
||||
606 - A ring of wing items 2048
|
||||
607 - A BIGGER ring of wing items 2010
|
||||
608 - A ring of rings and wings (alternating) 2046
|
||||
609 - A BIGGER ring of rings and wings (alternating) 2047
|
||||
|
||||
700 - 799 : Powerup indicators/environmental effects/miscellany
|
||||
700 - Ambient Water 1a (S) 2026
|
||||
701 - Ambient Water 1b (S) 2024
|
||||
702 - Ambient Water 2a (M) 2023
|
||||
703 - Ambient Water 2b (M) 2045
|
||||
704 - Ambient Water 3a (L) 83
|
||||
705 - Ambient Water 3b (L) 2019
|
||||
706 - Ambient Water 4a (XL) 2025
|
||||
707 - Ambient Water 4b (XL) 27
|
||||
708 - Random Ambient 1 14
|
||||
709 - Random Ambient 2 43
|
||||
750 - Chaos Spawner 8
|
||||
751 - Teleport Point 5003
|
||||
752 - Alternate View Point 5007
|
||||
753 - Zoom Tube Waypoint 18
|
||||
754 - Pusher 5001
|
||||
755 - Puller 5002
|
||||
756 - Street Light 2003
|
||||
|
||||
800 - 899 : Greenflower Scenery
|
||||
800 - Flower 1 36
|
||||
801 - Flower 2 70
|
||||
802 - Flower 3 73
|
||||
804 - Berry Bush 74
|
||||
805 - Bush 75
|
||||
|
||||
900 - 999 : Techno Hill Scenery
|
||||
900 - THZ Plant 2035
|
||||
901 - Alarm 2006
|
||||
|
||||
1000 - 1099 : Deep Sea Scenery
|
||||
1000 - Gargoyle 81
|
||||
|
||||
1100 - 1199 : Castle Eggman Scenery
|
||||
1100 - Ceiling Chain 49
|
||||
1101 - Torch Flame 24
|
||||
1102 - Eggman Statue 52
|
||||
1103 - CEZ Flower 2001
|
||||
|
||||
1200 - 1299 : Arid Canyon Scenery
|
||||
1300 - 1399 : Red Volcano Scenery
|
||||
1400 - 1499 : Dark City Scenery
|
||||
1500 - 1599 : Doom Ship Scenery
|
||||
1600 - 1699 : Egg Rock/Final Fight Scenery
|
||||
1700 - 1799 : NiGHTS Items
|
||||
1700 - Axis 72
|
||||
1701 - Axis Transfer (Normal) 61
|
||||
1702 - Axis Transfer (Line) 46
|
||||
1703 - Nights Drone 60
|
||||
1704 - Nights Bumper 82
|
||||
1705 - Hoop 57
|
||||
1706 - Nights Wing 37
|
||||
1707 - Super Loop Powerup 3007
|
||||
1708 - Drill Refill Powerup 3008
|
||||
1709 - Helper Powerup 3009
|
||||
1710 - Egg Capsule 40
|
||||
|
||||
1800 - 1849 : Mario Items
|
||||
1800 - Coin 10005
|
||||
1801 - Goomba 10000
|
||||
1802 - Blue Goomba 10001
|
||||
1803 - FireFlower 50
|
||||
1804 - Shell 10
|
||||
1805 - Puma 29
|
||||
1806 - Koopa 19
|
||||
1807 - Axe 12
|
||||
1808 - Mario Bush 1 10002
|
||||
1809 - Mario Bush 2 10003
|
||||
1810 - Toad 10004
|
||||
|
||||
1850 - 1899 : Christmas Items
|
||||
1850 - Xmas Pole 5
|
||||
1851 - Candy Cane 13
|
||||
1852 - Snowman 6
|
||||
|
||||
1900 - 1999 : Misc Scenery
|
||||
1900 - Stalagmite 0
|
||||
1901 - Stalagmite 1
|
||||
1902 - Stalagmite 2
|
||||
1903 - Stalagmite 3
|
||||
1904 - Stalagmite 4
|
||||
1905 - Stalagmite 5
|
||||
1906 - Stalagmite 6
|
||||
1907 - Stalagmite 7
|
||||
1908 - Stalagmite 8
|
||||
1909 - Stalagmite 9
|
||||
@@ -0,0 +1,223 @@
|
||||
Description OldNum NewNum Description
|
||||
Old Water 14 Removed
|
||||
|
||||
Level Parameters/Misc:
|
||||
Per-Sector Gravity 64 1
|
||||
Custom Exit 71 2
|
||||
Zoom Tube Parameters 18 3
|
||||
Speed Pad 65 4
|
||||
Camera Scanner 63 5
|
||||
Disable Linedef 73 6
|
||||
Flat Alignment 66 7
|
||||
Sector Special Parameters New 8
|
||||
Mace Parameters New 9
|
||||
Sprite Cull Height New 10
|
||||
Rope Hang Parameters New 11
|
||||
Rock Spawner Parameters New 12
|
||||
|
||||
PolyObjects
|
||||
Marks first line in PolyObject New 20
|
||||
Explicitly includes a PolyObject line New 21
|
||||
PolyObject: Parameters New 22
|
||||
PolyObject: Waving Flag New 31
|
||||
|
||||
Level-Load Effects:
|
||||
Instant Floor Lower 26 50
|
||||
Instant Ceiling Raise 24 51
|
||||
Continuously Falling Sector 88 52
|
||||
Continuous Floor/Ceiling Mover 2 53
|
||||
Continuous Floor Mover 3 54
|
||||
Continuous Ceiling Mover 4 55
|
||||
Continuous Two-Speed Floor/Ceiling Mover 6 56
|
||||
Continuous Two-Speed Floor Mover 7 57
|
||||
Continuous Two-Speed Ceiling Mover 8 58
|
||||
Activate Floating Platform 232 59
|
||||
Activate Floating Platform (Adjustable Speed) 233 60
|
||||
Crusher 1 (Ceiling to Floor) 43 61
|
||||
Crusher 2 (Floor to Ceiling) 50 62
|
||||
Fake Floor/Ceiling 242 63
|
||||
Appearing/Disappearing FOF New 64
|
||||
Bridge Thinker New 65
|
||||
|
||||
Floor Over Floors:
|
||||
"Floor Over Floor: Solid, Opaque, Shadowcasting " 25 100
|
||||
"Floor Over Floor: Solid, Opaque, Non-Shadowcasting " 33 101
|
||||
"Floor Over Floor: Solid, Translucent " 44 102
|
||||
"Floor Over Floor: Solid, Sides Only " 69 103
|
||||
"Floor Over Floor: Solid, No Sides " 51 104
|
||||
"Floor Over Floor: Solid, Invisible " 57 105
|
||||
|
||||
"Floor Over Floor: Water, Opaque " 48 120
|
||||
"Floor Over Floor: Water, Translucent " 45 121
|
||||
"Floor Over Floor: Water, Opaque, No Sides " 75 122
|
||||
"Floor Over Floor: Water, Translucent, No Sides " 74 123
|
||||
|
||||
"Floor Over Floor: Platform, Opaque " 59 140
|
||||
"Floor Over Floor: Platform, Translucent " 81 141
|
||||
"Floor Over Floor: Platform, Translucent, No Sides " 77 142
|
||||
|
||||
Floor Over Floor: Bobbing (Air) 38 150
|
||||
Floor Over Floor: Adjustable Bobbing (Air) 68 151
|
||||
Floor Over Floor: Reverse Adjustable Bobbing (Air) 72 152
|
||||
|
||||
"Floor Over Floor: Floating, Bobbing " 34 160
|
||||
|
||||
Floor Over Floor: Crumbling (Respawn) 36 170
|
||||
Floor Over Floor: Crumbling (No Respawn) 35 171
|
||||
"Floor Over Floor: Crumbling (Respawn), Platform " 79 172
|
||||
"Floor Over Floor: Crumbling (No Respawn), Platform " 80 173
|
||||
"Floor Over Floor: Crumbling (Respawn), Platform, Translucent " 82 174
|
||||
"Floor Over Floor: Crumbling (No Respawn), Platform, Translucent " 83 175
|
||||
"Floor Over Floor: Crumbling (Respawn), Floating, Bobbing " 39 176
|
||||
"Floor Over Floor: Crumbling (No Respawn), Floating, Bobbing " 1 177
|
||||
"Floor Over Floor: Crumbling (Respawn), Floating " 37 178
|
||||
"Floor Over Floor: Crumbling (No Respawn), Floating " 42 179
|
||||
"Floor Over Floor: Crumbling (Respawn), Bobbing (Air) " 40 180
|
||||
|
||||
"Floor Over Floor: Rising Platform, Solid, Opaque, Shadowcasting " 89 190
|
||||
"Floor Over Floor: Rising Platform, Solid, Opaque, Non-Shadowcasting " 90 191
|
||||
"Floor Over Floor: Rising Platform, Solid, Translucent " 91 192
|
||||
"Floor Over Floor: Rising Platform, Solid, Invisible " 94 193
|
||||
"Floor Over Floor: Rising Platform, Platform, Opaque " 92 194
|
||||
"Floor Over Floor: Rising Platform, Platform, Translucent " 93 195
|
||||
|
||||
Floor Over Floor: Light Block 49 200
|
||||
Floor Over Floor: Half Light Block 47 201
|
||||
Floor Over Floor: Fog Block 46 202
|
||||
|
||||
"Floor Over Floor: Intangible, Opaque " 62 220
|
||||
"Floor Over Floor: Intangible, Translucent " 52 221
|
||||
"Floor Over Floor: Intangible, Sides Only " 67 222
|
||||
"Floor Over Floor: Intangible, Invisible " 58 223
|
||||
|
||||
Floor Over Floor: Mario Block 41 250
|
||||
Floor Over Floor: Thwomp Block 54 251
|
||||
Floor Over Floor: Shatter Block 76 252
|
||||
"Floor Over Floor: Shatter Block, Translucent " 86 253
|
||||
Floor Over Floor: Bustable Block 55 254
|
||||
Floor Over Floor: Spin Bust Block 78 255
|
||||
"Floor Over Floor: Spin Bust Block, Translucent " 84 256
|
||||
Floor Over Floor: Quicksand Block 56 257
|
||||
Floor Over Floor: Laser Block 53 258
|
||||
Floor Over Floor: Custom 87 259
|
||||
|
||||
Linedef Executor Triggers:
|
||||
Trigger Linedef Executor (Continuous) 96 300
|
||||
Trigger Linedef Executor (Each Time) 97 301
|
||||
Trigger Linedef Executor (Once) 98 302
|
||||
Trigger Linedef Executor (Ring Count - Continuous) 95 303
|
||||
Trigger Linedef Executor (Ring Count - Once) 99 304
|
||||
Trigger Linedef Executor (Character Ability - Continuous) 19 305
|
||||
Trigger Linedef Executor (Character Ability - Each Time) 20 306
|
||||
Trigger Linedef Executor (Character Ability - Once) 21 307
|
||||
"Trigger Linedef Executor (Race Only, Once) " 9 308
|
||||
Trigger Linedef Executor (CTF Red Team - Continuous) 10 309
|
||||
Trigger Linedef Executor (CTF Red Team - Each Time) 11 310
|
||||
Trigger Linedef Executor (CTF Blue Team - Continuous) 12 311
|
||||
Trigger Linedef Executor (CTF Blue Team - Each Time) 13 312
|
||||
Trigger Linedef Executor (No More Enemies - Once) 15 313
|
||||
Trigger Linedef Executor (# of Pushables - Continuous) New 314
|
||||
Trigger Linedef Executor (# of Pushables - Once) New 315
|
||||
Trigger Linedef Executors (PolyObject - Land On) New 316
|
||||
Trigger Linedef Executor (Level Load) New 399
|
||||
|
||||
Linedef Executor Options:
|
||||
Linedef Executor: Set Tagged Sector's Floor Height/Pic 101 400
|
||||
Linedef Executor: Set Tagged Sector's Ceiling Height/Pic 102 401
|
||||
Linedef Executor: Set Tagged Sector's Light Level 103 402
|
||||
Linedef Executor: Move Tagged Sector's Floor 106 403
|
||||
Linedef Executor: Move Tagged Sector's Ceiling 107 404
|
||||
Linedef Executor: Lower Floor by Line 108 405
|
||||
Linedef Executor: Raise Floor by Line 109 406
|
||||
Linedef Executor: Lower Ceiling by Line 110 407
|
||||
Linedef Executor: Raise Ceiling by Line 111 408
|
||||
Linedef Executor: Change Calling Sector's Tag 112 409
|
||||
Linedef Executor: Change Front Sector's Tag 114 410
|
||||
Linedef Executor: Stop Plane Movement 116 411
|
||||
Linedef Executor: Teleport Player to Tagged Sector 104 412
|
||||
Linedef Executor: Change Music 105 413
|
||||
Linedef Executor: Play SFX 115 414
|
||||
Linedef Executor: Run Script 113 415
|
||||
Linedef Executor: Start Adjustable Fire Flicker 119 416
|
||||
Linedef Executor: Start Adjustable Glowing Light 120 417
|
||||
Linedef Executor: Start Adjustable Strobe Flash (unsynchronized) New 418
|
||||
Linedef Executor: Start Adjustable Strobe Flash (synchronized) New 419
|
||||
Linedef Executor: Fade Light Level 117 420
|
||||
Linedef Executor: Stop Lighting Effect 118 421
|
||||
Linedef Executor: Cut-Away View 121 422
|
||||
Linedef Executor: Change Sky 123 423
|
||||
Linedef Executor: Change Weather 124 424
|
||||
Linedef Executor: Change Object State 125 425
|
||||
Linedef Executor: Stop Object 122 426
|
||||
Linedef Executor: Award Score 126 427
|
||||
Linedef Executor: Start Platform Movement 127 428
|
||||
Linedef Executor: Crush Ceiling Once New 429
|
||||
Linedef Executor: Crush Floor Once New 430
|
||||
Linedef Executor: Crush Floor & Ceiling Once New 431
|
||||
Linedef Executor: Enable 2D Mode New 432
|
||||
Linedef Executor: Disable 2D Mode New 433
|
||||
Linedef Executor: Award Custom Power New 434
|
||||
Linedef Executor: Stop Conveyor New 435
|
||||
Linedef Executor: Start Conveyor New 436
|
||||
Linedef Executor: Disable Player Movement New 437
|
||||
|
||||
Linedef Executor: Execute Linedef Executor New 450
|
||||
|
||||
Linedef Executor: PolyObject: Door Slide New 480
|
||||
Linedef Executor: PolyObject: Door Swing New 481
|
||||
Linedef Executor: PolyObject: Move XY New 482
|
||||
Linedef Executor: PolyObject: Move XY w/ override New 483
|
||||
Linedef Executor: PolyObject: Rotate Right New 484
|
||||
Linedef Executor: PolyObject: Rotate Right w/ override New 485
|
||||
Linedef Executor: PolyObject: Rotate Left New 486
|
||||
Linedef Executor: PolyObject: Rotate Left w/ override New 487
|
||||
Linedef Executor: PolyObject: Start waypoint movement New 488
|
||||
Linedef Executor: PolyObject: Make Invisible New 489
|
||||
Linedef Executor: PolyObject: Make Visible New 490
|
||||
|
||||
Scrollers/Pushers:
|
||||
Scroll Wall First Side Left 100 500
|
||||
Scroll Wall First Side Opposite Direction 85 501
|
||||
Scroll Wall According to Linedef 254 502
|
||||
Acc Scroll Wall According to Linedef 218 503
|
||||
Disp Scroll Wall According to Linedef 249 504
|
||||
Scroll Texture by Offsets 255 505
|
||||
|
||||
Scroll Floor Texture 251 510
|
||||
Acc Scroll Floor Texture 215 511
|
||||
Disp Scroll Floor Texture 246 512
|
||||
Scroll Ceiling Texture 250 513
|
||||
Acc Scroll Ceiling Texture 214 514
|
||||
Disp Scroll Ceiling Texture 245 515
|
||||
|
||||
Carry Objects on Floor (no scroll) 252 520
|
||||
Acc Carry Objects on Floor 216 521
|
||||
Disp Carry Objects on Floor 247 522
|
||||
Carry Objects on Ceiling 203 523
|
||||
Acc Carry Objects on Ceiling 205 524
|
||||
Disp Carry Objects on Ceiling 201 525
|
||||
|
||||
Scroll Floor Texture and Carry Objects 253 530
|
||||
Acc Scroll Floor Texture and Carry Objects 217 531
|
||||
Disp Scroll Floor Texture and Carry Objects 248 532
|
||||
Scroll Ceiling Texture and Carry Objects 202 533
|
||||
Acc Scroll Ceiling Texture and Carry Objects 204 534
|
||||
Disp Scroll Ceiling Texture and Carry Objects 200 535
|
||||
|
||||
Friction 223 540
|
||||
Horizontal Wind 224 541
|
||||
Upwards Wind 229 542
|
||||
Downwards Wind 230 543
|
||||
Horizontal Current 225 544
|
||||
Upwards Current 227 545
|
||||
Downwards Current 228 546
|
||||
Boom Push/Pull Thing 226 547
|
||||
|
||||
Lighting:
|
||||
Floor Lighting 213 600
|
||||
Ceiling Lighting 5 601
|
||||
Adjustable Pulsating Light 60 602
|
||||
Adjustable Flickering Light 61 603
|
||||
Adjustable Blinking Light (unsynchronized) New 604
|
||||
Adjustable Blinking Light (synchronized) New 605
|
||||
Colormap 16 606
|
||||
Binary file not shown.
@@ -0,0 +1,78 @@
|
||||
Removed:
|
||||
- Buttons 1-20 690-709
|
||||
- Button 21 (THZ2 A/740 B/741 D/742 E/745 710
|
||||
- Close Door Blazing (Tag 743) 711
|
||||
- Raise Ceiling to Highest (Tag 744) 981
|
||||
- THZ2 Slime Raise (B/712 W713 P714 D715 S716) 986
|
||||
|
||||
Stuff to Remove/Change:
|
||||
- Light Blinks On Every 0.5 Seconds 2 Add Linedef Combine
|
||||
- Light Blinks On Every 1 Second 3 Add Linedef Combine
|
||||
- Light Pulses Smoothly 8 Remove
|
||||
- Light Blinks On Every 0.5 Seconds (Sync) 12 Add Linedef Combine
|
||||
- Lights Blinks On Every 1 Second (Sync) 13 Add Linedef Combine
|
||||
- Light Flickers Like Fire 17 Remove
|
||||
? - Damage (Fire) and Current 519 Remove (convert to combination)
|
||||
? - Damage (Water) and Current 984 Remove (convert to combination)
|
||||
|
||||
Section 1:
|
||||
1 - Damage (Generic) 11
|
||||
2 - Damage (Water) 983
|
||||
3 - Damage (Fire) 7
|
||||
4 - Damage (Electrical) 18
|
||||
5 - Spikes 4
|
||||
6 - Death Pit (Camera Mod) 16
|
||||
7 - Death Pit (No Camera Mod) 5
|
||||
8 - Instant Kill 10
|
||||
9 - Ring Drainer (Floor Touch) 978
|
||||
10 - Ring Drainer (No Floor Touch) 980
|
||||
11 - Special Stage Damage 9
|
||||
12 - Space Countdown 6
|
||||
13 - Ramp Sector (Increase step-up) 992
|
||||
14 - Non-Ramp Sector (Don't step-down) 996
|
||||
15 - Bouncy Sector (FOF Control Only) 14
|
||||
|
||||
Section 2: << 4
|
||||
1 - Trigger Linedef Exec (Pushable Objects) 971
|
||||
2 - Trigger LD Exec (Anywhere in Sec/All Pls) 972
|
||||
3 - Trigger Linedef Exec (Floor Touch/All Pls) 973
|
||||
4 - Trigger Linedef Exec (Anywhere in Sec) 974
|
||||
5 - Trigger Linedef Exec (Floor Touch) 975
|
||||
6 - Trigger Linedef Exec (Emerald Check) 967
|
||||
7 - Trigger Linedef Exec (NiGHTS Mare) 968
|
||||
8 - Check for linedef executor on FOFs (ANY) 970
|
||||
9 - Egg Trap Capsule 666
|
||||
10 - Special Stage Time/Rings, Par 990
|
||||
11 - Custom Global Gravity 991
|
||||
|
||||
Section 3: << 8
|
||||
1 - Ice/Sludge (required?!) 256
|
||||
2 - Wind/Current (required?!) 512
|
||||
3 - Ice/Sludge and Wind/Current 768
|
||||
4 - Conveyor Belt 985
|
||||
5 - Speed Pad (No Spin) 976
|
||||
6 - Speed Pad (Spin) 977
|
||||
7 - Bustable Block Sprite Parameter 1500-1515
|
||||
8 - "
|
||||
9 - "
|
||||
10 - "
|
||||
11 - "
|
||||
12 - "
|
||||
13 - "
|
||||
14 - "
|
||||
15 - "
|
||||
|
||||
Section 4: << 12
|
||||
1 - Starpost Activator 993
|
||||
2 - Special Stage Goal Combine 33
|
||||
2 - Exit Sector Combine 982
|
||||
2 - No Tag Zone Combine 987
|
||||
2 - CTF: Flag Return Combine 995
|
||||
3 - CTF: Red Team Base 988
|
||||
4 - CTF: Blue Team Base 989
|
||||
5 - Fan Sector 997
|
||||
6 - Super Sonic Transform 969
|
||||
7 - Spinner 979
|
||||
8 - Zoom Tube Start 998
|
||||
9 - Zoom Tube End 999
|
||||
10 - Finish Line 994
|
||||
+307
@@ -0,0 +1,307 @@
|
||||
SRB2
|
||||
Release v1.09, ? 2005.
|
||||
|
||||
Last Updated: June 2005
|
||||
|
||||
Original game & sources by: Id Software.
|
||||
Additions: (c)1998 by: Fabrice Denis & Boris Pereira
|
||||
(c)1999 by: Fabrice Denis, Boris Pereira & Thierry Van Elsuwe
|
||||
(c)2000 by: Boris Pereira & Thierry Van Elsuwe
|
||||
(c)2004 By: AJ, Graue, Alam Arias, Logan Arias & Andrew Clunis
|
||||
|
||||
Special thanks to Steven McGranahan, Lee Killough, Robert Bäuml and Bell Kin for
|
||||
their large contribution and to other DooM LEGACY & SRB2 Team members.
|
||||
|
||||
Web site: http://www.SRB2.org/
|
||||
e-mail: none@none.com
|
||||
|
||||
OpenGL specific:
|
||||
Web site: http://legacy.newdoom.com/gl
|
||||
|
||||
|
||||
-----------------------------------------------------------------------
|
||||
F.A.Q.
|
||||
-----------------------------------------------------------------------
|
||||
|
||||
|
||||
If you have any trouble with SRB2, you might find a solution
|
||||
here.
|
||||
|
||||
If you find a solution to a problem that was not listed here,
|
||||
please tell us so that we can update the FAQ and help other people!
|
||||
|
||||
Mail your hardware/software problems to:
|
||||
|
||||
None@none.com subject: FAQ
|
||||
|
||||
|
||||
--------
|
||||
CONTENTS
|
||||
--------
|
||||
|
||||
[0] Miscellaneous
|
||||
[1] Mouse/Joystick/Keyboard
|
||||
[2] Video
|
||||
[3] Sound
|
||||
[4] Network
|
||||
[5] Troubleshooting
|
||||
|
||||
|
||||
-----------------
|
||||
[0] MISCELLANEOUS
|
||||
-----------------
|
||||
|
||||
* under win95 or OS/2, I don't have enough memory. How can i handle with ?
|
||||
|
||||
Tell win95 to put more dpmi memory for your dos box.
|
||||
Or use the -mb option.
|
||||
|
||||
|
||||
|
||||
---------------------------
|
||||
[1] MOUSE/JOYSTICK/KEYBOARD
|
||||
---------------------------
|
||||
|
||||
* My mouse/joystick does not work in SRB2.
|
||||
|
||||
First, check that the mouse/joystick is activated : go at the
|
||||
console and type either 'use_mouse' (or use the respective
|
||||
menuitem) or 'use_joystick'.
|
||||
|
||||
If it tells '0' or off than the mouse/joystick is not used,
|
||||
set the variable to 1. eg: 'use_mouse 1'.
|
||||
|
||||
For the joystick, different values will support different
|
||||
types of joystick, check the console documentation for the
|
||||
command 'use_joystick' for more.
|
||||
|
||||
Even if the mouse or joystick is activated, you have to
|
||||
set up the contols into the Setup Controls menu. That is:
|
||||
tell what use you will make of the mouse/joystick buttons.
|
||||
|
||||
|
||||
---------
|
||||
[2] VIDEO
|
||||
---------
|
||||
|
||||
|
||||
* Where are the other video modes ? I have only '320x200' in the
|
||||
Video Modes menu.
|
||||
|
||||
DOS
|
||||
---
|
||||
|
||||
SRB2 adds new video modes only if a VESA2 (or better) driver
|
||||
is present. The VESA2 driver is a standard of 'talking' between a
|
||||
program and the huge amount of different graphics cards
|
||||
available today.
|
||||
|
||||
If you don't have a VESA2 driver, you can download UNIVBE, or
|
||||
SMART DISPLAY DOCTOR from
|
||||
|
||||
http://www.scitechsoft.com/products/ent/free_titles.html
|
||||
|
||||
or if you have an S3 based card, you can download the free
|
||||
software called 'S3VBE'.
|
||||
|
||||
ftp://ftp.externet.hu/pub/mirror/sac/graph/s3vbe318.zip
|
||||
ftp://ftp.digsys.bg/pub/simtelnet/msdos/graphics/s3vbe318.zip
|
||||
http://www.filesearching.com/cgi-bin/s?q=s3vbe318.zip
|
||||
http://www.google.com/search?q=s3vbe318.zip
|
||||
|
||||
* The game doesn't restore the video mode I have chosen the last time
|
||||
I played SRB2.
|
||||
|
||||
The current video mode has to be made the 'default' so that it is
|
||||
saved to the config : press the key 'D' on the Video Options menu
|
||||
to set the current video mode the default.
|
||||
|
||||
* I have some problems with OpenGL mode
|
||||
|
||||
Have a look at the FAQ for OpenGL on the glLegacy web site:
|
||||
|
||||
http://www.doomnation.com/gllegacy/faqe.htm
|
||||
|
||||
# Linux: I only have a 1024x768 (or 800x600, 1280x1024, ...) resolution
|
||||
in fullscreen mode under X and SRB2 is really really slow. Can I
|
||||
have lower resolutions like 320x200 in fullscreen mode as well?
|
||||
|
||||
Probably yes. SRB2 can only use the resolutions offered by the
|
||||
X-Server. So if all fullscreen modes have a very high resolution you
|
||||
have to modify /etc/XF86Config (or /etc/X11/XF86Config). Use XF86Setup
|
||||
(or the appropriate tool coming with your distribution - sax,
|
||||
xf86config, ...) to do this.
|
||||
If you do not succeed there, you can enter them manually into your
|
||||
XF86Config file. ONLY RECOMMENDED FOR USERS WHO KNOW WHAT THEY DO!
|
||||
For a short guide on how to do this, have a look at the file
|
||||
"Doublescan.txt".
|
||||
In case of doubt consult the XFree86-HOWTO (or ask your system
|
||||
administrator :).
|
||||
|
||||
# Linux: I cannot have any fullscreen modes at all!
|
||||
|
||||
You have only modes above 1024x768 in your XF86Config. Proceed as
|
||||
described above.
|
||||
|
||||
# Linux: After a certain idle time my screensaver jams the display of
|
||||
SRB2. I can still operate SRB2, but I do not see what's happening
|
||||
and the screensaver won't go away.
|
||||
|
||||
You probably have KDE. The KDE screensaver does not obey the screensaver
|
||||
rules (at least mine, version 1.1). The solution is to deactivate the
|
||||
KDE screensaver and use another screensaver (like the xscreensaver,
|
||||
e.g.). But the hell, when you started SRB2 you should have played it
|
||||
as well and not left it alone!!!
|
||||
|
||||
---------
|
||||
[3] SOUND
|
||||
---------
|
||||
|
||||
+ DOS:I can't have CD audio music, why ?
|
||||
|
||||
Make sure that the MSCDEX driver version 2.0 or later is loaded.
|
||||
If it says 'MSCDEX version xxx' at game startup, and you still
|
||||
don't hear the cd music, then probably your card doesn't respond
|
||||
when SRB2 tries to set the cd volume. If so, make sure your sound
|
||||
card's mixer have the cd volume set up so that you can hear something.
|
||||
|
||||
+ When the CD plays, the game is very 'jerky'. It doesn't do that when
|
||||
I type 'cd off' in the console.
|
||||
|
||||
You have an old/bad cd driver, that can take up to a second to
|
||||
respond to cd driver commands. Either get the latest version of
|
||||
your driver, or turn cd update off. Check 'cd_udpate' in the
|
||||
console documentation for more.
|
||||
|
||||
* DOS:How can I *ALWAYS* disable the sounds or music of the game ?
|
||||
|
||||
Edit the allegro.cfg file and set digicard/midicard to 0 (none)
|
||||
|
||||
* DOS:My sterero sound is reversed, how can I set it the right way ?
|
||||
|
||||
Change the console variable 'stereoreverse' to either 1 or 0.
|
||||
Or, you can edit the allegro.cfg file, and set the 'flip_pan' variable.
|
||||
|
||||
|
||||
* DOS:The sounds are too 'slow', or 'low-pitched'
|
||||
|
||||
It seems to be a problem of the auto-detection of some 8bit sound
|
||||
cards. You will have to set manually the 'sb_freq' value in the
|
||||
allegro.cfg file to a lower value : 11906, 16129.
|
||||
|
||||
* DOS:SRB2 doesn't play any sound/music, but I have a sound
|
||||
blaster genuine/compatible card.
|
||||
|
||||
If you have a genuine or compatible SoundBlaster card, it is very
|
||||
important that you set the BLASTER environment variable.
|
||||
|
||||
If you are playing under DOS, and never installed your sound card
|
||||
under DOS, run the setup of your sound card for DOS.
|
||||
|
||||
Check if the BLASTER variable was set: type 'SET' under dos
|
||||
(or DOSbox)
|
||||
|
||||
Do you see something like 'BLASTER=A220 I5 D1 ...' ?
|
||||
|
||||
Yes? If you don't hear sounds/music, then tweak the settings in the
|
||||
allegro.cfg file until you get something, first try changing the
|
||||
type of the sound card, it is not always properly detected.
|
||||
|
||||
No? You have to set this variable in order that your sound card is
|
||||
detected. Run the setup that was shipped with your sound card, and
|
||||
make sure you run the setup for DOS too, it will usually add a
|
||||
line of the type 'SET BLASTER=... ...' in the autoexec.bat file.
|
||||
|
||||
|
||||
* DOS:How can I have better midi music on my 8bit sound card ?
|
||||
|
||||
Use the DIGMID driver, it is supported in SRB2.
|
||||
|
||||
What the hell is this? Well, the Gravis Ultrasound uses digital
|
||||
samples to play midi music. On a simple 8bit card, you can use digital
|
||||
samples too, which will sound usually better than what is output
|
||||
by the poor fm synthesis chip of 8bit cards.
|
||||
|
||||
You will need to get a Gravis Ultrasound patch set, you can find
|
||||
several ones for free on internet, it consists of a bunch of '.pat'
|
||||
files which are the digital samples to play the midi instruments
|
||||
(eg: piano, conga, guitar, ect.).
|
||||
|
||||
Check the Allegro homepage for some links to GUS patches:
|
||||
http://alleg.sourceforge.net/digmid.html
|
||||
http://alleg.sourceforge.net/
|
||||
http://www.talula.demon.co.uk/allegro/digmid.html
|
||||
http://www.talula.demon.co.uk/allegro/
|
||||
|
||||
Now to activate the DIGMID driver:
|
||||
|
||||
Set the 'midi_card' value to 8 (DIGMID) in the allegro.cfg file.
|
||||
Make sure you leave the 'digi_voices' blank, or set it to a low
|
||||
value, because the midi music will use digital voices.
|
||||
At the end of the allegro.cfg file, set the 'patches' value
|
||||
to the path, where you have installed a Gravis Ultrasound midi
|
||||
patch set. eg: patches = d:\music\midipat\
|
||||
|
||||
# Linux: CD music does not work or only works when run as root.
|
||||
|
||||
We do not encourage you to run SRB2 as root (you never know
|
||||
what SRB2 can do to your system - it's a mighty piece of code :).
|
||||
There is a common problem with ATAPI CD-rom drives, which are
|
||||
treated as harddisks. Usually there is a link /dev/cdrom pointing to
|
||||
device hd[b,c,d]. As harddisks are not supposed to be read directly
|
||||
via this device (especially not by a common user), there are no read
|
||||
permissions for "all". For CD-roms you can savely set read permissions
|
||||
unless you are very paranoid. Assuming your CD-rom drive is /dev/hdc,
|
||||
set permissions with "chmod +r /dev/hdc" (as root). SCSI CD-rom drives
|
||||
should not have this problem. But if they do, proceed as described
|
||||
with ATAPI drives.
|
||||
|
||||
# Linux: The CD music volume is not set properly.
|
||||
|
||||
Go to the console and type "jigglecdvolume 1".
|
||||
|
||||
-----------
|
||||
[4] NETWORK
|
||||
-----------
|
||||
|
||||
* Where can I find Internet servers ?
|
||||
|
||||
For the moment there is one public server.
|
||||
http://srb2.servegame.org/ Master server web page
|
||||
srb2.servegame.org:28910 current Master Server
|
||||
|
||||
* When I start SRB2 with -server or -connect it say :
|
||||
"BinToPort: Address already in use (EADDRINUSE)"
|
||||
|
||||
It appears only when SRB2 crashes or when you leave with ctrl-break.
|
||||
use -udpport 12345 (or any other free slot) on both sides (client and
|
||||
server).
|
||||
|
||||
This can also happens when there is already a SRB2 running on your
|
||||
computer if you whant to try two SRB2 running on the same computer
|
||||
use -clientport 12345 (or any other free slot). Then the second will
|
||||
connect to the first one.
|
||||
|
||||
* Do you use the tcp protocol ?
|
||||
|
||||
No, we use the udp protocol which is faster, but don't worry udp is a
|
||||
part of the internet protocol.
|
||||
|
||||
|
||||
-------------------
|
||||
[5] Troubleshooting
|
||||
-------------------
|
||||
|
||||
# Linux: SRB2 is hung in fullscreen mode and won´t let me leave.
|
||||
What shall I do?
|
||||
|
||||
Some people press the reset button, but hey, we are not in the
|
||||
stoneage of operating systems! There are two "proper" ways to
|
||||
get out: kill your X-Server. You can usually do this by pressing
|
||||
"CTRL-ALT-BACKSPACE". But if you have other open applications with
|
||||
important data (probably hacked away on your diploma thesis for 3
|
||||
weeks without saving once) you can also kill SRB2 directly. Press
|
||||
"CTRL-ALT-F2" and you will get to a console. Log in, type
|
||||
"killall llxSRB2" and switch back to the X-Server with "CTRL-ALT-F7".
|
||||
Some X-Server crash on this procedure - blame the X-Server for the
|
||||
loss of 3 weeks work on your diploma thesis :)
|
||||
@@ -0,0 +1,68 @@
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<title>
|
||||
Sonic Robo Blast 2 Manual
|
||||
</title>
|
||||
<link rel="stylesheet" type="text/css" href="srb2manstyle.css">
|
||||
<!-- Borrowed some javascript code so the height of the iframe is equal to the size of the document - Sonict -->
|
||||
<script type="text/javascript">
|
||||
/* free code from dyn-web.com */
|
||||
|
||||
function getDocHeight(doc) {
|
||||
doc = doc || document;
|
||||
// from http://stackoverflow.com/questions/1145850/get-height-of-entire-document-with-javascript
|
||||
var body = doc.body, html = doc.documentElement;
|
||||
var height = Math.max( body.scrollHeight, body.offsetHeight,
|
||||
html.clientHeight, html.scrollHeight, html.offsetHeight );
|
||||
return height;
|
||||
}
|
||||
|
||||
function setIframeHeight(id) {
|
||||
var ifrm = document.getElementById(id);
|
||||
var doc = ifrm.contentDocument? ifrm.contentDocument: ifrm.contentWindow.document;
|
||||
ifrm.style.visibility = 'hidden';
|
||||
ifrm.style.height = "10px"; // reset to minimal height in case going from longer to shorter doc
|
||||
ifrm.style.height = getDocHeight( doc ) + "px";
|
||||
ifrm.style.visibility = 'visible';
|
||||
}
|
||||
</script>
|
||||
<meta http-equiv="Content-type" content="text/html; charset=UTF-8">
|
||||
</head>
|
||||
<body>
|
||||
<p class="c1">
|
||||
<img src="manual_img/sonicname2.png" alt="SONIC" width="136" height="36">
|
||||
<br>
|
||||
<img src="manual_img/srb2banner.png" alt="ROBO BLAST 2" width="224" height="43">
|
||||
</p>
|
||||
<p class="c1">
|
||||
<big><big><strong>Manual</strong></big></big>
|
||||
</p>
|
||||
<table class="cf" align="center">
|
||||
<tr><td class="c">
|
||||
<ul class="hmenu">
|
||||
<li class="hmenu"><a class="hmenu" href="intro.htm" target="ifrm">Main</a></li>
|
||||
<li class="hmenu"><a class="hmenu" href="items.htm" target="ifrm">Items</a></li>
|
||||
<li class="hmenu"><a class="hmenu" href="playerabilities.htm" target="ifrm">Player Abilities</a></li>
|
||||
<li class="hmenu"><a class="hmenu" href="basicplay.htm" target="ifrm">Gameplay</a></li>
|
||||
<li class="hmenu"><a class="hmenu" href="surroundings.htm" target="ifrm">Surroundings</a></li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
<tr><td class="c">
|
||||
<ul class="hmenu">
|
||||
<li class="hmenu"><a class="hmenu" href="multiplayer.htm" target="ifrm">Multiplayer</a></li>
|
||||
<li class="hmenu"><a class="hmenu" href="zones.htm" target="ifrm">Zones</a></li>
|
||||
<li class="hmenu"><a class="hmenu" href="controls.htm" target="ifrm">Controls</a></li>
|
||||
<li class="hmenu"><a class="hmenu" href="consolecommands.htm" target="ifrm">Console Commands</a></li>
|
||||
<li class="hmenu"><a class="hmenu" href="misc.htm" target="ifrm">Misc</a></li>
|
||||
</ul>
|
||||
</td></tr>
|
||||
</table>
|
||||
<hr>
|
||||
<p class="c1">
|
||||
<!-- The "onload" property of the iframe makes an error when validated through the W3C validation checker. -->
|
||||
<!-- This will not be fixed as it isn't worth the time to fix it up properly. - Sonict -->
|
||||
<iframe id="ifrm" name="ifrm" src="intro.htm" onload="setIframeHeight(this.id)"> </iframe>
|
||||
</p>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,39 @@
|
||||
SVN-RULES
|
||||
|
||||
- As you can see, there is sub-directory in the repository, one for eatch
|
||||
platform (djgpp (dos),win32,SDL) the root directory is for all platform,
|
||||
so take care of the order we have put in.
|
||||
- do not commit/upload tests of bugged code, try to fix a maximum of know
|
||||
bugs and update know bugs list in source.txt. If you must commit your source
|
||||
make your code in #ifdef so we can disable it
|
||||
- SRB2 is a modification of doom/Doom Legacy source. We allow additionnal feature
|
||||
and visual addition.
|
||||
- Maximize communications between members, do not impose your changes, if your
|
||||
are not sure about a feature/change, talk about it in irc://irc.esper.net/srb2 chat room.
|
||||
|
||||
CODE-RULES
|
||||
|
||||
- We use no tab, 4 space indent, and tab size 8 (in case some tab have filtred
|
||||
and for makefile)
|
||||
- Self documented code, variable and function must have a name that help
|
||||
understand the code, so do not call variable and function a,b, a2, ...
|
||||
- the usage of extern in a c file is prohibited, except for declaration of a
|
||||
function with body (so it is like public keyword in c++)
|
||||
Also function protos haren't allowed for external function, put it un the
|
||||
corresponding h file.
|
||||
- Try to minimize #ifdef usage for :
|
||||
- code readability
|
||||
- the main code is for all port so if something is good for a platform all
|
||||
platform can benefit by this feature
|
||||
- Take care of platform dependent code, we would like to have code that work
|
||||
on Dos, Win32, SDL, ... little and big endian, software/Glide/OpenGl.
|
||||
|
||||
GOOD PRACTICE
|
||||
|
||||
- Try to put as mush static variable and function on module so it help to
|
||||
understand the role of the varaible/function in the module also this
|
||||
help the compiler to optimize
|
||||
- minimise global variable
|
||||
- make a log of your work, so you don't need to put a lot of comment in
|
||||
the code, this will also help us to update the what's new section of doc
|
||||
when doing final release
|
||||
+240
@@ -0,0 +1,240 @@
|
||||
|
||||
1. Compile SRB2
|
||||
2. Explanation of the code
|
||||
2.1 The memory model
|
||||
2.2 Hardware Texture model
|
||||
|
||||
1. Compile SRB2
|
||||
=================
|
||||
|
||||
DOS
|
||||
---
|
||||
|
||||
need:
|
||||
- djgpp 2.03 (http://www.delorie.com/djgpp/)
|
||||
- allegro 3.12 (http://alleg.sourceforge.net/index.html)
|
||||
(
|
||||
- libsocket 0.7.4 (beta 4) or better
|
||||
for use with Winsock 1.1 (example Windows 3.1)
|
||||
(http://www.phekda.freeserve.co.uk/richdawe/lsck/lsck.htm)
|
||||
OR
|
||||
- Wattcp-32 v2.2 dev.rel 6 or better
|
||||
For use with a packet driver
|
||||
(http://www.bgnett.no/~giva/)
|
||||
(http://groups.yahoo.com/group/watt-32/)
|
||||
(http://groups.yahoo.com/group/watt-32/files/v2.2/)
|
||||
)
|
||||
- bcd 1.03 (inlcude in this package)
|
||||
- gcc 2.95.2 is recommended
|
||||
- nasm 0.98 (or better) (http://nasm.sourceforge.net/)
|
||||
|
||||
compile:
|
||||
make
|
||||
make WATTCP=1 (to make a Wattcp-32 version)
|
||||
|
||||
debug:
|
||||
when craching SRB2 will return eip
|
||||
type make asm, then you will have a 8 megs srb2.s (a assembler file)
|
||||
the you can find the faulting instruction and function
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Linux/SDL
|
||||
-----
|
||||
|
||||
need:
|
||||
- tested with gcc 2.95 and 3.X.
|
||||
- SDL 1.2
|
||||
- SDL_mixer 1.2
|
||||
- ibogg and libvorbis (http://Xiph.org/)
|
||||
- nasm 0.98 (or better)(http://nasm.sourceforge.net/) only with 2.95, else add CC30=1
|
||||
|
||||
compile
|
||||
make LINUX=1
|
||||
|
||||
debug:
|
||||
gdb ?
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Win32
|
||||
-----
|
||||
|
||||
need :
|
||||
- glide 3.x sdk (optional) (http://www.3dfx.com)
|
||||
- directx6 sdk (or higher) (http://www.micosoft.com/directx)
|
||||
- nasm 0.98 (or better) (http://nasm.sourceforge.net/)
|
||||
- use src\win32\wLegacy.dsp
|
||||
- VC6 should also work with VC5, and VS.NET 200X
|
||||
|
||||
debug:
|
||||
press on "step over" with the release version (there is some debug info
|
||||
on it). Then change the eip in the regster window when you will type
|
||||
enter the edi will go to the faulting instruction. don't forget that
|
||||
you can follow the stack for calls.
|
||||
You can also use trace with the debug version but add -win and -nomouse.
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
Win32/minGW/SDL
|
||||
-----
|
||||
|
||||
need:
|
||||
- tested with gcc 2.95 and 3.X.
|
||||
- can also use Dev-C++ 5.0 beta 9 (4.9.9.0) from http://www.bloodshed.net/dev/devcpp.html
|
||||
- SDL 1.2
|
||||
- SDL_mixer 1.2
|
||||
|
||||
compile
|
||||
make minGW=1 SDL=1
|
||||
or use src\SDL\Win32SDL.dev with Dev-C++ 4.9.9.0 or later
|
||||
|
||||
debug:
|
||||
gdb ?
|
||||
|
||||
------------------------------------------------------------------------
|
||||
|
||||
WinCE/SDL WIP
|
||||
-----
|
||||
|
||||
need:
|
||||
- ActiveSync 3.8
|
||||
http://www.microsoft.com/windowsmobile/downloads/activesync38.mspx
|
||||
|
||||
- ActiveSync 3.7.1, if 3.8 isn't available for your language
|
||||
http://www.microsoft.com/windowsmobile/downloads/activesync37.mspx
|
||||
|
||||
- eMbedded Visual Tools 3.0 - 2002 Edition
|
||||
http://www.microsoft.com/downloads/details.aspx?FamilyID=f663bf48-31ee-4cbe-aac5-0affd5fb27dd
|
||||
|
||||
- Pocket PC 2000 SDK
|
||||
http://www.microsoft.com/downloads/details.aspx?FamilyID=bb3f4d7b-de2a-4e1a-a175-26a68c301ac4
|
||||
|
||||
- Pocket PC 2002 SDK (eMVT 3.0 2002 Ed. comes with this)
|
||||
http://www.microsoft.com/downloads/details.aspx?FamilyID=2dbee84a-bd94-4167-b817-2b2e548b2e92
|
||||
|
||||
- Pocket PC 2002 SDK Emulator Images (eMVT 3.0 2002 Ed. comes with this)
|
||||
http://www.microsoft.com/downloads/details.aspx?FamilyID=25f4de97-ae80-477a-9df1-496b85b3d3e3
|
||||
|
||||
- eMbedded Visual C++ 4.0
|
||||
http://www.microsoft.com/downloads/details.aspx?familyid=1DACDB3D-50D1-41B2-A107-FA75AE960856
|
||||
|
||||
- eMbedded Visual C++ 4.0 SP3 (Win CE 4.0-4.2)
|
||||
http://www.microsoft.com/downloads/details.aspx?FamilyID=5bb36f3e-5b3d-419a-9610-2fe53815ae3b
|
||||
|
||||
OR
|
||||
|
||||
- eMbedded Visual C++ 4.0 SP4 (No SH3 support,Win CE 4.0-5.0 support)
|
||||
http://www.microsoft.com/downloads/details.aspx?FamilyID=4a4ed1f4-91d3-4dbe-986e-a812984318e5
|
||||
|
||||
- eMbedded Visual C++ 4.0 Update 5625 (SP4 only)
|
||||
http://www.microsoft.com/downloads/details.aspx?FamilyID=aa282a6d-6f57-436d-8c10-0ec02d94f5b1
|
||||
|
||||
- Windows CE: Standard Software Development Kit
|
||||
http://www.microsoft.com/downloads/details.aspx?familyid=a08f6991-16b0-4019-a174-0c40e6d25fe7
|
||||
|
||||
- SDK for Windows Mobile 2003-based Pocket PCs
|
||||
http://www.microsoft.com/downloads/details.aspx?FamilyId=9996B314-0364-4623-9EDE-0B5FBB133652
|
||||
|
||||
- Emulator Images for Windows Mobile 2003 Second Edition software for Pocket PC
|
||||
http://www.microsoft.com/downloads/details.aspx?familyid=5C53E3B5-F2A2-47D7-A41D-825FD68EBB6C
|
||||
|
||||
- Microsoft Device Emulator 1.0 Community Preview
|
||||
http://beta.microsoft.com Use Guest ID "MSDEVICE" to access the Community Preview website
|
||||
|
||||
- Windows CE Utilities for Visual Studio .NET 2003 Add-on Pack 1.1
|
||||
(if you also have VS 2003 installed, you need this to install Win CE 5.0 SDK, else no need)
|
||||
http://www.microsoft.com/downloads/details.aspx?FamilyId=7EC99CA6-2095-4086-B0CC-7C6C39B28762
|
||||
|
||||
- Windows CE 5.0: Standard Software Development Kit (eMC++ 4 SP4 only)
|
||||
http://www.microsoft.com/downloads/details.aspx?FamilyID=fa1a3d66-3f61-4ddc-9510-ae450e2318c3
|
||||
|
||||
- SDL 1.27 (use patch and zip in tools\SDL1.2.7_CE)
|
||||
|
||||
compile
|
||||
use src\SDL\WinCE\SRB2CE.vcw
|
||||
|
||||
debug:
|
||||
?
|
||||
|
||||
|
||||
2. Explanation of the code
|
||||
==========================
|
||||
|
||||
2.1 The memory model (original) (z_zone.c) (by BP)
|
||||
--------------------
|
||||
|
||||
SRB2 allocate a heap of 6/32/48 megs at begining and provide a Z_Malloc function
|
||||
to allocate in this heap.
|
||||
|
||||
Z_Malloc( int size,int tag,void* user )
|
||||
|
||||
size is the size in byte
|
||||
tag can be : PU_STATIC allocated static (like malloc do)
|
||||
call Z_Free to free it
|
||||
PU_LEVEL same as static but the zone is "tagged" with the
|
||||
tag PU_LEVEL, when calling
|
||||
Z_FreeTag (PU_LEVEL, PU_LEVEL) all zone tagged
|
||||
with PU_LEVEL are freed (at the end of the level)
|
||||
PU_CACHE this one _can_ be freed automatiquely by one other
|
||||
call to Z_Malloc. the *user point to a pointer
|
||||
to this zone so when freed automatiquely the
|
||||
pointer is set to NULL so eatch time you use it
|
||||
you must check if the pointer is not NULL and
|
||||
reload it.
|
||||
|
||||
(...)
|
||||
|
||||
2.2 Hardware Texture model (by BP)
|
||||
--------------------------
|
||||
|
||||
Eatch texture/patch/flats/pic in SRB2 are converted to hardware texture at
|
||||
runtime (the GlideMipmap_s structure (hw_data.h)). I will call hardware
|
||||
texture a gr_texture so there is no confusion.
|
||||
|
||||
To remind you :
|
||||
- Texture are set of patch and are associate to linedefs (walls) can be
|
||||
upper, lower or middle texture. It can have hole on it.
|
||||
- patch are sprites (the doom patch are run of vertical lines)
|
||||
- flats are used for floors and ceiling of sectors and have size of 64x64
|
||||
it can't have hole on it
|
||||
- pic are new legacy format for picture, it can only handle plain texture
|
||||
like flats it is now used for hud in full screen for the main picture
|
||||
of legacy and for coronas (the format was extended to handle 32 bit color
|
||||
or intensity + alpha, not all are implemented at this time)
|
||||
|
||||
Since patch, flat and pic are basic structure represented by only one lump in
|
||||
the wad, the wad loader allocate for eatch lump a GlideMipmap_s (cache3Dfx)
|
||||
and init data field to NULL. Since the data structure is allocated in
|
||||
PU_3DFXCACHE (like PU_CACHE) the data will be initilised when needed
|
||||
(hw_cache.c).
|
||||
|
||||
The GlideMipmap_s structures for textures are initialized on
|
||||
HWR_PrepLevelCache (hw_cache.c) it is called in P_SetupLevel (load level)
|
||||
the number of textures is computed with TEXTURE1, TEXTURE2 lumps since this
|
||||
can be changed in runtime in SRB2 (load a wad while runing) it must be
|
||||
reallocated. Well, at this time it is realloceted at eatch level start. We
|
||||
can do better, since numtextures change only when a wad is loaded.
|
||||
|
||||
The 3dfx driver use glide3, it load gr_texture in gr_texture memory of the
|
||||
card in fifo order when there is no more place it remove the first gr_texture,
|
||||
the downloaded field of GlideMipmap_s go to false and when needed it is
|
||||
reloaded in gr_texture memory. In OpenGl, since OpenGl keep texture in there
|
||||
own memory and handle gr_texture memory of the card we no more need to
|
||||
redownload it but if we not free time to time gr_texture memory in opengl,
|
||||
it will get alot of memory, so the gr_texture memory is cleared at eatch
|
||||
new level (same time of texture reallocation). Opengl and 3dfx link the
|
||||
loaded gr_texture with the nextmipmap field of GlideMipmap_s so before clear
|
||||
textures of the heap we MUST free gr_texture memory of OpenGl or 3dfx !
|
||||
|
||||
SRB2 can also draw patch with a differant colormap (thanks to Hurdler).
|
||||
When needed it create the same gr_texture but just with a differant colormap.
|
||||
This one is linked with the original in the GlideMipmap_s with the
|
||||
nextcolormap field.
|
||||
|
||||
So when a polygone with a gr_texture must be drawn, first we check if the
|
||||
gr_textures is not allready loaded in hadware memory (downloaded field) if
|
||||
not then we check if gr_texture data is there (not grabbed by z_malloc
|
||||
function) if not we must recompute it eatch type of gr_texture (texture,
|
||||
patch, flat, pic have there own methode) the we can send the gr_texture
|
||||
to 3dfx or OpenGl.
|
||||
+1992
File diff suppressed because it is too large.
Load diff
Submodule
+1
Submodule libs/bluajit added at 14f5b60567.
@@ -5,13 +5,13 @@
|
||||
# met:
|
||||
|
||||
# (1) Redistributions of source code must retain the above copyright
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
# notice, this list of conditions and the following disclaimer.
|
||||
|
||||
# (2) Redistributions in binary form must reproduce the above copyright
|
||||
# notice, this list of conditions and the following disclaimer in
|
||||
# the documentation and/or other materials provided with the
|
||||
# distribution.
|
||||
|
||||
# distribution.
|
||||
|
||||
# (3) The name of the author may not be used to
|
||||
# endorse or promote products derived from this software without
|
||||
# specific prior written permission.
|
||||
@@ -26,4 +26,4 @@
|
||||
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
|
||||
# STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
|
||||
# IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
# POSSIBILITY OF SUCH DAMAGE.
|
||||
@@ -10,18 +10,8 @@ The libbacktrace library may be linked into a program or library and
|
||||
used to produce symbolic backtraces.
|
||||
Sample uses would be to print a detailed backtrace when an error
|
||||
occurs or to gather detailed profiling information.
|
||||
|
||||
In general the functions provided by this library are async-signal-safe,
|
||||
meaning that they may be safely called from a signal handler.
|
||||
That said, on systems that use `dl_iterate_phdr`, such as GNU/Linux,
|
||||
the first call to a libbacktrace function will call `dl_iterate_phdr`,
|
||||
which is not in general async-signal-safe. Therefore, programs
|
||||
that call libbacktrace from a signal handler should ensure that they
|
||||
make an initial call from outside of a signal handler.
|
||||
Similar considerations apply when arranging to call libbacktrace
|
||||
from within malloc; `dl_iterate_phdr` can also call malloc,
|
||||
so make an initial call to a libbacktrace function outside of
|
||||
malloc before trying to call libbacktrace functions within malloc.
|
||||
|
||||
The libbacktrace library is provided under a BSD license.
|
||||
See the source files for the exact license text.
|
||||
@@ -35,7 +25,7 @@ will work.
|
||||
See the source file backtrace-supported.h.in for the macros that it
|
||||
defines.
|
||||
|
||||
As of July 2024, libbacktrace supports ELF, PE/COFF, Mach-O, and
|
||||
As of October 2020, libbacktrace supports ELF, PE/COFF, Mach-O, and
|
||||
XCOFF executables with DWARF debugging information.
|
||||
In other words, it supports GNU/Linux, *BSD, macOS, Windows, and AIX.
|
||||
The library is written to make it straightforward to add support for
|
||||
|
||||
Binary file not shown.
@@ -1,41 +0,0 @@
|
||||
# libbacktrace.la - a libtool library file
|
||||
# Generated by libtool (GNU libtool 1.3134 2009-11-29) 2.2.7a
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname=''
|
||||
|
||||
# Names of this library.
|
||||
library_names=''
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libbacktrace.a'
|
||||
|
||||
# Linker flags that can not go in dependency_libs.
|
||||
inherited_linker_flags=''
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=''
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libbacktrace.
|
||||
current=0
|
||||
age=0
|
||||
revision=0
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=no
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/mingw64/lib'
|
||||
@@ -1,41 +0,0 @@
|
||||
# libbacktrace.la - a libtool library file
|
||||
# Generated by libtool (GNU libtool 1.3134 2009-11-29) 2.2.7a
|
||||
#
|
||||
# Please DO NOT delete this file!
|
||||
# It is necessary for linking the library.
|
||||
|
||||
# The name that we can dlopen(3).
|
||||
dlname=''
|
||||
|
||||
# Names of this library.
|
||||
library_names=''
|
||||
|
||||
# The name of the static archive.
|
||||
old_library='libbacktrace.a'
|
||||
|
||||
# Linker flags that can not go in dependency_libs.
|
||||
inherited_linker_flags=''
|
||||
|
||||
# Libraries that this one depends upon.
|
||||
dependency_libs=''
|
||||
|
||||
# Names of additional weak libraries provided by this library
|
||||
weak_library_names=''
|
||||
|
||||
# Version information for libbacktrace.
|
||||
current=0
|
||||
age=0
|
||||
revision=0
|
||||
|
||||
# Is this an already installed library?
|
||||
installed=yes
|
||||
|
||||
# Should we warn about portability when linking against -modules?
|
||||
shouldnotlink=no
|
||||
|
||||
# Files to dlopen/dlpreopen
|
||||
dlopen=''
|
||||
dlpreopen=''
|
||||
|
||||
# Directory that this library needs to be installed in:
|
||||
libdir='/mingw64/lib'
|
||||
@@ -1,27 +0,0 @@
|
||||
codecov:
|
||||
max_report_age: off
|
||||
notify:
|
||||
wait_for_ci: false
|
||||
require_ci_to_pass: false
|
||||
comment:
|
||||
require_base: false
|
||||
require_head: false
|
||||
coverage:
|
||||
status:
|
||||
project:
|
||||
default:
|
||||
threshold: 0.07
|
||||
fixes:
|
||||
- '/home/actions-runner/_work/zlib-ng/zlib-ng::'
|
||||
- '/home/actions-runner/_work/zlib-ng/zlib-ng/build/::'
|
||||
ignore:
|
||||
- usr/include/.*
|
||||
- /usr/include/.*
|
||||
- /build/usr/include/.*
|
||||
- usr/lib/.*
|
||||
- /usr/lib/.*
|
||||
- /build/usr/lib/.*
|
||||
- usr/lib64/.*
|
||||
- /usr/lib64/.*
|
||||
- /build/usr/lib64/.*
|
||||
- _deps/**/*
|
||||
@@ -1 +0,0 @@
|
||||
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
|
||||
+125
-1414
File diff suppressed because it is too large.
Load diff
@@ -1,373 +0,0 @@
|
||||
##
|
||||
# THIS IS AN UNMAINTAINED COPY OF THE ORIGINAL FILE DISTRIBUTED WITH ZLIB 1.2.11
|
||||
##
|
||||
|
||||
|
||||
|
||||
|
||||
Frequently Asked Questions about zlib
|
||||
|
||||
|
||||
If your question is not there, please check the zlib home page
|
||||
https://zlib.net/ which may have more recent information.
|
||||
The latest zlib FAQ is at https://zlib.net/zlib_faq.html
|
||||
|
||||
|
||||
1. Is zlib Y2K-compliant?
|
||||
|
||||
Yes. zlib doesn't handle dates.
|
||||
|
||||
2. Where can I get a Windows DLL version?
|
||||
|
||||
The zlib sources can be compiled without change to produce a DLL. See the
|
||||
file win32/DLL_FAQ.txt in the zlib distribution.
|
||||
|
||||
3. Where can I get a Visual Basic interface to zlib?
|
||||
|
||||
See
|
||||
* https://marknelson.us/1997/01/01/zlib-engine/
|
||||
* win32/DLL_FAQ.txt in the zlib distribution
|
||||
|
||||
4. compress() returns Z_BUF_ERROR.
|
||||
|
||||
Make sure that before the call of compress(), the length of the compressed
|
||||
buffer is equal to the available size of the compressed buffer and not
|
||||
zero. For Visual Basic, check that this parameter is passed by reference
|
||||
("as any"), not by value ("as long").
|
||||
|
||||
5. deflate() or inflate() returns Z_BUF_ERROR.
|
||||
|
||||
Before making the call, make sure that avail_in and avail_out are not zero.
|
||||
When setting the parameter flush equal to Z_FINISH, also make sure that
|
||||
avail_out is big enough to allow processing all pending input. Note that a
|
||||
Z_BUF_ERROR is not fatal--another call to deflate() or inflate() can be
|
||||
made with more input or output space. A Z_BUF_ERROR may in fact be
|
||||
unavoidable depending on how the functions are used, since it is not
|
||||
possible to tell whether or not there is more output pending when
|
||||
strm.avail_out returns with zero. See https://zlib.net/zlib_how.html for a
|
||||
heavily annotated example.
|
||||
|
||||
6. Where's the zlib documentation (man pages, etc.)?
|
||||
|
||||
It's in zlib.h . Examples of zlib usage are in the files test/example.c
|
||||
and test/minigzip.c, with more in examples/ .
|
||||
|
||||
7. Why don't you use GNU autoconf or libtool or ...?
|
||||
|
||||
Because we would like to keep zlib as a very small and simple package.
|
||||
zlib is rather portable and doesn't need much configuration.
|
||||
|
||||
8. I found a bug in zlib.
|
||||
|
||||
Most of the time, such problems are due to an incorrect usage of zlib.
|
||||
Please try to reproduce the problem with a small program and send the
|
||||
corresponding source to us at zlib@gzip.org . Do not send multi-megabyte
|
||||
data files without prior agreement.
|
||||
|
||||
9. Why do I get "undefined reference to gzputc"?
|
||||
|
||||
If "make test" produces something like
|
||||
|
||||
example.o(.text+0x154): undefined reference to `gzputc'
|
||||
|
||||
check that you don't have old files libz.* in /usr/lib, /usr/local/lib or
|
||||
/usr/X11R6/lib. Remove any old versions, then do "make install".
|
||||
|
||||
10. I need a Delphi interface to zlib.
|
||||
|
||||
See the contrib/delphi directory in the zlib distribution.
|
||||
|
||||
11. Can zlib handle .zip archives?
|
||||
|
||||
Not by itself, no. See the directory contrib/minizip in the zlib
|
||||
distribution.
|
||||
|
||||
12. Can zlib handle .Z files?
|
||||
|
||||
No, sorry. You have to spawn an uncompress or gunzip subprocess, or adapt
|
||||
the code of uncompress on your own.
|
||||
|
||||
13. How can I make a Unix shared library?
|
||||
|
||||
By default a shared (and a static) library is built for Unix. So:
|
||||
|
||||
make distclean
|
||||
./configure
|
||||
make
|
||||
|
||||
14. How do I install a shared zlib library on Unix?
|
||||
|
||||
After the above, then:
|
||||
|
||||
make install
|
||||
|
||||
However, many flavors of Unix come with a shared zlib already installed.
|
||||
Before going to the trouble of compiling a shared version of zlib and
|
||||
trying to install it, you may want to check if it's already there! If you
|
||||
can #include <zlib.h>, it's there. The -lz option will probably link to
|
||||
it. You can check the version at the top of zlib.h or with the
|
||||
ZLIB_VERSION symbol defined in zlib.h .
|
||||
|
||||
15. I have a question about OttoPDF.
|
||||
|
||||
We are not the authors of OttoPDF. The real author is on the OttoPDF web
|
||||
site: Joel Hainley, jhainley@myndkryme.com.
|
||||
|
||||
16. Can zlib decode Flate data in an Adobe PDF file?
|
||||
|
||||
Yes. See https://www.pdflib.com/ . To modify PDF forms, see
|
||||
https://sourceforge.net/projects/acroformtool/ .
|
||||
|
||||
17. Why am I getting this "register_frame_info not found" error on Solaris?
|
||||
|
||||
After installing zlib 1.1.4 on Solaris 2.6, running applications using zlib
|
||||
generates an error such as:
|
||||
|
||||
ld.so.1: rpm: fatal: relocation error: file /usr/local/lib/libz.so:
|
||||
symbol __register_frame_info: referenced symbol not found
|
||||
|
||||
The symbol __register_frame_info is not part of zlib, it is generated by
|
||||
the C compiler (cc or gcc). You must recompile applications using zlib
|
||||
which have this problem. This problem is specific to Solaris. See
|
||||
http://www.sunfreeware.com/ for Solaris versions of zlib and applications
|
||||
using zlib.
|
||||
|
||||
18. Why does gzip give an error on a file I make with compress/deflate?
|
||||
|
||||
The compress and deflate functions produce data in the zlib format, which
|
||||
is different and incompatible with the gzip format. The gz* functions in
|
||||
zlib on the other hand use the gzip format. Both the zlib and gzip formats
|
||||
use the same compressed data format internally, but have different headers
|
||||
and trailers around the compressed data.
|
||||
|
||||
19. Ok, so why are there two different formats?
|
||||
|
||||
The gzip format was designed to retain the directory information about a
|
||||
single file, such as the name and last modification date. The zlib format
|
||||
on the other hand was designed for in-memory and communication channel
|
||||
applications, and has a much more compact header and trailer and uses a
|
||||
faster integrity check than gzip.
|
||||
|
||||
20. Well that's nice, but how do I make a gzip file in memory?
|
||||
|
||||
You can request that deflate write the gzip format instead of the zlib
|
||||
format using deflateInit2(). You can also request that inflate decode the
|
||||
gzip format using inflateInit2(). Read zlib.h for more details.
|
||||
|
||||
21. Is zlib thread-safe?
|
||||
|
||||
Yes. However any library routines that zlib uses and any application-
|
||||
provided memory allocation routines must also be thread-safe. zlib's gz*
|
||||
functions use stdio library routines, and most of zlib's functions use the
|
||||
library memory allocation routines by default. zlib's *Init* functions
|
||||
allow for the application to provide custom memory allocation routines.
|
||||
|
||||
Of course, you should only operate on any given zlib or gzip stream from a
|
||||
single thread at a time.
|
||||
|
||||
22. Can I use zlib in my commercial application?
|
||||
|
||||
Yes. Please read the license in zlib.h.
|
||||
|
||||
23. Is zlib under the GNU license?
|
||||
|
||||
No. Please read the license in zlib.h.
|
||||
|
||||
24. The license says that altered source versions must be "plainly marked". So
|
||||
what exactly do I need to do to meet that requirement?
|
||||
|
||||
You need to change the ZLIB_VERSION and ZLIB_VERNUM #defines in zlib.h. In
|
||||
particular, the final version number needs to be changed to "f", and an
|
||||
identification string should be appended to ZLIB_VERSION. Version numbers
|
||||
x.x.x.f are reserved for modifications to zlib by others than the zlib
|
||||
maintainers. For example, if the version of the base zlib you are altering
|
||||
is "1.2.3.4", then in zlib.h you should change ZLIB_VERNUM to 0x123f, and
|
||||
ZLIB_VERSION to something like "1.2.3.f-zachary-mods-v3". You can also
|
||||
update the version strings in deflate.c and inftrees.c.
|
||||
|
||||
For altered source distributions, you should also note the origin and
|
||||
nature of the changes in zlib.h, as well as in ChangeLog and README, along
|
||||
with the dates of the alterations. The origin should include at least your
|
||||
name (or your company's name), and an email address to contact for help or
|
||||
issues with the library.
|
||||
|
||||
Note that distributing a compiled zlib library along with zlib.h and
|
||||
zconf.h is also a source distribution, and so you should change
|
||||
ZLIB_VERSION and ZLIB_VERNUM and note the origin and nature of the changes
|
||||
in zlib.h as you would for a full source distribution.
|
||||
|
||||
25. Will zlib work on a big-endian or little-endian architecture, and can I
|
||||
exchange compressed data between them?
|
||||
|
||||
Yes and yes.
|
||||
|
||||
26. Will zlib work on a 64-bit machine?
|
||||
|
||||
Yes. It has been tested on 64-bit machines, and has no dependence on any
|
||||
data types being limited to 32-bits in length. If you have any
|
||||
difficulties, please provide a complete problem report to zlib@gzip.org
|
||||
|
||||
27. Will zlib decompress data from the PKWare Data Compression Library?
|
||||
|
||||
No. The PKWare DCL uses a completely different compressed data format than
|
||||
does PKZIP and zlib. However, you can look in zlib's contrib/blast
|
||||
directory for a possible solution to your problem.
|
||||
|
||||
28. Can I access data randomly in a compressed stream?
|
||||
|
||||
No, not without some preparation. If when compressing you periodically use
|
||||
Z_FULL_FLUSH, carefully write all the pending data at those points, and
|
||||
keep an index of those locations, then you can start decompression at those
|
||||
points. You have to be careful to not use Z_FULL_FLUSH too often, since it
|
||||
can significantly degrade compression. Alternatively, you can scan a
|
||||
deflate stream once to generate an index, and then use that index for
|
||||
random access. See examples/zran.c .
|
||||
|
||||
29. Does zlib work on MVS, OS/390, CICS, etc.?
|
||||
|
||||
It has in the past, but we have not heard of any recent evidence. There
|
||||
were working ports of zlib 1.1.4 to MVS, but those links no longer work.
|
||||
If you know of recent, successful applications of zlib on these operating
|
||||
systems, please let us know. Thanks.
|
||||
|
||||
30. Is there some simpler, easier to read version of inflate I can look at to
|
||||
understand the deflate format?
|
||||
|
||||
First off, you should read RFC 1951. Second, yes. Look in zlib's
|
||||
contrib/puff directory.
|
||||
|
||||
31. Does zlib infringe on any patents?
|
||||
|
||||
As far as we know, no. In fact, that was originally the whole point behind
|
||||
zlib. Look here for some more information:
|
||||
|
||||
https://www.gzip.org/#faq11
|
||||
|
||||
32. Can zlib work with greater than 4 GB of data?
|
||||
|
||||
Yes. inflate() and deflate() will process any amount of data correctly.
|
||||
Each call of inflate() or deflate() is limited to input and output chunks
|
||||
of the maximum value that can be stored in the compiler's "unsigned int"
|
||||
type, but there is no limit to the number of chunks. Note however that the
|
||||
strm.total_in and strm_total_out counters may be limited to 4 GB. These
|
||||
counters are provided as a convenience and are not used internally by
|
||||
inflate() or deflate(). The application can easily set up its own counters
|
||||
updated after each call of inflate() or deflate() to count beyond 4 GB.
|
||||
compress() and uncompress() may be limited to 4 GB, since they operate in a
|
||||
single call. gzseek() and gztell() may be limited to 4 GB depending on how
|
||||
zlib is compiled. See the zlibCompileFlags() function in zlib.h.
|
||||
|
||||
The word "may" appears several times above since there is a 4 GB limit only
|
||||
if the compiler's "long" type is 32 bits. If the compiler's "long" type is
|
||||
64 bits, then the limit is 16 exabytes.
|
||||
|
||||
33. Does zlib have any security vulnerabilities?
|
||||
|
||||
The only one that we are aware of is potentially in gzprintf(). If zlib is
|
||||
compiled to use sprintf() or vsprintf(), then there is no protection
|
||||
against a buffer overflow of an 8K string space (or other value as set by
|
||||
gzbuffer()), other than the caller of gzprintf() assuring that the output
|
||||
will not exceed 8K. On the other hand, if zlib is compiled to use
|
||||
snprintf() or vsnprintf(), which should normally be the case, then there is
|
||||
no vulnerability. The ./configure script will display warnings if an
|
||||
insecure variation of sprintf() will be used by gzprintf(). Also the
|
||||
zlibCompileFlags() function will return information on what variant of
|
||||
sprintf() is used by gzprintf().
|
||||
|
||||
If you don't have snprintf() or vsnprintf() and would like one, you can
|
||||
find a portable implementation here:
|
||||
|
||||
https://www.ijs.si/software/snprintf/
|
||||
|
||||
Note that you should be using the most recent version of zlib. Versions
|
||||
1.1.3 and before were subject to a double-free vulnerability, and versions
|
||||
1.2.1 and 1.2.2 were subject to an access exception when decompressing
|
||||
invalid compressed data.
|
||||
|
||||
34. Is there a Java version of zlib?
|
||||
|
||||
Probably what you want is to use zlib in Java. zlib is already included
|
||||
as part of the Java SDK in the java.util.zip package. If you really want
|
||||
a version of zlib written in the Java language, look on the zlib home
|
||||
page for links: https://zlib.net/ .
|
||||
|
||||
35. I get this or that compiler or source-code scanner warning when I crank it
|
||||
up to maximally-pedantic. Can't you guys write proper code?
|
||||
|
||||
Many years ago, we gave up attempting to avoid warnings on every compiler
|
||||
in the universe. It just got to be a waste of time, and some compilers
|
||||
were downright silly as well as contradicted each other. So now, we simply
|
||||
make sure that the code always works.
|
||||
|
||||
36. Valgrind (or some similar memory access checker) says that deflate is
|
||||
performing a conditional jump that depends on an uninitialized value.
|
||||
Isn't that a bug?
|
||||
|
||||
No. That is intentional for performance reasons, and the output of deflate
|
||||
is not affected. This only started showing up recently since zlib 1.2.x
|
||||
uses malloc() by default for allocations, whereas earlier versions used
|
||||
calloc(), which zeros out the allocated memory. Even though the code was
|
||||
correct, versions 1.2.4 and later was changed to not stimulate these
|
||||
checkers.
|
||||
|
||||
37. Will zlib read the (insert any ancient or arcane format here) compressed
|
||||
data format?
|
||||
|
||||
Probably not. Look in the comp.compression FAQ for pointers to various
|
||||
formats and associated software.
|
||||
|
||||
38. How can I encrypt/decrypt zip files with zlib?
|
||||
|
||||
zlib doesn't support encryption. The original PKZIP encryption is very
|
||||
weak and can be broken with freely available programs. To get strong
|
||||
encryption, use GnuPG, https://www.gnupg.org/ , which already includes zlib
|
||||
compression. For PKZIP compatible "encryption", look at
|
||||
http://infozip.sourceforge.net/
|
||||
|
||||
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
|
||||
|
||||
"gzip" is the gzip format, and "deflate" is the zlib format. They should
|
||||
probably have called the second one "zlib" instead to avoid confusion with
|
||||
the raw deflate compressed data format. While the HTTP 1.1 RFC 2616
|
||||
correctly points to the zlib specification in RFC 1950 for the "deflate"
|
||||
transfer encoding, there have been reports of servers and browsers that
|
||||
incorrectly produce or expect raw deflate data per the deflate
|
||||
specification in RFC 1951, most notably Microsoft. So even though the
|
||||
"deflate" transfer encoding using the zlib format would be the more
|
||||
efficient approach (and in fact exactly what the zlib format was designed
|
||||
for), using the "gzip" transfer encoding is probably more reliable due to
|
||||
an unfortunate choice of name on the part of the HTTP 1.1 authors.
|
||||
|
||||
Bottom line: use the gzip format for HTTP 1.1 encoding.
|
||||
|
||||
40. Does zlib support the new "Deflate64" format introduced by PKWare?
|
||||
|
||||
No. PKWare has apparently decided to keep that format proprietary, since
|
||||
they have not documented it as they have previous compression formats. In
|
||||
any case, the compression improvements are so modest compared to other more
|
||||
modern approaches, that it's not worth the effort to implement.
|
||||
|
||||
41. I'm having a problem with the zip functions in zlib, can you help?
|
||||
|
||||
There are no zip functions in zlib. You are probably using minizip by
|
||||
Giles Vollant, which is found in the contrib directory of zlib. It is not
|
||||
part of zlib. In fact none of the stuff in contrib is part of zlib. The
|
||||
files in there are not supported by the zlib authors. You need to contact
|
||||
the authors of the respective contribution for help.
|
||||
|
||||
42. The match.asm code in contrib is under the GNU General Public License.
|
||||
Since it's part of zlib, doesn't that mean that all of zlib falls under the
|
||||
GNU GPL?
|
||||
|
||||
No. The files in contrib are not part of zlib. They were contributed by
|
||||
other authors and are provided as a convenience to the user within the zlib
|
||||
distribution. Each item in contrib has its own license.
|
||||
|
||||
43. Is zlib subject to export controls? What is its ECCN?
|
||||
|
||||
zlib is not subject to export controls, and so is classified as EAR99.
|
||||
|
||||
44. Can you please sign these lengthy legal documents and fax them back to us
|
||||
so that we can use your software in our product?
|
||||
|
||||
No. Go away. Shoo.
|
||||
@@ -1,36 +0,0 @@
|
||||
Contents
|
||||
--------
|
||||
|
||||
| Name | Description |
|
||||
|:-----------------|:---------------------------------------------------------------|
|
||||
| arch/ | Architecture-specific code |
|
||||
| doc/ | Documentation for formats and algorithms |
|
||||
| test/example.c | Zlib usages examples for build testing |
|
||||
| test/minigzip.c | Minimal gzip-like functionality for build testing |
|
||||
| test/infcover.c | Inflate code coverage for build testing |
|
||||
| win32/ | Shared library version resources for Windows |
|
||||
| CMakeLists.txt | Cmake build script |
|
||||
| configure | Bash configure/build script |
|
||||
| adler32.c | Compute the Adler-32 checksum of a data stream |
|
||||
| chunkset.* | Inline functions to copy small data chunks |
|
||||
| compress.c | Compress a memory buffer |
|
||||
| deflate.* | Compress data using the deflate algorithm |
|
||||
| deflate_fast.c | Compress data using the deflate algorithm with fast strategy |
|
||||
| deflate_medium.c | Compress data using the deflate algorithm with medium strategy |
|
||||
| deflate_slow.c | Compress data using the deflate algorithm with slow strategy |
|
||||
| functable.* | Struct containing function pointers to optimized functions |
|
||||
| gzguts.h | Internal definitions for gzip operations |
|
||||
| gzlib.c | Functions common to reading and writing gzip files |
|
||||
| gzread.c | Read gzip files |
|
||||
| gzwrite.c | Write gzip files |
|
||||
| infback.* | Inflate using a callback interface |
|
||||
| inflate.* | Decompress data |
|
||||
| inffast.* | Decompress data with speed optimizations |
|
||||
| inffixed_tbl.h | Table for decoding fixed codes |
|
||||
| inftrees.h | Generate Huffman trees for efficient decoding |
|
||||
| trees.* | Output deflated data using Huffman coding |
|
||||
| uncompr.c | Decompress a memory buffer |
|
||||
| zconf.h.cmakein | zconf.h template for cmake |
|
||||
| zendian.h | BYTE_ORDER for endian tests |
|
||||
| zlib.map | Linux symbol information |
|
||||
| zlib.pc.in | Pkg-config template |
|
||||
@@ -1,19 +0,0 @@
|
||||
(C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
@@ -1,411 +0,0 @@
|
||||
# Makefile for zlib
|
||||
# Copyright (C) 1995-2024 Jean-loup Gailly, Mark Adler
|
||||
# For conditions of distribution and use, see copyright notice in zlib.h
|
||||
|
||||
# To compile and test, type:
|
||||
# ./configure; make test
|
||||
# Normally configure builds both a static and a shared library.
|
||||
# If you want to build just a static library, use: ./configure --static
|
||||
|
||||
# To install /usr/local/lib/libz.* and /usr/local/include/zlib.h, type:
|
||||
# make install
|
||||
# To install in $HOME instead of /usr/local, use:
|
||||
# make install prefix=$HOME
|
||||
|
||||
CC=cc
|
||||
|
||||
CFLAGS=-O
|
||||
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
|
||||
#CFLAGS=-g -DZLIB_DEBUG
|
||||
#CFLAGS=-O3 -Wall -Wwrite-strings -Wpointer-arith -Wconversion \
|
||||
# -Wstrict-prototypes -Wmissing-prototypes
|
||||
|
||||
SFLAGS=-O
|
||||
LDFLAGS=-L.
|
||||
LIBNAME1=libz-ng
|
||||
LIBNAME2=zlib-ng
|
||||
SUFFIX=-ng
|
||||
TEST_LIBS=$(LIBNAME1).a
|
||||
LDSHARED=$(CC)
|
||||
LDSHAREDFLAGS=-shared
|
||||
LDVERSIONSCRIPT=
|
||||
|
||||
VER=2.2.4
|
||||
VER1=2
|
||||
|
||||
STATICLIB=$(LIBNAME1).a
|
||||
SHAREDLIB=$(LIBNAME1).so
|
||||
SHAREDLIBV=$(LIBNAME1).so.$(VER)
|
||||
SHAREDLIBM=$(LIBNAME1).so.$(VER1)
|
||||
IMPORTLIB=
|
||||
SHAREDTARGET=$(LIBNAME1).so.$(VER)
|
||||
PKGFILE=$(LIBNAME2).pc
|
||||
|
||||
LIBS=$(STATICLIB) $(SHAREDTARGET)
|
||||
|
||||
AR=ar
|
||||
ARFLAGS=rc
|
||||
DEFFILE=
|
||||
RC=
|
||||
RCFLAGS=
|
||||
RCOBJS=
|
||||
STRIP=
|
||||
RANLIB=ranlib
|
||||
LDCONFIG=ldconfig
|
||||
LDSHAREDLIBC=
|
||||
EXE=
|
||||
|
||||
SRCDIR=.
|
||||
INCLUDES=-I$(SRCDIR)
|
||||
|
||||
BUILDDIR=.
|
||||
|
||||
ARCHDIR=arch/generic
|
||||
ARCH_STATIC_OBJS=
|
||||
ARCH_SHARED_OBJS=
|
||||
|
||||
prefix = /usr/local
|
||||
exec_prefix = ${prefix}
|
||||
bindir = ${exec_prefix}/bin
|
||||
libdir = ${exec_prefix}/lib
|
||||
sharedlibdir = ${libdir}
|
||||
includedir = ${prefix}/include
|
||||
mandir = ${prefix}/share/man
|
||||
man3dir = ${mandir}/man3
|
||||
pkgconfigdir = ${libdir}/pkgconfig
|
||||
|
||||
OBJZ = \
|
||||
arch/generic/adler32_c.o \
|
||||
arch/generic/adler32_fold_c.o \
|
||||
arch/generic/chunkset_c.o \
|
||||
arch/generic/compare256_c.o \
|
||||
arch/generic/crc32_braid_c.o \
|
||||
arch/generic/crc32_c.o \
|
||||
arch/generic/crc32_fold_c.o \
|
||||
arch/generic/slide_hash_c.o \
|
||||
adler32.o \
|
||||
compress.o \
|
||||
crc32.o \
|
||||
crc32_braid_comb.o \
|
||||
deflate.o \
|
||||
deflate_fast.o \
|
||||
deflate_huff.o \
|
||||
deflate_medium.o \
|
||||
deflate_quick.o \
|
||||
deflate_rle.o \
|
||||
deflate_slow.o \
|
||||
deflate_stored.o \
|
||||
functable.o \
|
||||
infback.o \
|
||||
inflate.o \
|
||||
inftrees.o \
|
||||
insert_string.o \
|
||||
insert_string_roll.o \
|
||||
trees.o \
|
||||
uncompr.o \
|
||||
zutil.o \
|
||||
arch/generic/crc32_chorba_c.o \
|
||||
cpu_features.o \
|
||||
$(ARCH_STATIC_OBJS)
|
||||
|
||||
OBJG = \
|
||||
gzlib.o \
|
||||
gzread.o \
|
||||
gzwrite.o
|
||||
|
||||
TESTOBJG =
|
||||
OBJC = $(OBJZ) $(OBJG)
|
||||
|
||||
PIC_OBJZ = \
|
||||
arch/generic/adler32_c.lo \
|
||||
arch/generic/adler32_fold_c.lo \
|
||||
arch/generic/chunkset_c.lo \
|
||||
arch/generic/compare256_c.lo \
|
||||
arch/generic/crc32_braid_c.lo \
|
||||
arch/generic/crc32_c.lo \
|
||||
arch/generic/crc32_fold_c.lo \
|
||||
arch/generic/slide_hash_c.lo \
|
||||
adler32.lo \
|
||||
compress.lo \
|
||||
crc32.lo \
|
||||
crc32_braid_comb.lo \
|
||||
deflate.lo \
|
||||
deflate_fast.lo \
|
||||
deflate_huff.lo \
|
||||
deflate_medium.lo \
|
||||
deflate_quick.lo \
|
||||
deflate_rle.lo \
|
||||
deflate_slow.lo \
|
||||
deflate_stored.lo \
|
||||
functable.lo \
|
||||
infback.lo \
|
||||
inflate.lo \
|
||||
inftrees.lo \
|
||||
insert_string.lo \
|
||||
insert_string_roll.lo \
|
||||
trees.lo \
|
||||
uncompr.lo \
|
||||
zutil.lo \
|
||||
arch/generic/crc32_chorba_c.lo \
|
||||
cpu_features.lo \
|
||||
$(ARCH_SHARED_OBJS)
|
||||
|
||||
PIC_OBJG = \
|
||||
gzlib.lo \
|
||||
gzread.lo \
|
||||
gzwrite.lo
|
||||
|
||||
PIC_TESTOBJG =
|
||||
PIC_OBJC = $(PIC_OBJZ) $(PIC_OBJG)
|
||||
|
||||
OBJS = $(OBJC)
|
||||
|
||||
PIC_OBJS = $(PIC_OBJC)
|
||||
|
||||
all: static shared
|
||||
|
||||
static: example$(EXE) minigzip$(EXE) makefixed$(EXE) maketrees$(EXE) makecrct$(EXE)
|
||||
|
||||
shared: examplesh$(EXE) minigzipsh$(EXE)
|
||||
|
||||
check: test
|
||||
|
||||
.SECONDARY:
|
||||
|
||||
$(ARCHDIR)/%.o: $(SRCDIR)/$(ARCHDIR)/%.c
|
||||
$(MAKE) -C $(ARCHDIR) $(notdir $@)
|
||||
|
||||
$(ARCHDIR)/%.lo: $(SRCDIR)/$(ARCHDIR)/%.c
|
||||
$(MAKE) -C $(ARCHDIR) $(notdir $@)
|
||||
|
||||
arch/generic/%.o: $(SRCDIR)/arch/generic/%.c
|
||||
$(MAKE) -C arch/generic $(notdir $@)
|
||||
|
||||
arch/generic/%.lo: $(SRCDIR)/arch/generic/%.c
|
||||
$(MAKE) -C arch/generic $(notdir $@)
|
||||
|
||||
%.o: $(ARCHDIR)/%.o
|
||||
-cp $< $@
|
||||
|
||||
%.lo: $(ARCHDIR)/%.lo
|
||||
-cp $< $@
|
||||
|
||||
test: all
|
||||
$(MAKE) -C test
|
||||
|
||||
infcover.o: $(SRCDIR)/test/infcover.c zlib$(SUFFIX).h zconf$(SUFFIX).h zlib_name_mangling$(SUFFIX).h
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/test/infcover.c
|
||||
|
||||
infcover$(EXE): infcover.o $(STATICLIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ infcover.o $(STATICLIB)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
cover: infcover$(EXE)
|
||||
rm -f *.gcda
|
||||
./infcover
|
||||
gcov inf*.c
|
||||
|
||||
$(STATICLIB): $(OBJS)
|
||||
$(AR) $(ARFLAGS) $@ $(OBJS)
|
||||
-@ ($(RANLIB) $@ || true) >/dev/null 2>&1
|
||||
|
||||
example.o:
|
||||
$(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $(SRCDIR)/test/example.c
|
||||
|
||||
minigzip.o:
|
||||
$(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $(SRCDIR)/test/minigzip.c
|
||||
|
||||
makefixed.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/tools/makefixed.c
|
||||
|
||||
maketrees.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/tools/maketrees.c
|
||||
|
||||
makecrct.o:
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $(SRCDIR)/tools/makecrct.c
|
||||
|
||||
zlibrc.o: $(SRCDIR)/win32/zlib$(SUFFIX)1.rc
|
||||
$(RC) $(RCFLAGS) -o $@ $(SRCDIR)/win32/zlib$(SUFFIX)1.rc
|
||||
|
||||
.SUFFIXES: .lo
|
||||
|
||||
%.o: $(SRCDIR)/%.c
|
||||
$(CC) $(CFLAGS) $(INCLUDES) -c -o $@ $<
|
||||
|
||||
%.lo: $(SRCDIR)/%.c
|
||||
$(CC) $(SFLAGS) -DPIC $(INCLUDES) -c -o $@ $<
|
||||
|
||||
gzlib.o: $(SRCDIR)/gzlib.c
|
||||
$(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<
|
||||
|
||||
gzlib.lo: $(SRCDIR)/gzlib.c
|
||||
$(CC) $(SFLAGS) -DPIC -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<
|
||||
|
||||
gzread.o: gzread.c
|
||||
$(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<
|
||||
|
||||
gzread.lo: gzread.c
|
||||
$(CC) $(SFLAGS) -DPIC -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<
|
||||
|
||||
gzwrite.o: $(SRCDIR)/gzwrite.c
|
||||
$(CC) $(CFLAGS) -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<
|
||||
|
||||
gzwrite.lo: $(SRCDIR)/gzwrite.c
|
||||
$(CC) $(SFLAGS) -DPIC -DWITH_GZFILEOP $(INCLUDES) -c -o $@ $<
|
||||
|
||||
$(SHAREDTARGET): $(PIC_OBJS) $(DEFFILE) $(RCOBJS)
|
||||
ifneq ($(SHAREDTARGET),)
|
||||
$(LDSHARED) $(CFLAGS) $(LDSHAREDFLAGS) $(LDVERSIONSCRIPT) $(LDFLAGS) -o $@ $(DEFFILE) $(PIC_OBJS) $(RCOBJS) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
ifneq ($(SHAREDLIB),$(SHAREDTARGET))
|
||||
rm -f $(SHAREDLIB) $(SHAREDLIBM)
|
||||
ln -s $@ $(SHAREDLIB)
|
||||
ln -s $@ $(SHAREDLIBM)
|
||||
endif
|
||||
endif
|
||||
|
||||
example$(EXE): example.o $(TESTOBJG) $(STATICLIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ example.o $(TESTOBJG) $(TEST_LIBS) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
minigzip$(EXE): minigzip.o $(TESTOBJG) $(STATICLIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip.o $(TESTOBJG) $(TEST_LIBS) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
minigzipsh$(EXE): minigzip.o $(PIC_TESTOBJG) $(SHAREDTARGET)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip.o $(PIC_TESTOBJG) $(SHAREDLIB) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
|
||||
examplesh$(EXE): example.o $(PIC_TESTOBJG) $(SHAREDTARGET)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ example.o $(PIC_TESTOBJG) $(SHAREDLIB) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
makefixed$(EXE): makefixed.o $(STATICLIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ makefixed.o $(TEST_LIBS) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
maketrees$(EXE): maketrees.o $(STATICLIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ maketrees.o $(TEST_LIBS) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
makecrct$(EXE): makecrct.o $(STATICLIB)
|
||||
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ makecrct.o $(TEST_LIBS) $(LDSHAREDLIBC)
|
||||
ifneq ($(STRIP),)
|
||||
$(STRIP) $@
|
||||
endif
|
||||
|
||||
install-shared: $(SHAREDTARGET)
|
||||
ifneq ($(SHAREDTARGET),)
|
||||
-@if [ ! -d $(DESTDIR)$(sharedlibdir) ]; then mkdir -p $(DESTDIR)$(sharedlibdir); fi
|
||||
rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDTARGET)
|
||||
cp $(SHAREDTARGET) $(DESTDIR)$(sharedlibdir)
|
||||
chmod 755 $(DESTDIR)$(sharedlibdir)/$(SHAREDTARGET)
|
||||
ifneq ($(SHAREDLIB),$(SHAREDTARGET))
|
||||
rm -f $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM)
|
||||
ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIB)
|
||||
ln -s $(SHAREDLIBV) $(DESTDIR)$(sharedlibdir)/$(SHAREDLIBM)
|
||||
($(LDCONFIG) || true) >/dev/null 2>&1
|
||||
# ldconfig is for Linux
|
||||
endif
|
||||
ifneq ($(IMPORTLIB),)
|
||||
cp $(IMPORTLIB) $(DESTDIR)$(sharedlibdir)
|
||||
chmod 644 $(DESTDIR)$(sharedlibdir)/$(IMPORTLIB)
|
||||
endif
|
||||
endif
|
||||
|
||||
install-static: $(STATICLIB)
|
||||
-@if [ ! -d $(DESTDIR)$(libdir) ]; then mkdir -p $(DESTDIR)$(libdir); fi
|
||||
rm -f $(DESTDIR)$(libdir)/$(STATICLIB)
|
||||
cp $(STATICLIB) $(DESTDIR)$(libdir)
|
||||
chmod 644 $(DESTDIR)$(libdir)/$(STATICLIB)
|
||||
-@($(RANLIB) $(DESTDIR)$(libdir)/$(STATICLIB) || true) >/dev/null 2>&1
|
||||
# The ranlib in install-static is needed on NeXTSTEP which checks file times
|
||||
|
||||
install-libs: install-shared install-static
|
||||
-@if [ ! -d $(DESTDIR)$(man3dir) ]; then mkdir -p $(DESTDIR)$(man3dir); fi
|
||||
-@if [ ! -d $(DESTDIR)$(pkgconfigdir) ]; then mkdir -p $(DESTDIR)$(pkgconfigdir); fi
|
||||
rm -f $(DESTDIR)$(pkgconfigdir)/$(PKGFILE)
|
||||
cp $(PKGFILE) $(DESTDIR)$(pkgconfigdir)
|
||||
chmod 644 $(DESTDIR)$(pkgconfigdir)/$(PKGFILE)
|
||||
|
||||
install: install-libs
|
||||
-@if [ ! -d $(DESTDIR)$(includedir) ]; then mkdir -p $(DESTDIR)$(includedir); fi
|
||||
rm -f $(DESTDIR)$(includedir)/zlib$(SUFFIX).h $(DESTDIR)$(includedir)/zconf$(SUFFIX).h $(DESTDIR)$(includedir)/zlib_name_mangling$(SUFFIX).h
|
||||
cp zlib$(SUFFIX).h $(DESTDIR)$(includedir)/zlib$(SUFFIX).h
|
||||
cp zconf$(SUFFIX).h $(DESTDIR)$(includedir)/zconf$(SUFFIX).h
|
||||
cp zlib_name_mangling$(SUFFIX).h $(DESTDIR)$(includedir)/zlib_name_mangling$(SUFFIX).h
|
||||
chmod 644 $(DESTDIR)$(includedir)/zlib$(SUFFIX).h $(DESTDIR)$(includedir)/zconf$(SUFFIX).h $(DESTDIR)$(includedir)/zlib_name_mangling$(SUFFIX).h
|
||||
|
||||
uninstall-static:
|
||||
cd $(DESTDIR)$(libdir) && rm -f $(STATICLIB)
|
||||
|
||||
uninstall-shared:
|
||||
ifneq ($(SHAREDLIB),)
|
||||
cd $(DESTDIR)$(sharedlibdir) && rm -f $(SHAREDLIBV) $(SHAREDLIB) $(SHAREDLIBM)
|
||||
endif
|
||||
ifneq ($(IMPORTLIB),)
|
||||
cd $(DESTDIR)$(sharedlibdir) && rm -f $(IMPORTLIB)
|
||||
endif
|
||||
|
||||
uninstall: uninstall-static uninstall-shared
|
||||
cd $(DESTDIR)$(includedir) && rm -f zlib$(SUFFIX).h zconf$(SUFFIX).h zlib_name_mangling$(SUFFIX).h
|
||||
cd $(DESTDIR)$(pkgconfigdir) && rm -f $(PKGFILE)
|
||||
|
||||
mostlyclean: clean
|
||||
clean:
|
||||
@if [ -f $(ARCHDIR)/Makefile ]; then $(MAKE) -C $(ARCHDIR) clean; fi
|
||||
@if [ -f arch/generic/Makefile ]; then $(MAKE) -C arch/generic clean; fi
|
||||
@if [ -f test/Makefile ]; then $(MAKE) -C test clean; fi
|
||||
rm -f *.o *.lo *~ \
|
||||
example$(EXE) minigzip$(EXE) minigzipsh$(EXE) \
|
||||
infcover makefixed$(EXE) maketrees$(EXE) makecrct$(EXE) \
|
||||
$(STATICLIB) $(IMPORTLIB) $(SHAREDLIB) $(SHAREDLIBV) $(SHAREDLIBM) \
|
||||
foo.gz so_locations \
|
||||
_match.s maketree
|
||||
rm -rf objs
|
||||
rm -f *.gcda *.gcno *.gcov
|
||||
rm -f a.out a.exe
|
||||
rm -f *._h
|
||||
rm -rf btmp1 btmp2 pkgtmp1 pkgtmp2
|
||||
|
||||
maintainer-clean: distclean
|
||||
distclean: clean
|
||||
@if [ -f $(ARCHDIR)/Makefile ]; then $(MAKE) -C $(ARCHDIR) distclean; fi
|
||||
@if [ -f test/Makefile ]; then $(MAKE) -C test distclean; fi
|
||||
rm -f $(PKGFILE) configure.log zconf.h zconf.h.cmakein zlib$(SUFFIX).h zlib_name_mangling$(SUFFIX).h *.pc gzread.c
|
||||
-@rm -f .DS_Store
|
||||
# Reset Makefile if building inside source tree
|
||||
@if [ -f Makefile.in ]; then \
|
||||
printf 'all:\n\t-@echo "Please use ./configure first. Thank you."\n' > Makefile ; \
|
||||
printf '\ndistclean:\n\t$(MAKE) -f Makefile.in distclean\n' >> Makefile ; \
|
||||
touch -r $(SRCDIR)/Makefile.in Makefile ; fi
|
||||
# Reset zconf.h and zconf.h.cmakein if building inside source tree
|
||||
@if [ -f zconf.h.in ]; then \
|
||||
cp -p $(SRCDIR)/zconf.h.in zconf.h ; \
|
||||
grep -v '^#cmakedefine' $(SRCDIR)/zconf.h.in > zconf.h.cmakein &&\
|
||||
touch -r $(SRCDIR)/zconf.h.in zconf.h.cmakein ; fi
|
||||
# Cleanup these files if building outside source tree
|
||||
@if [ ! -f README.md ]; then rm -f Makefile; fi
|
||||
# Remove arch and test directory if building outside source tree
|
||||
@if [ ! -f $(ARCHDIR)/Makefile.in ]; then rm -rf arch; fi
|
||||
@if [ ! -f test/Makefile.in ]; then rm -rf test; fi
|
||||
|
||||
tags:
|
||||
etags $(SRCDIR)/*.[ch]
|
||||
@@ -1,111 +0,0 @@
|
||||
Porting applications to use zlib-ng
|
||||
===================================
|
||||
|
||||
Zlib-ng can be used/compiled in two different modes, that require some
|
||||
consideration by the application developer.
|
||||
|
||||
Changes from zlib affecting native and compat modes
|
||||
---------------------------------------------------
|
||||
Zlib-ng is not as conservative with memory allocation as Zlib is.
|
||||
|
||||
Where Zlib's inflate will allocate a lower amount of memory depending on
|
||||
compression level and window size, zlib-ng will always allocate the maximum
|
||||
amount of memory and possibly leave parts of it unused.
|
||||
Zlib-ng's deflate will however allocate a lower amount of memory depending
|
||||
on compression level and window size.
|
||||
|
||||
Zlib-ng also allocates one "big" buffer instead of doing multiple smaller
|
||||
allocations. This is faster, can lead to better cache locality and reduces
|
||||
space lost to alignment padding.
|
||||
|
||||
At the time of writing, by default zlib-ng allocates the following amounts
|
||||
of memory on a 64-bit system (except on S390x that requires ~4KiB more):
|
||||
- Deflate: 350.272 Bytes
|
||||
- Inflate: 42.112 Bytes
|
||||
|
||||
**Advantages:**
|
||||
- All memory is allocated during DeflateInit or InflateInit functions,
|
||||
leaving the actual deflate/inflate functions free from allocations.
|
||||
- Zlib-ng can only fail from memory allocation errors during init.
|
||||
- Time spent doing memory allocation systemcalls is all done during init,
|
||||
allowing applications to do prepare this before doing latency-sensitive
|
||||
deflate/inflate later.
|
||||
- Can reduce wasted memory due to buffer alignment padding both by OS and zlib-ng.
|
||||
- Potentially improved memory locality.
|
||||
|
||||
**Disadvantages:**
|
||||
- Zlib-ng allocates a little more memory than zlib does.
|
||||
|
||||
zlib-compat mode
|
||||
----------------
|
||||
Zlib-ng can be compiled in zlib-compat mode, suitable for zlib-replacement
|
||||
in a single application or system-wide.
|
||||
|
||||
Please note that zlib-ng in zlib-compat mode tries to maintain both API and
|
||||
ABI compatibility with the original zlib. Any issues regarding compatibility
|
||||
can be reported as bugs.
|
||||
|
||||
In certain instances you may not be able to simply replace the zlib library/dll
|
||||
files and expect the application to work. The application may need to be
|
||||
recompiled against the zlib-ng headers and libs to ensure full compatibility.
|
||||
|
||||
It is also possible for the deflate output stream to differ from the original
|
||||
zlib due to algorithmic differences between the two libraries. Any tests or
|
||||
applications that depend on the exact length of the deflate stream being a
|
||||
certain value will need to be updated.
|
||||
|
||||
**Advantages:**
|
||||
- Easy to port to, since it only requires a recompile of the application and
|
||||
no changes to the application code.
|
||||
|
||||
**Disadvantages:**
|
||||
- Can conflict with a system-installed zlib, as that can often be linked in
|
||||
by another library you are linking into your application. This can cause
|
||||
crashes or incorrect output.
|
||||
- If your application is pre-allocating a memory buffer and you are providing
|
||||
deflate/inflate init with your own allocator that allocates from that buffer
|
||||
(looking at you nginx), you should be aware that zlib-ng needs to allocate
|
||||
more memory than stock zlib needs. The same problem exists with Intel’s and
|
||||
Cloudflare’s zlib forks. Doing this is not recommended since it makes it
|
||||
very hard to maintain compatibility over time.
|
||||
|
||||
**Build Considerations:**
|
||||
- Compile against the *zlib.h* provided by zlib-ng
|
||||
- Configuration header is named *zconf.h*
|
||||
- Static library is *libz.a* on Unix and macOS, or *zlib.lib* on Windows
|
||||
- Shared library is *libz.so* on Unix, *libz.dylib* on macOS, or *zlib1.dll*
|
||||
on Windows
|
||||
- Type `z_size_t` is *unsigned __int64* on 64-bit Windows, and *unsigned long* on 32-bit Windows, Unix and macOS
|
||||
- Type `z_uintmax_t` is *unsigned long* in zlib-compat mode, and *size_t* with zlib-ng API
|
||||
|
||||
zlib-ng native mode
|
||||
-------------------
|
||||
Zlib-ng in native mode is suitable for co-existing with the standard zlib
|
||||
library, allowing applications to implement support and testing separately.
|
||||
|
||||
The zlib-ng native has implemented some modernization and simplifications
|
||||
in its API, intended to make life easier for application developers.
|
||||
|
||||
**Advantages:**
|
||||
- Does not conflict with other zlib implementations, and can co-exist as a
|
||||
system library along with zlib.
|
||||
- In certain places zlib-ng native uses more appropriate data types, removing
|
||||
the need for some workarounds in the API compared to zlib.
|
||||
|
||||
**Disadvantages:**
|
||||
- Requires minor changes to applications to use the prefixed zlib-ng
|
||||
function calls and structs. Usually this means a small prefix `zng_` has to be added.
|
||||
|
||||
**Build Considerations:**
|
||||
- Compile against *zlib-ng.h*
|
||||
- Configuration header is named *zconf-ng.h*
|
||||
- Static library is *libz-ng.a* on Unix and macOS, or *zlib-ng.lib* on Windows
|
||||
- Shared library is *libz-ng.so* on Unix, *libz-ng.dylib* on macOS, or
|
||||
*zlib-ng2.dll* on Windows
|
||||
- Type `z_size_t` is *size_t*
|
||||
|
||||
zlib-ng compile-time detection
|
||||
------------------------------
|
||||
|
||||
To distinguish zlib-ng from other zlib implementations at compile-time check for the
|
||||
existence of `ZLIBNG_VERSION` defined in the zlib header.
|
||||
@@ -1,228 +0,0 @@
|
||||
| CI | Stable | Develop |
|
||||
|:---|:-------|:--------|
|
||||
| GitHub Actions | [](https://github.com/zlib-ng/zlib-ng/actions/workflows/cmake.yml?query=branch%3Astable) <br> [](https://github.com/zlib-ng/zlib-ng/actions/workflows/configure.yml?query=branch%3Astable) <br> [](https://github.com/zlib-ng/zlib-ng/actions/workflows/nmake.yml?query=branch%3Astable) | [](https://github.com/zlib-ng/zlib-ng/actions/workflows/cmake.yml?query=branch%3Adevelop) <br> [](https://github.com/zlib-ng/zlib-ng/actions/workflows/configure.yml?query=branch%3Adevelop) <br> [](https://github.com/zlib-ng/zlib-ng/actions/workflows/nmake.yml?query=branch%3Adevelop) |
|
||||
| CodeFactor | [](https://www.codefactor.io/repository/github/zlib-ng/zlib-ng/overview/stable) | [](https://www.codefactor.io/repository/github/zlib-ng/zlib-ng/overview/develop) |
|
||||
| OSS-Fuzz | [](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:zlib-ng) | [](https://bugs.chromium.org/p/oss-fuzz/issues/list?sort=-opened&can=1&q=proj:zlib-ng) |
|
||||
| Codecov | [](https://codecov.io/github/zlib-ng/zlib-ng/tree/stable) | [](https://codecov.io/github/zlib-ng/zlib-ng/tree/develop) |
|
||||
|
||||
## zlib-ng
|
||||
*zlib data compression library for the next generation systems*
|
||||
|
||||
Maintained by Hans Kristian Rosbach
|
||||
aka Dead2 (zlib-ng àt circlestorm dót org)
|
||||
|
||||
Features
|
||||
--------
|
||||
|
||||
* Zlib compatible API with support for dual-linking
|
||||
* Modernized native API based on zlib API for ease of porting
|
||||
* Modern C11 syntax and a clean code layout
|
||||
* Deflate medium and quick algorithms based on Intel’s zlib fork
|
||||
* Support for CPU intrinsics when available
|
||||
* Adler32 implementation using SSSE3, AVX2, AVX512, AVX512-VNNI, Neon, VMX & VSX
|
||||
* CRC32-B implementation using PCLMULQDQ, VPCLMULQDQ, ARMv8, & IBM Z
|
||||
* Slide hash implementations using SSE2, AVX2, ARMv6, Neon, VMX & VSX
|
||||
* Compare256 implementations using SSE2, AVX2, Neon, POWER9 & RVV
|
||||
* Inflate chunk copying using SSE2, SSSE3, AVX, Neon & VSX
|
||||
* Support for hardware-accelerated deflate using IBM Z DFLTCC
|
||||
* Safe unaligned memory read/writes and large bit buffer improvements
|
||||
* Includes improvements from Cloudflare and Intel forks
|
||||
* Configure, CMake, and NMake build system support
|
||||
* Comprehensive set of CMake unit tests
|
||||
* Code sanitizers, fuzzing, and coverage
|
||||
* GitHub Actions continuous integration on Windows, macOS, and Linux
|
||||
* Emulated CI for ARM, AARCH64, PPC, PPC64, RISCV, SPARC64, S390x using qemu
|
||||
|
||||
|
||||
History
|
||||
-------
|
||||
|
||||
The motivation for this fork was seeing several 3rd party contributions with new optimizations not getting
|
||||
implemented into the official zlib repository.
|
||||
|
||||
Mark Adler has been maintaining zlib for a very long time, and he has done a great job and hopefully he will continue
|
||||
for a long time yet. The idea of zlib-ng is not to replace zlib, but to co-exist as a drop-in replacement with a
|
||||
lower threshold for code change.
|
||||
|
||||
zlib has a long history and is incredibly portable, even supporting many systems that predate the Internet.<br>
|
||||
That is great, but it can complicate further development and maintainability. The zlib code contains many workarounds
|
||||
for really old compilers or to accommodate systems with limitations such as operating in a 16-bit environment.
|
||||
|
||||
Many of these workarounds are only maintenance burdens, some of them are pretty huge code-wise. With many workarounds
|
||||
cluttered throughout the code, it makes it harder for new programmers with an idea/interest for zlib to contribute.
|
||||
|
||||
I decided to make a fork, merge all the Intel optimizations, some of the Cloudflare optimizations, plus a couple other
|
||||
smaller patches. Then started cleaning out workarounds, various dead code, all contrib and example code.<br>
|
||||
The result is a better performing and easier to maintain zlib-ng.
|
||||
|
||||
A lot of improvements have gone into zlib-ng since its start, and numerous people and companies have contributed both
|
||||
small and big improvements, or valuable testing.
|
||||
|
||||
|
||||
Build
|
||||
-----
|
||||
<sup>Please read LICENSE.md, it is very simple and very liberal.</sup>
|
||||
|
||||
There are two ways to build zlib-ng:
|
||||
|
||||
### Cmake
|
||||
|
||||
To build zlib-ng using the cross-platform makefile generator cmake.
|
||||
|
||||
```
|
||||
cmake .
|
||||
cmake --build . --config Release
|
||||
ctest --verbose -C Release
|
||||
```
|
||||
|
||||
Alternatively, you can use the cmake configuration GUI tool ccmake:
|
||||
|
||||
```
|
||||
ccmake .
|
||||
```
|
||||
|
||||
### Configure
|
||||
|
||||
To build zlib-ng using the bash configure script:
|
||||
|
||||
```
|
||||
./configure
|
||||
make
|
||||
make test
|
||||
```
|
||||
|
||||
Build Options
|
||||
-------------
|
||||
|
||||
| CMake | configure | Description | Default |
|
||||
|:---------------------------|:-------------------------|:------------------------------------------------------------------------------------|---------|
|
||||
| ZLIB_COMPAT | --zlib-compat | Compile with zlib compatible API | OFF |
|
||||
| ZLIB_ENABLE_TESTS | | Build test binaries | ON |
|
||||
| WITH_GZFILEOP | --without-gzfileops | Compile with support for gzFile related functions | ON |
|
||||
| WITH_OPTIM | --without-optimizations | Build with optimisations | ON |
|
||||
| WITH_NEW_STRATEGIES | --without-new-strategies | Use new strategies | ON |
|
||||
| WITH_NATIVE_INSTRUCTIONS | | Compiles with full instruction set supported on this host (gcc/clang -march=native) | OFF |
|
||||
| WITH_RUNTIME_CPU_DETECTION | | Compiles with runtime CPU detection | ON |
|
||||
| WITH_SANITIZER | | Build with sanitizer (memory, address, undefined) | OFF |
|
||||
| WITH_GTEST | | Build gtest_zlib | ON |
|
||||
| WITH_FUZZERS | | Build test/fuzz | OFF |
|
||||
| WITH_BENCHMARKS | | Build test/benchmarks | OFF |
|
||||
| WITH_MAINTAINER_WARNINGS | | Build with project maintainer warnings | OFF |
|
||||
| WITH_CODE_COVERAGE | | Enable code coverage reporting | OFF |
|
||||
|
||||
|
||||
Install
|
||||
-------
|
||||
|
||||
WARNING: We do not recommend manually installing unless you really know what you are doing, because this can
|
||||
potentially override the system default zlib library, and any incompatibility or wrong configuration of zlib-ng
|
||||
can make the whole system unusable, requiring recovery or reinstall.
|
||||
If you still want a manual install, we recommend using the /opt/ path prefix.
|
||||
|
||||
For Linux distros, an alternative way to use zlib-ng (if compiled in zlib-compat mode) instead of zlib, is through
|
||||
the use of the _LD_PRELOAD_ environment variable. If the program is dynamically linked with zlib, then the program
|
||||
will temporarily attempt to use zlib-ng instead, without risking system-wide instability.
|
||||
|
||||
```
|
||||
LD_PRELOAD=/opt/zlib-ng/libz.so.1.2.13.zlib-ng /usr/bin/program
|
||||
```
|
||||
|
||||
### Cmake
|
||||
|
||||
To install zlib-ng system-wide using cmake:
|
||||
|
||||
```sh or powershell
|
||||
cmake --build . --target install
|
||||
```
|
||||
|
||||
### Configure
|
||||
|
||||
To install zlib-ng system-wide using the configure script:
|
||||
|
||||
```sh
|
||||
make install
|
||||
```
|
||||
|
||||
### CPack
|
||||
|
||||
After building with cmake, an installation package can be created using cpack. By default a tgz package is created,
|
||||
but you can append `-G <format>` to each command to generate alternative packages types (TGZ, ZIP, RPM, DEB). To easily
|
||||
create a rpm or deb package, you would use `-G RPM` or `-G DEB` respectively.
|
||||
|
||||
```sh or powershell
|
||||
cd build
|
||||
cpack --config CPackConfig.cmake
|
||||
cpack --config CPackSourceConfig.cmake
|
||||
```
|
||||
|
||||
### Vcpkg
|
||||
|
||||
Alternatively, you can build and install zlib-ng using the [vcpkg](https://github.com/Microsoft/vcpkg/) dependency manager:
|
||||
|
||||
```sh or powershell
|
||||
git clone https://github.com/Microsoft/vcpkg.git
|
||||
cd vcpkg
|
||||
./bootstrap-vcpkg.sh # "./bootstrap-vcpkg.bat" for powershell
|
||||
./vcpkg integrate install
|
||||
./vcpkg install zlib-ng
|
||||
```
|
||||
|
||||
The zlib-ng port in vcpkg is kept up to date by Microsoft team members and community contributors.
|
||||
If the version is out of date, please [create an issue or pull request](https://github.com/Microsoft/vcpkg) on the vcpkg repository.
|
||||
|
||||
Contributing
|
||||
------------
|
||||
|
||||
Zlib-ng is aiming to be open to contributions, and we would be delighted to receive pull requests on github.
|
||||
Help with testing and reviewing pull requests etc is also very much appreciated.
|
||||
|
||||
Please check the Wiki for more info: [Contributing](https://github.com/zlib-ng/zlib-ng/wiki/Contributing)
|
||||
|
||||
Acknowledgments
|
||||
----------------
|
||||
|
||||
Thanks go out to all the people and companies who have taken the time to contribute
|
||||
code reviews, testing and/or patches. Zlib-ng would not have been nearly as good without you.
|
||||
|
||||
The deflate format used by zlib was defined by Phil Katz.<br>
|
||||
The deflate and zlib specifications were written by L. Peter Deutsch.
|
||||
|
||||
zlib was originally created by Jean-loup Gailly (compression) and Mark Adler (decompression).
|
||||
|
||||
|
||||
Advanced Build Options
|
||||
----------------------
|
||||
|
||||
| CMake | configure | Description | Default |
|
||||
|:--------------------------------|:----------------------|:--------------------------------------------------------------------|------------------------|
|
||||
| FORCE_SSE2 | --force-sse2 | Skip runtime check for SSE2 instructions (Always on for x86_64) | OFF (x86) |
|
||||
| WITH_AVX2 | | Build with AVX2 intrinsics | ON |
|
||||
| WITH_AVX512 | | Build with AVX512 intrinsics | ON |
|
||||
| WITH_AVX512VNNI | | Build with AVX512VNNI intrinsics | ON |
|
||||
| WITH_SSE2 | | Build with SSE2 intrinsics | ON |
|
||||
| WITH_SSSE3 | | Build with SSSE3 intrinsics | ON |
|
||||
| WITH_SSE42 | | Build with SSE42 intrinsics | ON |
|
||||
| WITH_PCLMULQDQ | | Build with PCLMULQDQ intrinsics | ON |
|
||||
| WITH_VPCLMULQDQ | --without-vpclmulqdq | Build with VPCLMULQDQ intrinsics | ON |
|
||||
| WITH_ARMV8 | --without-armv8 | Build with ARMv8 intrinsics | ON |
|
||||
| WITH_NEON | --without-neon | Build with NEON intrinsics | ON |
|
||||
| WITH_ARMV6 | --without-armv6 | Build with ARMv6 intrinsics | ON |
|
||||
| WITH_ALTIVEC | --without-altivec | Build with AltiVec (VMX) intrinsics | ON |
|
||||
| WITH_POWER8 | --without-power8 | Build with POWER8 optimisations | ON |
|
||||
| WITH_RVV | | Build with RVV intrinsics | ON |
|
||||
| WITH_CRC32_VX | --without-crc32-vx | Build with vectorized CRC32 on IBM Z | ON |
|
||||
| WITH_DFLTCC_DEFLATE | --with-dfltcc-deflate | Build with DFLTCC intrinsics for compression on IBM Z | OFF |
|
||||
| WITH_DFLTCC_INFLATE | --with-dfltcc-inflate | Build with DFLTCC intrinsics for decompression on IBM Z | OFF |
|
||||
| WITH_INFLATE_STRICT | | Build with strict inflate distance checking | OFF |
|
||||
| WITH_INFLATE_ALLOW_INVALID_DIST | | Build with zero fill for inflate invalid distances | OFF |
|
||||
| INSTALL_UTILS | | Copy minigzip and minideflate during install | OFF |
|
||||
| ZLIBNG_ENABLE_TESTS | | Test zlib-ng specific API | ON |
|
||||
|
||||
|
||||
Related Projects
|
||||
----------------
|
||||
|
||||
* Fork of the popular minizip https://github.com/zlib-ng/minizip-ng
|
||||
* Python tool to benchmark minigzip/minideflate https://github.com/zlib-ng/deflatebench
|
||||
* Python tool to benchmark pigz https://github.com/zlib-ng/pigzbench
|
||||
* 3rd party patches for zlib-ng compatibility https://github.com/zlib-ng/patches
|
||||
+128
-33
@@ -3,47 +3,148 @@
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "functable.h"
|
||||
#include "adler32_p.h"
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#ifdef ZLIB_COMPAT
|
||||
unsigned long Z_EXPORT PREFIX(adler32_z)(unsigned long adler, const unsigned char *buf, size_t len) {
|
||||
return (unsigned long)FUNCTABLE_CALL(adler32)((uint32_t)adler, buf, len);
|
||||
}
|
||||
#include "zutil.h"
|
||||
|
||||
#define BASE 65521U /* largest prime smaller than 65536 */
|
||||
#define NMAX 5552
|
||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||
|
||||
#define DO1(buf,i) {adler += (buf)[i]; sum2 += adler;}
|
||||
#define DO2(buf,i) DO1(buf,i); DO1(buf,i+1);
|
||||
#define DO4(buf,i) DO2(buf,i); DO2(buf,i+2);
|
||||
#define DO8(buf,i) DO4(buf,i); DO4(buf,i+4);
|
||||
#define DO16(buf) DO8(buf,0); DO8(buf,8);
|
||||
|
||||
/* use NO_DIVIDE if your processor does not do division in hardware --
|
||||
try it both ways to see which is faster */
|
||||
#ifdef NO_DIVIDE
|
||||
/* note that this assumes BASE is 65521, where 65536 % 65521 == 15
|
||||
(thank you to John Reiser for pointing this out) */
|
||||
# define CHOP(a) \
|
||||
do { \
|
||||
unsigned long tmp = a >> 16; \
|
||||
a &= 0xffffUL; \
|
||||
a += (tmp << 4) - tmp; \
|
||||
} while (0)
|
||||
# define MOD28(a) \
|
||||
do { \
|
||||
CHOP(a); \
|
||||
if (a >= BASE) a -= BASE; \
|
||||
} while (0)
|
||||
# define MOD(a) \
|
||||
do { \
|
||||
CHOP(a); \
|
||||
MOD28(a); \
|
||||
} while (0)
|
||||
# define MOD63(a) \
|
||||
do { /* this assumes a is not negative */ \
|
||||
z_off64_t tmp = a >> 32; \
|
||||
a &= 0xffffffffL; \
|
||||
a += (tmp << 8) - (tmp << 5) + tmp; \
|
||||
tmp = a >> 16; \
|
||||
a &= 0xffffL; \
|
||||
a += (tmp << 4) - tmp; \
|
||||
tmp = a >> 16; \
|
||||
a &= 0xffffL; \
|
||||
a += (tmp << 4) - tmp; \
|
||||
if (a >= BASE) a -= BASE; \
|
||||
} while (0)
|
||||
#else
|
||||
uint32_t Z_EXPORT PREFIX(adler32_z)(uint32_t adler, const unsigned char *buf, size_t len) {
|
||||
return FUNCTABLE_CALL(adler32)(adler, buf, len);
|
||||
}
|
||||
# define MOD(a) a %= BASE
|
||||
# define MOD28(a) a %= BASE
|
||||
# define MOD63(a) a %= BASE
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
#ifdef ZLIB_COMPAT
|
||||
unsigned long Z_EXPORT PREFIX(adler32)(unsigned long adler, const unsigned char *buf, unsigned int len) {
|
||||
return (unsigned long)FUNCTABLE_CALL(adler32)((uint32_t)adler, buf, len);
|
||||
uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
|
||||
unsigned long sum2;
|
||||
unsigned n;
|
||||
|
||||
/* split Adler-32 into component sums */
|
||||
sum2 = (adler >> 16) & 0xffff;
|
||||
adler &= 0xffff;
|
||||
|
||||
/* in case user likes doing a byte at a time, keep it fast */
|
||||
if (len == 1) {
|
||||
adler += buf[0];
|
||||
if (adler >= BASE)
|
||||
adler -= BASE;
|
||||
sum2 += adler;
|
||||
if (sum2 >= BASE)
|
||||
sum2 -= BASE;
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* initial Adler-32 value (deferred check for len == 1 speed) */
|
||||
if (buf == Z_NULL)
|
||||
return 1L;
|
||||
|
||||
/* in case short lengths are provided, keep it somewhat fast */
|
||||
if (len < 16) {
|
||||
while (len--) {
|
||||
adler += *buf++;
|
||||
sum2 += adler;
|
||||
}
|
||||
if (adler >= BASE)
|
||||
adler -= BASE;
|
||||
MOD28(sum2); /* only added so many BASE's */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
/* do length NMAX blocks -- requires just one modulo operation */
|
||||
while (len >= NMAX) {
|
||||
len -= NMAX;
|
||||
n = NMAX / 16; /* NMAX is divisible by 16 */
|
||||
do {
|
||||
DO16(buf); /* 16 sums unrolled */
|
||||
buf += 16;
|
||||
} while (--n);
|
||||
MOD(adler);
|
||||
MOD(sum2);
|
||||
}
|
||||
|
||||
/* do remaining bytes (less than NMAX, still just one modulo) */
|
||||
if (len) { /* avoid modulos if none remaining */
|
||||
while (len >= 16) {
|
||||
len -= 16;
|
||||
DO16(buf);
|
||||
buf += 16;
|
||||
}
|
||||
while (len--) {
|
||||
adler += *buf++;
|
||||
sum2 += adler;
|
||||
}
|
||||
MOD(adler);
|
||||
MOD(sum2);
|
||||
}
|
||||
|
||||
/* return recombined sums */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
#else
|
||||
uint32_t Z_EXPORT PREFIX(adler32)(uint32_t adler, const unsigned char *buf, uint32_t len) {
|
||||
return FUNCTABLE_CALL(adler32)(adler, buf, len);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len2) {
|
||||
uint32_t sum1;
|
||||
uint32_t sum2;
|
||||
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
|
||||
return adler32_z(adler, buf, len);
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
|
||||
unsigned long sum1;
|
||||
unsigned long sum2;
|
||||
unsigned rem;
|
||||
|
||||
/* for negative len, return invalid adler32 as a clue for debugging */
|
||||
if (len2 < 0)
|
||||
return 0xffffffff;
|
||||
return 0xffffffffUL;
|
||||
|
||||
/* the derivation of this formula is left as an exercise for the reader */
|
||||
len2 %= BASE; /* assumes len2 >= 0 */
|
||||
MOD63(len2); /* assumes len2 >= 0 */
|
||||
rem = (unsigned)len2;
|
||||
sum1 = adler1 & 0xffff;
|
||||
sum2 = rem * sum1;
|
||||
sum2 %= BASE;
|
||||
MOD(sum2);
|
||||
sum1 += (adler2 & 0xffff) + BASE - 1;
|
||||
sum2 += ((adler1 >> 16) & 0xffff) + ((adler2 >> 16) & 0xffff) + BASE - rem;
|
||||
if (sum1 >= BASE) sum1 -= BASE;
|
||||
@@ -54,16 +155,10 @@ static uint32_t adler32_combine_(uint32_t adler1, uint32_t adler2, z_off64_t len
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
#ifdef ZLIB_COMPAT
|
||||
unsigned long Z_EXPORT PREFIX(adler32_combine)(unsigned long adler1, unsigned long adler2, z_off_t len2) {
|
||||
return (unsigned long)adler32_combine_((uint32_t)adler1, (uint32_t)adler2, len2);
|
||||
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) {
|
||||
return adler32_combine_(adler1, adler2, len2);
|
||||
}
|
||||
|
||||
unsigned long Z_EXPORT PREFIX4(adler32_combine)(unsigned long adler1, unsigned long adler2, z_off64_t len2) {
|
||||
return (unsigned long)adler32_combine_((uint32_t)adler1, (uint32_t)adler2, len2);
|
||||
}
|
||||
#else
|
||||
uint32_t Z_EXPORT PREFIX4(adler32_combine)(uint32_t adler1, uint32_t adler2, z_off64_t len2) {
|
||||
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) {
|
||||
return adler32_combine_(adler1, adler2, len2);
|
||||
}
|
||||
#endif
|
||||
@@ -1,70 +0,0 @@
|
||||
/* adler32_p.h -- Private inline functions and macros shared with
|
||||
* different computation of the Adler-32 checksum
|
||||
* of a data stream.
|
||||
* Copyright (C) 1995-2011, 2016 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#ifndef ADLER32_P_H
|
||||
#define ADLER32_P_H
|
||||
|
||||
#define BASE 65521U /* largest prime smaller than 65536 */
|
||||
#define NMAX 5552
|
||||
/* NMAX is the largest n such that 255n(n+1)/2 + (n+1)(BASE-1) <= 2^32-1 */
|
||||
|
||||
#define ADLER_DO1(sum1, sum2, buf, i) {(sum1) += buf[(i)]; (sum2) += (sum1);}
|
||||
#define ADLER_DO2(sum1, sum2, buf, i) {ADLER_DO1(sum1, sum2, buf, i); ADLER_DO1(sum1, sum2, buf, i+1);}
|
||||
#define ADLER_DO4(sum1, sum2, buf, i) {ADLER_DO2(sum1, sum2, buf, i); ADLER_DO2(sum1, sum2, buf, i+2);}
|
||||
#define ADLER_DO8(sum1, sum2, buf, i) {ADLER_DO4(sum1, sum2, buf, i); ADLER_DO4(sum1, sum2, buf, i+4);}
|
||||
#define ADLER_DO16(sum1, sum2, buf) {ADLER_DO8(sum1, sum2, buf, 0); ADLER_DO8(sum1, sum2, buf, 8);}
|
||||
|
||||
static inline uint32_t adler32_len_1(uint32_t adler, const uint8_t *buf, uint32_t sum2) {
|
||||
adler += buf[0];
|
||||
adler %= BASE;
|
||||
sum2 += adler;
|
||||
sum2 %= BASE;
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
static inline uint32_t adler32_len_16(uint32_t adler, const uint8_t *buf, size_t len, uint32_t sum2) {
|
||||
while (len) {
|
||||
--len;
|
||||
adler += *buf++;
|
||||
sum2 += adler;
|
||||
}
|
||||
adler %= BASE;
|
||||
sum2 %= BASE; /* only added so many BASE's */
|
||||
/* return recombined sums */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
static inline uint32_t adler32_copy_len_16(uint32_t adler, const uint8_t *buf, uint8_t *dst, size_t len, uint32_t sum2) {
|
||||
while (len--) {
|
||||
*dst = *buf++;
|
||||
adler += *dst++;
|
||||
sum2 += adler;
|
||||
}
|
||||
adler %= BASE;
|
||||
sum2 %= BASE; /* only added so many BASE's */
|
||||
/* return recombined sums */
|
||||
return adler | (sum2 << 16);
|
||||
}
|
||||
|
||||
static inline uint32_t adler32_len_64(uint32_t adler, const uint8_t *buf, size_t len, uint32_t sum2) {
|
||||
#ifdef UNROLL_MORE
|
||||
while (len >= 16) {
|
||||
len -= 16;
|
||||
ADLER_DO16(adler, sum2, buf);
|
||||
buf += 16;
|
||||
#else
|
||||
while (len >= 8) {
|
||||
len -= 8;
|
||||
ADLER_DO8(adler, sum2, buf, 0);
|
||||
buf += 8;
|
||||
#endif
|
||||
}
|
||||
/* Process tail (len < 16). */
|
||||
return adler32_len_16(adler, buf, len, sum2);
|
||||
}
|
||||
|
||||
#endif /* ADLER32_P_H */
|
||||
@@ -1,29 +0,0 @@
|
||||
/* arch_functions.h -- Arch-specific function prototypes.
|
||||
* Copyright (C) 2017 Hans Kristian Rosbach
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#ifndef CPU_FUNCTIONS_H_
|
||||
#define CPU_FUNCTIONS_H_
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "zutil.h"
|
||||
#include "crc32.h"
|
||||
#include "deflate.h"
|
||||
#include "fallback_builtins.h"
|
||||
|
||||
#include "arch/generic/generic_functions.h"
|
||||
|
||||
#if defined(X86_FEATURES)
|
||||
# include "arch/x86/x86_functions.h"
|
||||
#elif defined(ARM_FEATURES)
|
||||
# include "arch/arm/arm_functions.h"
|
||||
#elif defined(PPC_FEATURES) || defined(POWER_FEATURES)
|
||||
# include "arch/power/power_functions.h"
|
||||
#elif defined(S390_FEATURES)
|
||||
# include "arch/s390/s390_functions.h"
|
||||
#elif defined(RISCV_FEATURES)
|
||||
# include "arch/riscv/riscv_functions.h"
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -1,283 +0,0 @@
|
||||
/* chunkset_tpl.h -- inline functions to copy small data chunks.
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include <stdlib.h>
|
||||
|
||||
/* Returns the chunk size */
|
||||
Z_INTERNAL uint32_t CHUNKSIZE(void) {
|
||||
return sizeof(chunk_t);
|
||||
}
|
||||
|
||||
/* Behave like memcpy, but assume that it's OK to overwrite at least
|
||||
chunk_t bytes of output even if the length is shorter than this,
|
||||
that the length is non-zero, and that `from` lags `out` by at least
|
||||
sizeof chunk_t bytes (or that they don't overlap at all or simply that
|
||||
the distance is less than the length of the copy).
|
||||
|
||||
Aside from better memory bus utilisation, this means that short copies
|
||||
(chunk_t bytes or fewer) will fall straight through the loop
|
||||
without iteration, which will hopefully make the branch prediction more
|
||||
reliable. */
|
||||
#ifndef HAVE_CHUNKCOPY
|
||||
static inline uint8_t* CHUNKCOPY(uint8_t *out, uint8_t const *from, unsigned len) {
|
||||
Assert(len > 0, "chunkcopy should never have a length 0");
|
||||
chunk_t chunk;
|
||||
int32_t align = ((len - 1) % sizeof(chunk_t)) + 1;
|
||||
loadchunk(from, &chunk);
|
||||
storechunk(out, &chunk);
|
||||
out += align;
|
||||
from += align;
|
||||
len -= align;
|
||||
while (len > 0) {
|
||||
loadchunk(from, &chunk);
|
||||
storechunk(out, &chunk);
|
||||
out += sizeof(chunk_t);
|
||||
from += sizeof(chunk_t);
|
||||
len -= sizeof(chunk_t);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Perform short copies until distance can be rewritten as being at least
|
||||
sizeof chunk_t.
|
||||
|
||||
This assumes that it's OK to overwrite at least the first
|
||||
2*sizeof(chunk_t) bytes of output even if the copy is shorter than this.
|
||||
This assumption holds because inflate_fast() starts every iteration with at
|
||||
least 258 bytes of output space available (258 being the maximum length
|
||||
output from a single token; see inflate_fast()'s assumptions below). */
|
||||
#ifndef HAVE_CHUNKUNROLL
|
||||
static inline uint8_t* CHUNKUNROLL(uint8_t *out, unsigned *dist, unsigned *len) {
|
||||
unsigned char const *from = out - *dist;
|
||||
chunk_t chunk;
|
||||
while (*dist < *len && *dist < sizeof(chunk_t)) {
|
||||
loadchunk(from, &chunk);
|
||||
storechunk(out, &chunk);
|
||||
out += *dist;
|
||||
*len -= *dist;
|
||||
*dist += *dist;
|
||||
}
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_CHUNK_MAG
|
||||
/* Loads a magazine to feed into memory of the pattern */
|
||||
static inline chunk_t GET_CHUNK_MAG(uint8_t *buf, uint32_t *chunk_rem, uint32_t dist) {
|
||||
/* This code takes string of length dist from "from" and repeats
|
||||
* it for as many times as can fit in a chunk_t (vector register) */
|
||||
uint64_t cpy_dist;
|
||||
uint64_t bytes_remaining = sizeof(chunk_t);
|
||||
chunk_t chunk_load;
|
||||
uint8_t *cur_chunk = (uint8_t *)&chunk_load;
|
||||
while (bytes_remaining) {
|
||||
cpy_dist = MIN(dist, bytes_remaining);
|
||||
memcpy(cur_chunk, buf, (size_t)cpy_dist);
|
||||
bytes_remaining -= cpy_dist;
|
||||
cur_chunk += cpy_dist;
|
||||
/* This allows us to bypass an expensive integer division since we're effectively
|
||||
* counting in this loop, anyway */
|
||||
*chunk_rem = (uint32_t)cpy_dist;
|
||||
}
|
||||
|
||||
return chunk_load;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_HALF_CHUNK) && !defined(HAVE_HALFCHUNKCOPY)
|
||||
static inline uint8_t* HALFCHUNKCOPY(uint8_t *out, uint8_t const *from, unsigned len) {
|
||||
halfchunk_t chunk;
|
||||
int32_t align = ((len - 1) % sizeof(halfchunk_t)) + 1;
|
||||
loadhalfchunk(from, &chunk);
|
||||
storehalfchunk(out, &chunk);
|
||||
out += align;
|
||||
from += align;
|
||||
len -= align;
|
||||
while (len > 0) {
|
||||
loadhalfchunk(from, &chunk);
|
||||
storehalfchunk(out, &chunk);
|
||||
out += sizeof(halfchunk_t);
|
||||
from += sizeof(halfchunk_t);
|
||||
len -= sizeof(halfchunk_t);
|
||||
}
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Copy DIST bytes from OUT - DIST into OUT + DIST * k, for 0 <= k < LEN/DIST.
|
||||
Return OUT + LEN. */
|
||||
static inline uint8_t* CHUNKMEMSET(uint8_t *out, uint8_t *from, unsigned len) {
|
||||
/* Debug performance related issues when len < sizeof(uint64_t):
|
||||
Assert(len >= sizeof(uint64_t), "chunkmemset should be called on larger chunks"); */
|
||||
Assert(from != out, "chunkmemset cannot have a distance 0");
|
||||
|
||||
chunk_t chunk_load;
|
||||
uint32_t chunk_mod = 0;
|
||||
uint32_t adv_amount;
|
||||
int64_t sdist = out - from;
|
||||
uint64_t dist = llabs(sdist);
|
||||
|
||||
/* We are supporting the case for when we are reading bytes from ahead in the buffer.
|
||||
* We now have to handle this, though it wasn't _quite_ clear if this rare circumstance
|
||||
* always needed to be handled here or if we're just now seeing it because we are
|
||||
* dispatching to this function, more */
|
||||
if (sdist < 0 && dist < len) {
|
||||
#ifdef HAVE_MASKED_READWRITE
|
||||
/* We can still handle this case if we can mitigate over writing _and_ we
|
||||
* fit the entirety of the copy length with one load */
|
||||
if (len <= sizeof(chunk_t)) {
|
||||
/* Tempting to add a goto to the block below but hopefully most compilers
|
||||
* collapse these identical code segments as one label to jump to */
|
||||
return CHUNKCOPY(out, from, len);
|
||||
}
|
||||
#endif
|
||||
/* Here the memmove semantics match perfectly, as when this happens we are
|
||||
* effectively sliding down the contents of memory by dist bytes */
|
||||
memmove(out, from, len);
|
||||
return out + len;
|
||||
}
|
||||
|
||||
if (dist == 1) {
|
||||
memset(out, *from, len);
|
||||
return out + len;
|
||||
} else if (dist >= sizeof(chunk_t)) {
|
||||
return CHUNKCOPY(out, from, len);
|
||||
}
|
||||
|
||||
/* Only AVX2+ as there's 128 bit vectors and 256 bit. We allow for shorter vector
|
||||
* lengths because they serve to allow more cases to fall into chunkcopy, as the
|
||||
* distance of the shorter length is still deemed a safe distance. We rewrite this
|
||||
* here rather than calling the ssse3 variant directly now because doing so required
|
||||
* dispatching to another function and broke inlining for this function entirely. We
|
||||
* also can merge an assert and some remainder peeling behavior into the same code blocks,
|
||||
* making the code a little smaller. */
|
||||
#ifdef HAVE_HALF_CHUNK
|
||||
if (len <= sizeof(halfchunk_t)) {
|
||||
if (dist >= sizeof(halfchunk_t))
|
||||
return HALFCHUNKCOPY(out, from, len);
|
||||
|
||||
if ((dist % 2) != 0 || dist == 6) {
|
||||
halfchunk_t halfchunk_load = GET_HALFCHUNK_MAG(from, &chunk_mod, (unsigned)dist);
|
||||
|
||||
if (len == sizeof(halfchunk_t)) {
|
||||
storehalfchunk(out, &halfchunk_load);
|
||||
len -= sizeof(halfchunk_t);
|
||||
out += sizeof(halfchunk_t);
|
||||
}
|
||||
|
||||
chunk_load = halfchunk2whole(&halfchunk_load);
|
||||
goto rem_bytes;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_CHUNKMEMSET_2
|
||||
if (dist == 2) {
|
||||
chunkmemset_2(from, &chunk_load);
|
||||
} else
|
||||
#endif
|
||||
#ifdef HAVE_CHUNKMEMSET_4
|
||||
if (dist == 4) {
|
||||
chunkmemset_4(from, &chunk_load);
|
||||
} else
|
||||
#endif
|
||||
#ifdef HAVE_CHUNKMEMSET_8
|
||||
if (dist == 8) {
|
||||
chunkmemset_8(from, &chunk_load);
|
||||
} else
|
||||
#endif
|
||||
#ifdef HAVE_CHUNKMEMSET_16
|
||||
if (dist == 16) {
|
||||
chunkmemset_16(from, &chunk_load);
|
||||
} else
|
||||
#endif
|
||||
chunk_load = GET_CHUNK_MAG(from, &chunk_mod, (unsigned)dist);
|
||||
|
||||
adv_amount = sizeof(chunk_t) - chunk_mod;
|
||||
|
||||
while (len >= (2 * sizeof(chunk_t))) {
|
||||
storechunk(out, &chunk_load);
|
||||
storechunk(out + adv_amount, &chunk_load);
|
||||
out += 2 * adv_amount;
|
||||
len -= 2 * adv_amount;
|
||||
}
|
||||
|
||||
/* If we don't have a "dist" length that divides evenly into a vector
|
||||
* register, we can write the whole vector register but we need only
|
||||
* advance by the amount of the whole string that fits in our chunk_t.
|
||||
* If we do divide evenly into the vector length, adv_amount = chunk_t size*/
|
||||
while (len >= sizeof(chunk_t)) {
|
||||
storechunk(out, &chunk_load);
|
||||
len -= adv_amount;
|
||||
out += adv_amount;
|
||||
}
|
||||
|
||||
#ifdef HAVE_HALF_CHUNK
|
||||
rem_bytes:
|
||||
#endif
|
||||
if (len) {
|
||||
memcpy(out, &chunk_load, len);
|
||||
out += len;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
Z_INTERNAL uint8_t* CHUNKMEMSET_SAFE(uint8_t *out, uint8_t *from, unsigned len, unsigned left) {
|
||||
#if OPTIMAL_CMP < 32
|
||||
static const uint32_t align_mask = 7;
|
||||
#elif OPTIMAL_CMP == 32
|
||||
static const uint32_t align_mask = 3;
|
||||
#endif
|
||||
|
||||
len = MIN(len, left);
|
||||
|
||||
#if OPTIMAL_CMP < 64
|
||||
while (((uintptr_t)out & align_mask) && (len > 0)) {
|
||||
*out++ = *from++;
|
||||
--len;
|
||||
--left;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_MASKED_READWRITE
|
||||
if (UNLIKELY(left < sizeof(chunk_t))) {
|
||||
while (len > 0) {
|
||||
*out++ = *from++;
|
||||
--len;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (len)
|
||||
out = CHUNKMEMSET(out, from, len);
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
static inline uint8_t *CHUNKCOPY_SAFE(uint8_t *out, uint8_t *from, uint64_t len, uint8_t *safe)
|
||||
{
|
||||
if (out == from)
|
||||
return out + len;
|
||||
|
||||
uint64_t safelen = (safe - out);
|
||||
len = MIN(len, safelen);
|
||||
|
||||
#ifndef HAVE_MASKED_READWRITE
|
||||
uint64_t from_dist = (uint64_t)llabs(safe - from);
|
||||
if (UNLIKELY(from_dist < sizeof(chunk_t) || safelen < sizeof(chunk_t))) {
|
||||
while (len--) {
|
||||
*out++ = *from++;
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
#endif
|
||||
|
||||
return CHUNKMEMSET(out, from, (unsigned)len);
|
||||
}
|
||||
@@ -1,133 +0,0 @@
|
||||
/* compare256_rle.h -- 256 byte run-length encoding comparison
|
||||
* Copyright (C) 2022 Nathan Moinvaziri
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "zmemory.h"
|
||||
#include "fallback_builtins.h"
|
||||
|
||||
typedef uint32_t (*compare256_rle_func)(const uint8_t* src0, const uint8_t* src1);
|
||||
|
||||
/* 8-bit integer comparison */
|
||||
static inline uint32_t compare256_rle_8(const uint8_t *src0, const uint8_t *src1) {
|
||||
uint32_t len = 0;
|
||||
|
||||
do {
|
||||
if (*src0 != *src1)
|
||||
return len;
|
||||
src1 += 1, len += 1;
|
||||
if (*src0 != *src1)
|
||||
return len;
|
||||
src1 += 1, len += 1;
|
||||
if (*src0 != *src1)
|
||||
return len;
|
||||
src1 += 1, len += 1;
|
||||
if (*src0 != *src1)
|
||||
return len;
|
||||
src1 += 1, len += 1;
|
||||
if (*src0 != *src1)
|
||||
return len;
|
||||
src1 += 1, len += 1;
|
||||
if (*src0 != *src1)
|
||||
return len;
|
||||
src1 += 1, len += 1;
|
||||
if (*src0 != *src1)
|
||||
return len;
|
||||
src1 += 1, len += 1;
|
||||
if (*src0 != *src1)
|
||||
return len;
|
||||
src1 += 1, len += 1;
|
||||
} while (len < 256);
|
||||
|
||||
return 256;
|
||||
}
|
||||
|
||||
/* 16-bit integer comparison */
|
||||
static inline uint32_t compare256_rle_16(const uint8_t *src0, const uint8_t *src1) {
|
||||
uint32_t len = 0;
|
||||
uint16_t src0_cmp;
|
||||
|
||||
src0_cmp = zng_memread_2(src0);
|
||||
|
||||
do {
|
||||
if (src0_cmp != zng_memread_2(src1))
|
||||
return len + (*src0 == *src1);
|
||||
src1 += 2, len += 2;
|
||||
if (src0_cmp != zng_memread_2(src1))
|
||||
return len + (*src0 == *src1);
|
||||
src1 += 2, len += 2;
|
||||
if (src0_cmp != zng_memread_2(src1))
|
||||
return len + (*src0 == *src1);
|
||||
src1 += 2, len += 2;
|
||||
if (src0_cmp != zng_memread_2(src1))
|
||||
return len + (*src0 == *src1);
|
||||
src1 += 2, len += 2;
|
||||
} while (len < 256);
|
||||
|
||||
return 256;
|
||||
}
|
||||
|
||||
#ifdef HAVE_BUILTIN_CTZ
|
||||
/* 32-bit integer comparison */
|
||||
static inline uint32_t compare256_rle_32(const uint8_t *src0, const uint8_t *src1) {
|
||||
uint32_t sv, len = 0;
|
||||
uint16_t src0_cmp;
|
||||
|
||||
src0_cmp = zng_memread_2(src0);
|
||||
sv = ((uint32_t)src0_cmp << 16) | src0_cmp;
|
||||
|
||||
do {
|
||||
uint32_t mv, diff;
|
||||
|
||||
mv = zng_memread_4(src1);
|
||||
|
||||
diff = sv ^ mv;
|
||||
if (diff) {
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
uint32_t match_byte = __builtin_ctz(diff) / 8;
|
||||
#else
|
||||
uint32_t match_byte = __builtin_clz(diff) / 8;
|
||||
#endif
|
||||
return len + match_byte;
|
||||
}
|
||||
|
||||
src1 += 4, len += 4;
|
||||
} while (len < 256);
|
||||
|
||||
return 256;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef HAVE_BUILTIN_CTZLL
|
||||
/* 64-bit integer comparison */
|
||||
static inline uint32_t compare256_rle_64(const uint8_t *src0, const uint8_t *src1) {
|
||||
uint32_t src0_cmp32, len = 0;
|
||||
uint16_t src0_cmp;
|
||||
uint64_t sv;
|
||||
|
||||
src0_cmp = zng_memread_2(src0);
|
||||
src0_cmp32 = ((uint32_t)src0_cmp << 16) | src0_cmp;
|
||||
sv = ((uint64_t)src0_cmp32 << 32) | src0_cmp32;
|
||||
|
||||
do {
|
||||
uint64_t mv, diff;
|
||||
|
||||
mv = zng_memread_8(src1);
|
||||
|
||||
diff = sv ^ mv;
|
||||
if (diff) {
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
uint64_t match_byte = __builtin_ctzll(diff) / 8;
|
||||
#else
|
||||
uint64_t match_byte = __builtin_clzll(diff) / 8;
|
||||
#endif
|
||||
return len + (uint32_t)match_byte;
|
||||
}
|
||||
|
||||
src1 += 8, len += 8;
|
||||
} while (len < 256);
|
||||
|
||||
return 256;
|
||||
}
|
||||
#endif
|
||||
+25
-48
@@ -3,19 +3,10 @@
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "zutil.h"
|
||||
/* @(#) $Id$ */
|
||||
|
||||
/* ===========================================================================
|
||||
* Architecture-specific hooks.
|
||||
*/
|
||||
#ifdef S390_DFLTCC_DEFLATE
|
||||
# include "arch/s390/dfltcc_common.h"
|
||||
#else
|
||||
/* Returns the upper bound on compressed data length based on uncompressed data length, assuming default settings.
|
||||
* Zero means that arch-specific deflation code behaves identically to the regular zlib-ng algorithms. */
|
||||
# define DEFLATE_BOUND_COMPLEN(source_len) 0
|
||||
#endif
|
||||
#define ZLIB_INTERNAL
|
||||
#include "zlib.h"
|
||||
|
||||
/* ===========================================================================
|
||||
Compresses the source buffer into the destination buffer. The level
|
||||
@@ -28,71 +19,57 @@
|
||||
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
|
||||
Z_STREAM_ERROR if the level parameter is invalid.
|
||||
*/
|
||||
int Z_EXPORT PREFIX(compress2)(unsigned char *dest, z_uintmax_t *destLen, const unsigned char *source,
|
||||
z_uintmax_t sourceLen, int level) {
|
||||
PREFIX3(stream) stream;
|
||||
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||
uLong sourceLen, int level) {
|
||||
z_stream stream;
|
||||
int err;
|
||||
const unsigned int max = (unsigned int)-1;
|
||||
z_size_t left;
|
||||
const uInt max = (uInt)-1;
|
||||
uLong left;
|
||||
|
||||
left = *destLen;
|
||||
*destLen = 0;
|
||||
|
||||
stream.zalloc = NULL;
|
||||
stream.zfree = NULL;
|
||||
stream.opaque = NULL;
|
||||
stream.zalloc = (alloc_func)0;
|
||||
stream.zfree = (free_func)0;
|
||||
stream.opaque = (voidpf)0;
|
||||
|
||||
err = PREFIX(deflateInit)(&stream, level);
|
||||
if (err != Z_OK)
|
||||
return err;
|
||||
err = deflateInit(&stream, level);
|
||||
if (err != Z_OK) return err;
|
||||
|
||||
stream.next_out = dest;
|
||||
stream.avail_out = 0;
|
||||
stream.next_in = (z_const unsigned char *)source;
|
||||
stream.next_in = (z_const Bytef *)source;
|
||||
stream.avail_in = 0;
|
||||
|
||||
do {
|
||||
if (stream.avail_out == 0) {
|
||||
stream.avail_out = left > (unsigned long)max ? max : (unsigned int)left;
|
||||
stream.avail_out = left > (uLong)max ? max : (uInt)left;
|
||||
left -= stream.avail_out;
|
||||
}
|
||||
if (stream.avail_in == 0) {
|
||||
stream.avail_in = sourceLen > (unsigned long)max ? max : (unsigned int)sourceLen;
|
||||
stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
|
||||
sourceLen -= stream.avail_in;
|
||||
}
|
||||
err = PREFIX(deflate)(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
|
||||
err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
|
||||
} while (err == Z_OK);
|
||||
|
||||
*destLen = stream.total_out;
|
||||
PREFIX(deflateEnd)(&stream);
|
||||
deflateEnd(&stream);
|
||||
return err == Z_STREAM_END ? Z_OK : err;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
*/
|
||||
int Z_EXPORT PREFIX(compress)(unsigned char *dest, z_uintmax_t *destLen, const unsigned char *source, z_uintmax_t sourceLen) {
|
||||
return PREFIX(compress2)(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
||||
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
|
||||
uLong sourceLen) {
|
||||
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
If the default memLevel or windowBits for deflateInit() is changed, then
|
||||
If the default memLevel or windowBits for deflateInit() is changed, then
|
||||
this function needs to be updated.
|
||||
*/
|
||||
z_uintmax_t Z_EXPORT PREFIX(compressBound)(z_uintmax_t sourceLen) {
|
||||
z_uintmax_t complen = DEFLATE_BOUND_COMPLEN(sourceLen);
|
||||
|
||||
if (complen > 0)
|
||||
/* Architecture-specific code provided an upper bound. */
|
||||
return complen + ZLIB_WRAPLEN;
|
||||
|
||||
#ifndef NO_QUICK_STRATEGY
|
||||
return sourceLen /* The source size itself */
|
||||
+ (sourceLen == 0 ? 1 : 0) /* Always at least one byte for any input */
|
||||
+ (sourceLen < 9 ? 1 : 0) /* One extra byte for lengths less than 9 */
|
||||
+ DEFLATE_QUICK_OVERHEAD(sourceLen) /* Source encoding overhead, padded to next full byte */
|
||||
+ DEFLATE_BLOCK_OVERHEAD /* Deflate block overhead bytes */
|
||||
+ ZLIB_WRAPLEN; /* zlib wrapper */
|
||||
#else
|
||||
return sourceLen + (sourceLen >> 4) + 7 + ZLIB_WRAPLEN;
|
||||
#endif
|
||||
uLong ZEXPORT compressBound(uLong sourceLen) {
|
||||
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
|
||||
(sourceLen >> 25) + 13;
|
||||
}
|
||||
+505
-1915
File diff suppressed because it is too large.
Load diff
@@ -1,23 +0,0 @@
|
||||
/* cpu_features.c -- CPU architecture feature check
|
||||
* Copyright (C) 2017 Hans Kristian Rosbach
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "cpu_features.h"
|
||||
#include <string.h>
|
||||
|
||||
Z_INTERNAL void cpu_check_features(struct cpu_features *features) {
|
||||
memset(features, 0, sizeof(struct cpu_features));
|
||||
#if defined(X86_FEATURES)
|
||||
x86_check_features(&features->x86);
|
||||
#elif defined(ARM_FEATURES)
|
||||
arm_check_features(&features->arm);
|
||||
#elif defined(PPC_FEATURES) || defined(POWER_FEATURES)
|
||||
power_check_features(&features->power);
|
||||
#elif defined(S390_FEATURES)
|
||||
s390_check_features(&features->s390);
|
||||
#elif defined(RISCV_FEATURES)
|
||||
riscv_check_features(&features->riscv);
|
||||
#endif
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/* cpu_features.h -- CPU architecture feature check
|
||||
* Copyright (C) 2017 Hans Kristian Rosbach
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#ifndef CPU_FEATURES_H_
|
||||
#define CPU_FEATURES_H_
|
||||
|
||||
#ifndef DISABLE_RUNTIME_CPU_DETECTION
|
||||
|
||||
#if defined(X86_FEATURES)
|
||||
# include "arch/x86/x86_features.h"
|
||||
#elif defined(ARM_FEATURES)
|
||||
# include "arch/arm/arm_features.h"
|
||||
#elif defined(PPC_FEATURES) || defined(POWER_FEATURES)
|
||||
# include "arch/power/power_features.h"
|
||||
#elif defined(S390_FEATURES)
|
||||
# include "arch/s390/s390_features.h"
|
||||
#elif defined(RISCV_FEATURES)
|
||||
# include "arch/riscv/riscv_features.h"
|
||||
#endif
|
||||
|
||||
struct cpu_features {
|
||||
#if defined(X86_FEATURES)
|
||||
struct x86_cpu_features x86;
|
||||
#elif defined(ARM_FEATURES)
|
||||
struct arm_cpu_features arm;
|
||||
#elif defined(PPC_FEATURES) || defined(POWER_FEATURES)
|
||||
struct power_cpu_features power;
|
||||
#elif defined(S390_FEATURES)
|
||||
struct s390_cpu_features s390;
|
||||
#elif defined(RISCV_FEATURES)
|
||||
struct riscv_cpu_features riscv;
|
||||
#else
|
||||
char empty;
|
||||
#endif
|
||||
};
|
||||
|
||||
void cpu_check_features(struct cpu_features *features);
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+1031
-24
File diff suppressed because it is too large.
Load diff
+9440
-17
File diff suppressed because it is too large.
Load diff
@@ -1,56 +0,0 @@
|
||||
/* crc32_braid_comb.c -- compute the CRC-32 of a data stream
|
||||
* Copyright (C) 1995-2022 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*
|
||||
* This interleaved implementation of a CRC makes use of pipelined multiple
|
||||
* arithmetic-logic units, commonly found in modern CPU cores. It is due to
|
||||
* Kadatch and Jenkins (2010). See doc/crc-doc.1.0.pdf in this distribution.
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "crc32_braid_p.h"
|
||||
#include "crc32_braid_tbl.h"
|
||||
#include "crc32_braid_comb_p.h"
|
||||
|
||||
/* ========================================================================= */
|
||||
static uint32_t crc32_combine_(uint32_t crc1, uint32_t crc2, z_off64_t len2) {
|
||||
return multmodp(x2nmodp(len2, 3), crc1) ^ crc2;
|
||||
}
|
||||
static uint32_t crc32_combine_gen_(z_off64_t len2) {
|
||||
return x2nmodp(len2, 3);
|
||||
}
|
||||
static uint32_t crc32_combine_op_(uint32_t crc1, uint32_t crc2, const uint32_t op) {
|
||||
return multmodp(op, crc1) ^ crc2;
|
||||
}
|
||||
|
||||
/* ========================================================================= */
|
||||
|
||||
#ifdef ZLIB_COMPAT
|
||||
unsigned long Z_EXPORT PREFIX(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off_t len2) {
|
||||
return (unsigned long)crc32_combine_((uint32_t)crc1, (uint32_t)crc2, len2);
|
||||
}
|
||||
unsigned long Z_EXPORT PREFIX4(crc32_combine)(unsigned long crc1, unsigned long crc2, z_off64_t len2) {
|
||||
return (unsigned long)crc32_combine_((uint32_t)crc1, (uint32_t)crc2, len2);
|
||||
}
|
||||
unsigned long Z_EXPORT PREFIX(crc32_combine_gen)(z_off_t len2) {
|
||||
return crc32_combine_gen_(len2);
|
||||
}
|
||||
unsigned long Z_EXPORT PREFIX4(crc32_combine_gen)(z_off64_t len2) {
|
||||
return crc32_combine_gen_(len2);
|
||||
}
|
||||
unsigned long Z_EXPORT PREFIX(crc32_combine_op)(unsigned long crc1, unsigned long crc2, const unsigned long op) {
|
||||
return (unsigned long)crc32_combine_op_((uint32_t)crc1, (uint32_t)crc2, (uint32_t)op);
|
||||
}
|
||||
#else
|
||||
uint32_t Z_EXPORT PREFIX4(crc32_combine)(uint32_t crc1, uint32_t crc2, z_off64_t len2) {
|
||||
return crc32_combine_(crc1, crc2, len2);
|
||||
}
|
||||
uint32_t Z_EXPORT PREFIX(crc32_combine_gen)(z_off64_t len2) {
|
||||
return crc32_combine_gen_(len2);
|
||||
}
|
||||
uint32_t Z_EXPORT PREFIX(crc32_combine_op)(uint32_t crc1, uint32_t crc2, const uint32_t op) {
|
||||
return crc32_combine_op_(crc1, crc2, op);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* ========================================================================= */
|
||||
@@ -1,42 +0,0 @@
|
||||
#ifndef CRC32_BRAID_COMB_P_H_
|
||||
#define CRC32_BRAID_COMB_P_H_
|
||||
|
||||
/*
|
||||
Return a(x) multiplied by b(x) modulo p(x), where p(x) is the CRC polynomial,
|
||||
reflected. For speed, this requires that a not be zero.
|
||||
*/
|
||||
static uint32_t multmodp(uint32_t a, uint32_t b) {
|
||||
uint32_t m, p;
|
||||
|
||||
m = (uint32_t)1 << 31;
|
||||
p = 0;
|
||||
for (;;) {
|
||||
if (a & m) {
|
||||
p ^= b;
|
||||
if ((a & (m - 1)) == 0)
|
||||
break;
|
||||
}
|
||||
m >>= 1;
|
||||
b = b & 1 ? (b >> 1) ^ POLY : b >> 1;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
/*
|
||||
Return x^(n * 2^k) modulo p(x). Requires that x2n_table[] has been
|
||||
initialized.
|
||||
*/
|
||||
static uint32_t x2nmodp(z_off64_t n, unsigned k) {
|
||||
uint32_t p;
|
||||
|
||||
p = (uint32_t)1 << 31; /* x^0 == 1 */
|
||||
while (n) {
|
||||
if (n & 1)
|
||||
p = multmodp(x2n_table[k & 31], p);
|
||||
n >>= 1;
|
||||
k++;
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
#endif /* CRC32_BRAID_COMB_P_H_ */
|
||||
@@ -1,40 +0,0 @@
|
||||
#ifndef CRC32_BRAID_P_H_
|
||||
#define CRC32_BRAID_P_H_
|
||||
|
||||
#include "zendian.h"
|
||||
|
||||
/* Define BRAID_N, valid range is 1..6 */
|
||||
#define BRAID_N 5
|
||||
|
||||
/* Define BRAID_W and the associated z_word_t type. If BRAID_W is not defined, then a braided
|
||||
calculation is not used, and the associated tables and code are not compiled.
|
||||
*/
|
||||
#if defined(__x86_64__) || defined(_M_AMD64) || defined(__aarch64__) || defined(_M_ARM64) || defined(__powerpc64__)
|
||||
# define BRAID_W 8
|
||||
typedef uint64_t z_word_t;
|
||||
#else
|
||||
# define BRAID_W 4
|
||||
typedef uint32_t z_word_t;
|
||||
#endif
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
# define ZSWAPWORD(word) (word)
|
||||
# define BRAID_TABLE crc_braid_table
|
||||
#elif BYTE_ORDER == BIG_ENDIAN
|
||||
# if BRAID_W == 8
|
||||
# define ZSWAPWORD(word) ZSWAP64(word)
|
||||
# elif BRAID_W == 4
|
||||
# define ZSWAPWORD(word) ZSWAP32(word)
|
||||
# endif
|
||||
# define BRAID_TABLE crc_braid_big_table
|
||||
#else
|
||||
# error "No endian defined"
|
||||
#endif
|
||||
|
||||
#define CRC_DO1 c = crc_table[(c ^ *buf++) & 0xff] ^ (c >> 8)
|
||||
#define CRC_DO8 CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1; CRC_DO1
|
||||
|
||||
/* CRC polynomial. */
|
||||
#define POLY 0xedb88320 /* p(x) reflected, with x^32 implied */
|
||||
|
||||
#endif /* CRC32_BRAID_P_H_ */
|
||||
File diff suppressed because it is too large.
Load diff
+1458
-832
File diff suppressed because it is too large.
Load diff
+193
-272
@@ -1,7 +1,5 @@
|
||||
#ifndef DEFLATE_H_
|
||||
#define DEFLATE_H_
|
||||
/* deflate.h -- internal compression state
|
||||
* Copyright (C) 1995-2016 Jean-loup Gailly
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
@@ -10,15 +8,12 @@
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
#include "zutil.h"
|
||||
#include "zendian.h"
|
||||
#include "zmemory.h"
|
||||
#include "crc32.h"
|
||||
/* @(#) $Id$ */
|
||||
|
||||
#ifdef S390_DFLTCC_DEFLATE
|
||||
# include "arch/s390/dfltcc_common.h"
|
||||
# define HAVE_ARCH_DEFLATE_STATE
|
||||
#endif
|
||||
#ifndef DEFLATE_H
|
||||
#define DEFLATE_H
|
||||
|
||||
#include "zutil.h"
|
||||
|
||||
/* define NO_GZIP when compiling if you want to disable gzip header and
|
||||
trailer creation by deflate(). NO_GZIP would be used to avoid linking in
|
||||
@@ -30,9 +25,7 @@
|
||||
|
||||
/* define LIT_MEM to slightly increase the speed of deflate (order 1% to 2%) at
|
||||
the cost of a larger memory footprint */
|
||||
#ifndef NO_LIT_MEM
|
||||
# define LIT_MEM
|
||||
#endif
|
||||
/* #define LIT_MEM */
|
||||
|
||||
/* ===========================================================================
|
||||
* Internal compression state.
|
||||
@@ -56,47 +49,36 @@
|
||||
#define HEAP_SIZE (2*L_CODES+1)
|
||||
/* maximum heap size */
|
||||
|
||||
#define BIT_BUF_SIZE 64
|
||||
#define MAX_BITS 15
|
||||
/* All codes must not exceed MAX_BITS bits */
|
||||
|
||||
#define Buf_size 16
|
||||
/* size of bit buffer in bi_buf */
|
||||
|
||||
#define END_BLOCK 256
|
||||
/* end of block literal code */
|
||||
|
||||
#define INIT_STATE 1 /* zlib header -> BUSY_STATE */
|
||||
#define INIT_STATE 42 /* zlib header -> BUSY_STATE */
|
||||
#ifdef GZIP
|
||||
# define GZIP_STATE 4 /* gzip header -> BUSY_STATE | EXTRA_STATE */
|
||||
# define EXTRA_STATE 5 /* gzip extra block -> NAME_STATE */
|
||||
# define NAME_STATE 6 /* gzip file name -> COMMENT_STATE */
|
||||
# define COMMENT_STATE 7 /* gzip comment -> HCRC_STATE */
|
||||
# define HCRC_STATE 8 /* gzip header CRC -> BUSY_STATE */
|
||||
#endif
|
||||
#define BUSY_STATE 2 /* deflate -> FINISH_STATE */
|
||||
#define FINISH_STATE 3 /* stream complete */
|
||||
#ifdef GZIP
|
||||
# define MAX_STATE HCRC_STATE
|
||||
#else
|
||||
# define MAX_STATE FINISH_STATE
|
||||
# define GZIP_STATE 57 /* gzip header -> BUSY_STATE | EXTRA_STATE */
|
||||
#endif
|
||||
#define EXTRA_STATE 69 /* gzip extra block -> NAME_STATE */
|
||||
#define NAME_STATE 73 /* gzip file name -> COMMENT_STATE */
|
||||
#define COMMENT_STATE 91 /* gzip comment -> HCRC_STATE */
|
||||
#define HCRC_STATE 103 /* gzip header CRC -> BUSY_STATE */
|
||||
#define BUSY_STATE 113 /* deflate -> FINISH_STATE */
|
||||
#define FINISH_STATE 666 /* stream complete */
|
||||
/* Stream status */
|
||||
|
||||
#define HASH_BITS 16u /* log2(HASH_SIZE) */
|
||||
#ifndef HASH_SIZE
|
||||
# define HASH_SIZE 65536u /* number of elements in hash table */
|
||||
#endif
|
||||
#define HASH_MASK (HASH_SIZE - 1u) /* HASH_SIZE-1 */
|
||||
|
||||
|
||||
/* Data structure describing a single value and its code string. */
|
||||
typedef struct ct_data_s {
|
||||
union {
|
||||
uint16_t freq; /* frequency count */
|
||||
uint16_t code; /* bit string */
|
||||
ush freq; /* frequency count */
|
||||
ush code; /* bit string */
|
||||
} fc;
|
||||
union {
|
||||
uint16_t dad; /* father node in Huffman tree */
|
||||
uint16_t len; /* length of bit string */
|
||||
ush dad; /* father node in Huffman tree */
|
||||
ush len; /* length of bit string */
|
||||
} dl;
|
||||
} ct_data;
|
||||
} FAR ct_data;
|
||||
|
||||
#define Freq fc.freq
|
||||
#define Code fc.code
|
||||
@@ -106,123 +88,100 @@ typedef struct ct_data_s {
|
||||
typedef struct static_tree_desc_s static_tree_desc;
|
||||
|
||||
typedef struct tree_desc_s {
|
||||
ct_data *dyn_tree; /* the dynamic tree */
|
||||
int max_code; /* largest code with non zero frequency */
|
||||
const static_tree_desc *stat_desc; /* the corresponding static tree */
|
||||
} tree_desc;
|
||||
ct_data *dyn_tree; /* the dynamic tree */
|
||||
int max_code; /* largest code with non zero frequency */
|
||||
const static_tree_desc *stat_desc; /* the corresponding static tree */
|
||||
} FAR tree_desc;
|
||||
|
||||
typedef uint16_t Pos;
|
||||
typedef ush Pos;
|
||||
typedef Pos FAR Posf;
|
||||
typedef unsigned IPos;
|
||||
|
||||
/* A Pos is an index in the character window. We use short instead of int to
|
||||
* save space in the various tables.
|
||||
* save space in the various tables. IPos is used only for parameter passing.
|
||||
*/
|
||||
/* Type definitions for hash callbacks */
|
||||
typedef struct internal_state deflate_state;
|
||||
|
||||
typedef uint32_t (* update_hash_cb) (uint32_t h, uint32_t val);
|
||||
typedef void (* insert_string_cb) (deflate_state *const s, uint32_t str, uint32_t count);
|
||||
typedef Pos (* quick_insert_string_cb)(deflate_state *const s, uint32_t str);
|
||||
|
||||
uint32_t update_hash (uint32_t h, uint32_t val);
|
||||
void insert_string (deflate_state *const s, uint32_t str, uint32_t count);
|
||||
Pos quick_insert_string (deflate_state *const s, uint32_t str);
|
||||
|
||||
uint32_t update_hash_roll (uint32_t h, uint32_t val);
|
||||
void insert_string_roll (deflate_state *const s, uint32_t str, uint32_t count);
|
||||
Pos quick_insert_string_roll(deflate_state *const s, uint32_t str);
|
||||
|
||||
/* Struct for memory allocation handling */
|
||||
typedef struct deflate_allocs_s {
|
||||
char *buf_start;
|
||||
free_func zfree;
|
||||
deflate_state *state;
|
||||
unsigned char *window;
|
||||
unsigned char *pending_buf;
|
||||
Pos *prev;
|
||||
Pos *head;
|
||||
} deflate_allocs;
|
||||
|
||||
struct ALIGNED_(64) internal_state {
|
||||
PREFIX3(stream) *strm; /* pointer back to this zlib stream */
|
||||
unsigned char *pending_buf; /* output still pending */
|
||||
unsigned char *pending_out; /* next pending byte to output to the stream */
|
||||
uint32_t pending_buf_size; /* size of pending_buf */
|
||||
uint32_t pending; /* nb of bytes in the pending buffer */
|
||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
||||
uint32_t gzindex; /* where in extra, name, or comment */
|
||||
PREFIX(gz_headerp) gzhead; /* gzip header information to write */
|
||||
int status; /* as the name implies */
|
||||
int last_flush; /* value of flush param for previous deflate call */
|
||||
int reproducible; /* Whether reproducible compression results are required. */
|
||||
|
||||
int block_open;
|
||||
/* Whether or not a block is currently open for the QUICK deflation scheme.
|
||||
* This is set to 1 if there is an active block, or 0 if the block was just closed.
|
||||
*/
|
||||
typedef struct internal_state {
|
||||
z_streamp strm; /* pointer back to this zlib stream */
|
||||
int status; /* as the name implies */
|
||||
Bytef *pending_buf; /* output still pending */
|
||||
ulg pending_buf_size; /* size of pending_buf */
|
||||
Bytef *pending_out; /* next pending byte to output to the stream */
|
||||
ulg pending; /* nb of bytes in the pending buffer */
|
||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip */
|
||||
gz_headerp gzhead; /* gzip header information to write */
|
||||
ulg gzindex; /* where in extra, name, or comment */
|
||||
Byte method; /* can only be DEFLATED */
|
||||
int last_flush; /* value of flush param for previous deflate call */
|
||||
|
||||
/* used by deflate.c: */
|
||||
|
||||
unsigned int w_size; /* LZ77 window size (32K by default) */
|
||||
unsigned int w_bits; /* log2(w_size) (8..16) */
|
||||
unsigned int w_mask; /* w_size - 1 */
|
||||
unsigned int lookahead; /* number of valid bytes ahead in window */
|
||||
uInt w_size; /* LZ77 window size (32K by default) */
|
||||
uInt w_bits; /* log2(w_size) (8..16) */
|
||||
uInt w_mask; /* w_size - 1 */
|
||||
|
||||
unsigned int high_water;
|
||||
/* High water mark offset in window for initialized bytes -- bytes above
|
||||
* this are set to zero in order to avoid memory check warnings when
|
||||
* longest match routines access bytes past the input. This is then
|
||||
* updated to the new high water mark.
|
||||
*/
|
||||
|
||||
unsigned int window_size;
|
||||
/* Actual size of window: 2*wSize, except when the user input buffer
|
||||
* is directly used as sliding window.
|
||||
*/
|
||||
|
||||
unsigned char *window;
|
||||
Bytef *window;
|
||||
/* Sliding window. Input bytes are read into the second half of the window,
|
||||
* and move to the first half later to keep a dictionary of at least wSize
|
||||
* bytes. With this organization, matches are limited to a distance of
|
||||
* wSize-STD_MAX_MATCH bytes, but this ensures that IO is always
|
||||
* wSize-MAX_MATCH bytes, but this ensures that IO is always
|
||||
* performed with a length multiple of the block size. Also, it limits
|
||||
* the window size to 64K, which is quite useful on MSDOS.
|
||||
* To do: use the user input buffer as sliding window.
|
||||
*/
|
||||
|
||||
Pos *prev;
|
||||
ulg window_size;
|
||||
/* Actual size of window: 2*wSize, except when the user input buffer
|
||||
* is directly used as sliding window.
|
||||
*/
|
||||
|
||||
Posf *prev;
|
||||
/* Link to older string with same hash index. To limit the size of this
|
||||
* array to 64K, this link is maintained only for the last 32K strings.
|
||||
* An index in this array is thus a window index modulo 32K.
|
||||
*/
|
||||
|
||||
Pos *head; /* Heads of the hash chains or 0. */
|
||||
Posf *head; /* Heads of the hash chains or NIL. */
|
||||
|
||||
uint32_t ins_h; /* hash index of string to be inserted */
|
||||
uInt ins_h; /* hash index of string to be inserted */
|
||||
uInt hash_size; /* number of elements in hash table */
|
||||
uInt hash_bits; /* log2(hash_size) */
|
||||
uInt hash_mask; /* hash_size-1 */
|
||||
|
||||
int block_start;
|
||||
uInt hash_shift;
|
||||
/* Number of bits by which ins_h must be shifted at each input
|
||||
* step. It must be such that after MIN_MATCH steps, the oldest
|
||||
* byte no longer takes part in the hash key, that is:
|
||||
* hash_shift * MIN_MATCH >= hash_bits
|
||||
*/
|
||||
|
||||
long block_start;
|
||||
/* Window position at the beginning of the current output block. Gets
|
||||
* negative when the window is moved backwards.
|
||||
*/
|
||||
|
||||
unsigned int match_length; /* length of best match */
|
||||
Pos prev_match; /* previous match */
|
||||
int match_available; /* set if previous match exists */
|
||||
unsigned int strstart; /* start of string to insert */
|
||||
unsigned int match_start; /* start of matching string */
|
||||
uInt match_length; /* length of best match */
|
||||
IPos prev_match; /* previous match */
|
||||
int match_available; /* set if previous match exists */
|
||||
uInt strstart; /* start of string to insert */
|
||||
uInt match_start; /* start of matching string */
|
||||
uInt lookahead; /* number of valid bytes ahead in window */
|
||||
|
||||
unsigned int prev_length;
|
||||
uInt prev_length;
|
||||
/* Length of the best match at previous step. Matches not greater than this
|
||||
* are discarded. This is used in the lazy match evaluation.
|
||||
*/
|
||||
|
||||
unsigned int max_chain_length;
|
||||
/* To speed up deflation, hash chains are never searched beyond this length.
|
||||
* A higher limit improves compression ratio but degrades the speed.
|
||||
uInt max_chain_length;
|
||||
/* To speed up deflation, hash chains are never searched beyond this
|
||||
* length. A higher limit improves compression ratio but degrades the
|
||||
* speed.
|
||||
*/
|
||||
|
||||
unsigned int max_lazy_match;
|
||||
/* Attempt to find a better match only when the current match is strictly smaller
|
||||
* than this value. This mechanism is used only for compression levels >= 4.
|
||||
uInt max_lazy_match;
|
||||
/* Attempt to find a better match only when the current match is strictly
|
||||
* smaller than this value. This mechanism is used only for compression
|
||||
* levels >= 4.
|
||||
*/
|
||||
# define max_insert_length max_lazy_match
|
||||
/* Insert new strings in the hash table only if the match length is not
|
||||
@@ -230,26 +189,14 @@ struct ALIGNED_(64) internal_state {
|
||||
* max_insert_length is used only for compression levels <= 3.
|
||||
*/
|
||||
|
||||
update_hash_cb update_hash;
|
||||
insert_string_cb insert_string;
|
||||
quick_insert_string_cb quick_insert_string;
|
||||
/* Hash function callbacks that can be configured depending on the deflate
|
||||
* algorithm being used */
|
||||
|
||||
int level; /* compression level (1..9) */
|
||||
int strategy; /* favor or force Huffman coding*/
|
||||
|
||||
unsigned int good_match;
|
||||
uInt good_match;
|
||||
/* Use a faster search when the previous match is longer than this */
|
||||
|
||||
int nice_match; /* Stop searching when current match exceeds this */
|
||||
|
||||
#if defined(_M_IX86) || defined(_M_ARM)
|
||||
int padding[2];
|
||||
#endif
|
||||
|
||||
struct crc32_fold_s ALIGNED_(16) crc_fold;
|
||||
|
||||
/* used by trees.c: */
|
||||
/* Didn't use ct_data typedef below to suppress compiler warning */
|
||||
struct ct_data_s dyn_ltree[HEAP_SIZE]; /* literal and length tree */
|
||||
@@ -260,7 +207,7 @@ struct ALIGNED_(64) internal_state {
|
||||
struct tree_desc_s d_desc; /* desc. for distance tree */
|
||||
struct tree_desc_s bl_desc; /* desc. for bit length tree */
|
||||
|
||||
uint16_t bl_count[MAX_BITS+1];
|
||||
ush bl_count[MAX_BITS+1];
|
||||
/* number of codes at each bit length for an optimal tree */
|
||||
|
||||
int heap[2*L_CODES+1]; /* heap used to build the Huffman trees */
|
||||
@@ -270,11 +217,20 @@ struct ALIGNED_(64) internal_state {
|
||||
* The same heap array is used to build all trees.
|
||||
*/
|
||||
|
||||
unsigned char depth[2*L_CODES+1];
|
||||
uch depth[2*L_CODES+1];
|
||||
/* Depth of each subtree used as tie breaker for trees of equal frequency
|
||||
*/
|
||||
|
||||
unsigned int lit_bufsize;
|
||||
#ifdef LIT_MEM
|
||||
# define LIT_BUFS 5
|
||||
ushf *d_buf; /* buffer for distances */
|
||||
uchf *l_buf; /* buffer for literals/lengths */
|
||||
#else
|
||||
# define LIT_BUFS 4
|
||||
uchf *sym_buf; /* buffer for distances and literals/lengths */
|
||||
#endif
|
||||
|
||||
uInt lit_bufsize;
|
||||
/* Size of match buffer for literals/lengths. There are 4 reasons for
|
||||
* limiting lit_bufsize to 64K:
|
||||
* - frequencies can be kept in 16 bit counters
|
||||
@@ -294,163 +250,128 @@ struct ALIGNED_(64) internal_state {
|
||||
* - I can't count above 4
|
||||
*/
|
||||
|
||||
#ifdef LIT_MEM
|
||||
# define LIT_BUFS 5
|
||||
uint16_t *d_buf; /* buffer for distances */
|
||||
unsigned char *l_buf; /* buffer for literals/lengths */
|
||||
#else
|
||||
# define LIT_BUFS 4
|
||||
unsigned char *sym_buf; /* buffer for distances and literals/lengths */
|
||||
uInt sym_next; /* running index in symbol buffer */
|
||||
uInt sym_end; /* symbol table full when sym_next reaches this */
|
||||
|
||||
ulg opt_len; /* bit length of current block with optimal trees */
|
||||
ulg static_len; /* bit length of current block with static trees */
|
||||
uInt matches; /* number of string matches in current block */
|
||||
uInt insert; /* bytes at end of window left to insert */
|
||||
|
||||
#ifdef ZLIB_DEBUG
|
||||
ulg compressed_len; /* total bit length of compressed file mod 2^32 */
|
||||
ulg bits_sent; /* bit length of compressed data sent mod 2^32 */
|
||||
#endif
|
||||
|
||||
unsigned int sym_next; /* running index in symbol buffer */
|
||||
unsigned int sym_end; /* symbol table full when sym_next reaches this */
|
||||
ush bi_buf;
|
||||
/* Output buffer. bits are inserted starting at the bottom (least
|
||||
* significant bits).
|
||||
*/
|
||||
int bi_valid;
|
||||
/* Number of valid bits in bi_buf. All bits above the last valid bit
|
||||
* are always zero.
|
||||
*/
|
||||
|
||||
unsigned long opt_len; /* bit length of current block with optimal trees */
|
||||
unsigned long static_len; /* bit length of current block with static trees */
|
||||
unsigned int matches; /* number of string matches in current block */
|
||||
unsigned int insert; /* bytes at end of window left to insert */
|
||||
ulg high_water;
|
||||
/* High water mark offset in window for initialized bytes -- bytes above
|
||||
* this are set to zero in order to avoid memory check warnings when
|
||||
* longest match routines access bytes past the input. This is then
|
||||
* updated to the new high water mark.
|
||||
*/
|
||||
|
||||
/* compressed_len and bits_sent are only used if ZLIB_DEBUG is defined */
|
||||
unsigned long compressed_len; /* total bit length of compressed file mod 2^32 */
|
||||
unsigned long bits_sent; /* bit length of compressed data sent mod 2^32 */
|
||||
|
||||
deflate_allocs *alloc_bufs;
|
||||
|
||||
#ifdef HAVE_ARCH_DEFLATE_STATE
|
||||
arch_deflate_state arch; /* architecture-specific extensions */
|
||||
#endif
|
||||
|
||||
uint64_t bi_buf;
|
||||
/* Output buffer. bits are inserted starting at the bottom (least significant bits). */
|
||||
|
||||
int32_t bi_valid;
|
||||
/* Number of valid bits in bi_buf. All bits above the last valid bit are always zero. */
|
||||
|
||||
/* Reserved for future use and alignment purposes */
|
||||
int32_t reserved[19];
|
||||
#if defined(_M_IX86) || defined(_M_ARM)
|
||||
int32_t padding2[4];
|
||||
#endif
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
need_more, /* block not completed, need more input or more output */
|
||||
block_done, /* block flush performed */
|
||||
finish_started, /* finish started, need only more output at next deflate */
|
||||
finish_done /* finish done, accept no more input or output */
|
||||
} block_state;
|
||||
} FAR deflate_state;
|
||||
|
||||
/* Output a byte on the stream.
|
||||
* IN assertion: there is enough room in pending_buf.
|
||||
*/
|
||||
#define put_byte(s, c) { \
|
||||
s->pending_buf[s->pending++] = (unsigned char)(c); \
|
||||
}
|
||||
#define put_byte(s, c) {s->pending_buf[s->pending++] = (Bytef)(c);}
|
||||
|
||||
/* ===========================================================================
|
||||
* Output a short LSB first on the stream.
|
||||
* IN assertion: there is enough room in pending_buf.
|
||||
*/
|
||||
static inline void put_short(deflate_state *s, uint16_t w) {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
w = ZSWAP16(w);
|
||||
#endif
|
||||
zng_memwrite_2(&s->pending_buf[s->pending], w);
|
||||
s->pending += 2;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Output a short MSB first on the stream.
|
||||
* IN assertion: there is enough room in pending_buf.
|
||||
*/
|
||||
static inline void put_short_msb(deflate_state *s, uint16_t w) {
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
w = ZSWAP16(w);
|
||||
#endif
|
||||
zng_memwrite_2(&s->pending_buf[s->pending], w);
|
||||
s->pending += 2;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Output a 32-bit unsigned int LSB first on the stream.
|
||||
* IN assertion: there is enough room in pending_buf.
|
||||
*/
|
||||
static inline void put_uint32(deflate_state *s, uint32_t dw) {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
dw = ZSWAP32(dw);
|
||||
#endif
|
||||
zng_memwrite_4(&s->pending_buf[s->pending], dw);
|
||||
s->pending += 4;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Output a 32-bit unsigned int MSB first on the stream.
|
||||
* IN assertion: there is enough room in pending_buf.
|
||||
*/
|
||||
static inline void put_uint32_msb(deflate_state *s, uint32_t dw) {
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
dw = ZSWAP32(dw);
|
||||
#endif
|
||||
zng_memwrite_4(&s->pending_buf[s->pending], dw);
|
||||
s->pending += 4;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Output a 64-bit unsigned int LSB first on the stream.
|
||||
* IN assertion: there is enough room in pending_buf.
|
||||
*/
|
||||
static inline void put_uint64(deflate_state *s, uint64_t lld) {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
lld = ZSWAP64(lld);
|
||||
#endif
|
||||
zng_memwrite_8(&s->pending_buf[s->pending], lld);
|
||||
s->pending += 8;
|
||||
}
|
||||
|
||||
#define MIN_LOOKAHEAD (STD_MAX_MATCH + STD_MIN_MATCH + 1)
|
||||
#define MIN_LOOKAHEAD (MAX_MATCH+MIN_MATCH+1)
|
||||
/* Minimum amount of lookahead, except at the end of the input file.
|
||||
* See deflate.c for comments about the STD_MIN_MATCH+1.
|
||||
* See deflate.c for comments about the MIN_MATCH+1.
|
||||
*/
|
||||
|
||||
#define MAX_DIST(s) ((s)->w_size - MIN_LOOKAHEAD)
|
||||
#define MAX_DIST(s) ((s)->w_size-MIN_LOOKAHEAD)
|
||||
/* In order to simplify the code, particularly on 16 bit machines, match
|
||||
* distances are limited to MAX_DIST instead of WSIZE.
|
||||
*/
|
||||
|
||||
#define WIN_INIT STD_MAX_MATCH
|
||||
#define WIN_INIT MAX_MATCH
|
||||
/* Number of bytes after end of data in window to initialize in order to avoid
|
||||
memory checker errors from longest match routines */
|
||||
|
||||
|
||||
void Z_INTERNAL PREFIX(fill_window)(deflate_state *s);
|
||||
void Z_INTERNAL slide_hash_c(deflate_state *s);
|
||||
|
||||
/* in trees.c */
|
||||
void Z_INTERNAL zng_tr_init(deflate_state *s);
|
||||
void Z_INTERNAL zng_tr_flush_block(deflate_state *s, char *buf, uint32_t stored_len, int last);
|
||||
void Z_INTERNAL zng_tr_flush_bits(deflate_state *s);
|
||||
void Z_INTERNAL zng_tr_align(deflate_state *s);
|
||||
void Z_INTERNAL zng_tr_stored_block(deflate_state *s, char *buf, uint32_t stored_len, int last);
|
||||
uint16_t Z_INTERNAL PREFIX(bi_reverse)(unsigned code, int len);
|
||||
void Z_INTERNAL PREFIX(flush_pending)(PREFIX3(streamp) strm);
|
||||
#define d_code(dist) ((dist) < 256 ? zng_dist_code[dist] : zng_dist_code[256+((dist)>>7)])
|
||||
void ZLIB_INTERNAL _tr_init(deflate_state *s);
|
||||
int ZLIB_INTERNAL _tr_tally(deflate_state *s, unsigned dist, unsigned lc);
|
||||
void ZLIB_INTERNAL _tr_flush_block(deflate_state *s, charf *buf,
|
||||
ulg stored_len, int last);
|
||||
void ZLIB_INTERNAL _tr_flush_bits(deflate_state *s);
|
||||
void ZLIB_INTERNAL _tr_align(deflate_state *s);
|
||||
void ZLIB_INTERNAL _tr_stored_block(deflate_state *s, charf *buf,
|
||||
ulg stored_len, int last);
|
||||
|
||||
#define d_code(dist) \
|
||||
((dist) < 256 ? _dist_code[dist] : _dist_code[256+((dist)>>7)])
|
||||
/* Mapping from a distance to a distance code. dist is the distance - 1 and
|
||||
* must not have side effects. zng_dist_code[256] and zng_dist_code[257] are never
|
||||
* must not have side effects. _dist_code[256] and _dist_code[257] are never
|
||||
* used.
|
||||
*/
|
||||
|
||||
/* Bit buffer and compress bits calculation debugging */
|
||||
#ifdef ZLIB_DEBUG
|
||||
# define cmpr_bits_add(s, len) s->compressed_len += (len)
|
||||
# define cmpr_bits_align(s) s->compressed_len = (s->compressed_len + 7) & ~7L
|
||||
# define sent_bits_add(s, bits) s->bits_sent += (bits)
|
||||
# define sent_bits_align(s) s->bits_sent = (s->bits_sent + 7) & ~7L
|
||||
#ifndef ZLIB_DEBUG
|
||||
/* Inline versions of _tr_tally for speed: */
|
||||
|
||||
#if defined(GEN_TREES_H) || !defined(STDC)
|
||||
extern uch ZLIB_INTERNAL _length_code[];
|
||||
extern uch ZLIB_INTERNAL _dist_code[];
|
||||
#else
|
||||
# define cmpr_bits_add(s, len) Z_UNUSED(len)
|
||||
# define cmpr_bits_align(s)
|
||||
# define sent_bits_add(s, bits) Z_UNUSED(bits)
|
||||
# define sent_bits_align(s)
|
||||
extern const uch ZLIB_INTERNAL _length_code[];
|
||||
extern const uch ZLIB_INTERNAL _dist_code[];
|
||||
#endif
|
||||
|
||||
#endif /* DEFLATE_H_ */
|
||||
#ifdef LIT_MEM
|
||||
# define _tr_tally_lit(s, c, flush) \
|
||||
{ uch cc = (c); \
|
||||
s->d_buf[s->sym_next] = 0; \
|
||||
s->l_buf[s->sym_next++] = cc; \
|
||||
s->dyn_ltree[cc].Freq++; \
|
||||
flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
{ uch len = (uch)(length); \
|
||||
ush dist = (ush)(distance); \
|
||||
s->d_buf[s->sym_next] = dist; \
|
||||
s->l_buf[s->sym_next++] = len; \
|
||||
dist--; \
|
||||
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||
flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
#else
|
||||
# define _tr_tally_lit(s, c, flush) \
|
||||
{ uch cc = (c); \
|
||||
s->sym_buf[s->sym_next++] = 0; \
|
||||
s->sym_buf[s->sym_next++] = 0; \
|
||||
s->sym_buf[s->sym_next++] = cc; \
|
||||
s->dyn_ltree[cc].Freq++; \
|
||||
flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
{ uch len = (uch)(length); \
|
||||
ush dist = (ush)(distance); \
|
||||
s->sym_buf[s->sym_next++] = (uch)dist; \
|
||||
s->sym_buf[s->sym_next++] = (uch)(dist >> 8); \
|
||||
s->sym_buf[s->sym_next++] = len; \
|
||||
dist--; \
|
||||
s->dyn_ltree[_length_code[len]+LITERALS+1].Freq++; \
|
||||
s->dyn_dtree[d_code(dist)].Freq++; \
|
||||
flush = (s->sym_next == s->sym_end); \
|
||||
}
|
||||
#endif
|
||||
#else
|
||||
# define _tr_tally_lit(s, c, flush) flush = _tr_tally(s, 0, c)
|
||||
# define _tr_tally_dist(s, distance, length, flush) \
|
||||
flush = _tr_tally(s, distance, length)
|
||||
#endif
|
||||
|
||||
#endif /* DEFLATE_H */
|
||||
@@ -1,104 +0,0 @@
|
||||
/* deflate_fast.c -- compress data using the fast strategy of deflation algorithm
|
||||
*
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "deflate.h"
|
||||
#include "deflate_p.h"
|
||||
#include "functable.h"
|
||||
|
||||
/* ===========================================================================
|
||||
* Compress as much as possible from the input stream, return the current
|
||||
* block state.
|
||||
* This function does not perform lazy evaluation of matches and inserts
|
||||
* new strings in the dictionary only for unmatched strings or for short
|
||||
* matches. It is used only for the fast compression options.
|
||||
*/
|
||||
Z_INTERNAL block_state deflate_fast(deflate_state *s, int flush) {
|
||||
Pos hash_head; /* head of the hash chain */
|
||||
int bflush = 0; /* set if current block must be flushed */
|
||||
int64_t dist;
|
||||
uint32_t match_len = 0;
|
||||
|
||||
for (;;) {
|
||||
/* Make sure that we always have enough lookahead, except
|
||||
* at the end of the input file. We need STD_MAX_MATCH bytes
|
||||
* for the next match, plus WANT_MIN_MATCH bytes to insert the
|
||||
* string following the next match.
|
||||
*/
|
||||
if (s->lookahead < MIN_LOOKAHEAD) {
|
||||
PREFIX(fill_window)(s);
|
||||
if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) {
|
||||
return need_more;
|
||||
}
|
||||
if (UNLIKELY(s->lookahead == 0))
|
||||
break; /* flush the current block */
|
||||
}
|
||||
|
||||
/* Insert the string window[strstart .. strstart+2] in the
|
||||
* dictionary, and set hash_head to the head of the hash chain:
|
||||
*/
|
||||
if (s->lookahead >= WANT_MIN_MATCH) {
|
||||
hash_head = quick_insert_string(s, s->strstart);
|
||||
dist = (int64_t)s->strstart - hash_head;
|
||||
|
||||
/* Find the longest match, discarding those <= prev_length.
|
||||
* At this point we have always match length < WANT_MIN_MATCH
|
||||
*/
|
||||
if (dist <= MAX_DIST(s) && dist > 0 && hash_head != 0) {
|
||||
/* To simplify the code, we prevent matches with the string
|
||||
* of window index 0 (in particular we have to avoid a match
|
||||
* of the string with itself at the start of the input file).
|
||||
*/
|
||||
match_len = FUNCTABLE_CALL(longest_match)(s, hash_head);
|
||||
/* longest_match() sets match_start */
|
||||
}
|
||||
}
|
||||
|
||||
if (match_len >= WANT_MIN_MATCH) {
|
||||
Assert(s->strstart <= UINT16_MAX, "strstart should fit in uint16_t");
|
||||
Assert(s->match_start <= UINT16_MAX, "match_start should fit in uint16_t");
|
||||
check_match(s, (Pos)s->strstart, (Pos)s->match_start, match_len);
|
||||
|
||||
bflush = zng_tr_tally_dist(s, s->strstart - s->match_start, match_len - STD_MIN_MATCH);
|
||||
|
||||
s->lookahead -= match_len;
|
||||
|
||||
/* Insert new strings in the hash table only if the match length
|
||||
* is not too large. This saves time but degrades compression.
|
||||
*/
|
||||
if (match_len <= s->max_insert_length && s->lookahead >= WANT_MIN_MATCH) {
|
||||
match_len--; /* string at strstart already in table */
|
||||
s->strstart++;
|
||||
|
||||
insert_string(s, s->strstart, match_len);
|
||||
s->strstart += match_len;
|
||||
} else {
|
||||
s->strstart += match_len;
|
||||
quick_insert_string(s, s->strstart + 2 - STD_MIN_MATCH);
|
||||
|
||||
/* If lookahead < STD_MIN_MATCH, ins_h is garbage, but it does not
|
||||
* matter since it will be recomputed at next deflate call.
|
||||
*/
|
||||
}
|
||||
match_len = 0;
|
||||
} else {
|
||||
/* No match, output a literal byte */
|
||||
bflush = zng_tr_tally_lit(s, s->window[s->strstart]);
|
||||
s->lookahead--;
|
||||
s->strstart++;
|
||||
}
|
||||
if (UNLIKELY(bflush))
|
||||
FLUSH_BLOCK(s, 0);
|
||||
}
|
||||
s->insert = s->strstart < (STD_MIN_MATCH - 1) ? s->strstart : (STD_MIN_MATCH - 1);
|
||||
if (UNLIKELY(flush == Z_FINISH)) {
|
||||
FLUSH_BLOCK(s, 1);
|
||||
return finish_done;
|
||||
}
|
||||
if (UNLIKELY(s->sym_next))
|
||||
FLUSH_BLOCK(s, 0);
|
||||
return block_done;
|
||||
}
|
||||
@@ -1,45 +0,0 @@
|
||||
/* deflate_huff.c -- compress data using huffman encoding only strategy
|
||||
*
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "deflate.h"
|
||||
#include "deflate_p.h"
|
||||
#include "functable.h"
|
||||
|
||||
/* ===========================================================================
|
||||
* For Z_HUFFMAN_ONLY, do not look for matches. Do not maintain a hash table.
|
||||
* (It will be regenerated if this run of deflate switches away from Huffman.)
|
||||
*/
|
||||
Z_INTERNAL block_state deflate_huff(deflate_state *s, int flush) {
|
||||
int bflush = 0; /* set if current block must be flushed */
|
||||
|
||||
for (;;) {
|
||||
/* Make sure that we have a literal to write. */
|
||||
if (s->lookahead == 0) {
|
||||
PREFIX(fill_window)(s);
|
||||
if (s->lookahead == 0) {
|
||||
if (flush == Z_NO_FLUSH)
|
||||
return need_more;
|
||||
break; /* flush the current block */
|
||||
}
|
||||
}
|
||||
|
||||
/* Output a literal byte */
|
||||
bflush = zng_tr_tally_lit(s, s->window[s->strstart]);
|
||||
s->lookahead--;
|
||||
s->strstart++;
|
||||
if (bflush)
|
||||
FLUSH_BLOCK(s, 0);
|
||||
}
|
||||
s->insert = 0;
|
||||
if (flush == Z_FINISH) {
|
||||
FLUSH_BLOCK(s, 1);
|
||||
return finish_done;
|
||||
}
|
||||
if (s->sym_next)
|
||||
FLUSH_BLOCK(s, 0);
|
||||
return block_done;
|
||||
}
|
||||
@@ -1,278 +0,0 @@
|
||||
/* deflate_medium.c -- The deflate_medium deflate strategy
|
||||
*
|
||||
* Copyright (C) 2013 Intel Corporation. All rights reserved.
|
||||
* Authors:
|
||||
* Arjan van de Ven <arjan@linux.intel.com>
|
||||
*
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
#ifndef NO_MEDIUM_STRATEGY
|
||||
#include "zbuild.h"
|
||||
#include "deflate.h"
|
||||
#include "deflate_p.h"
|
||||
#include "functable.h"
|
||||
|
||||
struct match {
|
||||
uint16_t match_start;
|
||||
uint16_t match_length;
|
||||
uint16_t strstart;
|
||||
uint16_t orgstart;
|
||||
};
|
||||
|
||||
static int emit_match(deflate_state *s, struct match match) {
|
||||
int bflush = 0;
|
||||
|
||||
/* matches that are not long enough we need to emit as literals */
|
||||
if (match.match_length < WANT_MIN_MATCH) {
|
||||
while (match.match_length) {
|
||||
bflush += zng_tr_tally_lit(s, s->window[match.strstart]);
|
||||
s->lookahead--;
|
||||
match.strstart++;
|
||||
match.match_length--;
|
||||
}
|
||||
return bflush;
|
||||
}
|
||||
|
||||
check_match(s, match.strstart, match.match_start, match.match_length);
|
||||
|
||||
bflush += zng_tr_tally_dist(s, match.strstart - match.match_start, match.match_length - STD_MIN_MATCH);
|
||||
|
||||
s->lookahead -= match.match_length;
|
||||
return bflush;
|
||||
}
|
||||
|
||||
static void insert_match(deflate_state *s, struct match match) {
|
||||
if (UNLIKELY(s->lookahead <= (unsigned int)(match.match_length + WANT_MIN_MATCH)))
|
||||
return;
|
||||
|
||||
/* string at strstart already in table */
|
||||
match.strstart++;
|
||||
match.match_length--;
|
||||
|
||||
/* matches that are not long enough we need to emit as literals */
|
||||
if (LIKELY(match.match_length < WANT_MIN_MATCH - 1)) {
|
||||
if (UNLIKELY(match.match_length > 0)) {
|
||||
if (match.strstart >= match.orgstart) {
|
||||
if (match.strstart + match.match_length - 1 >= match.orgstart) {
|
||||
insert_string(s, match.strstart, match.match_length);
|
||||
} else {
|
||||
insert_string(s, match.strstart, match.orgstart - match.strstart + 1);
|
||||
}
|
||||
match.strstart += match.match_length;
|
||||
match.match_length = 0;
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
/* Insert into hash table. */
|
||||
if (LIKELY(match.strstart >= match.orgstart)) {
|
||||
if (LIKELY(match.strstart + match.match_length - 1 >= match.orgstart)) {
|
||||
insert_string(s, match.strstart, match.match_length);
|
||||
} else {
|
||||
insert_string(s, match.strstart, match.orgstart - match.strstart + 1);
|
||||
}
|
||||
} else if (match.orgstart < match.strstart + match.match_length) {
|
||||
insert_string(s, match.orgstart, match.strstart + match.match_length - match.orgstart);
|
||||
}
|
||||
match.strstart += match.match_length;
|
||||
match.match_length = 0;
|
||||
}
|
||||
|
||||
static void fizzle_matches(deflate_state *s, struct match *current, struct match *next) {
|
||||
Pos limit;
|
||||
unsigned char *match, *orig;
|
||||
int changed = 0;
|
||||
struct match c, n;
|
||||
/* step zero: sanity checks */
|
||||
|
||||
if (current->match_length <= 1)
|
||||
return;
|
||||
|
||||
if (UNLIKELY(current->match_length > 1 + next->match_start))
|
||||
return;
|
||||
|
||||
if (UNLIKELY(current->match_length > 1 + next->strstart))
|
||||
return;
|
||||
|
||||
match = s->window - current->match_length + 1 + next->match_start;
|
||||
orig = s->window - current->match_length + 1 + next->strstart;
|
||||
|
||||
/* quick exit check.. if this fails then don't bother with anything else */
|
||||
if (LIKELY(*match != *orig))
|
||||
return;
|
||||
|
||||
c = *current;
|
||||
n = *next;
|
||||
|
||||
/* step one: try to move the "next" match to the left as much as possible */
|
||||
limit = next->strstart > MAX_DIST(s) ? next->strstart - (Pos)MAX_DIST(s) : 0;
|
||||
|
||||
match = s->window + n.match_start - 1;
|
||||
orig = s->window + n.strstart - 1;
|
||||
|
||||
while (*match == *orig) {
|
||||
if (UNLIKELY(c.match_length < 1))
|
||||
break;
|
||||
if (UNLIKELY(n.strstart <= limit))
|
||||
break;
|
||||
if (UNLIKELY(n.match_length >= 256))
|
||||
break;
|
||||
if (UNLIKELY(n.match_start <= 1))
|
||||
break;
|
||||
|
||||
n.strstart--;
|
||||
n.match_start--;
|
||||
n.match_length++;
|
||||
c.match_length--;
|
||||
match--;
|
||||
orig--;
|
||||
changed++;
|
||||
}
|
||||
|
||||
if (!changed)
|
||||
return;
|
||||
|
||||
if (c.match_length <= 1 && n.match_length != 2) {
|
||||
n.orgstart++;
|
||||
*current = c;
|
||||
*next = n;
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Z_INTERNAL block_state deflate_medium(deflate_state *s, int flush) {
|
||||
/* Align the first struct to start on a new cacheline, this allows us to fit both structs in one cacheline */
|
||||
ALIGNED_(16) struct match current_match;
|
||||
struct match next_match;
|
||||
|
||||
/* For levels below 5, don't check the next position for a better match */
|
||||
int early_exit = s->level < 5;
|
||||
|
||||
memset(¤t_match, 0, sizeof(struct match));
|
||||
memset(&next_match, 0, sizeof(struct match));
|
||||
|
||||
for (;;) {
|
||||
Pos hash_head = 0; /* head of the hash chain */
|
||||
int bflush = 0; /* set if current block must be flushed */
|
||||
int64_t dist;
|
||||
|
||||
/* Make sure that we always have enough lookahead, except
|
||||
* at the end of the input file. We need STD_MAX_MATCH bytes
|
||||
* for the next match, plus WANT_MIN_MATCH bytes to insert the
|
||||
* string following the next current_match.
|
||||
*/
|
||||
if (s->lookahead < MIN_LOOKAHEAD) {
|
||||
PREFIX(fill_window)(s);
|
||||
if (s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH) {
|
||||
return need_more;
|
||||
}
|
||||
if (UNLIKELY(s->lookahead == 0))
|
||||
break; /* flush the current block */
|
||||
next_match.match_length = 0;
|
||||
}
|
||||
|
||||
/* Insert the string window[strstart .. strstart+2] in the
|
||||
* dictionary, and set hash_head to the head of the hash chain:
|
||||
*/
|
||||
|
||||
/* If we already have a future match from a previous round, just use that */
|
||||
if (!early_exit && next_match.match_length > 0) {
|
||||
current_match = next_match;
|
||||
next_match.match_length = 0;
|
||||
} else {
|
||||
hash_head = 0;
|
||||
if (s->lookahead >= WANT_MIN_MATCH) {
|
||||
hash_head = quick_insert_string(s, s->strstart);
|
||||
}
|
||||
|
||||
current_match.strstart = (uint16_t)s->strstart;
|
||||
current_match.orgstart = current_match.strstart;
|
||||
|
||||
/* Find the longest match, discarding those <= prev_length.
|
||||
* At this point we have always match_length < WANT_MIN_MATCH
|
||||
*/
|
||||
|
||||
dist = (int64_t)s->strstart - hash_head;
|
||||
if (dist <= MAX_DIST(s) && dist > 0 && hash_head != 0) {
|
||||
/* To simplify the code, we prevent matches with the string
|
||||
* of window index 0 (in particular we have to avoid a match
|
||||
* of the string with itself at the start of the input file).
|
||||
*/
|
||||
current_match.match_length = (uint16_t)FUNCTABLE_CALL(longest_match)(s, hash_head);
|
||||
current_match.match_start = (uint16_t)s->match_start;
|
||||
if (UNLIKELY(current_match.match_length < WANT_MIN_MATCH))
|
||||
current_match.match_length = 1;
|
||||
if (UNLIKELY(current_match.match_start >= current_match.strstart)) {
|
||||
/* this can happen due to some restarts */
|
||||
current_match.match_length = 1;
|
||||
}
|
||||
} else {
|
||||
/* Set up the match to be a 1 byte literal */
|
||||
current_match.match_start = 0;
|
||||
current_match.match_length = 1;
|
||||
}
|
||||
}
|
||||
|
||||
insert_match(s, current_match);
|
||||
|
||||
/* now, look ahead one */
|
||||
if (LIKELY(!early_exit && s->lookahead > MIN_LOOKAHEAD && (uint32_t)(current_match.strstart + current_match.match_length) < (s->window_size - MIN_LOOKAHEAD))) {
|
||||
s->strstart = current_match.strstart + current_match.match_length;
|
||||
hash_head = quick_insert_string(s, s->strstart);
|
||||
|
||||
next_match.strstart = (uint16_t)s->strstart;
|
||||
next_match.orgstart = next_match.strstart;
|
||||
|
||||
/* Find the longest match, discarding those <= prev_length.
|
||||
* At this point we have always match_length < WANT_MIN_MATCH
|
||||
*/
|
||||
|
||||
dist = (int64_t)s->strstart - hash_head;
|
||||
if (dist <= MAX_DIST(s) && dist > 0 && hash_head != 0) {
|
||||
/* To simplify the code, we prevent matches with the string
|
||||
* of window index 0 (in particular we have to avoid a match
|
||||
* of the string with itself at the start of the input file).
|
||||
*/
|
||||
next_match.match_length = (uint16_t)FUNCTABLE_CALL(longest_match)(s, hash_head);
|
||||
next_match.match_start = (uint16_t)s->match_start;
|
||||
if (UNLIKELY(next_match.match_start >= next_match.strstart)) {
|
||||
/* this can happen due to some restarts */
|
||||
next_match.match_length = 1;
|
||||
}
|
||||
if (next_match.match_length < WANT_MIN_MATCH)
|
||||
next_match.match_length = 1;
|
||||
else
|
||||
fizzle_matches(s, ¤t_match, &next_match);
|
||||
} else {
|
||||
/* Set up the match to be a 1 byte literal */
|
||||
next_match.match_start = 0;
|
||||
next_match.match_length = 1;
|
||||
}
|
||||
|
||||
s->strstart = current_match.strstart;
|
||||
} else {
|
||||
next_match.match_length = 0;
|
||||
}
|
||||
|
||||
/* now emit the current match */
|
||||
bflush = emit_match(s, current_match);
|
||||
|
||||
/* move the "cursor" forward */
|
||||
s->strstart += current_match.match_length;
|
||||
|
||||
if (UNLIKELY(bflush))
|
||||
FLUSH_BLOCK(s, 0);
|
||||
}
|
||||
s->insert = s->strstart < (STD_MIN_MATCH - 1) ? s->strstart : (STD_MIN_MATCH - 1);
|
||||
if (flush == Z_FINISH) {
|
||||
FLUSH_BLOCK(s, 1);
|
||||
return finish_done;
|
||||
}
|
||||
if (UNLIKELY(s->sym_next))
|
||||
FLUSH_BLOCK(s, 0);
|
||||
|
||||
return block_done;
|
||||
}
|
||||
#endif
|
||||
@@ -1,128 +0,0 @@
|
||||
/* deflate_p.h -- Private inline functions and macros shared with more than
|
||||
* one deflate method
|
||||
*
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef DEFLATE_P_H
|
||||
#define DEFLATE_P_H
|
||||
|
||||
/* Forward declare common non-inlined functions declared in deflate.c */
|
||||
|
||||
#ifdef ZLIB_DEBUG
|
||||
/* ===========================================================================
|
||||
* Check that the match at match_start is indeed a match.
|
||||
*/
|
||||
static inline void check_match(deflate_state *s, Pos start, Pos match, int length) {
|
||||
/* check that the match length is valid*/
|
||||
if (length < STD_MIN_MATCH || length > STD_MAX_MATCH) {
|
||||
fprintf(stderr, " start %u, match %u, length %d\n", start, match, length);
|
||||
z_error("invalid match length");
|
||||
}
|
||||
/* check that the match isn't at the same position as the start string */
|
||||
if (match == start) {
|
||||
fprintf(stderr, " start %u, match %u, length %d\n", start, match, length);
|
||||
z_error("invalid match position");
|
||||
}
|
||||
/* check that the match is indeed a match */
|
||||
if (memcmp(s->window + match, s->window + start, length) != 0) {
|
||||
int32_t i = 0;
|
||||
fprintf(stderr, " start %u, match %u, length %d\n", start, match, length);
|
||||
do {
|
||||
fprintf(stderr, " %03d: match [%02x] start [%02x]\n", i++,
|
||||
s->window[match++], s->window[start++]);
|
||||
} while (--length != 0);
|
||||
z_error("invalid match");
|
||||
}
|
||||
if (z_verbose > 1) {
|
||||
fprintf(stderr, "\\[%u,%d]", start-match, length);
|
||||
do {
|
||||
putc(s->window[start++], stderr);
|
||||
} while (--length != 0);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#define check_match(s, start, match, length)
|
||||
#endif
|
||||
|
||||
Z_INTERNAL void PREFIX(flush_pending)(PREFIX3(stream) *strm);
|
||||
Z_INTERNAL unsigned PREFIX(read_buf)(PREFIX3(stream) *strm, unsigned char *buf, unsigned size);
|
||||
|
||||
/* ===========================================================================
|
||||
* Save the match info and tally the frequency counts. Return true if
|
||||
* the current block must be flushed.
|
||||
*/
|
||||
|
||||
extern const unsigned char Z_INTERNAL zng_length_code[];
|
||||
extern const unsigned char Z_INTERNAL zng_dist_code[];
|
||||
|
||||
static inline int zng_tr_tally_lit(deflate_state *s, unsigned char c) {
|
||||
/* c is the unmatched char */
|
||||
#ifdef LIT_MEM
|
||||
s->d_buf[s->sym_next] = 0;
|
||||
s->l_buf[s->sym_next++] = c;
|
||||
#else
|
||||
s->sym_buf[s->sym_next++] = 0;
|
||||
s->sym_buf[s->sym_next++] = 0;
|
||||
s->sym_buf[s->sym_next++] = c;
|
||||
#endif
|
||||
s->dyn_ltree[c].Freq++;
|
||||
Tracevv((stderr, "%c", c));
|
||||
Assert(c <= (STD_MAX_MATCH-STD_MIN_MATCH), "zng_tr_tally: bad literal");
|
||||
return (s->sym_next == s->sym_end);
|
||||
}
|
||||
|
||||
static inline int zng_tr_tally_dist(deflate_state* s, uint32_t dist, uint32_t len) {
|
||||
/* dist: distance of matched string */
|
||||
/* len: match length-STD_MIN_MATCH */
|
||||
#ifdef LIT_MEM
|
||||
Assert(dist <= UINT16_MAX, "dist should fit in uint16_t");
|
||||
Assert(len <= UINT8_MAX, "len should fit in uint8_t");
|
||||
s->d_buf[s->sym_next] = (uint16_t)dist;
|
||||
s->l_buf[s->sym_next++] = (uint8_t)len;
|
||||
#else
|
||||
s->sym_buf[s->sym_next++] = (uint8_t)(dist);
|
||||
s->sym_buf[s->sym_next++] = (uint8_t)(dist >> 8);
|
||||
s->sym_buf[s->sym_next++] = (uint8_t)len;
|
||||
#endif
|
||||
s->matches++;
|
||||
dist--;
|
||||
Assert(dist < MAX_DIST(s) && (uint16_t)d_code(dist) < (uint16_t)D_CODES,
|
||||
"zng_tr_tally: bad match");
|
||||
|
||||
s->dyn_ltree[zng_length_code[len] + LITERALS + 1].Freq++;
|
||||
s->dyn_dtree[d_code(dist)].Freq++;
|
||||
return (s->sym_next == s->sym_end);
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Flush the current block, with given end-of-file flag.
|
||||
* IN assertion: strstart is set to the end of the current match.
|
||||
*/
|
||||
#define FLUSH_BLOCK_ONLY(s, last) { \
|
||||
zng_tr_flush_block(s, (s->block_start >= 0 ? \
|
||||
(char *)&s->window[(unsigned)s->block_start] : \
|
||||
NULL), \
|
||||
(uint32_t)((int)s->strstart - s->block_start), \
|
||||
(last)); \
|
||||
s->block_start = (int)s->strstart; \
|
||||
PREFIX(flush_pending)(s->strm); \
|
||||
}
|
||||
|
||||
/* Same but force premature exit if necessary. */
|
||||
#define FLUSH_BLOCK(s, last) { \
|
||||
FLUSH_BLOCK_ONLY(s, last); \
|
||||
if (s->strm->avail_out == 0) return (last) ? finish_started : need_more; \
|
||||
}
|
||||
|
||||
/* Maximum stored block length in deflate format (not including header). */
|
||||
#define MAX_STORED 65535
|
||||
|
||||
/* Compression function. Returns the block state after the call. */
|
||||
typedef block_state (*compress_func) (deflate_state *s, int flush);
|
||||
/* Match function. Returns the longest match. */
|
||||
typedef uint32_t (*match_func) (deflate_state *const s, Pos cur_match);
|
||||
|
||||
#endif
|
||||
@@ -1,130 +0,0 @@
|
||||
/*
|
||||
* The deflate_quick deflate strategy, designed to be used when cycles are
|
||||
* at a premium.
|
||||
*
|
||||
* Copyright (C) 2013 Intel Corporation. All rights reserved.
|
||||
* Authors:
|
||||
* Wajdi Feghali <wajdi.k.feghali@intel.com>
|
||||
* Jim Guilford <james.guilford@intel.com>
|
||||
* Vinodh Gopal <vinodh.gopal@intel.com>
|
||||
* Erdinc Ozturk <erdinc.ozturk@intel.com>
|
||||
* Jim Kukunas <james.t.kukunas@linux.intel.com>
|
||||
*
|
||||
* Portions are Copyright (C) 2016 12Sided Technology, LLC.
|
||||
* Author:
|
||||
* Phil Vachon <pvachon@12sidedtech.com>
|
||||
*
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "zmemory.h"
|
||||
#include "deflate.h"
|
||||
#include "deflate_p.h"
|
||||
#include "functable.h"
|
||||
#include "trees_emit.h"
|
||||
|
||||
extern const ct_data static_ltree[L_CODES+2];
|
||||
extern const ct_data static_dtree[D_CODES];
|
||||
|
||||
#define QUICK_START_BLOCK(s, last) { \
|
||||
zng_tr_emit_tree(s, STATIC_TREES, last); \
|
||||
s->block_open = 1 + (int)last; \
|
||||
s->block_start = (int)s->strstart; \
|
||||
}
|
||||
|
||||
#define QUICK_END_BLOCK(s, last) { \
|
||||
if (s->block_open) { \
|
||||
zng_tr_emit_end_block(s, static_ltree, last); \
|
||||
s->block_open = 0; \
|
||||
s->block_start = (int)s->strstart; \
|
||||
PREFIX(flush_pending)(s->strm); \
|
||||
if (s->strm->avail_out == 0) \
|
||||
return (last) ? finish_started : need_more; \
|
||||
} \
|
||||
}
|
||||
|
||||
Z_INTERNAL block_state deflate_quick(deflate_state *s, int flush) {
|
||||
Pos hash_head;
|
||||
int64_t dist;
|
||||
unsigned match_len, last;
|
||||
|
||||
|
||||
last = (flush == Z_FINISH) ? 1 : 0;
|
||||
if (UNLIKELY(last && s->block_open != 2)) {
|
||||
/* Emit end of previous block */
|
||||
QUICK_END_BLOCK(s, 0);
|
||||
/* Emit start of last block */
|
||||
QUICK_START_BLOCK(s, last);
|
||||
} else if (UNLIKELY(s->block_open == 0 && s->lookahead > 0)) {
|
||||
/* Start new block only when we have lookahead data, so that if no
|
||||
input data is given an empty block will not be written */
|
||||
QUICK_START_BLOCK(s, last);
|
||||
}
|
||||
|
||||
for (;;) {
|
||||
if (UNLIKELY(s->pending + ((BIT_BUF_SIZE + 7) >> 3) >= s->pending_buf_size)) {
|
||||
PREFIX(flush_pending)(s->strm);
|
||||
if (s->strm->avail_out == 0) {
|
||||
return (last && s->strm->avail_in == 0 && s->bi_valid == 0 && s->block_open == 0) ? finish_started : need_more;
|
||||
}
|
||||
}
|
||||
|
||||
if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD)) {
|
||||
PREFIX(fill_window)(s);
|
||||
if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) {
|
||||
return need_more;
|
||||
}
|
||||
if (UNLIKELY(s->lookahead == 0))
|
||||
break;
|
||||
|
||||
if (UNLIKELY(s->block_open == 0)) {
|
||||
/* Start new block when we have lookahead data, so that if no
|
||||
input data is given an empty block will not be written */
|
||||
QUICK_START_BLOCK(s, last);
|
||||
}
|
||||
}
|
||||
|
||||
if (LIKELY(s->lookahead >= WANT_MIN_MATCH)) {
|
||||
hash_head = quick_insert_string(s, s->strstart);
|
||||
dist = (int64_t)s->strstart - hash_head;
|
||||
|
||||
if (dist <= MAX_DIST(s) && dist > 0) {
|
||||
const uint8_t *str_start = s->window + s->strstart;
|
||||
const uint8_t *match_start = s->window + hash_head;
|
||||
|
||||
if (zng_memcmp_2(str_start, match_start) == 0) {
|
||||
match_len = FUNCTABLE_CALL(compare256)(str_start+2, match_start+2) + 2;
|
||||
|
||||
if (match_len >= WANT_MIN_MATCH) {
|
||||
if (UNLIKELY(match_len > s->lookahead))
|
||||
match_len = s->lookahead;
|
||||
if (UNLIKELY(match_len > STD_MAX_MATCH))
|
||||
match_len = STD_MAX_MATCH;
|
||||
|
||||
Assert(s->strstart <= UINT16_MAX, "strstart should fit in uint16_t");
|
||||
check_match(s, (Pos)s->strstart, hash_head, match_len);
|
||||
|
||||
zng_tr_emit_dist(s, static_ltree, static_dtree, match_len - STD_MIN_MATCH, (uint32_t)dist);
|
||||
s->lookahead -= match_len;
|
||||
s->strstart += match_len;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
zng_tr_emit_lit(s, static_ltree, s->window[s->strstart]);
|
||||
s->strstart++;
|
||||
s->lookahead--;
|
||||
}
|
||||
|
||||
s->insert = s->strstart < (STD_MIN_MATCH - 1) ? s->strstart : (STD_MIN_MATCH - 1);
|
||||
if (UNLIKELY(last)) {
|
||||
QUICK_END_BLOCK(s, 1);
|
||||
return finish_done;
|
||||
}
|
||||
|
||||
QUICK_END_BLOCK(s, 0);
|
||||
return block_done;
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
/* deflate_rle.c -- compress data using RLE strategy of deflation algorithm
|
||||
*
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "deflate.h"
|
||||
#include "deflate_p.h"
|
||||
#include "functable.h"
|
||||
#include "compare256_rle.h"
|
||||
|
||||
#if OPTIMAL_CMP == 8
|
||||
# define compare256_rle compare256_rle_8
|
||||
#elif defined(HAVE_BUILTIN_CTZLL)
|
||||
# define compare256_rle compare256_rle_64
|
||||
#elif defined(HAVE_BUILTIN_CTZ)
|
||||
# define compare256_rle compare256_rle_32
|
||||
#else
|
||||
# define compare256_rle compare256_rle_16
|
||||
#endif
|
||||
|
||||
/* ===========================================================================
|
||||
* For Z_RLE, simply look for runs of bytes, generate matches only of distance
|
||||
* one. Do not maintain a hash table. (It will be regenerated if this run of
|
||||
* deflate switches away from Z_RLE.)
|
||||
*/
|
||||
Z_INTERNAL block_state deflate_rle(deflate_state *s, int flush) {
|
||||
int bflush = 0; /* set if current block must be flushed */
|
||||
unsigned char *scan; /* scan goes up to strend for length of run */
|
||||
uint32_t match_len = 0;
|
||||
|
||||
for (;;) {
|
||||
/* Make sure that we always have enough lookahead, except
|
||||
* at the end of the input file. We need STD_MAX_MATCH bytes
|
||||
* for the longest run, plus one for the unrolled loop.
|
||||
*/
|
||||
if (s->lookahead <= STD_MAX_MATCH) {
|
||||
PREFIX(fill_window)(s);
|
||||
if (s->lookahead <= STD_MAX_MATCH && flush == Z_NO_FLUSH)
|
||||
return need_more;
|
||||
if (s->lookahead == 0)
|
||||
break; /* flush the current block */
|
||||
}
|
||||
|
||||
/* See how many times the previous byte repeats */
|
||||
if (s->lookahead >= STD_MIN_MATCH && s->strstart > 0) {
|
||||
scan = s->window + s->strstart - 1;
|
||||
if (scan[0] == scan[1] && scan[1] == scan[2]) {
|
||||
match_len = compare256_rle(scan, scan+3)+2;
|
||||
match_len = MIN(match_len, s->lookahead);
|
||||
match_len = MIN(match_len, STD_MAX_MATCH);
|
||||
}
|
||||
Assert(scan+match_len <= s->window + s->window_size - 1, "wild scan");
|
||||
}
|
||||
|
||||
/* Emit match if have run of STD_MIN_MATCH or longer, else emit literal */
|
||||
if (match_len >= STD_MIN_MATCH) {
|
||||
Assert(s->strstart <= UINT16_MAX, "strstart should fit in uint16_t");
|
||||
check_match(s, (Pos)s->strstart, (Pos)(s->strstart - 1), match_len);
|
||||
|
||||
bflush = zng_tr_tally_dist(s, 1, match_len - STD_MIN_MATCH);
|
||||
|
||||
s->lookahead -= match_len;
|
||||
s->strstart += match_len;
|
||||
match_len = 0;
|
||||
} else {
|
||||
/* No match, output a literal byte */
|
||||
bflush = zng_tr_tally_lit(s, s->window[s->strstart]);
|
||||
s->lookahead--;
|
||||
s->strstart++;
|
||||
}
|
||||
if (bflush)
|
||||
FLUSH_BLOCK(s, 0);
|
||||
}
|
||||
s->insert = 0;
|
||||
if (flush == Z_FINISH) {
|
||||
FLUSH_BLOCK(s, 1);
|
||||
return finish_done;
|
||||
}
|
||||
if (s->sym_next)
|
||||
FLUSH_BLOCK(s, 0);
|
||||
return block_done;
|
||||
}
|
||||
@@ -1,144 +0,0 @@
|
||||
/* deflate_slow.c -- compress data using the slow strategy of deflation algorithm
|
||||
*
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "deflate.h"
|
||||
#include "deflate_p.h"
|
||||
#include "functable.h"
|
||||
|
||||
/* ===========================================================================
|
||||
* Same as deflate_medium, but achieves better compression. We use a lazy
|
||||
* evaluation for matches: a match is finally adopted only if there is
|
||||
* no better match at the next window position.
|
||||
*/
|
||||
Z_INTERNAL block_state deflate_slow(deflate_state *s, int flush) {
|
||||
Pos hash_head; /* head of hash chain */
|
||||
int bflush; /* set if current block must be flushed */
|
||||
int64_t dist;
|
||||
uint32_t match_len;
|
||||
match_func longest_match;
|
||||
|
||||
if (s->max_chain_length <= 1024)
|
||||
longest_match = FUNCTABLE_FPTR(longest_match);
|
||||
else
|
||||
longest_match = FUNCTABLE_FPTR(longest_match_slow);
|
||||
|
||||
/* Process the input block. */
|
||||
for (;;) {
|
||||
/* Make sure that we always have enough lookahead, except
|
||||
* at the end of the input file. We need STD_MAX_MATCH bytes
|
||||
* for the next match, plus WANT_MIN_MATCH bytes to insert the
|
||||
* string following the next match.
|
||||
*/
|
||||
if (s->lookahead < MIN_LOOKAHEAD) {
|
||||
PREFIX(fill_window)(s);
|
||||
if (UNLIKELY(s->lookahead < MIN_LOOKAHEAD && flush == Z_NO_FLUSH)) {
|
||||
return need_more;
|
||||
}
|
||||
if (UNLIKELY(s->lookahead == 0))
|
||||
break; /* flush the current block */
|
||||
}
|
||||
|
||||
/* Insert the string window[strstart .. strstart+2] in the
|
||||
* dictionary, and set hash_head to the head of the hash chain:
|
||||
*/
|
||||
hash_head = 0;
|
||||
if (LIKELY(s->lookahead >= WANT_MIN_MATCH)) {
|
||||
hash_head = s->quick_insert_string(s, s->strstart);
|
||||
}
|
||||
|
||||
/* Find the longest match, discarding those <= prev_length.
|
||||
*/
|
||||
s->prev_match = (Pos)s->match_start;
|
||||
match_len = STD_MIN_MATCH - 1;
|
||||
dist = (int64_t)s->strstart - hash_head;
|
||||
|
||||
if (dist <= MAX_DIST(s) && dist > 0 && s->prev_length < s->max_lazy_match && hash_head != 0) {
|
||||
/* To simplify the code, we prevent matches with the string
|
||||
* of window index 0 (in particular we have to avoid a match
|
||||
* of the string with itself at the start of the input file).
|
||||
*/
|
||||
match_len = longest_match(s, hash_head);
|
||||
/* longest_match() sets match_start */
|
||||
|
||||
if (match_len <= 5 && (s->strategy == Z_FILTERED)) {
|
||||
/* If prev_match is also WANT_MIN_MATCH, match_start is garbage
|
||||
* but we will ignore the current match anyway.
|
||||
*/
|
||||
match_len = STD_MIN_MATCH - 1;
|
||||
}
|
||||
}
|
||||
/* If there was a match at the previous step and the current
|
||||
* match is not better, output the previous match:
|
||||
*/
|
||||
if (s->prev_length >= STD_MIN_MATCH && match_len <= s->prev_length) {
|
||||
unsigned int max_insert = s->strstart + s->lookahead - STD_MIN_MATCH;
|
||||
/* Do not insert strings in hash table beyond this. */
|
||||
|
||||
Assert((s->strstart-1) <= UINT16_MAX, "strstart-1 should fit in uint16_t");
|
||||
check_match(s, (Pos)(s->strstart - 1), s->prev_match, s->prev_length);
|
||||
|
||||
bflush = zng_tr_tally_dist(s, s->strstart -1 - s->prev_match, s->prev_length - STD_MIN_MATCH);
|
||||
|
||||
/* Insert in hash table all strings up to the end of the match.
|
||||
* strstart-1 and strstart are already inserted. If there is not
|
||||
* enough lookahead, the last two strings are not inserted in
|
||||
* the hash table.
|
||||
*/
|
||||
s->prev_length -= 1;
|
||||
s->lookahead -= s->prev_length;
|
||||
|
||||
unsigned int mov_fwd = s->prev_length - 1;
|
||||
if (max_insert > s->strstart) {
|
||||
unsigned int insert_cnt = mov_fwd;
|
||||
if (UNLIKELY(insert_cnt > max_insert - s->strstart))
|
||||
insert_cnt = max_insert - s->strstart;
|
||||
s->insert_string(s, s->strstart + 1, insert_cnt);
|
||||
}
|
||||
s->prev_length = 0;
|
||||
s->match_available = 0;
|
||||
s->strstart += mov_fwd + 1;
|
||||
|
||||
if (UNLIKELY(bflush))
|
||||
FLUSH_BLOCK(s, 0);
|
||||
|
||||
} else if (s->match_available) {
|
||||
/* If there was no match at the previous position, output a
|
||||
* single literal. If there was a match but the current match
|
||||
* is longer, truncate the previous match to a single literal.
|
||||
*/
|
||||
bflush = zng_tr_tally_lit(s, s->window[s->strstart-1]);
|
||||
if (UNLIKELY(bflush))
|
||||
FLUSH_BLOCK_ONLY(s, 0);
|
||||
s->prev_length = match_len;
|
||||
s->strstart++;
|
||||
s->lookahead--;
|
||||
if (UNLIKELY(s->strm->avail_out == 0))
|
||||
return need_more;
|
||||
} else {
|
||||
/* There is no previous match to compare with, wait for
|
||||
* the next step to decide.
|
||||
*/
|
||||
s->prev_length = match_len;
|
||||
s->match_available = 1;
|
||||
s->strstart++;
|
||||
s->lookahead--;
|
||||
}
|
||||
}
|
||||
Assert(flush != Z_NO_FLUSH, "no flush?");
|
||||
if (UNLIKELY(s->match_available)) {
|
||||
Z_UNUSED(zng_tr_tally_lit(s, s->window[s->strstart-1]));
|
||||
s->match_available = 0;
|
||||
}
|
||||
s->insert = s->strstart < (STD_MIN_MATCH - 1) ? s->strstart : (STD_MIN_MATCH - 1);
|
||||
if (UNLIKELY(flush == Z_FINISH)) {
|
||||
FLUSH_BLOCK(s, 1);
|
||||
return finish_done;
|
||||
}
|
||||
if (UNLIKELY(s->sym_next))
|
||||
FLUSH_BLOCK(s, 0);
|
||||
return block_done;
|
||||
}
|
||||
@@ -1,186 +0,0 @@
|
||||
/* deflate_stored.c -- store data without compression using deflation algorithm
|
||||
*
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "deflate.h"
|
||||
#include "deflate_p.h"
|
||||
#include "functable.h"
|
||||
|
||||
/* ===========================================================================
|
||||
* Copy without compression as much as possible from the input stream, return
|
||||
* the current block state.
|
||||
*
|
||||
* In case deflateParams() is used to later switch to a non-zero compression
|
||||
* level, s->matches (otherwise unused when storing) keeps track of the number
|
||||
* of hash table slides to perform. If s->matches is 1, then one hash table
|
||||
* slide will be done when switching. If s->matches is 2, the maximum value
|
||||
* allowed here, then the hash table will be cleared, since two or more slides
|
||||
* is the same as a clear.
|
||||
*
|
||||
* deflate_stored() is written to minimize the number of times an input byte is
|
||||
* copied. It is most efficient with large input and output buffers, which
|
||||
* maximizes the opportunities to have a single copy from next_in to next_out.
|
||||
*/
|
||||
Z_INTERNAL block_state deflate_stored(deflate_state *s, int flush) {
|
||||
/* Smallest worthy block size when not flushing or finishing. By default
|
||||
* this is 32K. This can be as small as 507 bytes for memLevel == 1. For
|
||||
* large input and output buffers, the stored block size will be larger.
|
||||
*/
|
||||
unsigned min_block = MIN(s->pending_buf_size - 5, s->w_size);
|
||||
|
||||
/* Copy as many min_block or larger stored blocks directly to next_out as
|
||||
* possible. If flushing, copy the remaining available input to next_out as
|
||||
* stored blocks, if there is enough space.
|
||||
*/
|
||||
unsigned len, left, have, last = 0;
|
||||
unsigned used = s->strm->avail_in;
|
||||
do {
|
||||
/* Set len to the maximum size block that we can copy directly with the
|
||||
* available input data and output space. Set left to how much of that
|
||||
* would be copied from what's left in the window.
|
||||
*/
|
||||
len = MAX_STORED; /* maximum deflate stored block length */
|
||||
have = (s->bi_valid + 42) >> 3; /* number of header bytes */
|
||||
if (s->strm->avail_out < have) /* need room for header */
|
||||
break;
|
||||
/* maximum stored block length that will fit in avail_out: */
|
||||
have = s->strm->avail_out - have;
|
||||
left = (int)s->strstart - s->block_start; /* bytes left in window */
|
||||
if (len > (unsigned long)left + s->strm->avail_in)
|
||||
len = left + s->strm->avail_in; /* limit len to the input */
|
||||
len = MIN(len, have); /* limit len to the output */
|
||||
|
||||
/* If the stored block would be less than min_block in length, or if
|
||||
* unable to copy all of the available input when flushing, then try
|
||||
* copying to the window and the pending buffer instead. Also don't
|
||||
* write an empty block when flushing -- deflate() does that.
|
||||
*/
|
||||
if (len < min_block && ((len == 0 && flush != Z_FINISH) || flush == Z_NO_FLUSH || len != left + s->strm->avail_in))
|
||||
break;
|
||||
|
||||
/* Make a dummy stored block in pending to get the header bytes,
|
||||
* including any pending bits. This also updates the debugging counts.
|
||||
*/
|
||||
last = flush == Z_FINISH && len == left + s->strm->avail_in ? 1 : 0;
|
||||
zng_tr_stored_block(s, (char *)0, 0L, last);
|
||||
|
||||
/* Replace the lengths in the dummy stored block with len. */
|
||||
s->pending -= 4;
|
||||
put_short(s, (uint16_t)len);
|
||||
put_short(s, (uint16_t)~len);
|
||||
|
||||
/* Write the stored block header bytes. */
|
||||
PREFIX(flush_pending)(s->strm);
|
||||
|
||||
/* Update debugging counts for the data about to be copied. */
|
||||
cmpr_bits_add(s, len << 3);
|
||||
sent_bits_add(s, len << 3);
|
||||
|
||||
/* Copy uncompressed bytes from the window to next_out. */
|
||||
if (left) {
|
||||
left = MIN(left, len);
|
||||
memcpy(s->strm->next_out, s->window + s->block_start, left);
|
||||
s->strm->next_out += left;
|
||||
s->strm->avail_out -= left;
|
||||
s->strm->total_out += left;
|
||||
s->block_start += (int)left;
|
||||
len -= left;
|
||||
}
|
||||
|
||||
/* Copy uncompressed bytes directly from next_in to next_out, updating
|
||||
* the check value.
|
||||
*/
|
||||
if (len) {
|
||||
PREFIX(read_buf)(s->strm, s->strm->next_out, len);
|
||||
s->strm->next_out += len;
|
||||
s->strm->avail_out -= len;
|
||||
s->strm->total_out += len;
|
||||
}
|
||||
} while (last == 0);
|
||||
|
||||
/* Update the sliding window with the last s->w_size bytes of the copied
|
||||
* data, or append all of the copied data to the existing window if less
|
||||
* than s->w_size bytes were copied. Also update the number of bytes to
|
||||
* insert in the hash tables, in the event that deflateParams() switches to
|
||||
* a non-zero compression level.
|
||||
*/
|
||||
used -= s->strm->avail_in; /* number of input bytes directly copied */
|
||||
if (used) {
|
||||
/* If any input was used, then no unused input remains in the window,
|
||||
* therefore s->block_start == s->strstart.
|
||||
*/
|
||||
if (used >= s->w_size) { /* supplant the previous history */
|
||||
s->matches = 2; /* clear hash */
|
||||
memcpy(s->window, s->strm->next_in - s->w_size, s->w_size);
|
||||
s->strstart = s->w_size;
|
||||
s->insert = s->strstart;
|
||||
} else {
|
||||
if (s->window_size - s->strstart <= used) {
|
||||
/* Slide the window down. */
|
||||
s->strstart -= s->w_size;
|
||||
memcpy(s->window, s->window + s->w_size, s->strstart);
|
||||
if (s->matches < 2)
|
||||
s->matches++; /* add a pending slide_hash() */
|
||||
s->insert = MIN(s->insert, s->strstart);
|
||||
}
|
||||
memcpy(s->window + s->strstart, s->strm->next_in - used, used);
|
||||
s->strstart += used;
|
||||
s->insert += MIN(used, s->w_size - s->insert);
|
||||
}
|
||||
s->block_start = (int)s->strstart;
|
||||
}
|
||||
s->high_water = MAX(s->high_water, s->strstart);
|
||||
|
||||
/* If the last block was written to next_out, then done. */
|
||||
if (last)
|
||||
return finish_done;
|
||||
|
||||
/* If flushing and all input has been consumed, then done. */
|
||||
if (flush != Z_NO_FLUSH && flush != Z_FINISH && s->strm->avail_in == 0 && (int)s->strstart == s->block_start)
|
||||
return block_done;
|
||||
|
||||
/* Fill the window with any remaining input. */
|
||||
have = s->window_size - s->strstart;
|
||||
if (s->strm->avail_in > have && s->block_start >= (int)s->w_size) {
|
||||
/* Slide the window down. */
|
||||
s->block_start -= (int)s->w_size;
|
||||
s->strstart -= s->w_size;
|
||||
memcpy(s->window, s->window + s->w_size, s->strstart);
|
||||
if (s->matches < 2)
|
||||
s->matches++; /* add a pending slide_hash() */
|
||||
have += s->w_size; /* more space now */
|
||||
s->insert = MIN(s->insert, s->strstart);
|
||||
}
|
||||
|
||||
have = MIN(have, s->strm->avail_in);
|
||||
if (have) {
|
||||
PREFIX(read_buf)(s->strm, s->window + s->strstart, have);
|
||||
s->strstart += have;
|
||||
s->insert += MIN(have, s->w_size - s->insert);
|
||||
}
|
||||
s->high_water = MAX(s->high_water, s->strstart);
|
||||
|
||||
/* There was not enough avail_out to write a complete worthy or flushed
|
||||
* stored block to next_out. Write a stored block to pending instead, if we
|
||||
* have enough input for a worthy block, or if flushing and there is enough
|
||||
* room for the remaining input as a stored block in the pending buffer.
|
||||
*/
|
||||
have = (s->bi_valid + 42) >> 3; /* number of header bytes */
|
||||
/* maximum stored block length that will fit in pending: */
|
||||
have = MIN(s->pending_buf_size - have, MAX_STORED);
|
||||
min_block = MIN(have, s->w_size);
|
||||
left = (int)s->strstart - s->block_start;
|
||||
if (left >= min_block || ((left || flush == Z_FINISH) && flush != Z_NO_FLUSH && s->strm->avail_in == 0 && left <= have)) {
|
||||
len = MIN(left, have);
|
||||
last = flush == Z_FINISH && s->strm->avail_in == 0 && len == left ? 1 : 0;
|
||||
zng_tr_stored_block(s, (char *)s->window + s->block_start, len, last);
|
||||
s->block_start += (int)len;
|
||||
PREFIX(flush_pending)(s->strm);
|
||||
}
|
||||
|
||||
/* We've done all we can with the available input and output. */
|
||||
return last ? finish_started : need_more;
|
||||
}
|
||||
@@ -1,47 +0,0 @@
|
||||
#ifndef FALLBACK_BUILTINS_H
|
||||
#define FALLBACK_BUILTINS_H
|
||||
|
||||
#if defined(_MSC_VER) && !defined(__clang__)
|
||||
#if defined(_M_IX86) || defined(_M_AMD64) || defined(_M_IA64) || defined(_M_ARM) || defined(_M_ARM64) || defined(_M_ARM64EC)
|
||||
|
||||
#include <intrin.h>
|
||||
|
||||
/* This is not a general purpose replacement for __builtin_ctz. The function expects that value is != 0.
|
||||
* Because of that assumption trailing_zero is not initialized and the return value is not checked.
|
||||
* Tzcnt and bsf give identical results except when input value is 0, therefore this can not be allowed.
|
||||
* If tzcnt instruction is not supported, the cpu will itself execute bsf instead.
|
||||
* Performance tzcnt/bsf is identical on Intel cpu, tzcnt is faster than bsf on AMD cpu.
|
||||
*/
|
||||
static __forceinline int __builtin_ctz(unsigned int value) {
|
||||
Assert(value != 0, "Invalid input value: 0");
|
||||
# if defined(X86_FEATURES) && !(_MSC_VER < 1700)
|
||||
return (int)_tzcnt_u32(value);
|
||||
# else
|
||||
unsigned long trailing_zero;
|
||||
_BitScanForward(&trailing_zero, value);
|
||||
return (int)trailing_zero;
|
||||
# endif
|
||||
}
|
||||
#define HAVE_BUILTIN_CTZ
|
||||
|
||||
#ifdef _M_AMD64
|
||||
/* This is not a general purpose replacement for __builtin_ctzll. The function expects that value is != 0.
|
||||
* Because of that assumption trailing_zero is not initialized and the return value is not checked.
|
||||
*/
|
||||
static __forceinline int __builtin_ctzll(unsigned long long value) {
|
||||
Assert(value != 0, "Invalid input value: 0");
|
||||
# if defined(X86_FEATURES) && !(_MSC_VER < 1700)
|
||||
return (int)_tzcnt_u64(value);
|
||||
# else
|
||||
unsigned long trailing_zero;
|
||||
_BitScanForward64(&trailing_zero, value);
|
||||
return (int)trailing_zero;
|
||||
# endif
|
||||
}
|
||||
#define HAVE_BUILTIN_CTZLL
|
||||
#endif // Microsoft AMD64
|
||||
|
||||
#endif // Microsoft AMD64/IA64/x86/ARM/ARM64 test
|
||||
#endif // _MSC_VER & !clang
|
||||
|
||||
#endif // include guard FALLBACK_BUILTINS_H
|
||||
@@ -1,363 +0,0 @@
|
||||
/* functable.c -- Choose relevant optimized functions at runtime
|
||||
* Copyright (C) 2017 Hans Kristian Rosbach
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
#ifndef DISABLE_RUNTIME_CPU_DETECTION
|
||||
|
||||
#include "zbuild.h"
|
||||
|
||||
#if defined(_MSC_VER)
|
||||
# include <intrin.h>
|
||||
#endif
|
||||
|
||||
#include "functable.h"
|
||||
#include "cpu_features.h"
|
||||
#include "arch_functions.h"
|
||||
|
||||
/* Platform has pointer size atomic store */
|
||||
#if defined(__GNUC__) || defined(__clang__)
|
||||
# define FUNCTABLE_ASSIGN(VAR, FUNC_NAME) \
|
||||
__atomic_store(&(functable.FUNC_NAME), &(VAR.FUNC_NAME), __ATOMIC_SEQ_CST)
|
||||
# define FUNCTABLE_BARRIER() __atomic_thread_fence(__ATOMIC_SEQ_CST)
|
||||
#elif defined(_MSC_VER)
|
||||
# define FUNCTABLE_ASSIGN(VAR, FUNC_NAME) \
|
||||
_InterlockedExchangePointer((void * volatile *)&(functable.FUNC_NAME), (void *)(VAR.FUNC_NAME))
|
||||
# if defined(_M_ARM) || defined(_M_ARM64)
|
||||
# define FUNCTABLE_BARRIER() do { \
|
||||
_ReadWriteBarrier(); \
|
||||
__dmb(0xB); /* _ARM_BARRIER_ISH */ \
|
||||
_ReadWriteBarrier(); \
|
||||
} while (0)
|
||||
# else
|
||||
# define FUNCTABLE_BARRIER() _ReadWriteBarrier()
|
||||
# endif
|
||||
#else
|
||||
# warning Unable to detect atomic intrinsic support.
|
||||
# define FUNCTABLE_ASSIGN(VAR, FUNC_NAME) \
|
||||
*((void * volatile *)&(functable.FUNC_NAME)) = (void *)(VAR.FUNC_NAME)
|
||||
# define FUNCTABLE_BARRIER() do { /* Empty */ } while (0)
|
||||
#endif
|
||||
|
||||
static void force_init_empty(void) {
|
||||
// empty
|
||||
}
|
||||
|
||||
static void init_functable(void) {
|
||||
struct functable_s ft;
|
||||
struct cpu_features cf;
|
||||
|
||||
cpu_check_features(&cf);
|
||||
|
||||
// Generic code
|
||||
ft.force_init = &force_init_empty;
|
||||
ft.adler32 = &adler32_c;
|
||||
ft.adler32_fold_copy = &adler32_fold_copy_c;
|
||||
ft.chunkmemset_safe = &chunkmemset_safe_c;
|
||||
ft.chunksize = &chunksize_c;
|
||||
ft.crc32 = &crc32_c;
|
||||
ft.crc32_fold = &crc32_fold_c;
|
||||
ft.crc32_fold_copy = &crc32_fold_copy_c;
|
||||
ft.crc32_fold_final = &crc32_fold_final_c;
|
||||
ft.crc32_fold_reset = &crc32_fold_reset_c;
|
||||
ft.inflate_fast = &inflate_fast_c;
|
||||
ft.slide_hash = &slide_hash_c;
|
||||
ft.longest_match = &longest_match_c;
|
||||
ft.longest_match_slow = &longest_match_slow_c;
|
||||
ft.compare256 = &compare256_c;
|
||||
|
||||
// Select arch-optimized functions
|
||||
|
||||
// X86 - SSE2
|
||||
#ifdef X86_SSE2
|
||||
# if !defined(__x86_64__) && !defined(_M_X64) && !defined(X86_NOCHECK_SSE2)
|
||||
if (cf.x86.has_sse2)
|
||||
# endif
|
||||
{
|
||||
ft.chunkmemset_safe = &chunkmemset_safe_sse2;
|
||||
ft.chunksize = &chunksize_sse2;
|
||||
ft.inflate_fast = &inflate_fast_sse2;
|
||||
ft.slide_hash = &slide_hash_sse2;
|
||||
# ifdef HAVE_BUILTIN_CTZ
|
||||
ft.compare256 = &compare256_sse2;
|
||||
ft.longest_match = &longest_match_sse2;
|
||||
ft.longest_match_slow = &longest_match_slow_sse2;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
// X86 - SSSE3
|
||||
#ifdef X86_SSSE3
|
||||
if (cf.x86.has_ssse3) {
|
||||
ft.adler32 = &adler32_ssse3;
|
||||
ft.chunkmemset_safe = &chunkmemset_safe_ssse3;
|
||||
ft.inflate_fast = &inflate_fast_ssse3;
|
||||
}
|
||||
#endif
|
||||
// X86 - SSE4.2
|
||||
#ifdef X86_SSE42
|
||||
if (cf.x86.has_sse42) {
|
||||
ft.adler32_fold_copy = &adler32_fold_copy_sse42;
|
||||
}
|
||||
#endif
|
||||
// X86 - PCLMUL
|
||||
#ifdef X86_PCLMULQDQ_CRC
|
||||
if (cf.x86.has_pclmulqdq) {
|
||||
ft.crc32 = &crc32_pclmulqdq;
|
||||
ft.crc32_fold = &crc32_fold_pclmulqdq;
|
||||
ft.crc32_fold_copy = &crc32_fold_pclmulqdq_copy;
|
||||
ft.crc32_fold_final = &crc32_fold_pclmulqdq_final;
|
||||
ft.crc32_fold_reset = &crc32_fold_pclmulqdq_reset;
|
||||
}
|
||||
#endif
|
||||
// X86 - AVX
|
||||
#ifdef X86_AVX2
|
||||
/* BMI2 support is all but implicit with AVX2 but let's sanity check this just in case. Enabling BMI2 allows for
|
||||
* flagless shifts, resulting in fewer flag stalls for the pipeline, and allows us to set destination registers
|
||||
* for the shift results as an operand, eliminating several register-register moves when the original value needs
|
||||
* to remain intact. They also allow for a count operand that isn't the CL register, avoiding contention there */
|
||||
if (cf.x86.has_avx2 && cf.x86.has_bmi2) {
|
||||
ft.adler32 = &adler32_avx2;
|
||||
ft.adler32_fold_copy = &adler32_fold_copy_avx2;
|
||||
ft.chunkmemset_safe = &chunkmemset_safe_avx2;
|
||||
ft.chunksize = &chunksize_avx2;
|
||||
ft.inflate_fast = &inflate_fast_avx2;
|
||||
ft.slide_hash = &slide_hash_avx2;
|
||||
# ifdef HAVE_BUILTIN_CTZ
|
||||
ft.compare256 = &compare256_avx2;
|
||||
ft.longest_match = &longest_match_avx2;
|
||||
ft.longest_match_slow = &longest_match_slow_avx2;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
// X86 - AVX512 (F,DQ,BW,Vl)
|
||||
#ifdef X86_AVX512
|
||||
if (cf.x86.has_avx512_common) {
|
||||
ft.adler32 = &adler32_avx512;
|
||||
ft.adler32_fold_copy = &adler32_fold_copy_avx512;
|
||||
ft.chunkmemset_safe = &chunkmemset_safe_avx512;
|
||||
ft.chunksize = &chunksize_avx512;
|
||||
ft.inflate_fast = &inflate_fast_avx512;
|
||||
}
|
||||
#endif
|
||||
#ifdef X86_AVX512VNNI
|
||||
if (cf.x86.has_avx512vnni) {
|
||||
ft.adler32 = &adler32_avx512_vnni;
|
||||
ft.adler32_fold_copy = &adler32_fold_copy_avx512_vnni;
|
||||
}
|
||||
#endif
|
||||
// X86 - VPCLMULQDQ
|
||||
#ifdef X86_VPCLMULQDQ_CRC
|
||||
if (cf.x86.has_pclmulqdq && cf.x86.has_avx512_common && cf.x86.has_vpclmulqdq) {
|
||||
ft.crc32 = &crc32_vpclmulqdq;
|
||||
ft.crc32_fold = &crc32_fold_vpclmulqdq;
|
||||
ft.crc32_fold_copy = &crc32_fold_vpclmulqdq_copy;
|
||||
ft.crc32_fold_final = &crc32_fold_vpclmulqdq_final;
|
||||
ft.crc32_fold_reset = &crc32_fold_vpclmulqdq_reset;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// ARM - SIMD
|
||||
#ifdef ARM_SIMD
|
||||
# ifndef ARM_NOCHECK_SIMD
|
||||
if (cf.arm.has_simd)
|
||||
# endif
|
||||
{
|
||||
ft.slide_hash = &slide_hash_armv6;
|
||||
}
|
||||
#endif
|
||||
// ARM - NEON
|
||||
#ifdef ARM_NEON
|
||||
# ifndef ARM_NOCHECK_NEON
|
||||
if (cf.arm.has_neon)
|
||||
# endif
|
||||
{
|
||||
ft.adler32 = &adler32_neon;
|
||||
ft.adler32_fold_copy = &adler32_fold_copy_neon;
|
||||
ft.chunkmemset_safe = &chunkmemset_safe_neon;
|
||||
ft.chunksize = &chunksize_neon;
|
||||
ft.inflate_fast = &inflate_fast_neon;
|
||||
ft.slide_hash = &slide_hash_neon;
|
||||
# ifdef HAVE_BUILTIN_CTZLL
|
||||
ft.compare256 = &compare256_neon;
|
||||
ft.longest_match = &longest_match_neon;
|
||||
ft.longest_match_slow = &longest_match_slow_neon;
|
||||
# endif
|
||||
}
|
||||
#endif
|
||||
// ARM - CRC32
|
||||
#ifdef ARM_CRC32
|
||||
if (cf.arm.has_crc32) {
|
||||
ft.crc32 = &crc32_armv8;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Power - VMX
|
||||
#ifdef PPC_VMX
|
||||
if (cf.power.has_altivec) {
|
||||
ft.adler32 = &adler32_vmx;
|
||||
ft.slide_hash = &slide_hash_vmx;
|
||||
}
|
||||
#endif
|
||||
// Power8 - VSX
|
||||
#ifdef POWER8_VSX
|
||||
if (cf.power.has_arch_2_07) {
|
||||
ft.adler32 = &adler32_power8;
|
||||
ft.chunkmemset_safe = &chunkmemset_safe_power8;
|
||||
ft.chunksize = &chunksize_power8;
|
||||
ft.inflate_fast = &inflate_fast_power8;
|
||||
ft.slide_hash = &slide_hash_power8;
|
||||
}
|
||||
#endif
|
||||
#ifdef POWER8_VSX_CRC32
|
||||
if (cf.power.has_arch_2_07)
|
||||
ft.crc32 = &crc32_power8;
|
||||
#endif
|
||||
// Power9
|
||||
#ifdef POWER9
|
||||
if (cf.power.has_arch_3_00) {
|
||||
ft.compare256 = &compare256_power9;
|
||||
ft.longest_match = &longest_match_power9;
|
||||
ft.longest_match_slow = &longest_match_slow_power9;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// RISCV - RVV
|
||||
#ifdef RISCV_RVV
|
||||
if (cf.riscv.has_rvv) {
|
||||
ft.adler32 = &adler32_rvv;
|
||||
ft.adler32_fold_copy = &adler32_fold_copy_rvv;
|
||||
ft.chunkmemset_safe = &chunkmemset_safe_rvv;
|
||||
ft.chunksize = &chunksize_rvv;
|
||||
ft.compare256 = &compare256_rvv;
|
||||
ft.inflate_fast = &inflate_fast_rvv;
|
||||
ft.longest_match = &longest_match_rvv;
|
||||
ft.longest_match_slow = &longest_match_slow_rvv;
|
||||
ft.slide_hash = &slide_hash_rvv;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// S390
|
||||
#ifdef S390_CRC32_VX
|
||||
if (cf.s390.has_vx)
|
||||
ft.crc32 = crc32_s390_vx;
|
||||
#endif
|
||||
|
||||
// Assign function pointers individually for atomic operation
|
||||
FUNCTABLE_ASSIGN(ft, force_init);
|
||||
FUNCTABLE_ASSIGN(ft, adler32);
|
||||
FUNCTABLE_ASSIGN(ft, adler32_fold_copy);
|
||||
FUNCTABLE_ASSIGN(ft, chunkmemset_safe);
|
||||
FUNCTABLE_ASSIGN(ft, chunksize);
|
||||
FUNCTABLE_ASSIGN(ft, compare256);
|
||||
FUNCTABLE_ASSIGN(ft, crc32);
|
||||
FUNCTABLE_ASSIGN(ft, crc32_fold);
|
||||
FUNCTABLE_ASSIGN(ft, crc32_fold_copy);
|
||||
FUNCTABLE_ASSIGN(ft, crc32_fold_final);
|
||||
FUNCTABLE_ASSIGN(ft, crc32_fold_reset);
|
||||
FUNCTABLE_ASSIGN(ft, inflate_fast);
|
||||
FUNCTABLE_ASSIGN(ft, longest_match);
|
||||
FUNCTABLE_ASSIGN(ft, longest_match_slow);
|
||||
FUNCTABLE_ASSIGN(ft, slide_hash);
|
||||
|
||||
// Memory barrier for weak memory order CPUs
|
||||
FUNCTABLE_BARRIER();
|
||||
}
|
||||
|
||||
/* stub functions */
|
||||
static void force_init_stub(void) {
|
||||
init_functable();
|
||||
}
|
||||
|
||||
static uint32_t adler32_stub(uint32_t adler, const uint8_t* buf, size_t len) {
|
||||
init_functable();
|
||||
return functable.adler32(adler, buf, len);
|
||||
}
|
||||
|
||||
static uint32_t adler32_fold_copy_stub(uint32_t adler, uint8_t* dst, const uint8_t* src, size_t len) {
|
||||
init_functable();
|
||||
return functable.adler32_fold_copy(adler, dst, src, len);
|
||||
}
|
||||
|
||||
static uint8_t* chunkmemset_safe_stub(uint8_t* out, uint8_t *from, unsigned len, unsigned left) {
|
||||
init_functable();
|
||||
return functable.chunkmemset_safe(out, from, len, left);
|
||||
}
|
||||
|
||||
static uint32_t chunksize_stub(void) {
|
||||
init_functable();
|
||||
return functable.chunksize();
|
||||
}
|
||||
|
||||
static uint32_t compare256_stub(const uint8_t* src0, const uint8_t* src1) {
|
||||
init_functable();
|
||||
return functable.compare256(src0, src1);
|
||||
}
|
||||
|
||||
static uint32_t crc32_stub(uint32_t crc, const uint8_t* buf, size_t len) {
|
||||
init_functable();
|
||||
return functable.crc32(crc, buf, len);
|
||||
}
|
||||
|
||||
static void crc32_fold_stub(crc32_fold* crc, const uint8_t* src, size_t len, uint32_t init_crc) {
|
||||
init_functable();
|
||||
functable.crc32_fold(crc, src, len, init_crc);
|
||||
}
|
||||
|
||||
static void crc32_fold_copy_stub(crc32_fold* crc, uint8_t* dst, const uint8_t* src, size_t len) {
|
||||
init_functable();
|
||||
functable.crc32_fold_copy(crc, dst, src, len);
|
||||
}
|
||||
|
||||
static uint32_t crc32_fold_final_stub(crc32_fold* crc) {
|
||||
init_functable();
|
||||
return functable.crc32_fold_final(crc);
|
||||
}
|
||||
|
||||
static uint32_t crc32_fold_reset_stub(crc32_fold* crc) {
|
||||
init_functable();
|
||||
return functable.crc32_fold_reset(crc);
|
||||
}
|
||||
|
||||
static void inflate_fast_stub(PREFIX3(stream) *strm, uint32_t start) {
|
||||
init_functable();
|
||||
functable.inflate_fast(strm, start);
|
||||
}
|
||||
|
||||
static uint32_t longest_match_stub(deflate_state* const s, Pos cur_match) {
|
||||
init_functable();
|
||||
return functable.longest_match(s, cur_match);
|
||||
}
|
||||
|
||||
static uint32_t longest_match_slow_stub(deflate_state* const s, Pos cur_match) {
|
||||
init_functable();
|
||||
return functable.longest_match_slow(s, cur_match);
|
||||
}
|
||||
|
||||
static void slide_hash_stub(deflate_state* s) {
|
||||
init_functable();
|
||||
functable.slide_hash(s);
|
||||
}
|
||||
|
||||
/* functable init */
|
||||
Z_INTERNAL struct functable_s functable = {
|
||||
force_init_stub,
|
||||
adler32_stub,
|
||||
adler32_fold_copy_stub,
|
||||
chunkmemset_safe_stub,
|
||||
chunksize_stub,
|
||||
compare256_stub,
|
||||
crc32_stub,
|
||||
crc32_fold_stub,
|
||||
crc32_fold_copy_stub,
|
||||
crc32_fold_final_stub,
|
||||
crc32_fold_reset_stub,
|
||||
inflate_fast_stub,
|
||||
longest_match_stub,
|
||||
longest_match_slow_stub,
|
||||
slide_hash_stub,
|
||||
};
|
||||
|
||||
#endif
|
||||
@@ -1,55 +0,0 @@
|
||||
/* functable.h -- Struct containing function pointers to optimized functions
|
||||
* Copyright (C) 2017 Hans Kristian Rosbach
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#ifndef FUNCTABLE_H_
|
||||
#define FUNCTABLE_H_
|
||||
|
||||
#include "deflate.h"
|
||||
#include "crc32.h"
|
||||
|
||||
#ifdef DISABLE_RUNTIME_CPU_DETECTION
|
||||
|
||||
# include "arch_functions.h"
|
||||
|
||||
/* When compiling with native instructions it is not necessary to use functable.
|
||||
* Instead we use native_ macro indicating the best available variant of arch-specific
|
||||
* functions for the current platform.
|
||||
*/
|
||||
# define FUNCTABLE_INIT ((void)0)
|
||||
# define FUNCTABLE_CALL(name) native_ ## name
|
||||
# define FUNCTABLE_FPTR(name) &native_ ## name
|
||||
|
||||
#else
|
||||
|
||||
struct functable_s {
|
||||
void (* force_init) (void);
|
||||
uint32_t (* adler32) (uint32_t adler, const uint8_t *buf, size_t len);
|
||||
uint32_t (* adler32_fold_copy) (uint32_t adler, uint8_t *dst, const uint8_t *src, size_t len);
|
||||
uint8_t* (* chunkmemset_safe) (uint8_t *out, uint8_t *from, unsigned len, unsigned left);
|
||||
uint32_t (* chunksize) (void);
|
||||
uint32_t (* compare256) (const uint8_t *src0, const uint8_t *src1);
|
||||
uint32_t (* crc32) (uint32_t crc, const uint8_t *buf, size_t len);
|
||||
void (* crc32_fold) (struct crc32_fold_s *crc, const uint8_t *src, size_t len, uint32_t init_crc);
|
||||
void (* crc32_fold_copy) (struct crc32_fold_s *crc, uint8_t *dst, const uint8_t *src, size_t len);
|
||||
uint32_t (* crc32_fold_final) (struct crc32_fold_s *crc);
|
||||
uint32_t (* crc32_fold_reset) (struct crc32_fold_s *crc);
|
||||
void (* inflate_fast) (PREFIX3(stream) *strm, uint32_t start);
|
||||
uint32_t (* longest_match) (deflate_state *const s, Pos cur_match);
|
||||
uint32_t (* longest_match_slow) (deflate_state *const s, Pos cur_match);
|
||||
void (* slide_hash) (deflate_state *s);
|
||||
};
|
||||
|
||||
Z_INTERNAL extern struct functable_s functable;
|
||||
|
||||
|
||||
/* Explicitly indicate functions are conditionally dispatched.
|
||||
*/
|
||||
# define FUNCTABLE_INIT functable.force_init()
|
||||
# define FUNCTABLE_CALL(name) functable.name
|
||||
# define FUNCTABLE_FPTR(name) functable.name
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
+106
-38
@@ -1,5 +1,3 @@
|
||||
#ifndef GZGUTS_H_
|
||||
#define GZGUTS_H_
|
||||
/* gzguts.h -- zlib internal header definitions for gz* operations
|
||||
* Copyright (C) 2004-2024 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
@@ -13,32 +11,34 @@
|
||||
# undef _TIME_BITS
|
||||
#endif
|
||||
|
||||
#if defined(HAVE_VISIBILITY_INTERNAL)
|
||||
# define Z_INTERNAL __attribute__((visibility ("internal")))
|
||||
#elif defined(HAVE_VISIBILITY_HIDDEN)
|
||||
# define Z_INTERNAL __attribute__((visibility ("hidden")))
|
||||
#ifdef HAVE_HIDDEN
|
||||
# define ZLIB_INTERNAL __attribute__((visibility ("hidden")))
|
||||
#else
|
||||
# define Z_INTERNAL
|
||||
# define ZLIB_INTERNAL
|
||||
#endif
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#if defined(ZLIB_COMPAT)
|
||||
# include "zlib.h"
|
||||
#else
|
||||
# include "zlib-ng.h"
|
||||
#include "zlib.h"
|
||||
#ifdef STDC
|
||||
# include <string.h>
|
||||
# include <stdlib.h>
|
||||
# include <limits.h>
|
||||
#endif
|
||||
|
||||
#ifndef _POSIX_SOURCE
|
||||
# define _POSIX_SOURCE
|
||||
#endif
|
||||
#include <fcntl.h>
|
||||
|
||||
#ifdef _WIN32
|
||||
# include <stddef.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(__TURBOC__) || defined(_MSC_VER) || defined(_WIN32)
|
||||
# include <io.h>
|
||||
#endif
|
||||
|
||||
#if defined(_WIN32)
|
||||
# define WIDECHAR
|
||||
#endif
|
||||
|
||||
@@ -49,28 +49,98 @@
|
||||
# define close _close
|
||||
#endif
|
||||
|
||||
#ifdef NO_DEFLATE /* for compatibility with old definition */
|
||||
# define NO_GZCOMPRESS
|
||||
#endif
|
||||
|
||||
#if defined(STDC99) || (defined(__TURBOC__) && __TURBOC__ >= 0x550)
|
||||
# ifndef HAVE_VSNPRINTF
|
||||
# define HAVE_VSNPRINTF
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(__CYGWIN__)
|
||||
# ifndef HAVE_VSNPRINTF
|
||||
# define HAVE_VSNPRINTF
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#if defined(MSDOS) && defined(__BORLANDC__) && (BORLANDC > 0x410)
|
||||
# ifndef HAVE_VSNPRINTF
|
||||
# define HAVE_VSNPRINTF
|
||||
# endif
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_VSNPRINTF
|
||||
# ifdef MSDOS
|
||||
/* vsnprintf may exist on some MS-DOS compilers (DJGPP?),
|
||||
but for now we just assume it doesn't. */
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
# ifdef __TURBOC__
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
# ifdef WIN32
|
||||
/* In Win32, vsnprintf is available as the "non-ANSI" _vsnprintf. */
|
||||
#if !defined(STDC99) && !defined(__CYGWIN__) && !defined(__MINGW__) && defined(_WIN32)
|
||||
# if !defined(vsnprintf)
|
||||
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
|
||||
# define vsnprintf _vsnprintf
|
||||
# if !defined(vsnprintf) && !defined(NO_vsnprintf)
|
||||
# if !defined(_MSC_VER) || ( defined(_MSC_VER) && _MSC_VER < 1500 )
|
||||
# define vsnprintf _vsnprintf
|
||||
# endif
|
||||
# endif
|
||||
# endif
|
||||
# ifdef __SASC
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
# ifdef VMS
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
# ifdef __OS400__
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
# ifdef __MVS__
|
||||
# define NO_vsnprintf
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* unlike snprintf (which is required in C99), _snprintf does not guarantee
|
||||
null termination of the result -- however this is only used in gzlib.c
|
||||
where the result is assured to fit in the space provided */
|
||||
null termination of the result -- however this is only used in gzlib.c where
|
||||
the result is assured to fit in the space provided */
|
||||
#if defined(_MSC_VER) && _MSC_VER < 1900
|
||||
# define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#ifndef local
|
||||
# define local static
|
||||
#endif
|
||||
/* since "static" is used to mean two completely different things in C, we
|
||||
define "local" for the non-static meaning of "static", for readability
|
||||
(compile with -Dlocal if your debugger can't find static symbols) */
|
||||
|
||||
/* gz* functions always use library allocation functions */
|
||||
#ifndef STDC
|
||||
extern voidp malloc(uInt size);
|
||||
extern void free(voidpf ptr);
|
||||
#endif
|
||||
|
||||
/* get errno and strerror definition */
|
||||
#ifndef NO_STRERROR
|
||||
# include <errno.h>
|
||||
# define zstrerror() strerror(errno)
|
||||
#if defined UNDER_CE
|
||||
# include <windows.h>
|
||||
# define zstrerror() gz_strwinerror((DWORD)GetLastError())
|
||||
#else
|
||||
# define zstrerror() "stdio error (consult errno)"
|
||||
# ifndef NO_STRERROR
|
||||
# include <errno.h>
|
||||
# define zstrerror() strerror(errno)
|
||||
# else
|
||||
# define zstrerror() "stdio error (consult errno)"
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* provide prototypes for these when building zlib without LFS */
|
||||
#if !defined(_LARGEFILE64_SOURCE) || _LFS64_LARGEFILE-0 == 0
|
||||
ZEXTERN gzFile ZEXPORT gzopen64(const char *, const char *);
|
||||
ZEXTERN z_off64_t ZEXPORT gzseek64(gzFile, z_off64_t, int);
|
||||
ZEXTERN z_off64_t ZEXPORT gztell64(gzFile);
|
||||
ZEXTERN z_off64_t ZEXPORT gzoffset64(gzFile);
|
||||
#endif
|
||||
|
||||
/* default memLevel */
|
||||
@@ -82,9 +152,7 @@
|
||||
|
||||
/* default i/o buffer size -- double this for output when reading (this and
|
||||
twice this must be able to fit in an unsigned type) */
|
||||
#ifndef GZBUFSIZE
|
||||
# define GZBUFSIZE 131072
|
||||
#endif
|
||||
#define GZBUFSIZE 8192
|
||||
|
||||
/* gzip modes, also provide a little integrity check on the passed structure */
|
||||
#define GZ_NONE 0
|
||||
@@ -129,18 +197,18 @@ typedef struct {
|
||||
int err; /* error code */
|
||||
char *msg; /* error message */
|
||||
/* zlib inflate or deflate stream */
|
||||
PREFIX3(stream) strm; /* stream structure in-place (not a pointer) */
|
||||
z_stream strm; /* stream structure in-place (not a pointer) */
|
||||
} gz_state;
|
||||
typedef gz_state *gz_statep;
|
||||
typedef gz_state FAR *gz_statep;
|
||||
|
||||
/* shared functions */
|
||||
void Z_INTERNAL gz_error(gz_state *, int, const char *);
|
||||
#ifdef ZLIB_COMPAT
|
||||
unsigned Z_INTERNAL gz_intmax(void);
|
||||
void ZLIB_INTERNAL gz_error(gz_statep, int, const char *);
|
||||
#if defined UNDER_CE
|
||||
char ZLIB_INTERNAL *gz_strwinerror(DWORD error);
|
||||
#endif
|
||||
|
||||
/* GT_OFF(x), where x is an unsigned value, is true if x > maximum z_off64_t
|
||||
value -- needed when comparing unsigned to z_off64_t, which is signed
|
||||
(possible z_off64_t types off_t, off64_t, and long are all signed) */
|
||||
#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > INT_MAX)
|
||||
|
||||
#endif /* GZGUTS_H_ */
|
||||
unsigned ZLIB_INTERNAL gz_intmax(void);
|
||||
#define GT_OFF(x) (sizeof(int) == sizeof(z_off64_t) && (x) > gz_intmax())
|
||||
+154
-103
@@ -3,11 +3,9 @@
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "zutil_p.h"
|
||||
#include "gzguts.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#if defined(_WIN32) && !defined(__BORLANDC__)
|
||||
# define LSEEK _lseeki64
|
||||
#else
|
||||
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
|
||||
@@ -17,12 +15,58 @@
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/* Local functions */
|
||||
static void gz_reset(gz_state *);
|
||||
static gzFile gz_open(const void *, int, const char *);
|
||||
#if defined UNDER_CE
|
||||
|
||||
/* Map the Windows error number in ERROR to a locale-dependent error message
|
||||
string and return a pointer to it. Typically, the values for ERROR come
|
||||
from GetLastError.
|
||||
|
||||
The string pointed to shall not be modified by the application, but may be
|
||||
overwritten by a subsequent call to gz_strwinerror
|
||||
|
||||
The gz_strwinerror function does not change the current setting of
|
||||
GetLastError. */
|
||||
char ZLIB_INTERNAL *gz_strwinerror(DWORD error) {
|
||||
static char buf[1024];
|
||||
|
||||
wchar_t *msgbuf;
|
||||
DWORD lasterr = GetLastError();
|
||||
DWORD chars = FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM
|
||||
| FORMAT_MESSAGE_ALLOCATE_BUFFER,
|
||||
NULL,
|
||||
error,
|
||||
0, /* Default language */
|
||||
(LPVOID)&msgbuf,
|
||||
0,
|
||||
NULL);
|
||||
if (chars != 0) {
|
||||
/* If there is an \r\n appended, zap it. */
|
||||
if (chars >= 2
|
||||
&& msgbuf[chars - 2] == '\r' && msgbuf[chars - 1] == '\n') {
|
||||
chars -= 2;
|
||||
msgbuf[chars] = 0;
|
||||
}
|
||||
|
||||
if (chars > sizeof (buf) - 1) {
|
||||
chars = sizeof (buf) - 1;
|
||||
msgbuf[chars] = 0;
|
||||
}
|
||||
|
||||
wcstombs(buf, msgbuf, chars + 1);
|
||||
LocalFree(msgbuf);
|
||||
}
|
||||
else {
|
||||
sprintf(buf, "unknown win32 error (%ld)", error);
|
||||
}
|
||||
|
||||
SetLastError(lasterr);
|
||||
return buf;
|
||||
}
|
||||
|
||||
#endif /* UNDER_CE */
|
||||
|
||||
/* Reset gzip file state */
|
||||
static void gz_reset(gz_state *state) {
|
||||
local void gz_reset(gz_statep state) {
|
||||
state->x.have = 0; /* no output data available */
|
||||
if (state->mode == GZ_READ) { /* for reading ... */
|
||||
state->eof = 0; /* not at end of file */
|
||||
@@ -38,9 +82,9 @@ static void gz_reset(gz_state *state) {
|
||||
}
|
||||
|
||||
/* Open a gzip file either by name or file descriptor. */
|
||||
static gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
gz_state *state;
|
||||
size_t len;
|
||||
local gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
gz_statep state;
|
||||
z_size_t len;
|
||||
int oflag;
|
||||
#ifdef O_CLOEXEC
|
||||
int cloexec = 0;
|
||||
@@ -54,7 +98,7 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
return NULL;
|
||||
|
||||
/* allocate gzFile structure to return */
|
||||
state = (gz_state *)zng_alloc(sizeof(gz_state));
|
||||
state = (gz_statep)malloc(sizeof(gz_state));
|
||||
if (state == NULL)
|
||||
return NULL;
|
||||
state->size = 0; /* no buffers allocated yet */
|
||||
@@ -67,9 +111,9 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
state->strategy = Z_DEFAULT_STRATEGY;
|
||||
state->direct = 0;
|
||||
while (*mode) {
|
||||
if (*mode >= '0' && *mode <= '9') {
|
||||
if (*mode >= '0' && *mode <= '9')
|
||||
state->level = *mode - '0';
|
||||
} else {
|
||||
else
|
||||
switch (*mode) {
|
||||
case 'r':
|
||||
state->mode = GZ_READ;
|
||||
@@ -83,7 +127,7 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
break;
|
||||
#endif
|
||||
case '+': /* can't read and write at the same time */
|
||||
zng_free(state);
|
||||
free(state);
|
||||
return NULL;
|
||||
case 'b': /* ignore -- will request binary anyway */
|
||||
break;
|
||||
@@ -113,22 +157,21 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
state->direct = 1;
|
||||
break;
|
||||
default: /* could consider as an error, but just ignore */
|
||||
{}
|
||||
;
|
||||
}
|
||||
}
|
||||
mode++;
|
||||
}
|
||||
|
||||
/* must provide an "r", "w", or "a" */
|
||||
if (state->mode == GZ_NONE) {
|
||||
zng_free(state);
|
||||
free(state);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* can't force transparent read */
|
||||
if (state->mode == GZ_READ) {
|
||||
if (state->direct) {
|
||||
zng_free(state);
|
||||
free(state);
|
||||
return NULL;
|
||||
}
|
||||
state->direct = 1; /* for empty file */
|
||||
@@ -137,27 +180,31 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
/* save the path name for error messages */
|
||||
#ifdef WIDECHAR
|
||||
if (fd == -2) {
|
||||
len = wcstombs(NULL, (const wchar_t *)path, 0);
|
||||
if (len == (size_t)-1)
|
||||
len = wcstombs(NULL, path, 0);
|
||||
if (len == (z_size_t)-1)
|
||||
len = 0;
|
||||
} else
|
||||
}
|
||||
else
|
||||
#endif
|
||||
len = strlen((const char *)path);
|
||||
state->path = (char *)malloc(len + 1);
|
||||
if (state->path == NULL) {
|
||||
zng_free(state);
|
||||
free(state);
|
||||
return NULL;
|
||||
}
|
||||
#ifdef WIDECHAR
|
||||
if (fd == -2)
|
||||
if (len) {
|
||||
wcstombs(state->path, (const wchar_t *)path, len + 1);
|
||||
} else {
|
||||
if (len)
|
||||
wcstombs(state->path, path, len + 1);
|
||||
else
|
||||
*(state->path) = 0;
|
||||
}
|
||||
else
|
||||
#endif
|
||||
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
|
||||
(void)snprintf(state->path, len + 1, "%s", (const char *)path);
|
||||
#else
|
||||
strcpy(state->path, path);
|
||||
#endif
|
||||
|
||||
/* compute the flags for open() */
|
||||
oflag =
|
||||
@@ -182,15 +229,13 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
|
||||
/* open the file with the appropriate flags (or just use fd) */
|
||||
state->fd = fd > -1 ? fd : (
|
||||
#if defined(_WIN32)
|
||||
fd == -2 ? _wopen((const wchar_t *)path, oflag, 0666) :
|
||||
#elif __CYGWIN__
|
||||
fd == -2 ? open(state->path, oflag, 0666) :
|
||||
#ifdef WIDECHAR
|
||||
fd == -2 ? _wopen(path, oflag, 0666) :
|
||||
#endif
|
||||
open((const char *)path, oflag, 0666));
|
||||
if (state->fd == -1) {
|
||||
free(state->path);
|
||||
zng_free(state);
|
||||
free(state);
|
||||
return NULL;
|
||||
}
|
||||
if (state->mode == GZ_APPEND) {
|
||||
@@ -212,24 +257,27 @@ static gzFile gz_open(const void *path, int fd, const char *mode) {
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
gzFile Z_EXPORT PREFIX(gzopen)(const char *path, const char *mode) {
|
||||
gzFile ZEXPORT gzopen(const char *path, const char *mode) {
|
||||
return gz_open(path, -1, mode);
|
||||
}
|
||||
|
||||
#ifdef ZLIB_COMPAT
|
||||
gzFile Z_EXPORT PREFIX4(gzopen)(const char *path, const char *mode) {
|
||||
return gz_open(path, -1, mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
gzFile Z_EXPORT PREFIX(gzdopen)(int fd, const char *mode) {
|
||||
gzFile ZEXPORT gzopen64(const char *path, const char *mode) {
|
||||
return gz_open(path, -1, mode);
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
gzFile ZEXPORT gzdopen(int fd, const char *mode) {
|
||||
char *path; /* identifier for error messages */
|
||||
gzFile gz;
|
||||
|
||||
if (fd == -1 || (path = (char *)malloc(7 + 3 * sizeof(int))) == NULL)
|
||||
return NULL;
|
||||
(void)snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd); /* for debugging */
|
||||
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
|
||||
(void)snprintf(path, 7 + 3 * sizeof(int), "<fd:%d>", fd);
|
||||
#else
|
||||
sprintf(path, "<fd:%d>", fd); /* for debugging */
|
||||
#endif
|
||||
gz = gz_open(path, fd, mode);
|
||||
free(path);
|
||||
return gz;
|
||||
@@ -237,33 +285,19 @@ gzFile Z_EXPORT PREFIX(gzdopen)(int fd, const char *mode) {
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
#ifdef WIDECHAR
|
||||
gzFile Z_EXPORT PREFIX(gzopen_w)(const wchar_t *path, const char *mode) {
|
||||
gzFile ZEXPORT gzopen_w(const wchar_t *path, const char *mode) {
|
||||
return gz_open(path, -2, mode);
|
||||
}
|
||||
#endif
|
||||
|
||||
int Z_EXPORT PREFIX(gzclose)(gzFile file) {
|
||||
#ifndef NO_GZCOMPRESS
|
||||
gz_state *state;
|
||||
|
||||
if (file == NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
state = (gz_state *)file;
|
||||
|
||||
return state->mode == GZ_READ ? PREFIX(gzclose_r)(file) : PREFIX(gzclose_w)(file);
|
||||
#else
|
||||
return PREFIX(gzclose_r)(file);
|
||||
#endif
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORT PREFIX(gzbuffer)(gzFile file, unsigned size) {
|
||||
gz_state *state;
|
||||
int ZEXPORT gzbuffer(gzFile file, unsigned size) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure and check integrity */
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
if (state->mode != GZ_READ && state->mode != GZ_WRITE)
|
||||
return -1;
|
||||
|
||||
@@ -281,16 +315,17 @@ int Z_EXPORT PREFIX(gzbuffer)(gzFile file, unsigned size) {
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORT PREFIX(gzrewind)(gzFile file) {
|
||||
gz_state *state;
|
||||
int ZEXPORT gzrewind(gzFile file) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
|
||||
/* check that we're reading and that there's no error */
|
||||
if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR))
|
||||
if (state->mode != GZ_READ ||
|
||||
(state->err != Z_OK && state->err != Z_BUF_ERROR))
|
||||
return -1;
|
||||
|
||||
/* back up and start over */
|
||||
@@ -301,15 +336,15 @@ int Z_EXPORT PREFIX(gzrewind)(gzFile file) {
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off64_t Z_EXPORT PREFIX4(gzseek)(gzFile file, z_off64_t offset, int whence) {
|
||||
z_off64_t ZEXPORT gzseek64(gzFile file, z_off64_t offset, int whence) {
|
||||
unsigned n;
|
||||
z_off64_t ret;
|
||||
gz_state *state;
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure and check integrity */
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
if (state->mode != GZ_READ && state->mode != GZ_WRITE)
|
||||
return -1;
|
||||
|
||||
@@ -329,7 +364,8 @@ z_off64_t Z_EXPORT PREFIX4(gzseek)(gzFile file, z_off64_t offset, int whence) {
|
||||
state->seek = 0;
|
||||
|
||||
/* if within raw area while reading, just go there */
|
||||
if (state->mode == GZ_READ && state->how == COPY && state->x.pos + offset >= 0) {
|
||||
if (state->mode == GZ_READ && state->how == COPY &&
|
||||
state->x.pos + offset >= 0) {
|
||||
ret = LSEEK(state->fd, offset - (z_off64_t)state->x.have, SEEK_CUR);
|
||||
if (ret == -1)
|
||||
return -1;
|
||||
@@ -350,13 +386,14 @@ z_off64_t Z_EXPORT PREFIX4(gzseek)(gzFile file, z_off64_t offset, int whence) {
|
||||
offset += state->x.pos;
|
||||
if (offset < 0) /* before start of file! */
|
||||
return -1;
|
||||
if (PREFIX(gzrewind)(file) == -1) /* rewind, then skip to offset */
|
||||
if (gzrewind(file) == -1) /* rewind, then skip to offset */
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* if reading, skip what's in output buffer (one less gzgetc() check) */
|
||||
if (state->mode == GZ_READ) {
|
||||
n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ? (unsigned)offset : state->x.have;
|
||||
n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > offset ?
|
||||
(unsigned)offset : state->x.have;
|
||||
state->x.have -= n;
|
||||
state->x.next += n;
|
||||
state->x.pos += n;
|
||||
@@ -372,23 +409,21 @@ z_off64_t Z_EXPORT PREFIX4(gzseek)(gzFile file, z_off64_t offset, int whence) {
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
#ifdef ZLIB_COMPAT
|
||||
z_off_t Z_EXPORT PREFIX(gzseek)(gzFile file, z_off_t offset, int whence) {
|
||||
z_off_t ZEXPORT gzseek(gzFile file, z_off_t offset, int whence) {
|
||||
z_off64_t ret;
|
||||
|
||||
ret = PREFIX4(gzseek)(file, (z_off64_t)offset, whence);
|
||||
ret = gzseek64(file, (z_off64_t)offset, whence);
|
||||
return ret == (z_off_t)ret ? (z_off_t)ret : -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off64_t Z_EXPORT PREFIX4(gztell)(gzFile file) {
|
||||
gz_state *state;
|
||||
z_off64_t ZEXPORT gztell64(gzFile file) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure and check integrity */
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
if (state->mode != GZ_READ && state->mode != GZ_WRITE)
|
||||
return -1;
|
||||
|
||||
@@ -397,25 +432,22 @@ z_off64_t Z_EXPORT PREFIX4(gztell)(gzFile file) {
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
#ifdef ZLIB_COMPAT
|
||||
z_off_t Z_EXPORT PREFIX(gztell)(gzFile file) {
|
||||
|
||||
z_off_t ZEXPORT gztell(gzFile file) {
|
||||
z_off64_t ret;
|
||||
|
||||
ret = PREFIX4(gztell)(file);
|
||||
ret = gztell64(file);
|
||||
return ret == (z_off_t)ret ? (z_off_t)ret : -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
z_off64_t Z_EXPORT PREFIX4(gzoffset)(gzFile file) {
|
||||
z_off64_t ZEXPORT gzoffset64(gzFile file) {
|
||||
z_off64_t offset;
|
||||
gz_state *state;
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure and check integrity */
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
if (state->mode != GZ_READ && state->mode != GZ_WRITE)
|
||||
return -1;
|
||||
|
||||
@@ -429,23 +461,21 @@ z_off64_t Z_EXPORT PREFIX4(gzoffset)(gzFile file) {
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
#ifdef ZLIB_COMPAT
|
||||
z_off_t Z_EXPORT PREFIX(gzoffset)(gzFile file) {
|
||||
z_off_t ZEXPORT gzoffset(gzFile file) {
|
||||
z_off64_t ret;
|
||||
|
||||
ret = PREFIX4(gzoffset)(file);
|
||||
ret = gzoffset64(file);
|
||||
return ret == (z_off_t)ret ? (z_off_t)ret : -1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORT PREFIX(gzeof)(gzFile file) {
|
||||
gz_state *state;
|
||||
int ZEXPORT gzeof(gzFile file) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure and check integrity */
|
||||
if (file == NULL)
|
||||
return 0;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
if (state->mode != GZ_READ && state->mode != GZ_WRITE)
|
||||
return 0;
|
||||
|
||||
@@ -454,30 +484,31 @@ int Z_EXPORT PREFIX(gzeof)(gzFile file) {
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
const char * Z_EXPORT PREFIX(gzerror)(gzFile file, int *errnum) {
|
||||
gz_state *state;
|
||||
const char * ZEXPORT gzerror(gzFile file, int *errnum) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure and check integrity */
|
||||
if (file == NULL)
|
||||
return NULL;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
if (state->mode != GZ_READ && state->mode != GZ_WRITE)
|
||||
return NULL;
|
||||
|
||||
/* return error information */
|
||||
if (errnum != NULL)
|
||||
*errnum = state->err;
|
||||
return state->err == Z_MEM_ERROR ? "out of memory" : (state->msg == NULL ? "" : state->msg);
|
||||
return state->err == Z_MEM_ERROR ? "out of memory" :
|
||||
(state->msg == NULL ? "" : state->msg);
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
void Z_EXPORT PREFIX(gzclearerr)(gzFile file) {
|
||||
gz_state *state;
|
||||
void ZEXPORT gzclearerr(gzFile file) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure and check integrity */
|
||||
if (file == NULL)
|
||||
return;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
if (state->mode != GZ_READ && state->mode != GZ_WRITE)
|
||||
return;
|
||||
|
||||
@@ -495,7 +526,7 @@ void Z_EXPORT PREFIX(gzclearerr)(gzFile file) {
|
||||
memory). Simply save the error message as a static string. If there is an
|
||||
allocation failure constructing the error message, then convert the error to
|
||||
out of memory. */
|
||||
void Z_INTERNAL gz_error(gz_state *state, int err, const char *msg) {
|
||||
void ZLIB_INTERNAL gz_error(gz_statep state, int err, const char *msg) {
|
||||
/* free previously allocated message and clear */
|
||||
if (state->msg != NULL) {
|
||||
if (state->err != Z_MEM_ERROR)
|
||||
@@ -517,15 +548,35 @@ void Z_INTERNAL gz_error(gz_state *state, int err, const char *msg) {
|
||||
return;
|
||||
|
||||
/* construct error message with path */
|
||||
if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) == NULL) {
|
||||
if ((state->msg = (char *)malloc(strlen(state->path) + strlen(msg) + 3)) ==
|
||||
NULL) {
|
||||
state->err = Z_MEM_ERROR;
|
||||
return;
|
||||
}
|
||||
(void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3, "%s%s%s", state->path, ": ", msg);
|
||||
#if !defined(NO_snprintf) && !defined(NO_vsnprintf)
|
||||
(void)snprintf(state->msg, strlen(state->path) + strlen(msg) + 3,
|
||||
"%s%s%s", state->path, ": ", msg);
|
||||
#else
|
||||
strcpy(state->msg, state->path);
|
||||
strcat(state->msg, ": ");
|
||||
strcat(state->msg, msg);
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef ZLIB_COMPAT
|
||||
unsigned Z_INTERNAL gz_intmax(void) {
|
||||
/* portably return maximum value for an int (when limits.h presumed not
|
||||
available) -- we need to do this to cover cases where 2's complement not
|
||||
used, since C standard permits 1's complement and sign-bit representations,
|
||||
otherwise we could just use ((unsigned)-1) >> 1 */
|
||||
unsigned ZLIB_INTERNAL gz_intmax(void) {
|
||||
#ifdef INT_MAX
|
||||
return INT_MAX;
|
||||
}
|
||||
#else
|
||||
unsigned p = 1, q;
|
||||
do {
|
||||
q = p;
|
||||
p <<= 1;
|
||||
p++;
|
||||
} while (p > q);
|
||||
return q >> 1;
|
||||
#endif
|
||||
}
|
||||
@@ -1,606 +0,0 @@
|
||||
/* gzread.c -- zlib functions for reading gzip files
|
||||
* Copyright (C) 2004-2017 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "zutil_p.h"
|
||||
#include "gzguts.h"
|
||||
|
||||
/* Local functions */
|
||||
static int gz_load(gz_state *, unsigned char *, unsigned, unsigned *);
|
||||
static int gz_avail(gz_state *);
|
||||
static int gz_look(gz_state *);
|
||||
static int gz_decomp(gz_state *);
|
||||
static int gz_fetch(gz_state *);
|
||||
static int gz_skip(gz_state *, z_off64_t);
|
||||
static size_t gz_read(gz_state *, void *, size_t);
|
||||
|
||||
/* Use read() to load a buffer -- return -1 on error, otherwise 0. Read from
|
||||
state->fd, and update state->eof, state->err, and state->msg as appropriate.
|
||||
This function needs to loop on read(), since read() is not guaranteed to
|
||||
read the number of bytes requested, depending on the type of descriptor. */
|
||||
static int gz_load(gz_state *state, unsigned char *buf, unsigned len, unsigned *have) {
|
||||
ssize_t ret;
|
||||
|
||||
*have = 0;
|
||||
do {
|
||||
ret = read(state->fd, buf + *have, len - *have);
|
||||
if (ret <= 0)
|
||||
break;
|
||||
*have += (unsigned)ret;
|
||||
} while (*have < len);
|
||||
if (ret < 0) {
|
||||
gz_error(state, Z_ERRNO, zstrerror());
|
||||
return -1;
|
||||
}
|
||||
if (ret == 0)
|
||||
state->eof = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Load up input buffer and set eof flag if last data loaded -- return -1 on
|
||||
error, 0 otherwise. Note that the eof flag is set when the end of the input
|
||||
file is reached, even though there may be unused data in the buffer. Once
|
||||
that data has been used, no more attempts will be made to read the file.
|
||||
If strm->avail_in != 0, then the current data is moved to the beginning of
|
||||
the input buffer, and then the remainder of the buffer is loaded with the
|
||||
available data from the input file. */
|
||||
static int gz_avail(gz_state *state) {
|
||||
unsigned got;
|
||||
PREFIX3(stream) *strm = &(state->strm);
|
||||
|
||||
if (state->err != Z_OK && state->err != Z_BUF_ERROR)
|
||||
return -1;
|
||||
if (state->eof == 0) {
|
||||
if (strm->avail_in) { /* copy what's there to the start */
|
||||
unsigned char *p = state->in;
|
||||
unsigned const char *q = strm->next_in;
|
||||
unsigned n = strm->avail_in;
|
||||
do {
|
||||
*p++ = *q++;
|
||||
} while (--n);
|
||||
}
|
||||
if (gz_load(state, state->in + strm->avail_in, state->size - strm->avail_in, &got) == -1)
|
||||
return -1;
|
||||
strm->avail_in += got;
|
||||
strm->next_in = state->in;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Look for gzip header, set up for inflate or copy. state->x.have must be 0.
|
||||
If this is the first time in, allocate required memory. state->how will be
|
||||
left unchanged if there is no more input data available, will be set to COPY
|
||||
if there is no gzip header and direct copying will be performed, or it will
|
||||
be set to GZIP for decompression. If direct copying, then leftover input
|
||||
data from the input buffer will be copied to the output buffer. In that
|
||||
case, all further file reads will be directly to either the output buffer or
|
||||
a user buffer. If decompressing, the inflate state will be initialized.
|
||||
gz_look() will return 0 on success or -1 on failure. */
|
||||
static int gz_look(gz_state *state) {
|
||||
PREFIX3(stream) *strm = &(state->strm);
|
||||
|
||||
/* allocate read buffers and inflate memory */
|
||||
if (state->size == 0) {
|
||||
/* allocate buffers */
|
||||
state->in = (unsigned char *)zng_alloc(state->want);
|
||||
state->out = (unsigned char *)zng_alloc(state->want << 1);
|
||||
if (state->in == NULL || state->out == NULL) {
|
||||
zng_free(state->out);
|
||||
zng_free(state->in);
|
||||
gz_error(state, Z_MEM_ERROR, "out of memory");
|
||||
return -1;
|
||||
}
|
||||
state->size = state->want;
|
||||
|
||||
/* allocate inflate memory */
|
||||
state->strm.zalloc = NULL;
|
||||
state->strm.zfree = NULL;
|
||||
state->strm.opaque = NULL;
|
||||
state->strm.avail_in = 0;
|
||||
state->strm.next_in = NULL;
|
||||
if (PREFIX(inflateInit2)(&(state->strm), MAX_WBITS + 16) != Z_OK) { /* gunzip */
|
||||
zng_free(state->out);
|
||||
zng_free(state->in);
|
||||
state->size = 0;
|
||||
gz_error(state, Z_MEM_ERROR, "out of memory");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
/* get at least the magic bytes in the input buffer */
|
||||
if (strm->avail_in < 2) {
|
||||
if (gz_avail(state) == -1)
|
||||
return -1;
|
||||
if (strm->avail_in == 0)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* look for gzip magic bytes -- if there, do gzip decoding (note: there is
|
||||
a logical dilemma here when considering the case of a partially written
|
||||
gzip file, to wit, if a single 31 byte is written, then we cannot tell
|
||||
whether this is a single-byte file, or just a partially written gzip
|
||||
file -- for here we assume that if a gzip file is being written, then
|
||||
the header will be written in a single operation, so that reading a
|
||||
single byte is sufficient indication that it is not a gzip file) */
|
||||
if (strm->avail_in > 1 &&
|
||||
strm->next_in[0] == 31 && strm->next_in[1] == 139) {
|
||||
PREFIX(inflateReset)(strm);
|
||||
state->how = GZIP;
|
||||
state->direct = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* no gzip header -- if we were decoding gzip before, then this is trailing
|
||||
garbage. Ignore the trailing garbage and finish. */
|
||||
if (state->direct == 0) {
|
||||
strm->avail_in = 0;
|
||||
state->eof = 1;
|
||||
state->x.have = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* doing raw i/o, copy any leftover input to output -- this assumes that
|
||||
the output buffer is larger than the input buffer, which also assures
|
||||
space for gzungetc() */
|
||||
state->x.next = state->out;
|
||||
memcpy(state->x.next, strm->next_in, strm->avail_in);
|
||||
state->x.have = strm->avail_in;
|
||||
strm->avail_in = 0;
|
||||
state->how = COPY;
|
||||
state->direct = 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Decompress from input to the provided next_out and avail_out in the state.
|
||||
On return, state->x.have and state->x.next point to the just decompressed
|
||||
data. If the gzip stream completes, state->how is reset to LOOK to look for
|
||||
the next gzip stream or raw data, once state->x.have is depleted. Returns 0
|
||||
on success, -1 on failure. */
|
||||
static int gz_decomp(gz_state *state) {
|
||||
int ret = Z_OK;
|
||||
unsigned had;
|
||||
PREFIX3(stream) *strm = &(state->strm);
|
||||
|
||||
/* fill output buffer up to end of deflate stream */
|
||||
had = strm->avail_out;
|
||||
do {
|
||||
/* get more input for inflate() */
|
||||
if (strm->avail_in == 0 && gz_avail(state) == -1)
|
||||
return -1;
|
||||
if (strm->avail_in == 0) {
|
||||
gz_error(state, Z_BUF_ERROR, "unexpected end of file");
|
||||
break;
|
||||
}
|
||||
|
||||
/* decompress and handle errors */
|
||||
ret = PREFIX(inflate)(strm, Z_NO_FLUSH);
|
||||
if (ret == Z_STREAM_ERROR || ret == Z_NEED_DICT) {
|
||||
gz_error(state, Z_STREAM_ERROR, "internal error: inflate stream corrupt");
|
||||
return -1;
|
||||
}
|
||||
if (ret == Z_MEM_ERROR) {
|
||||
gz_error(state, Z_MEM_ERROR, "out of memory");
|
||||
return -1;
|
||||
}
|
||||
if (ret == Z_DATA_ERROR) { /* deflate stream invalid */
|
||||
gz_error(state, Z_DATA_ERROR, strm->msg == NULL ? "compressed data error" : strm->msg);
|
||||
return -1;
|
||||
}
|
||||
} while (strm->avail_out && ret != Z_STREAM_END);
|
||||
|
||||
/* update available output */
|
||||
state->x.have = had - strm->avail_out;
|
||||
state->x.next = strm->next_out - state->x.have;
|
||||
|
||||
/* if the gzip stream completed successfully, look for another */
|
||||
if (ret == Z_STREAM_END)
|
||||
state->how = LOOK;
|
||||
|
||||
/* good decompression */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Fetch data and put it in the output buffer. Assumes state->x.have is 0.
|
||||
Data is either copied from the input file or decompressed from the input
|
||||
file depending on state->how. If state->how is LOOK, then a gzip header is
|
||||
looked for to determine whether to copy or decompress. Returns -1 on error,
|
||||
otherwise 0. gz_fetch() will leave state->how as COPY or GZIP unless the
|
||||
end of the input file has been reached and all data has been processed. */
|
||||
static int gz_fetch(gz_state *state) {
|
||||
PREFIX3(stream) *strm = &(state->strm);
|
||||
|
||||
do {
|
||||
switch (state->how) {
|
||||
case LOOK: /* -> LOOK, COPY (only if never GZIP), or GZIP */
|
||||
if (gz_look(state) == -1)
|
||||
return -1;
|
||||
if (state->how == LOOK)
|
||||
return 0;
|
||||
break;
|
||||
case COPY: /* -> COPY */
|
||||
if (gz_load(state, state->out, state->size << 1, &(state->x.have))
|
||||
== -1)
|
||||
return -1;
|
||||
state->x.next = state->out;
|
||||
return 0;
|
||||
case GZIP: /* -> GZIP or LOOK (if end of gzip stream) */
|
||||
strm->avail_out = state->size << 1;
|
||||
strm->next_out = state->out;
|
||||
if (gz_decomp(state) == -1)
|
||||
return -1;
|
||||
}
|
||||
} while (state->x.have == 0 && (!state->eof || strm->avail_in));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Skip len uncompressed bytes of output. Return -1 on error, 0 on success. */
|
||||
static int gz_skip(gz_state *state, z_off64_t len) {
|
||||
unsigned n;
|
||||
|
||||
/* skip over len bytes or reach end-of-file, whichever comes first */
|
||||
while (len)
|
||||
/* skip over whatever is in output buffer */
|
||||
if (state->x.have) {
|
||||
n = GT_OFF(state->x.have) || (z_off64_t)state->x.have > len ?
|
||||
(unsigned)len : state->x.have;
|
||||
state->x.have -= n;
|
||||
state->x.next += n;
|
||||
state->x.pos += n;
|
||||
len -= n;
|
||||
} else if (state->eof && state->strm.avail_in == 0) {
|
||||
/* output buffer empty -- return if we're at the end of the input */
|
||||
break;
|
||||
} else {
|
||||
/* need more data to skip -- load up output buffer */
|
||||
/* get more output, looking for header if required */
|
||||
if (gz_fetch(state) == -1)
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Read len bytes into buf from file, or less than len up to the end of the
|
||||
input. Return the number of bytes read. If zero is returned, either the
|
||||
end of file was reached, or there was an error. state->err must be
|
||||
consulted in that case to determine which. */
|
||||
static size_t gz_read(gz_state *state, void *buf, size_t len) {
|
||||
size_t got;
|
||||
unsigned n;
|
||||
|
||||
/* if len is zero, avoid unnecessary operations */
|
||||
if (len == 0)
|
||||
return 0;
|
||||
|
||||
/* process a skip request */
|
||||
if (state->seek) {
|
||||
state->seek = 0;
|
||||
if (gz_skip(state, state->skip) == -1)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* get len bytes to buf, or less than len if at the end */
|
||||
got = 0;
|
||||
do {
|
||||
/* set n to the maximum amount of len that fits in an unsigned int */
|
||||
n = (unsigned)-1;
|
||||
if (n > len)
|
||||
n = (unsigned)len;
|
||||
|
||||
/* first just try copying data from the output buffer */
|
||||
if (state->x.have) {
|
||||
if (state->x.have < n)
|
||||
n = state->x.have;
|
||||
memcpy(buf, state->x.next, n);
|
||||
state->x.next += n;
|
||||
state->x.have -= n;
|
||||
}
|
||||
|
||||
/* output buffer empty -- return if we're at the end of the input */
|
||||
else if (state->eof && state->strm.avail_in == 0) {
|
||||
state->past = 1; /* tried to read past end */
|
||||
break;
|
||||
}
|
||||
|
||||
/* need output data -- for small len or new stream load up our output
|
||||
buffer */
|
||||
else if (state->how == LOOK || n < (state->size << 1)) {
|
||||
/* get more output, looking for header if required */
|
||||
if (gz_fetch(state) == -1)
|
||||
return 0;
|
||||
continue; /* no progress yet -- go back to copy above */
|
||||
/* the copy above assures that we will leave with space in the
|
||||
output buffer, allowing at least one gzungetc() to succeed */
|
||||
}
|
||||
|
||||
/* large len -- read directly into user buffer */
|
||||
else if (state->how == COPY) { /* read directly */
|
||||
if (gz_load(state, (unsigned char *)buf, n, &n) == -1)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* large len -- decompress directly into user buffer */
|
||||
else { /* state->how == GZIP */
|
||||
state->strm.avail_out = n;
|
||||
state->strm.next_out = (unsigned char *)buf;
|
||||
if (gz_decomp(state) == -1)
|
||||
return 0;
|
||||
n = state->x.have;
|
||||
state->x.have = 0;
|
||||
}
|
||||
|
||||
/* update progress */
|
||||
len -= n;
|
||||
buf = (char *)buf + n;
|
||||
got += n;
|
||||
state->x.pos += n;
|
||||
} while (len);
|
||||
|
||||
/* return number of bytes read into user buffer */
|
||||
return got;
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORT PREFIX(gzread)(gzFile file, void *buf, unsigned len) {
|
||||
gz_state *state;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
state = (gz_state *)file;
|
||||
|
||||
/* check that we're reading and that there's no (serious) error */
|
||||
if (state->mode != GZ_READ ||
|
||||
(state->err != Z_OK && state->err != Z_BUF_ERROR))
|
||||
return -1;
|
||||
|
||||
/* since an int is returned, make sure len fits in one, otherwise return
|
||||
with an error (this avoids a flaw in the interface) */
|
||||
if ((int)len < 0) {
|
||||
gz_error(state, Z_STREAM_ERROR, "request does not fit in an int");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* read len or fewer bytes to buf */
|
||||
len = (unsigned)gz_read(state, buf, len);
|
||||
|
||||
/* check for an error */
|
||||
if (len == 0 && state->err != Z_OK && state->err != Z_BUF_ERROR)
|
||||
return -1;
|
||||
|
||||
/* return the number of bytes read (this is assured to fit in an int) */
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
size_t Z_EXPORT PREFIX(gzfread)(void *buf, size_t size, size_t nitems, gzFile file) {
|
||||
size_t len;
|
||||
gz_state *state;
|
||||
|
||||
/* Exit early if size is zero, also prevents potential division by zero */
|
||||
if (size == 0)
|
||||
return 0;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return 0;
|
||||
state = (gz_state *)file;
|
||||
|
||||
/* check that we're reading and that there's no (serious) error */
|
||||
if (state->mode != GZ_READ ||
|
||||
(state->err != Z_OK && state->err != Z_BUF_ERROR))
|
||||
return 0;
|
||||
|
||||
/* compute bytes to read -- error on overflow */
|
||||
if (size && SIZE_MAX / size < nitems) {
|
||||
gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
|
||||
return 0;
|
||||
}
|
||||
len = nitems * size;
|
||||
|
||||
/* read len or fewer bytes to buf, return the number of full items read */
|
||||
return len ? gz_read(state, buf, len) / size : 0;
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
#undef @ZLIB_SYMBOL_PREFIX@gzgetc
|
||||
#undef @ZLIB_SYMBOL_PREFIX@zng_gzgetc
|
||||
int Z_EXPORT PREFIX(gzgetc)(gzFile file) {
|
||||
unsigned char buf[1];
|
||||
gz_state *state;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
state = (gz_state *)file;
|
||||
|
||||
/* check that we're reading and that there's no (serious) error */
|
||||
if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR))
|
||||
return -1;
|
||||
|
||||
/* try output buffer (no need to check for skip request) */
|
||||
if (state->x.have) {
|
||||
state->x.have--;
|
||||
state->x.pos++;
|
||||
return *(state->x.next)++;
|
||||
}
|
||||
|
||||
/* nothing there -- try gz_read() */
|
||||
return gz_read(state, buf, 1) < 1 ? -1 : buf[0];
|
||||
}
|
||||
|
||||
#ifdef ZLIB_COMPAT
|
||||
int Z_EXPORT PREFIX(gzgetc_)(gzFile file) {
|
||||
return PREFIX(gzgetc)(file);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORT PREFIX(gzungetc)(int c, gzFile file) {
|
||||
gz_state *state;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
state = (gz_state *)file;
|
||||
|
||||
/* in case this was just opened, set up the input buffer */
|
||||
if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
|
||||
(void)gz_look(state);
|
||||
|
||||
/* check that we're reading and that there's no (serious) error */
|
||||
if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR))
|
||||
return -1;
|
||||
|
||||
/* process a skip request */
|
||||
if (state->seek) {
|
||||
state->seek = 0;
|
||||
if (gz_skip(state, state->skip) == -1)
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* can't push EOF */
|
||||
if (c < 0)
|
||||
return -1;
|
||||
|
||||
/* if output buffer empty, put byte at end (allows more pushing) */
|
||||
if (state->x.have == 0) {
|
||||
state->x.have = 1;
|
||||
state->x.next = state->out + (state->size << 1) - 1;
|
||||
state->x.next[0] = (unsigned char)c;
|
||||
state->x.pos--;
|
||||
state->past = 0;
|
||||
return c;
|
||||
}
|
||||
|
||||
/* if no room, give up (must have already done a gzungetc()) */
|
||||
if (state->x.have == (state->size << 1)) {
|
||||
gz_error(state, Z_DATA_ERROR, "out of room to push characters");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* slide output data if needed and insert byte before existing data */
|
||||
if (state->x.next == state->out) {
|
||||
unsigned char *src = state->out + state->x.have;
|
||||
unsigned char *dest = state->out + (state->size << 1);
|
||||
while (src > state->out)
|
||||
*--dest = *--src;
|
||||
state->x.next = dest;
|
||||
}
|
||||
state->x.have++;
|
||||
state->x.next--;
|
||||
state->x.next[0] = (unsigned char)c;
|
||||
state->x.pos--;
|
||||
state->past = 0;
|
||||
return c;
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
char * Z_EXPORT PREFIX(gzgets)(gzFile file, char *buf, int len) {
|
||||
unsigned left, n;
|
||||
char *str;
|
||||
unsigned char *eol;
|
||||
gz_state *state;
|
||||
|
||||
/* check parameters and get internal structure */
|
||||
if (file == NULL || buf == NULL || len < 1)
|
||||
return NULL;
|
||||
state = (gz_state *)file;
|
||||
|
||||
/* check that we're reading and that there's no (serious) error */
|
||||
if (state->mode != GZ_READ || (state->err != Z_OK && state->err != Z_BUF_ERROR))
|
||||
return NULL;
|
||||
|
||||
/* process a skip request */
|
||||
if (state->seek) {
|
||||
state->seek = 0;
|
||||
if (gz_skip(state, state->skip) == -1)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* copy output bytes up to new line or len - 1, whichever comes first --
|
||||
append a terminating zero to the string (we don't check for a zero in
|
||||
the contents, let the user worry about that) */
|
||||
str = buf;
|
||||
left = (unsigned)len - 1;
|
||||
if (left) {
|
||||
do {
|
||||
/* assure that something is in the output buffer */
|
||||
if (state->x.have == 0 && gz_fetch(state) == -1)
|
||||
return NULL; /* error */
|
||||
if (state->x.have == 0) { /* end of file */
|
||||
state->past = 1; /* read past end */
|
||||
break; /* return what we have */
|
||||
}
|
||||
|
||||
/* look for end-of-line in current output buffer */
|
||||
n = state->x.have > left ? left : state->x.have;
|
||||
eol = (unsigned char *)memchr(state->x.next, '\n', n);
|
||||
if (eol != NULL)
|
||||
n = (unsigned)(eol - state->x.next) + 1;
|
||||
|
||||
/* copy through end-of-line, or remainder if not found */
|
||||
memcpy(buf, state->x.next, n);
|
||||
state->x.have -= n;
|
||||
state->x.next += n;
|
||||
state->x.pos += n;
|
||||
left -= n;
|
||||
buf += n;
|
||||
} while (left && eol == NULL);
|
||||
}
|
||||
|
||||
/* return terminated string, or if nothing, end of file */
|
||||
if (buf == str)
|
||||
return NULL;
|
||||
buf[0] = 0;
|
||||
return str;
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORT PREFIX(gzdirect)(gzFile file) {
|
||||
gz_state *state;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return 0;
|
||||
|
||||
state = (gz_state *)file;
|
||||
|
||||
/* if the state is not known, but we can find out, then do so (this is
|
||||
mainly for right after a gzopen() or gzdopen()) */
|
||||
if (state->mode == GZ_READ && state->how == LOOK && state->x.have == 0)
|
||||
(void)gz_look(state);
|
||||
|
||||
/* return 1 if transparent, 0 if processing a gzip stream */
|
||||
return state->direct;
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORT PREFIX(gzclose_r)(gzFile file) {
|
||||
int ret, err;
|
||||
gz_state *state;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
state = (gz_state *)file;
|
||||
|
||||
/* check that we're reading */
|
||||
if (state->mode != GZ_READ)
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
/* free memory and close file */
|
||||
if (state->size) {
|
||||
PREFIX(inflateEnd)(&(state->strm));
|
||||
zng_free(state->out);
|
||||
zng_free(state->in);
|
||||
}
|
||||
err = state->err == Z_BUF_ERROR ? Z_BUF_ERROR : Z_OK;
|
||||
gz_error(state, Z_OK, NULL);
|
||||
free(state->path);
|
||||
ret = close(state->fd);
|
||||
zng_free(state);
|
||||
return ret ? Z_ERRNO : err;
|
||||
}
|
||||
+193
-88
@@ -3,50 +3,41 @@
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "zutil_p.h"
|
||||
#include <stdarg.h>
|
||||
#include "gzguts.h"
|
||||
|
||||
/* Local functions */
|
||||
static int gz_init(gz_state *);
|
||||
static int gz_comp(gz_state *, int);
|
||||
static int gz_zero(gz_state *, z_off64_t);
|
||||
static size_t gz_write(gz_state *, void const *, size_t);
|
||||
|
||||
/* Initialize state for writing a gzip file. Mark initialization by setting
|
||||
state->size to non-zero. Return -1 on a memory allocation failure, or 0 on
|
||||
success. */
|
||||
static int gz_init(gz_state *state) {
|
||||
local int gz_init(gz_statep state) {
|
||||
int ret;
|
||||
PREFIX3(stream) *strm = &(state->strm);
|
||||
z_streamp strm = &(state->strm);
|
||||
|
||||
/* allocate input buffer (double size for gzprintf) */
|
||||
state->in = (unsigned char *)zng_alloc(state->want << 1);
|
||||
state->in = (unsigned char *)malloc(state->want << 1);
|
||||
if (state->in == NULL) {
|
||||
gz_error(state, Z_MEM_ERROR, "out of memory");
|
||||
return -1;
|
||||
}
|
||||
memset(state->in, 0, state->want << 1);
|
||||
|
||||
/* only need output buffer and deflate state if compressing */
|
||||
if (!state->direct) {
|
||||
/* allocate output buffer */
|
||||
state->out = (unsigned char *)zng_alloc(state->want);
|
||||
state->out = (unsigned char *)malloc(state->want);
|
||||
if (state->out == NULL) {
|
||||
zng_free(state->in);
|
||||
free(state->in);
|
||||
gz_error(state, Z_MEM_ERROR, "out of memory");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* allocate deflate memory, set up for gzip compression */
|
||||
strm->zalloc = NULL;
|
||||
strm->zfree = NULL;
|
||||
strm->opaque = NULL;
|
||||
ret = PREFIX(deflateInit2)(strm, state->level, Z_DEFLATED, MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy);
|
||||
strm->zalloc = Z_NULL;
|
||||
strm->zfree = Z_NULL;
|
||||
strm->opaque = Z_NULL;
|
||||
ret = deflateInit2(strm, state->level, Z_DEFLATED,
|
||||
MAX_WBITS + 16, DEF_MEM_LEVEL, state->strategy);
|
||||
if (ret != Z_OK) {
|
||||
zng_free(state->out);
|
||||
zng_free(state->in);
|
||||
free(state->out);
|
||||
free(state->in);
|
||||
gz_error(state, Z_MEM_ERROR, "out of memory");
|
||||
return -1;
|
||||
}
|
||||
@@ -71,11 +62,10 @@ static int gz_init(gz_state *state) {
|
||||
deflate() flush value. If flush is Z_FINISH, then the deflate() state is
|
||||
reset to start a new gzip stream. If gz->direct is true, then simply write
|
||||
to the output file without compressing, and ignore flush. */
|
||||
static int gz_comp(gz_state *state, int flush) {
|
||||
int ret;
|
||||
ssize_t got;
|
||||
unsigned have;
|
||||
PREFIX3(stream) *strm = &(state->strm);
|
||||
local int gz_comp(gz_statep state, int flush) {
|
||||
int ret, writ;
|
||||
unsigned have, put, max = ((unsigned)-1 >> 2) + 1;
|
||||
z_streamp strm = &(state->strm);
|
||||
|
||||
/* allocate memory if this is the first time through */
|
||||
if (state->size == 0 && gz_init(state) == -1)
|
||||
@@ -83,12 +73,16 @@ static int gz_comp(gz_state *state, int flush) {
|
||||
|
||||
/* write directly if requested */
|
||||
if (state->direct) {
|
||||
got = write(state->fd, strm->next_in, strm->avail_in);
|
||||
if (got < 0 || (unsigned)got != strm->avail_in) {
|
||||
gz_error(state, Z_ERRNO, zstrerror());
|
||||
return -1;
|
||||
while (strm->avail_in) {
|
||||
put = strm->avail_in > max ? max : strm->avail_in;
|
||||
writ = write(state->fd, strm->next_in, put);
|
||||
if (writ < 0) {
|
||||
gz_error(state, Z_ERRNO, zstrerror());
|
||||
return -1;
|
||||
}
|
||||
strm->avail_in -= (unsigned)writ;
|
||||
strm->next_in += writ;
|
||||
}
|
||||
strm->avail_in = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -97,7 +91,7 @@ static int gz_comp(gz_state *state, int flush) {
|
||||
/* don't start a new gzip member unless there is data to write */
|
||||
if (strm->avail_in == 0)
|
||||
return 0;
|
||||
PREFIX(deflateReset)(strm);
|
||||
deflateReset(strm);
|
||||
state->reset = 0;
|
||||
}
|
||||
|
||||
@@ -106,25 +100,31 @@ static int gz_comp(gz_state *state, int flush) {
|
||||
do {
|
||||
/* write out current buffer contents if full, or if flushing, but if
|
||||
doing Z_FINISH then don't write until we get to Z_STREAM_END */
|
||||
if (strm->avail_out == 0 || (flush != Z_NO_FLUSH && (flush != Z_FINISH || ret == Z_STREAM_END))) {
|
||||
have = (unsigned)(strm->next_out - state->x.next);
|
||||
if (have && ((got = write(state->fd, state->x.next, (unsigned long)have)) < 0 || (unsigned)got != have)) {
|
||||
gz_error(state, Z_ERRNO, zstrerror());
|
||||
return -1;
|
||||
if (strm->avail_out == 0 || (flush != Z_NO_FLUSH &&
|
||||
(flush != Z_FINISH || ret == Z_STREAM_END))) {
|
||||
while (strm->next_out > state->x.next) {
|
||||
put = strm->next_out - state->x.next > (int)max ? max :
|
||||
(unsigned)(strm->next_out - state->x.next);
|
||||
writ = write(state->fd, state->x.next, put);
|
||||
if (writ < 0) {
|
||||
gz_error(state, Z_ERRNO, zstrerror());
|
||||
return -1;
|
||||
}
|
||||
state->x.next += writ;
|
||||
}
|
||||
if (strm->avail_out == 0) {
|
||||
strm->avail_out = state->size;
|
||||
strm->next_out = state->out;
|
||||
state->x.next = state->out;
|
||||
}
|
||||
state->x.next = strm->next_out;
|
||||
}
|
||||
|
||||
/* compress */
|
||||
have = strm->avail_out;
|
||||
ret = PREFIX(deflate)(strm, flush);
|
||||
ret = deflate(strm, flush);
|
||||
if (ret == Z_STREAM_ERROR) {
|
||||
gz_error(state, Z_STREAM_ERROR, "internal error: deflate stream corrupt");
|
||||
gz_error(state, Z_STREAM_ERROR,
|
||||
"internal error: deflate stream corrupt");
|
||||
return -1;
|
||||
}
|
||||
have -= strm->avail_out;
|
||||
@@ -133,16 +133,17 @@ static int gz_comp(gz_state *state, int flush) {
|
||||
/* if that completed a deflate stream, allow another to start */
|
||||
if (flush == Z_FINISH)
|
||||
state->reset = 1;
|
||||
|
||||
/* all done, no errors */
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Compress len zeros to output. Return -1 on a write error or memory
|
||||
allocation failure by gz_comp(), or 0 on success. */
|
||||
static int gz_zero(gz_state *state, z_off64_t len) {
|
||||
local int gz_zero(gz_statep state, z_off64_t len) {
|
||||
int first;
|
||||
unsigned n;
|
||||
PREFIX3(stream) *strm = &(state->strm);
|
||||
z_streamp strm = &(state->strm);
|
||||
|
||||
/* consume whatever's left in the input buffer */
|
||||
if (strm->avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
|
||||
@@ -151,7 +152,8 @@ static int gz_zero(gz_state *state, z_off64_t len) {
|
||||
/* compress len zeros (len guaranteed > 0) */
|
||||
first = 1;
|
||||
while (len) {
|
||||
n = GT_OFF(state->size) || (z_off64_t)state->size > len ? (unsigned)len : state->size;
|
||||
n = GT_OFF(state->size) || (z_off64_t)state->size > len ?
|
||||
(unsigned)len : state->size;
|
||||
if (first) {
|
||||
memset(state->in, 0, n);
|
||||
first = 0;
|
||||
@@ -168,8 +170,8 @@ static int gz_zero(gz_state *state, z_off64_t len) {
|
||||
|
||||
/* Write len bytes from buf to file. Return the number of bytes written. If
|
||||
the returned value is less than len, then there was an error. */
|
||||
static size_t gz_write(gz_state *state, void const *buf, size_t len) {
|
||||
size_t put = len;
|
||||
local z_size_t gz_write(gz_statep state, voidpc buf, z_size_t len) {
|
||||
z_size_t put = len;
|
||||
|
||||
/* if len is zero, avoid unnecessary operations */
|
||||
if (len == 0)
|
||||
@@ -207,13 +209,14 @@ static size_t gz_write(gz_state *state, void const *buf, size_t len) {
|
||||
if (len && gz_comp(state, Z_NO_FLUSH) == -1)
|
||||
return 0;
|
||||
} while (len);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
/* consume whatever's left in the input buffer */
|
||||
if (state->strm.avail_in && gz_comp(state, Z_NO_FLUSH) == -1)
|
||||
return 0;
|
||||
|
||||
/* directly compress user buffer to file */
|
||||
state->strm.next_in = (z_const unsigned char *) buf;
|
||||
state->strm.next_in = (z_const Bytef *)buf;
|
||||
do {
|
||||
unsigned n = (unsigned)-1;
|
||||
if (n > len)
|
||||
@@ -231,13 +234,13 @@ static size_t gz_write(gz_state *state, void const *buf, size_t len) {
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORT PREFIX(gzwrite)(gzFile file, void const *buf, unsigned len) {
|
||||
gz_state *state;
|
||||
int ZEXPORT gzwrite(gzFile file, voidpc buf, unsigned len) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return 0;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
|
||||
/* check that we're writing and that there's no error */
|
||||
if (state->mode != GZ_WRITE || state->err != Z_OK)
|
||||
@@ -255,18 +258,15 @@ int Z_EXPORT PREFIX(gzwrite)(gzFile file, void const *buf, unsigned len) {
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
size_t Z_EXPORT PREFIX(gzfwrite)(void const *buf, size_t size, size_t nitems, gzFile file) {
|
||||
size_t len;
|
||||
gz_state *state;
|
||||
|
||||
/* Exit early if size is zero, also prevents potential division by zero */
|
||||
if (size == 0)
|
||||
return 0;
|
||||
z_size_t ZEXPORT gzfwrite(voidpc buf, z_size_t size, z_size_t nitems,
|
||||
gzFile file) {
|
||||
z_size_t len;
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return 0;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
|
||||
/* check that we're writing and that there's no error */
|
||||
if (state->mode != GZ_WRITE || state->err != Z_OK)
|
||||
@@ -274,7 +274,7 @@ size_t Z_EXPORT PREFIX(gzfwrite)(void const *buf, size_t size, size_t nitems, gz
|
||||
|
||||
/* compute bytes to read -- error on overflow */
|
||||
len = nitems * size;
|
||||
if (len / size != nitems) {
|
||||
if (size && len / size != nitems) {
|
||||
gz_error(state, Z_STREAM_ERROR, "request does not fit in a size_t");
|
||||
return 0;
|
||||
}
|
||||
@@ -284,16 +284,16 @@ size_t Z_EXPORT PREFIX(gzfwrite)(void const *buf, size_t size, size_t nitems, gz
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORT PREFIX(gzputc)(gzFile file, int c) {
|
||||
int ZEXPORT gzputc(gzFile file, int c) {
|
||||
unsigned have;
|
||||
unsigned char buf[1];
|
||||
gz_state *state;
|
||||
PREFIX3(stream) *strm;
|
||||
gz_statep state;
|
||||
z_streamp strm;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
strm = &(state->strm);
|
||||
|
||||
/* check that we're writing and that there's no error */
|
||||
@@ -329,14 +329,14 @@ int Z_EXPORT PREFIX(gzputc)(gzFile file, int c) {
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORT PREFIX(gzputs)(gzFile file, const char *s) {
|
||||
size_t len, put;
|
||||
gz_state *state;
|
||||
int ZEXPORT gzputs(gzFile file, const char *s) {
|
||||
z_size_t len, put;
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return -1;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
|
||||
/* check that we're writing and that there's no error */
|
||||
if (state->mode != GZ_WRITE || state->err != Z_OK)
|
||||
@@ -352,18 +352,21 @@ int Z_EXPORT PREFIX(gzputs)(gzFile file, const char *s) {
|
||||
return put < len ? -1 : (int)len;
|
||||
}
|
||||
|
||||
#if defined(STDC) || defined(Z_HAVE_STDARG_H)
|
||||
#include <stdarg.h>
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORTVA PREFIX(gzvprintf)(gzFile file, const char *format, va_list va) {
|
||||
int ZEXPORTVA gzvprintf(gzFile file, const char *format, va_list va) {
|
||||
int len;
|
||||
unsigned left;
|
||||
char *next;
|
||||
gz_state *state;
|
||||
PREFIX3(stream) *strm;
|
||||
gz_statep state;
|
||||
z_streamp strm;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
strm = &(state->strm);
|
||||
|
||||
/* check that we're writing and that there's no error */
|
||||
@@ -388,7 +391,22 @@ int Z_EXPORTVA PREFIX(gzvprintf)(gzFile file, const char *format, va_list va) {
|
||||
strm->next_in = state->in;
|
||||
next = (char *)(state->in + (strm->next_in - state->in) + strm->avail_in);
|
||||
next[state->size - 1] = 0;
|
||||
#ifdef NO_vsnprintf
|
||||
# ifdef HAS_vsprintf_void
|
||||
(void)vsprintf(next, format, va);
|
||||
for (len = 0; len < state->size; len++)
|
||||
if (next[len] == 0) break;
|
||||
# else
|
||||
len = vsprintf(next, format, va);
|
||||
# endif
|
||||
#else
|
||||
# ifdef HAS_vsnprintf_void
|
||||
(void)vsnprintf(next, state->size, format, va);
|
||||
len = strlen(next);
|
||||
# else
|
||||
len = vsnprintf(next, state->size, format, va);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* check that printf() results fit in buffer */
|
||||
if (len == 0 || (unsigned)len >= state->size || next[state->size - 1] != 0)
|
||||
@@ -409,24 +427,111 @@ int Z_EXPORTVA PREFIX(gzvprintf)(gzFile file, const char *format, va_list va) {
|
||||
return len;
|
||||
}
|
||||
|
||||
int Z_EXPORTVA PREFIX(gzprintf)(gzFile file, const char *format, ...) {
|
||||
int ZEXPORTVA gzprintf(gzFile file, const char *format, ...) {
|
||||
va_list va;
|
||||
int ret;
|
||||
|
||||
va_start(va, format);
|
||||
ret = PREFIX(gzvprintf)(file, format, va);
|
||||
ret = gzvprintf(file, format, va);
|
||||
va_end(va);
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else /* !STDC && !Z_HAVE_STDARG_H */
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORT PREFIX(gzflush)(gzFile file, int flush) {
|
||||
gz_state *state;
|
||||
int ZEXPORTVA gzprintf(gzFile file, const char *format, int a1, int a2, int a3,
|
||||
int a4, int a5, int a6, int a7, int a8, int a9, int a10,
|
||||
int a11, int a12, int a13, int a14, int a15, int a16,
|
||||
int a17, int a18, int a19, int a20) {
|
||||
unsigned len, left;
|
||||
char *next;
|
||||
gz_statep state;
|
||||
z_streamp strm;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
strm = &(state->strm);
|
||||
|
||||
/* check that can really pass pointer in ints */
|
||||
if (sizeof(int) != sizeof(void *))
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
/* check that we're writing and that there's no error */
|
||||
if (state->mode != GZ_WRITE || state->err != Z_OK)
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
/* make sure we have some buffer space */
|
||||
if (state->size == 0 && gz_init(state) == -1)
|
||||
return state->error;
|
||||
|
||||
/* check for seek request */
|
||||
if (state->seek) {
|
||||
state->seek = 0;
|
||||
if (gz_zero(state, state->skip) == -1)
|
||||
return state->error;
|
||||
}
|
||||
|
||||
/* do the printf() into the input buffer, put length in len -- the input
|
||||
buffer is double-sized just for this function, so there is guaranteed to
|
||||
be state->size bytes available after the current contents */
|
||||
if (strm->avail_in == 0)
|
||||
strm->next_in = state->in;
|
||||
next = (char *)(strm->next_in + strm->avail_in);
|
||||
next[state->size - 1] = 0;
|
||||
#ifdef NO_snprintf
|
||||
# ifdef HAS_sprintf_void
|
||||
sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11, a12,
|
||||
a13, a14, a15, a16, a17, a18, a19, a20);
|
||||
for (len = 0; len < size; len++)
|
||||
if (next[len] == 0)
|
||||
break;
|
||||
# else
|
||||
len = sprintf(next, format, a1, a2, a3, a4, a5, a6, a7, a8, a9, a10, a11,
|
||||
a12, a13, a14, a15, a16, a17, a18, a19, a20);
|
||||
# endif
|
||||
#else
|
||||
# ifdef HAS_snprintf_void
|
||||
snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8, a9,
|
||||
a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
|
||||
len = strlen(next);
|
||||
# else
|
||||
len = snprintf(next, state->size, format, a1, a2, a3, a4, a5, a6, a7, a8,
|
||||
a9, a10, a11, a12, a13, a14, a15, a16, a17, a18, a19, a20);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* check that printf() results fit in buffer */
|
||||
if (len == 0 || len >= state->size || next[state->size - 1] != 0)
|
||||
return 0;
|
||||
|
||||
/* update buffer and position, compress first half if past that */
|
||||
strm->avail_in += len;
|
||||
state->x.pos += len;
|
||||
if (strm->avail_in >= state->size) {
|
||||
left = strm->avail_in - state->size;
|
||||
strm->avail_in = state->size;
|
||||
if (gz_comp(state, Z_NO_FLUSH) == -1)
|
||||
return state->err;
|
||||
memmove(state->in, state->in + state->size, left);
|
||||
strm->next_in = state->in;
|
||||
strm->avail_in = left;
|
||||
}
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int ZEXPORT gzflush(gzFile file, int flush) {
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
state = (gz_statep)file;
|
||||
|
||||
/* check that we're writing and that there's no error */
|
||||
if (state->mode != GZ_WRITE || state->err != Z_OK)
|
||||
@@ -449,14 +554,14 @@ int Z_EXPORT PREFIX(gzflush)(gzFile file, int flush) {
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORT PREFIX(gzsetparams)(gzFile file, int level, int strategy) {
|
||||
gz_state *state;
|
||||
PREFIX3(stream) *strm;
|
||||
int ZEXPORT gzsetparams(gzFile file, int level, int strategy) {
|
||||
gz_statep state;
|
||||
z_streamp strm;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
strm = &(state->strm);
|
||||
|
||||
/* check that we're writing and that there's no error */
|
||||
@@ -479,7 +584,7 @@ int Z_EXPORT PREFIX(gzsetparams)(gzFile file, int level, int strategy) {
|
||||
/* flush previous input with previous parameters before changing */
|
||||
if (strm->avail_in && gz_comp(state, Z_BLOCK) == -1)
|
||||
return state->err;
|
||||
PREFIX(deflateParams)(strm, level, strategy);
|
||||
deflateParams(strm, level, strategy);
|
||||
}
|
||||
state->level = level;
|
||||
state->strategy = strategy;
|
||||
@@ -487,14 +592,14 @@ int Z_EXPORT PREFIX(gzsetparams)(gzFile file, int level, int strategy) {
|
||||
}
|
||||
|
||||
/* -- see zlib.h -- */
|
||||
int Z_EXPORT PREFIX(gzclose_w)(gzFile file) {
|
||||
int ZEXPORT gzclose_w(gzFile file) {
|
||||
int ret = Z_OK;
|
||||
gz_state *state;
|
||||
gz_statep state;
|
||||
|
||||
/* get internal structure */
|
||||
if (file == NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
state = (gz_state *)file;
|
||||
state = (gz_statep)file;
|
||||
|
||||
/* check that we're writing */
|
||||
if (state->mode != GZ_WRITE)
|
||||
@@ -512,15 +617,15 @@ int Z_EXPORT PREFIX(gzclose_w)(gzFile file) {
|
||||
ret = state->err;
|
||||
if (state->size) {
|
||||
if (!state->direct) {
|
||||
(void)PREFIX(deflateEnd)(&(state->strm));
|
||||
zng_free(state->out);
|
||||
(void)deflateEnd(&(state->strm));
|
||||
free(state->out);
|
||||
}
|
||||
zng_free(state->in);
|
||||
free(state->in);
|
||||
}
|
||||
gz_error(state, Z_OK, NULL);
|
||||
free(state->path);
|
||||
if (close(state->fd) == -1)
|
||||
ret = Z_ERRNO;
|
||||
zng_free(state);
|
||||
free(state);
|
||||
return ret;
|
||||
}
|
||||
+255
-150
@@ -10,77 +10,140 @@
|
||||
inflate_fast() can be used with either inflate.c or infback.c.
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
#include "inflate.h"
|
||||
#include "inflate_p.h"
|
||||
#include "functable.h"
|
||||
|
||||
/* Avoid conflicts with zlib.h macros */
|
||||
#ifdef ZLIB_COMPAT
|
||||
# undef inflateBackInit
|
||||
#endif
|
||||
#include "inffast.h"
|
||||
|
||||
/*
|
||||
strm provides memory allocation functions in zalloc and zfree, or
|
||||
NULL to use the library memory allocation functions.
|
||||
Z_NULL to use the library memory allocation functions.
|
||||
|
||||
windowBits is in the range 8..15, and window is a user-supplied
|
||||
window and output buffer that is 2**windowBits bytes.
|
||||
|
||||
This function is hidden in ZLIB_COMPAT builds.
|
||||
*/
|
||||
int32_t ZNG_CONDEXPORT PREFIX(inflateBackInit)(PREFIX3(stream) *strm, int32_t windowBits, uint8_t *window) {
|
||||
struct inflate_state *state;
|
||||
int ZEXPORT inflateBackInit_(z_streamp strm, int windowBits,
|
||||
unsigned char FAR *window, const char *version,
|
||||
int stream_size) {
|
||||
struct inflate_state FAR *state;
|
||||
|
||||
if (strm == NULL || window == NULL || windowBits < MIN_WBITS || windowBits > MAX_WBITS)
|
||||
if (version == Z_NULL || version[0] != ZLIB_VERSION[0] ||
|
||||
stream_size != (int)(sizeof(z_stream)))
|
||||
return Z_VERSION_ERROR;
|
||||
if (strm == Z_NULL || window == Z_NULL ||
|
||||
windowBits < 8 || windowBits > 15)
|
||||
return Z_STREAM_ERROR;
|
||||
strm->msg = NULL; /* in case we return an error */
|
||||
if (strm->zalloc == NULL) {
|
||||
strm->zalloc = PREFIX(zcalloc);
|
||||
strm->opaque = NULL;
|
||||
strm->msg = Z_NULL; /* in case we return an error */
|
||||
if (strm->zalloc == (alloc_func)0) {
|
||||
#ifdef Z_SOLO
|
||||
return Z_STREAM_ERROR;
|
||||
#else
|
||||
strm->zalloc = zcalloc;
|
||||
strm->opaque = (voidpf)0;
|
||||
#endif
|
||||
}
|
||||
if (strm->zfree == NULL)
|
||||
strm->zfree = PREFIX(zcfree);
|
||||
|
||||
inflate_allocs *alloc_bufs = alloc_inflate(strm);
|
||||
if (alloc_bufs == NULL)
|
||||
return Z_MEM_ERROR;
|
||||
|
||||
state = alloc_bufs->state;
|
||||
state->alloc_bufs = alloc_bufs;
|
||||
if (strm->zfree == (free_func)0)
|
||||
#ifdef Z_SOLO
|
||||
return Z_STREAM_ERROR;
|
||||
#else
|
||||
strm->zfree = zcfree;
|
||||
#endif
|
||||
state = (struct inflate_state FAR *)ZALLOC(strm, 1,
|
||||
sizeof(struct inflate_state));
|
||||
if (state == Z_NULL) return Z_MEM_ERROR;
|
||||
Tracev((stderr, "inflate: allocated\n"));
|
||||
|
||||
strm->state = (struct internal_state *)state;
|
||||
state->wbits = (unsigned int)windowBits;
|
||||
strm->state = (struct internal_state FAR *)state;
|
||||
state->dmax = 32768U;
|
||||
state->wbits = (uInt)windowBits;
|
||||
state->wsize = 1U << windowBits;
|
||||
state->wbufsize = 1U << windowBits;
|
||||
state->window = window;
|
||||
state->wnext = 0;
|
||||
state->whave = 0;
|
||||
state->chunksize = FUNCTABLE_CALL(chunksize)();
|
||||
#ifdef INFLATE_STRICT
|
||||
state->dmax = 32768U;
|
||||
#endif
|
||||
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||
state->sane = 1;
|
||||
#endif
|
||||
return Z_OK;
|
||||
}
|
||||
|
||||
/* Function used by zlib.h and zlib-ng version 2.0 macros */
|
||||
int32_t Z_EXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int32_t windowBits, uint8_t *window,
|
||||
const char *version, int32_t stream_size) {
|
||||
if (CHECK_VER_STSIZE(version, stream_size))
|
||||
return Z_VERSION_ERROR;
|
||||
return PREFIX(inflateBackInit)(strm, windowBits, window);
|
||||
/*
|
||||
Return state with length and distance decoding tables and index sizes set to
|
||||
fixed code decoding. Normally this returns fixed tables from inffixed.h.
|
||||
If BUILDFIXED is defined, then instead this routine builds the tables the
|
||||
first time it's called, and returns those tables the first time and
|
||||
thereafter. This reduces the size of the code by about 2K bytes, in
|
||||
exchange for a little execution time. However, BUILDFIXED should not be
|
||||
used for threaded applications, since the rewriting of the tables and virgin
|
||||
may not be thread-safe.
|
||||
*/
|
||||
local void fixedtables(struct inflate_state FAR *state) {
|
||||
#ifdef BUILDFIXED
|
||||
static int virgin = 1;
|
||||
static code *lenfix, *distfix;
|
||||
static code fixed[544];
|
||||
|
||||
/* build fixed huffman tables if first call (may not be thread safe) */
|
||||
if (virgin) {
|
||||
unsigned sym, bits;
|
||||
static code *next;
|
||||
|
||||
/* literal/length table */
|
||||
sym = 0;
|
||||
while (sym < 144) state->lens[sym++] = 8;
|
||||
while (sym < 256) state->lens[sym++] = 9;
|
||||
while (sym < 280) state->lens[sym++] = 7;
|
||||
while (sym < 288) state->lens[sym++] = 8;
|
||||
next = fixed;
|
||||
lenfix = next;
|
||||
bits = 9;
|
||||
inflate_table(LENS, state->lens, 288, &(next), &(bits), state->work);
|
||||
|
||||
/* distance table */
|
||||
sym = 0;
|
||||
while (sym < 32) state->lens[sym++] = 5;
|
||||
distfix = next;
|
||||
bits = 5;
|
||||
inflate_table(DISTS, state->lens, 32, &(next), &(bits), state->work);
|
||||
|
||||
/* do this just once */
|
||||
virgin = 0;
|
||||
}
|
||||
#else /* !BUILDFIXED */
|
||||
# include "inffixed.h"
|
||||
#endif /* BUILDFIXED */
|
||||
state->lencode = lenfix;
|
||||
state->lenbits = 9;
|
||||
state->distcode = distfix;
|
||||
state->distbits = 5;
|
||||
}
|
||||
|
||||
/*
|
||||
Private macros for inflateBack()
|
||||
Look in inflate_p.h for macros shared with inflate()
|
||||
*/
|
||||
/* Macros for inflateBack(): */
|
||||
|
||||
/* Load returned state from inflate_fast() */
|
||||
#define LOAD() \
|
||||
do { \
|
||||
put = strm->next_out; \
|
||||
left = strm->avail_out; \
|
||||
next = strm->next_in; \
|
||||
have = strm->avail_in; \
|
||||
hold = state->hold; \
|
||||
bits = state->bits; \
|
||||
} while (0)
|
||||
|
||||
/* Set state from registers for inflate_fast() */
|
||||
#define RESTORE() \
|
||||
do { \
|
||||
strm->next_out = put; \
|
||||
strm->avail_out = left; \
|
||||
strm->next_in = next; \
|
||||
strm->avail_in = have; \
|
||||
state->hold = hold; \
|
||||
state->bits = bits; \
|
||||
} while (0)
|
||||
|
||||
/* Clear the input bit accumulator */
|
||||
#define INITBITS() \
|
||||
do { \
|
||||
hold = 0; \
|
||||
bits = 0; \
|
||||
} while (0)
|
||||
|
||||
/* Assure that some input is available. If input is requested, but denied,
|
||||
then return a Z_BUF_ERROR from inflateBack(). */
|
||||
@@ -89,7 +152,7 @@ int32_t Z_EXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int32_t windowB
|
||||
if (have == 0) { \
|
||||
have = in(in_desc, &next); \
|
||||
if (have == 0) { \
|
||||
next = NULL; \
|
||||
next = Z_NULL; \
|
||||
ret = Z_BUF_ERROR; \
|
||||
goto inf_leave; \
|
||||
} \
|
||||
@@ -102,10 +165,37 @@ int32_t Z_EXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int32_t windowB
|
||||
do { \
|
||||
PULL(); \
|
||||
have--; \
|
||||
hold += ((uint64_t)(*next++) << bits); \
|
||||
hold += (unsigned long)(*next++) << bits; \
|
||||
bits += 8; \
|
||||
} while (0)
|
||||
|
||||
/* Assure that there are at least n bits in the bit accumulator. If there is
|
||||
not enough available input to do that, then return from inflateBack() with
|
||||
an error. */
|
||||
#define NEEDBITS(n) \
|
||||
do { \
|
||||
while (bits < (unsigned)(n)) \
|
||||
PULLBYTE(); \
|
||||
} while (0)
|
||||
|
||||
/* Return the low n bits of the bit accumulator (n < 16) */
|
||||
#define BITS(n) \
|
||||
((unsigned)hold & ((1U << (n)) - 1))
|
||||
|
||||
/* Remove n bits from the bit accumulator */
|
||||
#define DROPBITS(n) \
|
||||
do { \
|
||||
hold >>= (n); \
|
||||
bits -= (unsigned)(n); \
|
||||
} while (0)
|
||||
|
||||
/* Remove zero to seven bits as needed to go to a byte boundary */
|
||||
#define BYTEBITS() \
|
||||
do { \
|
||||
hold >>= bits & 7; \
|
||||
bits -= bits & 7; \
|
||||
} while (0)
|
||||
|
||||
/* Assure that some output space is available, by writing out the window
|
||||
if it's full. If the write fails, return from inflateBack() with a
|
||||
Z_BUF_ERROR. */
|
||||
@@ -142,41 +232,42 @@ int32_t Z_EXPORT PREFIX(inflateBackInit_)(PREFIX3(stream) *strm, int32_t windowB
|
||||
|
||||
in() should return zero on failure. out() should return non-zero on
|
||||
failure. If either in() or out() fails, than inflateBack() returns a
|
||||
Z_BUF_ERROR. strm->next_in can be checked for NULL to see whether it
|
||||
was in() or out() that caused in the error. Otherwise, inflateBack()
|
||||
Z_BUF_ERROR. strm->next_in can be checked for Z_NULL to see whether it
|
||||
was in() or out() that caused in the error. Otherwise, inflateBack()
|
||||
returns Z_STREAM_END on success, Z_DATA_ERROR for an deflate format
|
||||
error, or Z_MEM_ERROR if it could not allocate memory for the state.
|
||||
inflateBack() can also return Z_STREAM_ERROR if the input parameters
|
||||
are not correct, i.e. strm is NULL or the state was not initialized.
|
||||
are not correct, i.e. strm is Z_NULL or the state was not initialized.
|
||||
*/
|
||||
int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in_desc, out_func out, void *out_desc) {
|
||||
struct inflate_state *state;
|
||||
z_const unsigned char *next; /* next input */
|
||||
unsigned char *put; /* next output */
|
||||
unsigned have, left; /* available input and output */
|
||||
uint64_t hold; /* bit buffer */
|
||||
unsigned bits; /* bits in bit buffer */
|
||||
unsigned copy; /* number of stored or match bytes to copy */
|
||||
unsigned char *from; /* where to copy match bytes from */
|
||||
code here; /* current decoding table entry */
|
||||
code last; /* parent table entry */
|
||||
unsigned len; /* length to copy for repeats, bits to drop */
|
||||
int32_t ret; /* return code */
|
||||
static const uint16_t order[19] = /* permutation of code lengths */
|
||||
int ZEXPORT inflateBack(z_streamp strm, in_func in, void FAR *in_desc,
|
||||
out_func out, void FAR *out_desc) {
|
||||
struct inflate_state FAR *state;
|
||||
z_const unsigned char FAR *next; /* next input */
|
||||
unsigned char FAR *put; /* next output */
|
||||
unsigned have, left; /* available input and output */
|
||||
unsigned long hold; /* bit buffer */
|
||||
unsigned bits; /* bits in bit buffer */
|
||||
unsigned copy; /* number of stored or match bytes to copy */
|
||||
unsigned char FAR *from; /* where to copy match bytes from */
|
||||
code here; /* current decoding table entry */
|
||||
code last; /* parent table entry */
|
||||
unsigned len; /* length to copy for repeats, bits to drop */
|
||||
int ret; /* return code */
|
||||
static const unsigned short order[19] = /* permutation of code lengths */
|
||||
{16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15};
|
||||
|
||||
/* Check that the strm exists and that the state was initialized */
|
||||
if (strm == NULL || strm->state == NULL)
|
||||
if (strm == Z_NULL || strm->state == Z_NULL)
|
||||
return Z_STREAM_ERROR;
|
||||
state = (struct inflate_state *)strm->state;
|
||||
state = (struct inflate_state FAR *)strm->state;
|
||||
|
||||
/* Reset the state */
|
||||
strm->msg = NULL;
|
||||
strm->msg = Z_NULL;
|
||||
state->mode = TYPE;
|
||||
state->last = 0;
|
||||
state->whave = 0;
|
||||
next = strm->next_in;
|
||||
have = next != NULL ? strm->avail_in : 0;
|
||||
have = next != Z_NULL ? strm->avail_in : 0;
|
||||
hold = 0;
|
||||
bits = 0;
|
||||
put = state->window;
|
||||
@@ -197,20 +288,24 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in
|
||||
DROPBITS(1);
|
||||
switch (BITS(2)) {
|
||||
case 0: /* stored block */
|
||||
Tracev((stderr, "inflate: stored block%s\n", state->last ? " (last)" : ""));
|
||||
Tracev((stderr, "inflate: stored block%s\n",
|
||||
state->last ? " (last)" : ""));
|
||||
state->mode = STORED;
|
||||
break;
|
||||
case 1: /* fixed block */
|
||||
PREFIX(fixedtables)(state);
|
||||
Tracev((stderr, "inflate: fixed codes block%s\n", state->last ? " (last)" : ""));
|
||||
fixedtables(state);
|
||||
Tracev((stderr, "inflate: fixed codes block%s\n",
|
||||
state->last ? " (last)" : ""));
|
||||
state->mode = LEN; /* decode codes */
|
||||
break;
|
||||
case 2: /* dynamic block */
|
||||
Tracev((stderr, "inflate: dynamic codes block%s\n", state->last ? " (last)" : ""));
|
||||
Tracev((stderr, "inflate: dynamic codes block%s\n",
|
||||
state->last ? " (last)" : ""));
|
||||
state->mode = TABLE;
|
||||
break;
|
||||
case 3:
|
||||
SET_BAD("invalid block type");
|
||||
strm->msg = (char *)"invalid block type";
|
||||
state->mode = BAD;
|
||||
}
|
||||
DROPBITS(2);
|
||||
break;
|
||||
@@ -220,11 +315,13 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in
|
||||
BYTEBITS(); /* go to byte boundary */
|
||||
NEEDBITS(32);
|
||||
if ((hold & 0xffff) != ((hold >> 16) ^ 0xffff)) {
|
||||
SET_BAD("invalid stored block lengths");
|
||||
strm->msg = (char *)"invalid stored block lengths";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
state->length = (uint16_t)hold;
|
||||
Tracev((stderr, "inflate: stored length %u\n", state->length));
|
||||
state->length = (unsigned)hold & 0xffff;
|
||||
Tracev((stderr, "inflate: stored length %u\n",
|
||||
state->length));
|
||||
INITBITS();
|
||||
|
||||
/* copy stored block from input to output */
|
||||
@@ -232,9 +329,9 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in
|
||||
copy = state->length;
|
||||
PULL();
|
||||
ROOM();
|
||||
copy = MIN(copy, have);
|
||||
copy = MIN(copy, left);
|
||||
memcpy(put, next, copy);
|
||||
if (copy > have) copy = have;
|
||||
if (copy > left) copy = left;
|
||||
zmemcpy(put, next, copy);
|
||||
have -= copy;
|
||||
next += copy;
|
||||
left -= copy;
|
||||
@@ -256,60 +353,67 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in
|
||||
DROPBITS(4);
|
||||
#ifndef PKZIP_BUG_WORKAROUND
|
||||
if (state->nlen > 286 || state->ndist > 30) {
|
||||
SET_BAD("too many length or distance symbols");
|
||||
strm->msg = (char *)"too many length or distance symbols";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
Tracev((stderr, "inflate: table sizes ok\n"));
|
||||
state->have = 0;
|
||||
|
||||
/* get code length code lengths (not a typo) */
|
||||
state->have = 0;
|
||||
while (state->have < state->ncode) {
|
||||
NEEDBITS(3);
|
||||
state->lens[order[state->have++]] = (uint16_t)BITS(3);
|
||||
state->lens[order[state->have++]] = (unsigned short)BITS(3);
|
||||
DROPBITS(3);
|
||||
}
|
||||
while (state->have < 19)
|
||||
state->lens[order[state->have++]] = 0;
|
||||
state->next = state->codes;
|
||||
state->lencode = (const code *)(state->next);
|
||||
state->lencode = (code const FAR *)(state->next);
|
||||
state->lenbits = 7;
|
||||
ret = zng_inflate_table(CODES, state->lens, 19, &(state->next), &(state->lenbits), state->work);
|
||||
ret = inflate_table(CODES, state->lens, 19, &(state->next),
|
||||
&(state->lenbits), state->work);
|
||||
if (ret) {
|
||||
SET_BAD("invalid code lengths set");
|
||||
strm->msg = (char *)"invalid code lengths set";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
Tracev((stderr, "inflate: code lengths ok\n"));
|
||||
state->have = 0;
|
||||
|
||||
/* get length and distance code code lengths */
|
||||
state->have = 0;
|
||||
while (state->have < state->nlen + state->ndist) {
|
||||
for (;;) {
|
||||
here = state->lencode[BITS(state->lenbits)];
|
||||
if (here.bits <= bits) break;
|
||||
if ((unsigned)(here.bits) <= bits) break;
|
||||
PULLBYTE();
|
||||
}
|
||||
if (here.val < 16) {
|
||||
DROPBITS(here.bits);
|
||||
state->lens[state->have++] = here.val;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
if (here.val == 16) {
|
||||
NEEDBITS(here.bits + 2);
|
||||
DROPBITS(here.bits);
|
||||
if (state->have == 0) {
|
||||
SET_BAD("invalid bit length repeat");
|
||||
strm->msg = (char *)"invalid bit length repeat";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
len = state->lens[state->have - 1];
|
||||
len = (unsigned)(state->lens[state->have - 1]);
|
||||
copy = 3 + BITS(2);
|
||||
DROPBITS(2);
|
||||
} else if (here.val == 17) {
|
||||
}
|
||||
else if (here.val == 17) {
|
||||
NEEDBITS(here.bits + 3);
|
||||
DROPBITS(here.bits);
|
||||
len = 0;
|
||||
copy = 3 + BITS(3);
|
||||
DROPBITS(3);
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
NEEDBITS(here.bits + 7);
|
||||
DROPBITS(here.bits);
|
||||
len = 0;
|
||||
@@ -317,57 +421,58 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in
|
||||
DROPBITS(7);
|
||||
}
|
||||
if (state->have + copy > state->nlen + state->ndist) {
|
||||
SET_BAD("invalid bit length repeat");
|
||||
strm->msg = (char *)"invalid bit length repeat";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
while (copy) {
|
||||
--copy;
|
||||
state->lens[state->have++] = (uint16_t)len;
|
||||
}
|
||||
while (copy--)
|
||||
state->lens[state->have++] = (unsigned short)len;
|
||||
}
|
||||
}
|
||||
|
||||
/* handle error breaks in while */
|
||||
if (state->mode == BAD)
|
||||
break;
|
||||
if (state->mode == BAD) break;
|
||||
|
||||
/* check for end-of-block code (better have one) */
|
||||
if (state->lens[256] == 0) {
|
||||
SET_BAD("invalid code -- missing end-of-block");
|
||||
strm->msg = (char *)"invalid code -- missing end-of-block";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
|
||||
/* build code tables -- note: do not change the lenbits or distbits
|
||||
values here (10 and 9) without reading the comments in inftrees.h
|
||||
values here (9 and 6) without reading the comments in inftrees.h
|
||||
concerning the ENOUGH constants, which depend on those values */
|
||||
state->next = state->codes;
|
||||
state->lencode = (const code *)(state->next);
|
||||
state->lenbits = 10;
|
||||
ret = zng_inflate_table(LENS, state->lens, state->nlen, &(state->next), &(state->lenbits), state->work);
|
||||
state->lencode = (code const FAR *)(state->next);
|
||||
state->lenbits = 9;
|
||||
ret = inflate_table(LENS, state->lens, state->nlen, &(state->next),
|
||||
&(state->lenbits), state->work);
|
||||
if (ret) {
|
||||
SET_BAD("invalid literal/lengths set");
|
||||
strm->msg = (char *)"invalid literal/lengths set";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
state->distcode = (const code *)(state->next);
|
||||
state->distbits = 9;
|
||||
ret = zng_inflate_table(DISTS, state->lens + state->nlen, state->ndist,
|
||||
&(state->next), &(state->distbits), state->work);
|
||||
state->distcode = (code const FAR *)(state->next);
|
||||
state->distbits = 6;
|
||||
ret = inflate_table(DISTS, state->lens + state->nlen, state->ndist,
|
||||
&(state->next), &(state->distbits), state->work);
|
||||
if (ret) {
|
||||
SET_BAD("invalid distances set");
|
||||
strm->msg = (char *)"invalid distances set";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
Tracev((stderr, "inflate: codes ok\n"));
|
||||
state->mode = LEN;
|
||||
Z_FALLTHROUGH;
|
||||
/* fallthrough */
|
||||
|
||||
case LEN:
|
||||
/* use inflate_fast() if we have enough input and output */
|
||||
if (have >= INFLATE_FAST_MIN_HAVE &&
|
||||
left >= INFLATE_FAST_MIN_LEFT) {
|
||||
if (have >= 6 && left >= 258) {
|
||||
RESTORE();
|
||||
if (state->whave < state->wsize)
|
||||
state->whave = state->wsize - left;
|
||||
FUNCTABLE_CALL(inflate_fast)(strm, state->wsize);
|
||||
inflate_fast(strm, state->wsize);
|
||||
LOAD();
|
||||
break;
|
||||
}
|
||||
@@ -375,25 +480,24 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in
|
||||
/* get a literal, length, or end-of-block code */
|
||||
for (;;) {
|
||||
here = state->lencode[BITS(state->lenbits)];
|
||||
if (here.bits <= bits)
|
||||
break;
|
||||
if ((unsigned)(here.bits) <= bits) break;
|
||||
PULLBYTE();
|
||||
}
|
||||
if (here.op && (here.op & 0xf0) == 0) {
|
||||
last = here;
|
||||
for (;;) {
|
||||
here = state->lencode[last.val + (BITS(last.bits + last.op) >> last.bits)];
|
||||
if ((unsigned)last.bits + (unsigned)here.bits <= bits)
|
||||
break;
|
||||
here = state->lencode[last.val +
|
||||
(BITS(last.bits + last.op) >> last.bits)];
|
||||
if ((unsigned)(last.bits + here.bits) <= bits) break;
|
||||
PULLBYTE();
|
||||
}
|
||||
DROPBITS(last.bits);
|
||||
}
|
||||
DROPBITS(here.bits);
|
||||
state->length = here.val;
|
||||
state->length = (unsigned)here.val;
|
||||
|
||||
/* process literal */
|
||||
if ((int)(here.op) == 0) {
|
||||
if (here.op == 0) {
|
||||
Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
||||
"inflate: literal '%c'\n" :
|
||||
"inflate: literal 0x%02x\n", here.val));
|
||||
@@ -413,13 +517,14 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in
|
||||
|
||||
/* invalid code */
|
||||
if (here.op & 64) {
|
||||
SET_BAD("invalid literal/length code");
|
||||
strm->msg = (char *)"invalid literal/length code";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
|
||||
/* length code -- get extra bits, if any */
|
||||
state->extra = (here.op & MAX_BITS);
|
||||
if (state->extra) {
|
||||
state->extra = (unsigned)(here.op) & 15;
|
||||
if (state->extra != 0) {
|
||||
NEEDBITS(state->extra);
|
||||
state->length += BITS(state->extra);
|
||||
DROPBITS(state->extra);
|
||||
@@ -429,40 +534,40 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in
|
||||
/* get distance code */
|
||||
for (;;) {
|
||||
here = state->distcode[BITS(state->distbits)];
|
||||
if (here.bits <= bits)
|
||||
break;
|
||||
if ((unsigned)(here.bits) <= bits) break;
|
||||
PULLBYTE();
|
||||
}
|
||||
if ((here.op & 0xf0) == 0) {
|
||||
last = here;
|
||||
for (;;) {
|
||||
here = state->distcode[last.val + (BITS(last.bits + last.op) >> last.bits)];
|
||||
if ((unsigned)last.bits + (unsigned)here.bits <= bits)
|
||||
break;
|
||||
here = state->distcode[last.val +
|
||||
(BITS(last.bits + last.op) >> last.bits)];
|
||||
if ((unsigned)(last.bits + here.bits) <= bits) break;
|
||||
PULLBYTE();
|
||||
}
|
||||
DROPBITS(last.bits);
|
||||
}
|
||||
DROPBITS(here.bits);
|
||||
if (here.op & 64) {
|
||||
SET_BAD("invalid distance code");
|
||||
strm->msg = (char *)"invalid distance code";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
state->offset = here.val;
|
||||
state->extra = (here.op & MAX_BITS);
|
||||
state->offset = (unsigned)here.val;
|
||||
|
||||
/* get distance extra bits, if any */
|
||||
if (state->extra) {
|
||||
state->extra = (unsigned)(here.op) & 15;
|
||||
if (state->extra != 0) {
|
||||
NEEDBITS(state->extra);
|
||||
state->offset += BITS(state->extra);
|
||||
DROPBITS(state->extra);
|
||||
}
|
||||
#ifdef INFLATE_STRICT
|
||||
if (state->offset > state->wsize - (state->whave < state->wsize ? left : 0)) {
|
||||
SET_BAD("invalid distance too far back");
|
||||
if (state->offset > state->wsize - (state->whave < state->wsize ?
|
||||
left : 0)) {
|
||||
strm->msg = (char *)"invalid distance too far back";
|
||||
state->mode = BAD;
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
Tracevv((stderr, "inflate: distance %u\n", state->offset));
|
||||
|
||||
/* copy match from window to output */
|
||||
@@ -472,11 +577,12 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in
|
||||
if (copy < left) {
|
||||
from = put + copy;
|
||||
copy = left - copy;
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
from = put - state->offset;
|
||||
copy = left;
|
||||
}
|
||||
copy = MIN(copy, state->length);
|
||||
if (copy > state->length) copy = state->length;
|
||||
state->length -= copy;
|
||||
left -= copy;
|
||||
do {
|
||||
@@ -494,7 +600,8 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in
|
||||
ret = Z_DATA_ERROR;
|
||||
goto inf_leave;
|
||||
|
||||
default: /* can't happen, but makes compilers happy */
|
||||
default:
|
||||
/* can't happen, but makes compilers happy */
|
||||
ret = Z_STREAM_ERROR;
|
||||
goto inf_leave;
|
||||
}
|
||||
@@ -502,22 +609,20 @@ int32_t Z_EXPORT PREFIX(inflateBack)(PREFIX3(stream) *strm, in_func in, void *in
|
||||
/* Write leftover output and return unused input */
|
||||
inf_leave:
|
||||
if (left < state->wsize) {
|
||||
if (out(out_desc, state->window, state->wsize - left) && (ret == Z_STREAM_END)) {
|
||||
if (out(out_desc, state->window, state->wsize - left) &&
|
||||
ret == Z_STREAM_END)
|
||||
ret = Z_BUF_ERROR;
|
||||
}
|
||||
}
|
||||
strm->next_in = next;
|
||||
strm->avail_in = have;
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t Z_EXPORT PREFIX(inflateBackEnd)(PREFIX3(stream) *strm) {
|
||||
if (strm == NULL || strm->state == NULL || strm->zfree == NULL)
|
||||
int ZEXPORT inflateBackEnd(z_streamp strm) {
|
||||
if (strm == Z_NULL || strm->state == Z_NULL || strm->zfree == (free_func)0)
|
||||
return Z_STREAM_ERROR;
|
||||
|
||||
/* Free allocated buffers */
|
||||
free_inflate(strm);
|
||||
|
||||
ZFREE(strm, strm->state);
|
||||
strm->state = Z_NULL;
|
||||
Tracev((stderr, "inflate: end\n"));
|
||||
return Z_OK;
|
||||
}
|
||||
@@ -1,332 +0,0 @@
|
||||
/* inffast.c -- fast decoding
|
||||
* Copyright (C) 1995-2017 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "zendian.h"
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
#include "inflate.h"
|
||||
#include "inflate_p.h"
|
||||
#include "functable.h"
|
||||
|
||||
/*
|
||||
Decode literal, length, and distance codes and write out the resulting
|
||||
literal and match bytes until either not enough input or output is
|
||||
available, an end-of-block is encountered, or a data error is encountered.
|
||||
When large enough input and output buffers are supplied to inflate(), for
|
||||
example, a 16K input buffer and a 64K output buffer, more than 95% of the
|
||||
inflate execution time is spent in this routine.
|
||||
|
||||
Entry assumptions:
|
||||
|
||||
state->mode == LEN
|
||||
strm->avail_in >= INFLATE_FAST_MIN_HAVE
|
||||
strm->avail_out >= INFLATE_FAST_MIN_LEFT
|
||||
start >= strm->avail_out
|
||||
state->bits < 8
|
||||
|
||||
On return, state->mode is one of:
|
||||
|
||||
LEN -- ran out of enough output space or enough available input
|
||||
TYPE -- reached end of block code, inflate() to interpret next block
|
||||
BAD -- error in block data
|
||||
|
||||
Notes:
|
||||
|
||||
- The maximum input bits used by a length/distance pair is 15 bits for the
|
||||
length code, 5 bits for the length extra, 15 bits for the distance code,
|
||||
and 13 bits for the distance extra. This totals 48 bits, or six bytes.
|
||||
Therefore if strm->avail_in >= 6, then there is enough input to avoid
|
||||
checking for available input while decoding.
|
||||
|
||||
- On some architectures, it can be significantly faster (e.g. up to 1.2x
|
||||
faster on x86_64) to load from strm->next_in 64 bits, or 8 bytes, at a
|
||||
time, so INFLATE_FAST_MIN_HAVE == 8.
|
||||
|
||||
- The maximum bytes that a single length/distance pair can output is 258
|
||||
bytes, which is the maximum length that can be coded. inflate_fast()
|
||||
requires strm->avail_out >= 258 for each loop to avoid checking for
|
||||
output space.
|
||||
*/
|
||||
void Z_INTERNAL INFLATE_FAST(PREFIX3(stream) *strm, uint32_t start) {
|
||||
/* start: inflate()'s starting value for strm->avail_out */
|
||||
struct inflate_state *state;
|
||||
z_const unsigned char *in; /* local strm->next_in */
|
||||
const unsigned char *last; /* have enough input while in < last */
|
||||
unsigned char *out; /* local strm->next_out */
|
||||
unsigned char *beg; /* inflate()'s initial strm->next_out */
|
||||
unsigned char *end; /* while out < end, enough space available */
|
||||
unsigned char *safe; /* can use chunkcopy provided out < safe */
|
||||
unsigned char *window; /* allocated sliding window, if wsize != 0 */
|
||||
unsigned wsize; /* window size or zero if not using window */
|
||||
unsigned whave; /* valid bytes in the window */
|
||||
unsigned wnext; /* window write index */
|
||||
|
||||
/* hold is a local copy of strm->hold. By default, hold satisfies the same
|
||||
invariants that strm->hold does, namely that (hold >> bits) == 0. This
|
||||
invariant is kept by loading bits into hold one byte at a time, like:
|
||||
|
||||
hold |= next_byte_of_input << bits; in++; bits += 8;
|
||||
|
||||
If we need to ensure that bits >= 15 then this code snippet is simply
|
||||
repeated. Over one iteration of the outermost do/while loop, this
|
||||
happens up to six times (48 bits of input), as described in the NOTES
|
||||
above.
|
||||
|
||||
However, on some little endian architectures, it can be significantly
|
||||
faster to load 64 bits once instead of 8 bits six times:
|
||||
|
||||
if (bits <= 16) {
|
||||
hold |= next_8_bytes_of_input << bits; in += 6; bits += 48;
|
||||
}
|
||||
|
||||
Unlike the simpler one byte load, shifting the next_8_bytes_of_input
|
||||
by bits will overflow and lose those high bits, up to 2 bytes' worth.
|
||||
The conservative estimate is therefore that we have read only 6 bytes
|
||||
(48 bits). Again, as per the NOTES above, 48 bits is sufficient for the
|
||||
rest of the iteration, and we will not need to load another 8 bytes.
|
||||
|
||||
Inside this function, we no longer satisfy (hold >> bits) == 0, but
|
||||
this is not problematic, even if that overflow does not land on an 8 bit
|
||||
byte boundary. Those excess bits will eventually shift down lower as the
|
||||
Huffman decoder consumes input, and when new input bits need to be loaded
|
||||
into the bits variable, the same input bits will be or'ed over those
|
||||
existing bits. A bitwise or is idempotent: (a | b | b) equals (a | b).
|
||||
Note that we therefore write that load operation as "hold |= etc" and not
|
||||
"hold += etc".
|
||||
|
||||
Outside that loop, at the end of the function, hold is bitwise and'ed
|
||||
with (1<<bits)-1 to drop those excess bits so that, on function exit, we
|
||||
keep the invariant that (state->hold >> state->bits) == 0.
|
||||
*/
|
||||
unsigned bits; /* local strm->bits */
|
||||
uint64_t hold; /* local strm->hold */
|
||||
unsigned lmask; /* mask for first level of length codes */
|
||||
unsigned dmask; /* mask for first level of distance codes */
|
||||
code const *lcode; /* local strm->lencode */
|
||||
code const *dcode; /* local strm->distcode */
|
||||
const code *here; /* retrieved table entry */
|
||||
unsigned op; /* code bits, operation, extra bits, or */
|
||||
/* window position, window bytes to copy */
|
||||
unsigned len; /* match length, unused bytes */
|
||||
unsigned char *from; /* where to copy match from */
|
||||
unsigned dist; /* match distance */
|
||||
unsigned extra_safe; /* copy chunks safely in all cases */
|
||||
|
||||
/* copy state to local variables */
|
||||
state = (struct inflate_state *)strm->state;
|
||||
in = strm->next_in;
|
||||
last = in + (strm->avail_in - (INFLATE_FAST_MIN_HAVE - 1));
|
||||
out = strm->next_out;
|
||||
beg = out - (start - strm->avail_out);
|
||||
end = out + (strm->avail_out - (INFLATE_FAST_MIN_LEFT - 1));
|
||||
safe = out + strm->avail_out;
|
||||
wsize = state->wsize;
|
||||
whave = state->whave;
|
||||
wnext = state->wnext;
|
||||
window = state->window;
|
||||
hold = state->hold;
|
||||
bits = state->bits;
|
||||
lcode = state->lencode;
|
||||
dcode = state->distcode;
|
||||
lmask = (1U << state->lenbits) - 1;
|
||||
dmask = (1U << state->distbits) - 1;
|
||||
|
||||
/* Detect if out and window point to the same memory allocation. In this instance it is
|
||||
necessary to use safe chunk copy functions to prevent overwriting the window. If the
|
||||
window is overwritten then future matches with far distances will fail to copy correctly. */
|
||||
extra_safe = (wsize != 0 && out >= window && out + INFLATE_FAST_MIN_LEFT <= window + state->wbufsize);
|
||||
|
||||
#define REFILL() do { \
|
||||
hold |= load_64_bits(in, bits); \
|
||||
in += 7; \
|
||||
in -= ((bits >> 3) & 7); \
|
||||
bits |= 56; \
|
||||
} while (0)
|
||||
|
||||
/* decode literals and length/distances until end-of-block or not enough
|
||||
input data or output space */
|
||||
do {
|
||||
REFILL();
|
||||
here = lcode + (hold & lmask);
|
||||
if (here->op == 0) {
|
||||
*out++ = (unsigned char)(here->val);
|
||||
DROPBITS(here->bits);
|
||||
here = lcode + (hold & lmask);
|
||||
if (here->op == 0) {
|
||||
*out++ = (unsigned char)(here->val);
|
||||
DROPBITS(here->bits);
|
||||
here = lcode + (hold & lmask);
|
||||
}
|
||||
}
|
||||
dolen:
|
||||
DROPBITS(here->bits);
|
||||
op = here->op;
|
||||
if (op == 0) { /* literal */
|
||||
Tracevv((stderr, here->val >= 0x20 && here->val < 0x7f ?
|
||||
"inflate: literal '%c'\n" :
|
||||
"inflate: literal 0x%02x\n", here->val));
|
||||
*out++ = (unsigned char)(here->val);
|
||||
} else if (op & 16) { /* length base */
|
||||
len = here->val;
|
||||
op &= MAX_BITS; /* number of extra bits */
|
||||
len += BITS(op);
|
||||
DROPBITS(op);
|
||||
Tracevv((stderr, "inflate: length %u\n", len));
|
||||
here = dcode + (hold & dmask);
|
||||
if (bits < MAX_BITS + MAX_DIST_EXTRA_BITS) {
|
||||
REFILL();
|
||||
}
|
||||
dodist:
|
||||
DROPBITS(here->bits);
|
||||
op = here->op;
|
||||
if (op & 16) { /* distance base */
|
||||
dist = here->val;
|
||||
op &= MAX_BITS; /* number of extra bits */
|
||||
dist += BITS(op);
|
||||
#ifdef INFLATE_STRICT
|
||||
if (dist > state->dmax) {
|
||||
SET_BAD("invalid distance too far back");
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
DROPBITS(op);
|
||||
Tracevv((stderr, "inflate: distance %u\n", dist));
|
||||
op = (unsigned)(out - beg); /* max distance in output */
|
||||
if (dist > op) { /* see if copy from window */
|
||||
op = dist - op; /* distance back in window */
|
||||
if (op > whave) {
|
||||
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||
if (state->sane) {
|
||||
SET_BAD("invalid distance too far back");
|
||||
break;
|
||||
}
|
||||
if (len <= op - whave) {
|
||||
do {
|
||||
*out++ = 0;
|
||||
} while (--len);
|
||||
continue;
|
||||
}
|
||||
len -= op - whave;
|
||||
do {
|
||||
*out++ = 0;
|
||||
} while (--op > whave);
|
||||
if (op == 0) {
|
||||
from = out - dist;
|
||||
do {
|
||||
*out++ = *from++;
|
||||
} while (--len);
|
||||
continue;
|
||||
}
|
||||
#else
|
||||
SET_BAD("invalid distance too far back");
|
||||
break;
|
||||
#endif
|
||||
}
|
||||
from = window;
|
||||
if (wnext == 0) { /* very common case */
|
||||
from += wsize - op;
|
||||
} else if (wnext >= op) { /* contiguous in window */
|
||||
from += wnext - op;
|
||||
} else { /* wrap around window */
|
||||
op -= wnext;
|
||||
from += wsize - op;
|
||||
if (op < len) { /* some from end of window */
|
||||
len -= op;
|
||||
out = CHUNKCOPY_SAFE(out, from, op, safe);
|
||||
from = window; /* more from start of window */
|
||||
op = wnext;
|
||||
/* This (rare) case can create a situation where
|
||||
the first chunkcopy below must be checked.
|
||||
*/
|
||||
}
|
||||
}
|
||||
if (op < len) { /* still need some from output */
|
||||
len -= op;
|
||||
if (!extra_safe) {
|
||||
out = CHUNKCOPY_SAFE(out, from, op, safe);
|
||||
out = CHUNKUNROLL(out, &dist, &len);
|
||||
out = CHUNKCOPY_SAFE(out, out - dist, len, safe);
|
||||
} else {
|
||||
out = chunkcopy_safe(out, from, op, safe);
|
||||
out = chunkcopy_safe(out, out - dist, len, safe);
|
||||
}
|
||||
} else {
|
||||
#ifndef HAVE_MASKED_READWRITE
|
||||
if (extra_safe)
|
||||
out = chunkcopy_safe(out, from, len, safe);
|
||||
else
|
||||
#endif
|
||||
out = CHUNKCOPY_SAFE(out, from, len, safe);
|
||||
}
|
||||
#ifndef HAVE_MASKED_READWRITE
|
||||
} else if (extra_safe) {
|
||||
/* Whole reference is in range of current output. */
|
||||
out = chunkcopy_safe(out, out - dist, len, safe);
|
||||
#endif
|
||||
} else {
|
||||
/* Whole reference is in range of current output. No range checks are
|
||||
necessary because we start with room for at least 258 bytes of output,
|
||||
so unroll and roundoff operations can write beyond `out+len` so long
|
||||
as they stay within 258 bytes of `out`.
|
||||
*/
|
||||
if (dist >= len || dist >= state->chunksize)
|
||||
out = CHUNKCOPY(out, out - dist, len);
|
||||
else
|
||||
out = CHUNKMEMSET(out, out - dist, len);
|
||||
}
|
||||
} else if ((op & 64) == 0) { /* 2nd level distance code */
|
||||
here = dcode + here->val + BITS(op);
|
||||
goto dodist;
|
||||
} else {
|
||||
SET_BAD("invalid distance code");
|
||||
break;
|
||||
}
|
||||
} else if ((op & 64) == 0) { /* 2nd level length code */
|
||||
here = lcode + here->val + BITS(op);
|
||||
goto dolen;
|
||||
} else if (op & 32) { /* end-of-block */
|
||||
Tracevv((stderr, "inflate: end of block\n"));
|
||||
state->mode = TYPE;
|
||||
break;
|
||||
} else {
|
||||
SET_BAD("invalid literal/length code");
|
||||
break;
|
||||
}
|
||||
} while (in < last && out < end);
|
||||
|
||||
/* return unused bytes (on entry, bits < 8, so in won't go too far back) */
|
||||
len = bits >> 3;
|
||||
in -= len;
|
||||
bits -= len << 3;
|
||||
hold &= (UINT64_C(1) << bits) - 1;
|
||||
|
||||
/* update state and return */
|
||||
strm->next_in = in;
|
||||
strm->next_out = out;
|
||||
strm->avail_in = (unsigned)(in < last ? (INFLATE_FAST_MIN_HAVE - 1) + (last - in)
|
||||
: (INFLATE_FAST_MIN_HAVE - 1) - (in - last));
|
||||
strm->avail_out = (unsigned)(out < end ? (INFLATE_FAST_MIN_LEFT - 1) + (end - out)
|
||||
: (INFLATE_FAST_MIN_LEFT - 1) - (out - end));
|
||||
|
||||
Assert(bits <= 32, "Remaining bits greater than 32");
|
||||
state->hold = (uint32_t)hold;
|
||||
state->bits = bits;
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
inflate_fast() speedups that turned out slower (on a PowerPC G3 750CXe):
|
||||
- Using bit fields for code structure
|
||||
- Different op definition to avoid & for extra bits (do & for table bits)
|
||||
- Three separate decoding do-loops for direct, window, and wnext == 0
|
||||
- Special case for distance > 1 copies to do overlapped load and store copy
|
||||
- Explicit branch predictions (based on measured branch probabilities)
|
||||
- Deferring match copy and interspersed it with decoding subsequent codes
|
||||
- Swapping literal/length else
|
||||
- Swapping window/direct else
|
||||
- Larger unrolled copy loops (three is about right)
|
||||
- Moving len -= 3 statement into middle of loop
|
||||
*/
|
||||
@@ -1,94 +0,0 @@
|
||||
/* inffixed_tbl.h -- table for decoding fixed codes
|
||||
* Generated automatically by makefixed().
|
||||
*/
|
||||
|
||||
/* WARNING: this file should *not* be used by applications.
|
||||
* It is part of the implementation of this library and is
|
||||
* subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
static const code lenfix[512] = {
|
||||
{96,7,0},{0,8,80},{0,8,16},{20,8,115},{18,7,31},{0,8,112},{0,8,48},
|
||||
{0,9,192},{16,7,10},{0,8,96},{0,8,32},{0,9,160},{0,8,0},{0,8,128},
|
||||
{0,8,64},{0,9,224},{16,7,6},{0,8,88},{0,8,24},{0,9,144},{19,7,59},
|
||||
{0,8,120},{0,8,56},{0,9,208},{17,7,17},{0,8,104},{0,8,40},{0,9,176},
|
||||
{0,8,8},{0,8,136},{0,8,72},{0,9,240},{16,7,4},{0,8,84},{0,8,20},
|
||||
{21,8,227},{19,7,43},{0,8,116},{0,8,52},{0,9,200},{17,7,13},{0,8,100},
|
||||
{0,8,36},{0,9,168},{0,8,4},{0,8,132},{0,8,68},{0,9,232},{16,7,8},
|
||||
{0,8,92},{0,8,28},{0,9,152},{20,7,83},{0,8,124},{0,8,60},{0,9,216},
|
||||
{18,7,23},{0,8,108},{0,8,44},{0,9,184},{0,8,12},{0,8,140},{0,8,76},
|
||||
{0,9,248},{16,7,3},{0,8,82},{0,8,18},{21,8,163},{19,7,35},{0,8,114},
|
||||
{0,8,50},{0,9,196},{17,7,11},{0,8,98},{0,8,34},{0,9,164},{0,8,2},
|
||||
{0,8,130},{0,8,66},{0,9,228},{16,7,7},{0,8,90},{0,8,26},{0,9,148},
|
||||
{20,7,67},{0,8,122},{0,8,58},{0,9,212},{18,7,19},{0,8,106},{0,8,42},
|
||||
{0,9,180},{0,8,10},{0,8,138},{0,8,74},{0,9,244},{16,7,5},{0,8,86},
|
||||
{0,8,22},{64,8,0},{19,7,51},{0,8,118},{0,8,54},{0,9,204},{17,7,15},
|
||||
{0,8,102},{0,8,38},{0,9,172},{0,8,6},{0,8,134},{0,8,70},{0,9,236},
|
||||
{16,7,9},{0,8,94},{0,8,30},{0,9,156},{20,7,99},{0,8,126},{0,8,62},
|
||||
{0,9,220},{18,7,27},{0,8,110},{0,8,46},{0,9,188},{0,8,14},{0,8,142},
|
||||
{0,8,78},{0,9,252},{96,7,0},{0,8,81},{0,8,17},{21,8,131},{18,7,31},
|
||||
{0,8,113},{0,8,49},{0,9,194},{16,7,10},{0,8,97},{0,8,33},{0,9,162},
|
||||
{0,8,1},{0,8,129},{0,8,65},{0,9,226},{16,7,6},{0,8,89},{0,8,25},
|
||||
{0,9,146},{19,7,59},{0,8,121},{0,8,57},{0,9,210},{17,7,17},{0,8,105},
|
||||
{0,8,41},{0,9,178},{0,8,9},{0,8,137},{0,8,73},{0,9,242},{16,7,4},
|
||||
{0,8,85},{0,8,21},{16,8,258},{19,7,43},{0,8,117},{0,8,53},{0,9,202},
|
||||
{17,7,13},{0,8,101},{0,8,37},{0,9,170},{0,8,5},{0,8,133},{0,8,69},
|
||||
{0,9,234},{16,7,8},{0,8,93},{0,8,29},{0,9,154},{20,7,83},{0,8,125},
|
||||
{0,8,61},{0,9,218},{18,7,23},{0,8,109},{0,8,45},{0,9,186},{0,8,13},
|
||||
{0,8,141},{0,8,77},{0,9,250},{16,7,3},{0,8,83},{0,8,19},{21,8,195},
|
||||
{19,7,35},{0,8,115},{0,8,51},{0,9,198},{17,7,11},{0,8,99},{0,8,35},
|
||||
{0,9,166},{0,8,3},{0,8,131},{0,8,67},{0,9,230},{16,7,7},{0,8,91},
|
||||
{0,8,27},{0,9,150},{20,7,67},{0,8,123},{0,8,59},{0,9,214},{18,7,19},
|
||||
{0,8,107},{0,8,43},{0,9,182},{0,8,11},{0,8,139},{0,8,75},{0,9,246},
|
||||
{16,7,5},{0,8,87},{0,8,23},{64,8,0},{19,7,51},{0,8,119},{0,8,55},
|
||||
{0,9,206},{17,7,15},{0,8,103},{0,8,39},{0,9,174},{0,8,7},{0,8,135},
|
||||
{0,8,71},{0,9,238},{16,7,9},{0,8,95},{0,8,31},{0,9,158},{20,7,99},
|
||||
{0,8,127},{0,8,63},{0,9,222},{18,7,27},{0,8,111},{0,8,47},{0,9,190},
|
||||
{0,8,15},{0,8,143},{0,8,79},{0,9,254},{96,7,0},{0,8,80},{0,8,16},
|
||||
{20,8,115},{18,7,31},{0,8,112},{0,8,48},{0,9,193},{16,7,10},{0,8,96},
|
||||
{0,8,32},{0,9,161},{0,8,0},{0,8,128},{0,8,64},{0,9,225},{16,7,6},
|
||||
{0,8,88},{0,8,24},{0,9,145},{19,7,59},{0,8,120},{0,8,56},{0,9,209},
|
||||
{17,7,17},{0,8,104},{0,8,40},{0,9,177},{0,8,8},{0,8,136},{0,8,72},
|
||||
{0,9,241},{16,7,4},{0,8,84},{0,8,20},{21,8,227},{19,7,43},{0,8,116},
|
||||
{0,8,52},{0,9,201},{17,7,13},{0,8,100},{0,8,36},{0,9,169},{0,8,4},
|
||||
{0,8,132},{0,8,68},{0,9,233},{16,7,8},{0,8,92},{0,8,28},{0,9,153},
|
||||
{20,7,83},{0,8,124},{0,8,60},{0,9,217},{18,7,23},{0,8,108},{0,8,44},
|
||||
{0,9,185},{0,8,12},{0,8,140},{0,8,76},{0,9,249},{16,7,3},{0,8,82},
|
||||
{0,8,18},{21,8,163},{19,7,35},{0,8,114},{0,8,50},{0,9,197},{17,7,11},
|
||||
{0,8,98},{0,8,34},{0,9,165},{0,8,2},{0,8,130},{0,8,66},{0,9,229},
|
||||
{16,7,7},{0,8,90},{0,8,26},{0,9,149},{20,7,67},{0,8,122},{0,8,58},
|
||||
{0,9,213},{18,7,19},{0,8,106},{0,8,42},{0,9,181},{0,8,10},{0,8,138},
|
||||
{0,8,74},{0,9,245},{16,7,5},{0,8,86},{0,8,22},{64,8,0},{19,7,51},
|
||||
{0,8,118},{0,8,54},{0,9,205},{17,7,15},{0,8,102},{0,8,38},{0,9,173},
|
||||
{0,8,6},{0,8,134},{0,8,70},{0,9,237},{16,7,9},{0,8,94},{0,8,30},
|
||||
{0,9,157},{20,7,99},{0,8,126},{0,8,62},{0,9,221},{18,7,27},{0,8,110},
|
||||
{0,8,46},{0,9,189},{0,8,14},{0,8,142},{0,8,78},{0,9,253},{96,7,0},
|
||||
{0,8,81},{0,8,17},{21,8,131},{18,7,31},{0,8,113},{0,8,49},{0,9,195},
|
||||
{16,7,10},{0,8,97},{0,8,33},{0,9,163},{0,8,1},{0,8,129},{0,8,65},
|
||||
{0,9,227},{16,7,6},{0,8,89},{0,8,25},{0,9,147},{19,7,59},{0,8,121},
|
||||
{0,8,57},{0,9,211},{17,7,17},{0,8,105},{0,8,41},{0,9,179},{0,8,9},
|
||||
{0,8,137},{0,8,73},{0,9,243},{16,7,4},{0,8,85},{0,8,21},{16,8,258},
|
||||
{19,7,43},{0,8,117},{0,8,53},{0,9,203},{17,7,13},{0,8,101},{0,8,37},
|
||||
{0,9,171},{0,8,5},{0,8,133},{0,8,69},{0,9,235},{16,7,8},{0,8,93},
|
||||
{0,8,29},{0,9,155},{20,7,83},{0,8,125},{0,8,61},{0,9,219},{18,7,23},
|
||||
{0,8,109},{0,8,45},{0,9,187},{0,8,13},{0,8,141},{0,8,77},{0,9,251},
|
||||
{16,7,3},{0,8,83},{0,8,19},{21,8,195},{19,7,35},{0,8,115},{0,8,51},
|
||||
{0,9,199},{17,7,11},{0,8,99},{0,8,35},{0,9,167},{0,8,3},{0,8,131},
|
||||
{0,8,67},{0,9,231},{16,7,7},{0,8,91},{0,8,27},{0,9,151},{20,7,67},
|
||||
{0,8,123},{0,8,59},{0,9,215},{18,7,19},{0,8,107},{0,8,43},{0,9,183},
|
||||
{0,8,11},{0,8,139},{0,8,75},{0,9,247},{16,7,5},{0,8,87},{0,8,23},
|
||||
{64,8,0},{19,7,51},{0,8,119},{0,8,55},{0,9,207},{17,7,15},{0,8,103},
|
||||
{0,8,39},{0,9,175},{0,8,7},{0,8,135},{0,8,71},{0,9,239},{16,7,9},
|
||||
{0,8,95},{0,8,31},{0,9,159},{20,7,99},{0,8,127},{0,8,63},{0,9,223},
|
||||
{18,7,27},{0,8,111},{0,8,47},{0,9,191},{0,8,15},{0,8,143},{0,8,79},
|
||||
{0,9,255}
|
||||
};
|
||||
|
||||
static const code distfix[32] = {
|
||||
{16,5,1},{23,5,257},{19,5,17},{27,5,4097},{17,5,5},{25,5,1025},
|
||||
{21,5,65},{29,5,16385},{16,5,3},{24,5,513},{20,5,33},{28,5,8193},
|
||||
{18,5,9},{26,5,2049},{22,5,129},{64,5,0},{16,5,2},{23,5,385},
|
||||
{19,5,25},{27,5,6145},{17,5,7},{25,5,1537},{21,5,97},{29,5,24577},
|
||||
{16,5,4},{24,5,769},{20,5,49},{28,5,12289},{18,5,13},{26,5,3073},
|
||||
{22,5,193},{64,5,0}
|
||||
};
|
||||
+693
-629
File diff suppressed because it is too large.
Load diff
+27
-73
@@ -8,19 +8,10 @@
|
||||
subject to change. Applications should only use zlib.h.
|
||||
*/
|
||||
|
||||
#ifndef INFLATE_H_
|
||||
#define INFLATE_H_
|
||||
|
||||
#include "crc32.h"
|
||||
|
||||
#ifdef S390_DFLTCC_INFLATE
|
||||
# include "arch/s390/dfltcc_common.h"
|
||||
# define HAVE_ARCH_INFLATE_STATE
|
||||
#endif
|
||||
|
||||
/* define NO_GZIP when compiling if you want to disable gzip header and trailer decoding by inflate().
|
||||
NO_GZIP would be used to avoid linking in the crc code when it is not needed.
|
||||
For shared libraries, gzip decoding should be left enabled. */
|
||||
/* define NO_GZIP when compiling if you want to disable gzip header and
|
||||
trailer decoding by inflate(). NO_GZIP would be used to avoid linking in
|
||||
the crc code when it is not needed. For shared libraries, gzip decoding
|
||||
should be left enabled. */
|
||||
#ifndef NO_GZIP
|
||||
# define GUNZIP
|
||||
#endif
|
||||
@@ -57,13 +48,14 @@ typedef enum {
|
||||
LENGTH, /* i: waiting for 32-bit length (gzip) */
|
||||
DONE, /* finished check, done -- remain here until reset */
|
||||
BAD, /* got a data error -- remain here until reset */
|
||||
MEM, /* got an inflate() memory error -- remain here until reset */
|
||||
SYNC /* looking for synchronization bytes to restart inflate() */
|
||||
} inflate_mode;
|
||||
|
||||
/*
|
||||
State transitions between above modes -
|
||||
|
||||
(most modes can go to BAD on error -- not shown for clarity)
|
||||
(most modes can go to BAD or MEM on error -- not shown for clarity)
|
||||
|
||||
Process header:
|
||||
HEAD -> (gzip) or (zlib) or (raw)
|
||||
@@ -84,20 +76,11 @@ typedef enum {
|
||||
Process trailer:
|
||||
CHECK -> LENGTH -> DONE
|
||||
*/
|
||||
typedef struct inflate_state inflate_state;
|
||||
|
||||
/* Struct for memory allocation handling */
|
||||
typedef struct inflate_allocs_s {
|
||||
char *buf_start;
|
||||
free_func zfree;
|
||||
inflate_state *state;
|
||||
unsigned char *window;
|
||||
} inflate_allocs;
|
||||
|
||||
/* State maintained between inflate() calls -- approximately 7K bytes, not
|
||||
including the allocated sliding window, which is up to 32K bytes. */
|
||||
struct ALIGNED_(64) inflate_state {
|
||||
PREFIX3(stream) *strm; /* pointer back to this zlib stream */
|
||||
struct inflate_state {
|
||||
z_streamp strm; /* pointer back to this zlib stream */
|
||||
inflate_mode mode; /* current inflate mode */
|
||||
int last; /* true if processing last block */
|
||||
int wrap; /* bit 0 true for zlib, bit 1 true for gzip,
|
||||
@@ -105,68 +88,39 @@ struct ALIGNED_(64) inflate_state {
|
||||
int havedict; /* true if dictionary provided */
|
||||
int flags; /* gzip header method and flags, 0 if zlib, or
|
||||
-1 if raw or no header yet */
|
||||
unsigned was; /* initial length of match, for inflateMark */
|
||||
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
|
||||
unsigned long check; /* protected copy of check value */
|
||||
unsigned long total; /* protected copy of output count */
|
||||
PREFIX(gz_headerp) head; /* where to save gzip header information */
|
||||
int back; /* bits back of last unprocessed length/lit */
|
||||
|
||||
gz_headerp head; /* where to save gzip header information */
|
||||
/* sliding window */
|
||||
unsigned wbits; /* log base 2 of requested window size */
|
||||
uint32_t wsize; /* window size or zero if not using window */
|
||||
uint32_t wbufsize; /* real size of the allocated window buffer, including padding */
|
||||
uint32_t whave; /* valid bytes in the window */
|
||||
uint32_t wnext; /* window write index */
|
||||
unsigned char *window; /* allocated sliding window, if needed */
|
||||
uint32_t chunksize; /* size of memory copying chunk */
|
||||
|
||||
unsigned wsize; /* window size or zero if not using window */
|
||||
unsigned whave; /* valid bytes in the window */
|
||||
unsigned wnext; /* window write index */
|
||||
unsigned char FAR *window; /* allocated sliding window, if needed */
|
||||
/* bit accumulator */
|
||||
uint64_t hold; /* input bit accumulator */
|
||||
unsigned long hold; /* input bit accumulator */
|
||||
unsigned bits; /* number of bits in "in" */
|
||||
/* fixed and dynamic code tables */
|
||||
unsigned lenbits; /* index bits for lencode */
|
||||
code const *lencode; /* starting table for length/literal codes */
|
||||
code const *distcode; /* starting table for distance codes */
|
||||
unsigned distbits; /* index bits for distcode */
|
||||
/* for string and stored block copying */
|
||||
uint32_t length; /* literal or length of data to copy */
|
||||
unsigned length; /* literal or length of data to copy */
|
||||
unsigned offset; /* distance back to copy string from */
|
||||
/* for table and code decoding */
|
||||
unsigned extra; /* extra bits needed */
|
||||
/* fixed and dynamic code tables */
|
||||
code const FAR *lencode; /* starting table for length/literal codes */
|
||||
code const FAR *distcode; /* starting table for distance codes */
|
||||
unsigned lenbits; /* index bits for lencode */
|
||||
unsigned distbits; /* index bits for distcode */
|
||||
/* dynamic table building */
|
||||
unsigned ncode; /* number of code length code lengths */
|
||||
unsigned nlen; /* number of length code lengths */
|
||||
unsigned ndist; /* number of distance code lengths */
|
||||
uint32_t have; /* number of code lengths in lens[] */
|
||||
code *next; /* next available space in codes[] */
|
||||
|
||||
#if defined(_M_IX86) || defined(_M_ARM)
|
||||
uint32_t padding[1];
|
||||
#endif
|
||||
struct crc32_fold_s ALIGNED_(16) crc_fold;
|
||||
|
||||
uint16_t lens[320]; /* temporary storage for code lengths */
|
||||
uint16_t work[288]; /* work area for code table building */
|
||||
unsigned have; /* number of code lengths in lens[] */
|
||||
code FAR *next; /* next available space in codes[] */
|
||||
unsigned short lens[320]; /* temporary storage for code lengths */
|
||||
unsigned short work[288]; /* work area for code table building */
|
||||
code codes[ENOUGH]; /* space for code tables */
|
||||
|
||||
inflate_allocs *alloc_bufs; /* struct for handling memory allocations */
|
||||
|
||||
#ifdef INFLATE_STRICT
|
||||
unsigned dmax; /* zlib header max distance (INFLATE_STRICT) */
|
||||
#endif
|
||||
#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
||||
int sane; /* if false, allow invalid distance too far */
|
||||
#endif
|
||||
#ifdef HAVE_ARCH_INFLATE_STATE
|
||||
arch_inflate_state arch; /* architecture-specific extensions */
|
||||
#endif
|
||||
#if defined(_M_IX86) || defined(_M_ARM)
|
||||
int padding2[8];
|
||||
#endif
|
||||
int back; /* bits back of last unprocessed length/lit */
|
||||
unsigned was; /* initial length of match */
|
||||
};
|
||||
|
||||
void Z_INTERNAL PREFIX(fixedtables)(struct inflate_state *state);
|
||||
Z_INTERNAL inflate_allocs* alloc_inflate(PREFIX3(stream) *strm);
|
||||
Z_INTERNAL void free_inflate(PREFIX3(stream) *strm);
|
||||
|
||||
#endif /* INFLATE_H_ */
|
||||
@@ -1,215 +0,0 @@
|
||||
/* inflate_p.h -- Private inline functions and macros shared with more than one deflate method
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef INFLATE_P_H
|
||||
#define INFLATE_P_H
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "zmemory.h"
|
||||
|
||||
/* Architecture-specific hooks. */
|
||||
#ifdef S390_DFLTCC_INFLATE
|
||||
# include "arch/s390/dfltcc_inflate.h"
|
||||
/* DFLTCC instructions require window to be page-aligned */
|
||||
# define PAD_WINDOW PAD_4096
|
||||
# define WINDOW_PAD_SIZE 4096
|
||||
# define HINT_ALIGNED_WINDOW HINT_ALIGNED_4096
|
||||
#else
|
||||
# define PAD_WINDOW PAD_64
|
||||
# define WINDOW_PAD_SIZE 64
|
||||
# define HINT_ALIGNED_WINDOW HINT_ALIGNED_64
|
||||
/* Adjust the window size for the arch-specific inflate code. */
|
||||
# define INFLATE_ADJUST_WINDOW_SIZE(n) (n)
|
||||
/* Invoked at the end of inflateResetKeep(). Useful for initializing arch-specific extension blocks. */
|
||||
# define INFLATE_RESET_KEEP_HOOK(strm) do {} while (0)
|
||||
/* Invoked at the beginning of inflatePrime(). Useful for updating arch-specific buffers. */
|
||||
# define INFLATE_PRIME_HOOK(strm, bits, value) do {} while (0)
|
||||
/* Invoked at the beginning of each block. Useful for plugging arch-specific inflation code. */
|
||||
# define INFLATE_TYPEDO_HOOK(strm, flush) do {} while (0)
|
||||
/* Returns whether zlib-ng should compute a checksum. Set to 0 if arch-specific inflation code already does that. */
|
||||
# define INFLATE_NEED_CHECKSUM(strm) 1
|
||||
/* Returns whether zlib-ng should update a window. Set to 0 if arch-specific inflation code already does that. */
|
||||
# define INFLATE_NEED_UPDATEWINDOW(strm) 1
|
||||
/* Invoked at the beginning of inflateMark(). Useful for updating arch-specific pointers and offsets. */
|
||||
# define INFLATE_MARK_HOOK(strm) do {} while (0)
|
||||
/* Invoked at the beginning of inflateSyncPoint(). Useful for performing arch-specific state checks. */
|
||||
# define INFLATE_SYNC_POINT_HOOK(strm) do {} while (0)
|
||||
/* Invoked at the beginning of inflateSetDictionary(). Useful for checking arch-specific window data. */
|
||||
# define INFLATE_SET_DICTIONARY_HOOK(strm, dict, dict_len) do {} while (0)
|
||||
/* Invoked at the beginning of inflateGetDictionary(). Useful for adjusting arch-specific window data. */
|
||||
# define INFLATE_GET_DICTIONARY_HOOK(strm, dict, dict_len) do {} while (0)
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macros shared by inflate() and inflateBack()
|
||||
*/
|
||||
|
||||
/* check function to use adler32() for zlib or crc32() for gzip */
|
||||
#ifdef GUNZIP
|
||||
# define UPDATE(check, buf, len) \
|
||||
(state->flags ? PREFIX(crc32)(check, buf, len) : FUNCTABLE_CALL(adler32)(check, buf, len))
|
||||
#else
|
||||
# define UPDATE(check, buf, len) FUNCTABLE_CALL(adler32)(check, buf, len)
|
||||
#endif
|
||||
|
||||
/* check macros for header crc */
|
||||
#ifdef GUNZIP
|
||||
# define CRC2(check, word) \
|
||||
do { \
|
||||
hbuf[0] = (unsigned char)(word); \
|
||||
hbuf[1] = (unsigned char)((word) >> 8); \
|
||||
check = PREFIX(crc32)(check, hbuf, 2); \
|
||||
} while (0)
|
||||
|
||||
# define CRC4(check, word) \
|
||||
do { \
|
||||
hbuf[0] = (unsigned char)(word); \
|
||||
hbuf[1] = (unsigned char)((word) >> 8); \
|
||||
hbuf[2] = (unsigned char)((word) >> 16); \
|
||||
hbuf[3] = (unsigned char)((word) >> 24); \
|
||||
check = PREFIX(crc32)(check, hbuf, 4); \
|
||||
} while (0)
|
||||
#endif
|
||||
|
||||
/* Load registers with state in inflate() for speed */
|
||||
#define LOAD() \
|
||||
do { \
|
||||
put = strm->next_out; \
|
||||
left = strm->avail_out; \
|
||||
next = strm->next_in; \
|
||||
have = strm->avail_in; \
|
||||
hold = state->hold; \
|
||||
bits = state->bits; \
|
||||
} while (0)
|
||||
|
||||
/* Restore state from registers in inflate() */
|
||||
#define RESTORE() \
|
||||
do { \
|
||||
strm->next_out = put; \
|
||||
strm->avail_out = left; \
|
||||
strm->next_in = (z_const unsigned char *)next; \
|
||||
strm->avail_in = have; \
|
||||
state->hold = hold; \
|
||||
state->bits = bits; \
|
||||
} while (0)
|
||||
|
||||
/* Clear the input bit accumulator */
|
||||
#define INITBITS() \
|
||||
do { \
|
||||
hold = 0; \
|
||||
bits = 0; \
|
||||
} while (0)
|
||||
|
||||
/* Ensure that there is at least n bits in the bit accumulator. If there is
|
||||
not enough available input to do that, then return from inflate()/inflateBack(). */
|
||||
#define NEEDBITS(n) \
|
||||
do { \
|
||||
while (bits < (unsigned)(n)) \
|
||||
PULLBYTE(); \
|
||||
} while (0)
|
||||
|
||||
/* Return the low n bits of the bit accumulator (n < 16) */
|
||||
#define BITS(n) \
|
||||
(hold & ((1U << (unsigned)(n)) - 1))
|
||||
|
||||
/* Remove n bits from the bit accumulator */
|
||||
#define DROPBITS(n) \
|
||||
do { \
|
||||
hold >>= (n); \
|
||||
bits -= (unsigned)(n); \
|
||||
} while (0)
|
||||
|
||||
/* Remove zero to seven bits as needed to go to a byte boundary */
|
||||
#define BYTEBITS() \
|
||||
do { \
|
||||
hold >>= bits & 7; \
|
||||
bits -= bits & 7; \
|
||||
} while (0)
|
||||
|
||||
/* Set mode=BAD and prepare error message */
|
||||
#define SET_BAD(errmsg) \
|
||||
do { \
|
||||
state->mode = BAD; \
|
||||
strm->msg = (char *)errmsg; \
|
||||
} while (0)
|
||||
|
||||
#define INFLATE_FAST_MIN_HAVE 15
|
||||
#define INFLATE_FAST_MIN_LEFT 260
|
||||
|
||||
/* Load 64 bits from IN and place the bytes at offset BITS in the result. */
|
||||
static inline uint64_t load_64_bits(const unsigned char *in, unsigned bits) {
|
||||
uint64_t chunk = zng_memread_8(in);
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
return chunk << bits;
|
||||
#else
|
||||
return ZSWAP64(chunk) << bits;
|
||||
#endif
|
||||
}
|
||||
|
||||
/* Behave like chunkcopy, but avoid writing beyond of legal output. */
|
||||
static inline uint8_t* chunkcopy_safe(uint8_t *out, uint8_t *from, uint64_t len, uint8_t *safe) {
|
||||
uint64_t safelen = safe - out;
|
||||
len = MIN(len, safelen);
|
||||
int32_t olap_src = from >= out && from < out + len;
|
||||
int32_t olap_dst = out >= from && out < from + len;
|
||||
uint64_t tocopy;
|
||||
|
||||
/* For all cases without overlap, memcpy is ideal */
|
||||
if (!(olap_src || olap_dst)) {
|
||||
memcpy(out, from, (size_t)len);
|
||||
return out + len;
|
||||
}
|
||||
|
||||
/* Complete overlap: Source == destination */
|
||||
if (out == from) {
|
||||
return out + len;
|
||||
}
|
||||
|
||||
/* We are emulating a self-modifying copy loop here. To do this in a way that doesn't produce undefined behavior,
|
||||
* we have to get a bit clever. First if the overlap is such that src falls between dst and dst+len, we can do the
|
||||
* initial bulk memcpy of the nonoverlapping region. Then, we can leverage the size of this to determine the safest
|
||||
* atomic memcpy size we can pick such that we have non-overlapping regions. This effectively becomes a safe look
|
||||
* behind or lookahead distance. */
|
||||
uint64_t non_olap_size = llabs(from - out); // llabs vs labs for compatibility with windows
|
||||
|
||||
/* So this doesn't give use a worst case scenario of function calls in a loop,
|
||||
* we want to instead break this down into copy blocks of fixed lengths
|
||||
*
|
||||
* TODO: The memcpy calls aren't inlined on architectures with strict memory alignment
|
||||
*/
|
||||
while (len) {
|
||||
tocopy = MIN(non_olap_size, len);
|
||||
len -= tocopy;
|
||||
|
||||
while (tocopy >= 16) {
|
||||
memcpy(out, from, 16);
|
||||
out += 16;
|
||||
from += 16;
|
||||
tocopy -= 16;
|
||||
}
|
||||
|
||||
if (tocopy >= 8) {
|
||||
memcpy(out, from, 8);
|
||||
out += 8;
|
||||
from += 8;
|
||||
tocopy -= 8;
|
||||
}
|
||||
|
||||
if (tocopy >= 4) {
|
||||
memcpy(out, from, 4);
|
||||
out += 4;
|
||||
from += 4;
|
||||
tocopy -= 4;
|
||||
}
|
||||
|
||||
while (tocopy--) {
|
||||
*out++ = *from++;
|
||||
}
|
||||
}
|
||||
|
||||
return out;
|
||||
}
|
||||
|
||||
#endif
|
||||
+41
-37
@@ -3,11 +3,13 @@
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "zutil.h"
|
||||
#include "inftrees.h"
|
||||
|
||||
const char PREFIX(inflate_copyright)[] = " inflate 1.3.1 Copyright 1995-2024 Mark Adler ";
|
||||
#define MAXBITS 15
|
||||
|
||||
const char inflate_copyright[] =
|
||||
" inflate 1.3.1 Copyright 1995-2024 Mark Adler ";
|
||||
/*
|
||||
If you use the zlib library in a product, an acknowledgment is welcome
|
||||
in the documentation of your product. If for some reason you cannot
|
||||
@@ -27,8 +29,9 @@ const char PREFIX(inflate_copyright)[] = " inflate 1.3.1 Copyright 1995-2024 Mar
|
||||
table index bits. It will differ if the request is greater than the
|
||||
longest code or if it is less than the shortest code.
|
||||
*/
|
||||
int Z_INTERNAL zng_inflate_table(codetype type, uint16_t *lens, unsigned codes,
|
||||
code * *table, unsigned *bits, uint16_t *work) {
|
||||
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
||||
unsigned codes, code FAR * FAR *table,
|
||||
unsigned FAR *bits, unsigned short FAR *work) {
|
||||
unsigned len; /* a code's length in bits */
|
||||
unsigned sym; /* index of code symbols */
|
||||
unsigned min, max; /* minimum and maximum code lengths */
|
||||
@@ -43,23 +46,23 @@ int Z_INTERNAL zng_inflate_table(codetype type, uint16_t *lens, unsigned codes,
|
||||
unsigned low; /* low bits for current root entry */
|
||||
unsigned mask; /* mask for low root bits */
|
||||
code here; /* table entry for duplication */
|
||||
code *next; /* next available space in table */
|
||||
const uint16_t *base; /* base value table to use */
|
||||
const uint16_t *extra; /* extra bits table to use */
|
||||
code FAR *next; /* next available space in table */
|
||||
const unsigned short FAR *base; /* base value table to use */
|
||||
const unsigned short FAR *extra; /* extra bits table to use */
|
||||
unsigned match; /* use base and extra for symbol >= match */
|
||||
uint16_t count[MAX_BITS+1]; /* number of codes of each length */
|
||||
uint16_t offs[MAX_BITS+1]; /* offsets in table for each length */
|
||||
static const uint16_t lbase[31] = { /* Length codes 257..285 base */
|
||||
unsigned short count[MAXBITS+1]; /* number of codes of each length */
|
||||
unsigned short offs[MAXBITS+1]; /* offsets in table for each length */
|
||||
static const unsigned short lbase[31] = { /* Length codes 257..285 base */
|
||||
3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
|
||||
35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0};
|
||||
static const uint16_t lext[31] = { /* Length codes 257..285 extra */
|
||||
static const unsigned short lext[31] = { /* Length codes 257..285 extra */
|
||||
16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
||||
19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 203, 77};
|
||||
static const uint16_t dbase[32] = { /* Distance codes 0..29 base */
|
||||
static const unsigned short dbase[32] = { /* Distance codes 0..29 base */
|
||||
1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
||||
257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
||||
8193, 12289, 16385, 24577, 0, 0};
|
||||
static const uint16_t dext[32] = { /* Distance codes 0..29 extra */
|
||||
static const unsigned short dext[32] = { /* Distance codes 0..29 extra */
|
||||
16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
|
||||
23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
|
||||
28, 28, 29, 29, 64, 64};
|
||||
@@ -96,20 +99,20 @@ int Z_INTERNAL zng_inflate_table(codetype type, uint16_t *lens, unsigned codes,
|
||||
*/
|
||||
|
||||
/* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
|
||||
for (len = 0; len <= MAX_BITS; len++)
|
||||
for (len = 0; len <= MAXBITS; len++)
|
||||
count[len] = 0;
|
||||
for (sym = 0; sym < codes; sym++)
|
||||
count[lens[sym]]++;
|
||||
|
||||
/* bound code lengths, force root to be within code lengths */
|
||||
root = *bits;
|
||||
for (max = MAX_BITS; max >= 1; max--)
|
||||
for (max = MAXBITS; max >= 1; max--)
|
||||
if (count[max] != 0) break;
|
||||
root = MIN(root, max);
|
||||
if (UNLIKELY(max == 0)) { /* no symbols to code at all */
|
||||
if (root > max) root = max;
|
||||
if (max == 0) { /* no symbols to code at all */
|
||||
here.op = (unsigned char)64; /* invalid code marker */
|
||||
here.bits = (unsigned char)1;
|
||||
here.val = (uint16_t)0;
|
||||
here.val = (unsigned short)0;
|
||||
*(*table)++ = here; /* make a table to force an error */
|
||||
*(*table)++ = here;
|
||||
*bits = 1;
|
||||
@@ -117,11 +120,11 @@ int Z_INTERNAL zng_inflate_table(codetype type, uint16_t *lens, unsigned codes,
|
||||
}
|
||||
for (min = 1; min < max; min++)
|
||||
if (count[min] != 0) break;
|
||||
root = MAX(root, min);
|
||||
if (root < min) root = min;
|
||||
|
||||
/* check for an over-subscribed or incomplete set of lengths */
|
||||
left = 1;
|
||||
for (len = 1; len <= MAX_BITS; len++) {
|
||||
for (len = 1; len <= MAXBITS; len++) {
|
||||
left <<= 1;
|
||||
left -= count[len];
|
||||
if (left < 0) return -1; /* over-subscribed */
|
||||
@@ -131,12 +134,12 @@ int Z_INTERNAL zng_inflate_table(codetype type, uint16_t *lens, unsigned codes,
|
||||
|
||||
/* generate offsets into symbol table for each length for sorting */
|
||||
offs[1] = 0;
|
||||
for (len = 1; len < MAX_BITS; len++)
|
||||
for (len = 1; len < MAXBITS; len++)
|
||||
offs[len + 1] = offs[len] + count[len];
|
||||
|
||||
/* sort symbols by length, by symbol order within each length */
|
||||
for (sym = 0; sym < codes; sym++)
|
||||
if (lens[sym] != 0) work[offs[lens[sym]]++] = (uint16_t)sym;
|
||||
if (lens[sym] != 0) work[offs[lens[sym]]++] = (unsigned short)sym;
|
||||
|
||||
/*
|
||||
Create and fill in decoding tables. In this loop, the table being
|
||||
@@ -206,13 +209,15 @@ int Z_INTERNAL zng_inflate_table(codetype type, uint16_t *lens, unsigned codes,
|
||||
for (;;) {
|
||||
/* create table entry */
|
||||
here.bits = (unsigned char)(len - drop);
|
||||
if (LIKELY(work[sym] >= match)) {
|
||||
here.op = (unsigned char)(extra[work[sym] - match]);
|
||||
here.val = base[work[sym] - match];
|
||||
} else if (work[sym] + 1U < match) {
|
||||
if (work[sym] + 1U < match) {
|
||||
here.op = (unsigned char)0;
|
||||
here.val = work[sym];
|
||||
} else {
|
||||
}
|
||||
else if (work[sym] >= match) {
|
||||
here.op = (unsigned char)(extra[work[sym] - match]);
|
||||
here.val = base[work[sym] - match];
|
||||
}
|
||||
else {
|
||||
here.op = (unsigned char)(32 + 64); /* end of block */
|
||||
here.val = 0;
|
||||
}
|
||||
@@ -233,15 +238,14 @@ int Z_INTERNAL zng_inflate_table(codetype type, uint16_t *lens, unsigned codes,
|
||||
if (incr != 0) {
|
||||
huff &= incr - 1;
|
||||
huff += incr;
|
||||
} else {
|
||||
huff = 0;
|
||||
}
|
||||
else
|
||||
huff = 0;
|
||||
|
||||
/* go to next symbol, update count, len */
|
||||
sym++;
|
||||
if (--(count[len]) == 0) {
|
||||
if (len == max)
|
||||
break;
|
||||
if (len == max) break;
|
||||
len = lens[work[sym]];
|
||||
}
|
||||
|
||||
@@ -259,32 +263,32 @@ int Z_INTERNAL zng_inflate_table(codetype type, uint16_t *lens, unsigned codes,
|
||||
left = (int)(1 << curr);
|
||||
while (curr + drop < max) {
|
||||
left -= count[curr + drop];
|
||||
if (left <= 0)
|
||||
break;
|
||||
if (left <= 0) break;
|
||||
curr++;
|
||||
left <<= 1;
|
||||
}
|
||||
|
||||
/* check for enough space */
|
||||
used += 1U << curr;
|
||||
if ((type == LENS && used > ENOUGH_LENS) || (type == DISTS && used > ENOUGH_DISTS))
|
||||
if ((type == LENS && used > ENOUGH_LENS) ||
|
||||
(type == DISTS && used > ENOUGH_DISTS))
|
||||
return 1;
|
||||
|
||||
/* point entry in root table to sub-table */
|
||||
low = huff & mask;
|
||||
(*table)[low].op = (unsigned char)curr;
|
||||
(*table)[low].bits = (unsigned char)root;
|
||||
(*table)[low].val = (uint16_t)(next - *table);
|
||||
(*table)[low].val = (unsigned short)(next - *table);
|
||||
}
|
||||
}
|
||||
|
||||
/* fill in remaining table entry if code is incomplete (guaranteed to have
|
||||
at most one remaining entry, since if the code is incomplete, the
|
||||
maximum code length that was allowed to get this far is one bit) */
|
||||
if (UNLIKELY(huff != 0)) {
|
||||
if (huff != 0) {
|
||||
here.op = (unsigned char)64; /* invalid code marker */
|
||||
here.bits = (unsigned char)(len - drop);
|
||||
here.val = (uint16_t)0;
|
||||
here.val = (unsigned short)0;
|
||||
next[huff] = here;
|
||||
}
|
||||
|
||||
|
||||
+13
-17
@@ -1,8 +1,5 @@
|
||||
#ifndef INFTREES_H_
|
||||
#define INFTREES_H_
|
||||
|
||||
/* inftrees.h -- header to use inftrees.c
|
||||
* Copyright (C) 1995-2022 Mark Adler
|
||||
* Copyright (C) 1995-2005, 2010 Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*/
|
||||
|
||||
@@ -25,9 +22,9 @@
|
||||
of a literal, the base length or distance, or the offset from
|
||||
the current table to the next table. Each entry is four bytes. */
|
||||
typedef struct {
|
||||
unsigned char op; /* operation, extra bits, table bits */
|
||||
unsigned char bits; /* bits in this part of the code */
|
||||
uint16_t val; /* offset in table or code value */
|
||||
unsigned char op; /* operation, extra bits, table bits */
|
||||
unsigned char bits; /* bits in this part of the code */
|
||||
unsigned short val; /* offset in table or code value */
|
||||
} code;
|
||||
|
||||
/* op values as set by inflate_table():
|
||||
@@ -39,17 +36,17 @@ typedef struct {
|
||||
*/
|
||||
|
||||
/* Maximum size of the dynamic table. The maximum number of code structures is
|
||||
1924, which is the sum of 1332 for literal/length codes and 592 for distance
|
||||
1444, which is the sum of 852 for literal/length codes and 592 for distance
|
||||
codes. These values were found by exhaustive searches using the program
|
||||
examples/enough.c found in the zlib distributions. The arguments to that
|
||||
examples/enough.c found in the zlib distribution. The arguments to that
|
||||
program are the number of symbols, the initial root table size, and the
|
||||
maximum bit length of a code. "enough 286 10 15" for literal/length codes
|
||||
returns 1332, and "enough 30 9 15" for distance codes returns 592.
|
||||
The initial root table size (10 or 9) is found in the fifth argument of the
|
||||
maximum bit length of a code. "enough 286 9 15" for literal/length codes
|
||||
returns 852, and "enough 30 6 15" for distance codes returns 592. The
|
||||
initial root table size (9 or 6) is found in the fifth argument of the
|
||||
inflate_table() calls in inflate.c and infback.c. If the root table size is
|
||||
changed, then these maximum sizes would be need to be recalculated and
|
||||
updated. */
|
||||
#define ENOUGH_LENS 1332
|
||||
#define ENOUGH_LENS 852
|
||||
#define ENOUGH_DISTS 592
|
||||
#define ENOUGH (ENOUGH_LENS+ENOUGH_DISTS)
|
||||
|
||||
@@ -60,7 +57,6 @@ typedef enum {
|
||||
DISTS
|
||||
} codetype;
|
||||
|
||||
int Z_INTERNAL zng_inflate_table (codetype type, uint16_t *lens, unsigned codes,
|
||||
code * *table, unsigned *bits, uint16_t *work);
|
||||
|
||||
#endif /* INFTREES_H_ */
|
||||
int ZLIB_INTERNAL inflate_table(codetype type, unsigned short FAR *lens,
|
||||
unsigned codes, code FAR * FAR *table,
|
||||
unsigned FAR *bits, unsigned short FAR *work);
|
||||
@@ -1,21 +0,0 @@
|
||||
/* insert_string.c -- insert_string integer hash variant
|
||||
*
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "deflate.h"
|
||||
|
||||
#define HASH_SLIDE 16
|
||||
|
||||
#define HASH_CALC(h, val) h = ((val * 2654435761U) >> HASH_SLIDE);
|
||||
#define HASH_CALC_VAR h
|
||||
#define HASH_CALC_VAR_INIT uint32_t h = 0
|
||||
|
||||
#define UPDATE_HASH update_hash
|
||||
#define INSERT_STRING insert_string
|
||||
#define QUICK_INSERT_STRING quick_insert_string
|
||||
|
||||
#include "insert_string_tpl.h"
|
||||
@@ -1,24 +0,0 @@
|
||||
/* insert_string_roll.c -- insert_string rolling hash variant
|
||||
*
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*
|
||||
*/
|
||||
|
||||
#include "zbuild.h"
|
||||
#include "deflate.h"
|
||||
|
||||
#define HASH_SLIDE 5
|
||||
|
||||
#define HASH_CALC(h, val) h = ((h << HASH_SLIDE) ^ ((uint8_t)val))
|
||||
#define HASH_CALC_VAR s->ins_h
|
||||
#define HASH_CALC_VAR_INIT
|
||||
#define HASH_CALC_READ val = strstart[0]
|
||||
#define HASH_CALC_MASK (32768u - 1u)
|
||||
#define HASH_CALC_OFFSET (STD_MIN_MATCH-1)
|
||||
|
||||
#define UPDATE_HASH update_hash_roll
|
||||
#define INSERT_STRING insert_string_roll
|
||||
#define QUICK_INSERT_STRING quick_insert_string_roll
|
||||
|
||||
#include "insert_string_tpl.h"
|
||||
@@ -1,106 +0,0 @@
|
||||
#ifndef INSERT_STRING_H_
|
||||
#define INSERT_STRING_H_
|
||||
|
||||
/* insert_string_tpl.h -- Private insert_string functions shared with more than
|
||||
* one insert string implementation
|
||||
*
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||
*
|
||||
* Copyright (C) 2013 Intel Corporation. All rights reserved.
|
||||
* Authors:
|
||||
* Wajdi Feghali <wajdi.k.feghali@intel.com>
|
||||
* Jim Guilford <james.guilford@intel.com>
|
||||
* Vinodh Gopal <vinodh.gopal@intel.com>
|
||||
* Erdinc Ozturk <erdinc.ozturk@intel.com>
|
||||
* Jim Kukunas <james.t.kukunas@linux.intel.com>
|
||||
*
|
||||
* Portions are Copyright (C) 2016 12Sided Technology, LLC.
|
||||
* Author:
|
||||
* Phil Vachon <pvachon@12sidedtech.com>
|
||||
*
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*
|
||||
*/
|
||||
|
||||
#include "zmemory.h"
|
||||
|
||||
#ifndef HASH_CALC_OFFSET
|
||||
# define HASH_CALC_OFFSET 0
|
||||
#endif
|
||||
#ifndef HASH_CALC_MASK
|
||||
# define HASH_CALC_MASK HASH_MASK
|
||||
#endif
|
||||
#ifndef HASH_CALC_READ
|
||||
# if BYTE_ORDER == LITTLE_ENDIAN
|
||||
# define HASH_CALC_READ \
|
||||
val = zng_memread_4(strstart);
|
||||
# else
|
||||
# define HASH_CALC_READ \
|
||||
val = ZSWAP32(zng_memread_4(strstart));
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* ===========================================================================
|
||||
* Update a hash value with the given input byte
|
||||
* IN assertion: all calls to UPDATE_HASH are made with consecutive
|
||||
* input characters, so that a running hash key can be computed from the
|
||||
* previous key instead of complete recalculation each time.
|
||||
*/
|
||||
Z_INTERNAL uint32_t UPDATE_HASH(uint32_t h, uint32_t val) {
|
||||
HASH_CALC(h, val);
|
||||
return h & HASH_CALC_MASK;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Quick insert string str in the dictionary and set match_head to the previous head
|
||||
* of the hash chain (the most recent string with same hash key). Return
|
||||
* the previous length of the hash chain.
|
||||
*/
|
||||
Z_INTERNAL Pos QUICK_INSERT_STRING(deflate_state *const s, uint32_t str) {
|
||||
Pos head;
|
||||
uint8_t *strstart = s->window + str + HASH_CALC_OFFSET;
|
||||
uint32_t val, hm;
|
||||
|
||||
HASH_CALC_VAR_INIT;
|
||||
HASH_CALC_READ;
|
||||
HASH_CALC(HASH_CALC_VAR, val);
|
||||
HASH_CALC_VAR &= HASH_CALC_MASK;
|
||||
hm = HASH_CALC_VAR;
|
||||
|
||||
head = s->head[hm];
|
||||
if (LIKELY(head != str)) {
|
||||
s->prev[str & s->w_mask] = head;
|
||||
s->head[hm] = (Pos)str;
|
||||
}
|
||||
return head;
|
||||
}
|
||||
|
||||
/* ===========================================================================
|
||||
* Insert string str in the dictionary and set match_head to the previous head
|
||||
* of the hash chain (the most recent string with same hash key). Return
|
||||
* the previous length of the hash chain.
|
||||
* IN assertion: all calls to INSERT_STRING are made with consecutive
|
||||
* input characters and the first STD_MIN_MATCH bytes of str are valid
|
||||
* (except for the last STD_MIN_MATCH-1 bytes of the input file).
|
||||
*/
|
||||
Z_INTERNAL void INSERT_STRING(deflate_state *const s, uint32_t str, uint32_t count) {
|
||||
uint8_t *strstart = s->window + str + HASH_CALC_OFFSET;
|
||||
uint8_t *strend = strstart + count;
|
||||
|
||||
for (Pos idx = (Pos)str; strstart < strend; idx++, strstart++) {
|
||||
uint32_t val, hm;
|
||||
|
||||
HASH_CALC_VAR_INIT;
|
||||
HASH_CALC_READ;
|
||||
HASH_CALC(HASH_CALC_VAR, val);
|
||||
HASH_CALC_VAR &= HASH_CALC_MASK;
|
||||
hm = HASH_CALC_VAR;
|
||||
|
||||
Pos head = s->head[hm];
|
||||
if (LIKELY(head != idx)) {
|
||||
s->prev[idx & s->w_mask] = head;
|
||||
s->head[hm] = idx;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@@ -1,250 +0,0 @@
|
||||
/* match_tpl.h -- find longest match template for compare256 variants
|
||||
*
|
||||
* Copyright (C) 1995-2024 Jean-loup Gailly and Mark Adler
|
||||
* For conditions of distribution and use, see copyright notice in zlib.h
|
||||
*
|
||||
* Portions copyright (C) 2014-2021 Konstantin Nosov
|
||||
* Fast-zlib optimized longest_match
|
||||
* https://github.com/gildor2/fast_zlib
|
||||
*/
|
||||
|
||||
#ifndef MATCH_TPL_H
|
||||
#define MATCH_TPL_H
|
||||
|
||||
#define EARLY_EXIT_TRIGGER_LEVEL 5
|
||||
|
||||
#endif
|
||||
|
||||
/* Set match_start to the longest match starting at the given string and
|
||||
* return its length. Matches shorter or equal to prev_length are discarded,
|
||||
* in which case the result is equal to prev_length and match_start is garbage.
|
||||
*
|
||||
* IN assertions: cur_match is the head of the hash chain for the current
|
||||
* string (strstart) and its distance is <= MAX_DIST, and prev_length >=1
|
||||
* OUT assertion: the match length is not greater than s->lookahead
|
||||
*
|
||||
* The LONGEST_MATCH_SLOW variant spends more time to attempt to find longer
|
||||
* matches once a match has already been found.
|
||||
*/
|
||||
Z_INTERNAL uint32_t LONGEST_MATCH(deflate_state *const s, Pos cur_match) {
|
||||
unsigned int strstart = s->strstart;
|
||||
const unsigned wmask = s->w_mask;
|
||||
unsigned char *window = s->window;
|
||||
unsigned char *scan = window + strstart;
|
||||
Z_REGISTER unsigned char *mbase_start = window;
|
||||
Z_REGISTER unsigned char *mbase_end;
|
||||
const Pos *prev = s->prev;
|
||||
Pos limit;
|
||||
#ifdef LONGEST_MATCH_SLOW
|
||||
Pos limit_base;
|
||||
#else
|
||||
int32_t early_exit;
|
||||
#endif
|
||||
uint32_t chain_length, nice_match, best_len, offset;
|
||||
uint32_t lookahead = s->lookahead;
|
||||
Pos match_offset = 0;
|
||||
uint64_t scan_start;
|
||||
uint64_t scan_end;
|
||||
|
||||
#define GOTO_NEXT_CHAIN \
|
||||
if (--chain_length && (cur_match = prev[cur_match & wmask]) > limit) \
|
||||
continue; \
|
||||
return best_len;
|
||||
|
||||
/* The code is optimized for STD_MAX_MATCH-2 multiple of 16. */
|
||||
Assert(STD_MAX_MATCH == 258, "Code too clever");
|
||||
|
||||
best_len = s->prev_length ? s->prev_length : STD_MIN_MATCH-1;
|
||||
|
||||
/* Calculate read offset which should only extend an extra byte
|
||||
* to find the next best match length.
|
||||
*/
|
||||
offset = best_len-1;
|
||||
if (best_len >= sizeof(uint32_t)) {
|
||||
offset -= 2;
|
||||
if (best_len >= sizeof(uint64_t))
|
||||
offset -= 4;
|
||||
}
|
||||
|
||||
scan_start = zng_memread_8(scan);
|
||||
scan_end = zng_memread_8(scan+offset);
|
||||
mbase_end = (mbase_start+offset);
|
||||
|
||||
/* Do not waste too much time if we already have a good match */
|
||||
chain_length = s->max_chain_length;
|
||||
if (best_len >= s->good_match)
|
||||
chain_length >>= 2;
|
||||
nice_match = (uint32_t)s->nice_match;
|
||||
|
||||
/* Stop when cur_match becomes <= limit. To simplify the code,
|
||||
* we prevent matches with the string of window index 0
|
||||
*/
|
||||
limit = strstart > MAX_DIST(s) ? (Pos)(strstart - MAX_DIST(s)) : 0;
|
||||
#ifdef LONGEST_MATCH_SLOW
|
||||
limit_base = limit;
|
||||
if (best_len >= STD_MIN_MATCH) {
|
||||
/* We're continuing search (lazy evaluation). */
|
||||
uint32_t i, hash;
|
||||
Pos pos;
|
||||
|
||||
/* Find a most distant chain starting from scan with index=1 (index=0 corresponds
|
||||
* to cur_match). We cannot use s->prev[strstart+1,...] immediately, because
|
||||
* these strings are not yet inserted into the hash table.
|
||||
*/
|
||||
hash = s->update_hash(0, scan[1]);
|
||||
hash = s->update_hash(hash, scan[2]);
|
||||
|
||||
for (i = 3; i <= best_len; i++) {
|
||||
hash = s->update_hash(hash, scan[i]);
|
||||
|
||||
/* If we're starting with best_len >= 3, we can use offset search. */
|
||||
pos = s->head[hash];
|
||||
if (pos < cur_match) {
|
||||
match_offset = (Pos)(i - 2);
|
||||
cur_match = pos;
|
||||
}
|
||||
}
|
||||
|
||||
/* Update offset-dependent variables */
|
||||
limit = limit_base+match_offset;
|
||||
if (cur_match <= limit)
|
||||
goto break_matching;
|
||||
mbase_start -= match_offset;
|
||||
mbase_end -= match_offset;
|
||||
}
|
||||
#else
|
||||
early_exit = s->level < EARLY_EXIT_TRIGGER_LEVEL;
|
||||
#endif
|
||||
Assert((unsigned long)strstart <= s->window_size - MIN_LOOKAHEAD, "need lookahead");
|
||||
for (;;) {
|
||||
if (cur_match >= strstart)
|
||||
break;
|
||||
|
||||
/* Skip to next match if the match length cannot increase or if the match length is
|
||||
* less than 2. Note that the checks below for insufficient lookahead only occur
|
||||
* occasionally for performance reasons.
|
||||
* Therefore uninitialized memory will be accessed and conditional jumps will be made
|
||||
* that depend on those values. However the length of the match is limited to the
|
||||
* lookahead, so the output of deflate is not affected by the uninitialized values.
|
||||
*/
|
||||
if (best_len < sizeof(uint32_t)) {
|
||||
for (;;) {
|
||||
if (zng_memcmp_2(mbase_end+cur_match, &scan_end) == 0 &&
|
||||
zng_memcmp_2(mbase_start+cur_match, &scan_start) == 0)
|
||||
break;
|
||||
GOTO_NEXT_CHAIN;
|
||||
}
|
||||
} else if (best_len >= sizeof(uint64_t)) {
|
||||
for (;;) {
|
||||
if (zng_memcmp_8(mbase_end+cur_match, &scan_end) == 0 &&
|
||||
zng_memcmp_8(mbase_start+cur_match, &scan_start) == 0)
|
||||
break;
|
||||
GOTO_NEXT_CHAIN;
|
||||
}
|
||||
} else {
|
||||
for (;;) {
|
||||
if (zng_memcmp_4(mbase_end+cur_match, &scan_end) == 0 &&
|
||||
zng_memcmp_4(mbase_start+cur_match, &scan_start) == 0)
|
||||
break;
|
||||
GOTO_NEXT_CHAIN;
|
||||
}
|
||||
}
|
||||
uint32_t len = COMPARE256(scan+2, mbase_start+cur_match+2) + 2;
|
||||
Assert(scan+len <= window+(unsigned)(s->window_size-1), "wild scan");
|
||||
|
||||
if (len > best_len) {
|
||||
uint32_t match_start = cur_match - match_offset;
|
||||
s->match_start = match_start;
|
||||
|
||||
/* Do not look for matches beyond the end of the input. */
|
||||
if (len > lookahead)
|
||||
return lookahead;
|
||||
best_len = len;
|
||||
if (best_len >= nice_match)
|
||||
return best_len;
|
||||
|
||||
offset = best_len-1;
|
||||
if (best_len >= sizeof(uint32_t)) {
|
||||
offset -= 2;
|
||||
if (best_len >= sizeof(uint64_t))
|
||||
offset -= 4;
|
||||
}
|
||||
|
||||
scan_end = zng_memread_8(scan+offset);
|
||||
|
||||
#ifdef LONGEST_MATCH_SLOW
|
||||
/* Look for a better string offset */
|
||||
if (UNLIKELY(len > STD_MIN_MATCH && match_start + len < strstart)) {
|
||||
Pos pos, next_pos;
|
||||
uint32_t i, hash;
|
||||
unsigned char *scan_endstr;
|
||||
|
||||
/* Go back to offset 0 */
|
||||
cur_match -= match_offset;
|
||||
match_offset = 0;
|
||||
next_pos = cur_match;
|
||||
for (i = 0; i <= len - STD_MIN_MATCH; i++) {
|
||||
pos = prev[(cur_match + i) & wmask];
|
||||
if (pos < next_pos) {
|
||||
/* Hash chain is more distant, use it */
|
||||
if (pos <= limit_base + i)
|
||||
goto break_matching;
|
||||
next_pos = pos;
|
||||
match_offset = (Pos)i;
|
||||
}
|
||||
}
|
||||
/* Switch cur_match to next_pos chain */
|
||||
cur_match = next_pos;
|
||||
|
||||
/* Try hash head at len-(STD_MIN_MATCH-1) position to see if we could get
|
||||
* a better cur_match at the end of string. Using (STD_MIN_MATCH-1) lets
|
||||
* us include one more byte into hash - the byte which will be checked
|
||||
* in main loop now, and which allows to grow match by 1.
|
||||
*/
|
||||
scan_endstr = scan + len - (STD_MIN_MATCH+1);
|
||||
|
||||
hash = s->update_hash(0, scan_endstr[0]);
|
||||
hash = s->update_hash(hash, scan_endstr[1]);
|
||||
hash = s->update_hash(hash, scan_endstr[2]);
|
||||
|
||||
pos = s->head[hash];
|
||||
if (pos < cur_match) {
|
||||
match_offset = (Pos)(len - (STD_MIN_MATCH+1));
|
||||
if (pos <= limit_base + match_offset)
|
||||
goto break_matching;
|
||||
cur_match = pos;
|
||||
}
|
||||
|
||||
/* Update offset-dependent variables */
|
||||
limit = limit_base+match_offset;
|
||||
mbase_start = window-match_offset;
|
||||
mbase_end = (mbase_start+offset);
|
||||
continue;
|
||||
}
|
||||
#endif
|
||||
mbase_end = (mbase_start+offset);
|
||||
}
|
||||
#ifndef LONGEST_MATCH_SLOW
|
||||
else if (UNLIKELY(early_exit)) {
|
||||
/* The probability of finding a match later if we here is pretty low, so for
|
||||
* performance it's best to outright stop here for the lower compression levels
|
||||
*/
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
GOTO_NEXT_CHAIN;
|
||||
}
|
||||
return best_len;
|
||||
|
||||
#ifdef LONGEST_MATCH_SLOW
|
||||
break_matching:
|
||||
|
||||
if (best_len < s->lookahead)
|
||||
return best_len;
|
||||
|
||||
return s->lookahead;
|
||||
#endif
|
||||
}
|
||||
|
||||
#undef LONGEST_MATCH_SLOW
|
||||
#undef LONGEST_MATCH
|
||||
+685
-386
File diff suppressed because it is too large.
Load diff
Loaded 100 of 374 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user