Compare commits

..
1339 changed files with 175354 additions and 208456 deletions
+6 -4
View File
@@ -1,5 +1,4 @@
compat/zlib/contrib/dotzlib/readme.txt
compat/zlib/contrib/dotzlib/*.cs
compat/zlib/contrib/dotzlib/DotZLib/UnitTests.cs
compat/zlib/contrib/vstudio/readme.txt
compat/zlib/contrib/vstudio/*/zlib.rc
compat/zlib/contrib/vstudio/*/zlibvc.def
@@ -12,8 +11,11 @@ libtommath/*.dsp
libtommath/*.sln
libtommath/*.vcproj
tools/tcl.wse.in
win/*.bat
win/*.vc
win/buildall.vc.bat
win/coffbase.txt
win/makefile.vc
win/rules.vc
win/rules-ext.vc
win/targets.vc
win/tcl.dsp
win/tcl.dsw
-5
View File
@@ -48,11 +48,9 @@ libtommath/*.tex
macosx/configure
unix/autoMkindex.tcl
unix/dltest.marker
unix/dltest/embtest
unix/dltest/*.bundle
unix/dltest/*.dll
unix/dltest/*.dylib
unix/dltest/*.exe
unix/dltest/*.o
unix/dltest/*.sl
unix/dltest/*.so
@@ -60,13 +58,10 @@ unix/tcl.pc
unix/tclIndex
unix/Tcl-Info.plist
unix/Tclsh-Info.plist
unix/pkgs8/*
unix/pkgs/*
win/Debug*
win/Release*
win/tcl.pc
win/*.manifest
win/pkgs8/*
win/pkgs/*
win/coffbase.txt
win/tcl.hpj
-3
View File
@@ -22,9 +22,6 @@
# Declare files that will always have CRLF line endings on checkout.
*.bat eol=crlf
*.cs eol=crlf
*.dsp eol=crlf
*.dsw eol=crlf
*.sln eol=crlf
*.vc eol=crlf
-15
View File
@@ -1,15 +0,0 @@
{
"problemMatcher": [
{
"owner": "tcltest",
"pattern": [
{
"regexp": "^==== ([-\\w]+) (.+) (FAILED)$",
"severity": 3,
"message": 2,
"code": 1
}
]
}
]
}
-250
View File
@@ -1,250 +0,0 @@
# This workflow is meant for development use and run only on demand.
# It is customizable to select
# - Platforms
# - Toolchains
# - Branches (no need for core-* prefixes)
# - Tests
# To run the workflow, select "Custom" on the left side in the GH Actions
# page. Then click the Run workflow button on the right. This will display
# a dropdown that allows customization as above.
#
# To run the workflow, you need to have permissions to the repository.
# The simplest way is to clone the Tcl mirror on Github. However, that means
# if you work in fossil, you have a potential 24-hour wait before the mirror
# updates, which apart from nostalgia about the punched card batch processing
# era, is not so convenient. My preference instead is to mirror the fossil
# repository to Github via a local checkout on my system, do the work there
# pushing to github and running this workflow to verify across platforms
# and then committing back to the master fossil repository.
#
# Improvements to the workflow welcome.
name: Custom
on:
workflow_dispatch:
inputs:
platform:
description: 'Target platform(s)")'
required: true
default: 'all'
type: choice
options:
- all
- windows
- linux
- macos
windows_toolchains:
description: 'Windows toolchain'
required: true
type: choice
options:
- '["nmake", "msys"]'
- '["nmake"]'
- '["msys"]'
default: '["nmake"]'
windows_architectures:
description: 'Architecture (Windows Nmake only)'
required: true
type: choice
options:
- '["x64"]'
- '["x86"]'
- '["x64", "x86"]'
default: '["x64"]'
linux_compiler:
description: 'Linux compiler'
required: true
default: 'gcc'
type: choice
options:
- gcc
- clang
run_tests:
description: 'Run tests'
required: false
default: true
type: boolean
test_flags:
description: 'TESTFLAGS'
required: false
default: ''
jobs:
windows:
if: ${{ github.event.inputs.platform == 'windows' || github.event.inputs.platform == 'all' }}
runs-on: windows-2025-vs2026
strategy:
matrix:
arch: ${{ fromJSON(github.event.inputs.windows_architectures) }}
toolchain: ${{ fromJSON(github.event.inputs.windows_toolchains) }}
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ github.ref }}
# Nmake builds
- name: Setup MSVC (for nmake)
if: ${{ matrix.toolchain == 'nmake' }}
uses: ilammy/msvc-dev-cmd@v1
with:
arch: ${{ matrix.arch }}
- name: Build with nmake (Visual C++)
if: ${{ matrix.toolchain == 'nmake' }}
shell: cmd
env:
ERROR_ON_FAILURES: 1
working-directory: win
run: |
nmake /s /f makefile.vc
- name: Tests with nmake (Visual C++)
if: ${{ matrix.toolchain == 'nmake' && inputs.run_tests != 'false' }}
shell: cmd
env:
ERROR_ON_FAILURES: 1
TESTFLAGS: ${{ github.event.inputs.test_flags }}
working-directory: win
run: |
echo TESTFLAGS=%TESTFLAGS%
nmake /s /f makefile.vc test
# Msys builds
- name: Set up msys2 (x64)
if: ${{ matrix.toolchain == 'msys' && matrix.arch == 'x64'}}
uses: msys2/setup-msys2@v2
with:
msystem: UCRT64
pacboy: "git: make: gcc:p"
path-type: minimal
release: true
update: false
cache: true
- name: Set up msys2 (x86)
if: ${{ matrix.toolchain == 'msys' && matrix.arch == 'x86'}}
uses: msys2/setup-msys2@v2
with:
msystem: MINGW32
pacboy: "git: make: gcc:p"
path-type: minimal
release: true
update: false
cache: true
- name: Verify toolchain
if: ${{ matrix.toolchain == 'msys' }}
shell: bash -l {0}
run: |
gcc -v
make -v
- name: Configure with MSYS
if: ${{ matrix.toolchain == 'msys' }}
env:
ERROR_ON_FAILURES: 1
working-directory: win
shell: msys2 {0}
run: |
mkdir build
cd build
../configure
- name: Compile with MSYS
if: ${{ matrix.toolchain == 'msys' }}
env:
ERROR_ON_FAILURES: 1
shell: msys2 {0}
working-directory: win\build
run: |
file ../../libtommath/win32/tommath.lib
make -s
- name: Tests with MSYS
if: ${{ matrix.toolchain == 'msys' && inputs.run_tests != 'false' }}
env:
ERROR_ON_FAILURES: 1
TESTFLAGS: ${{ github.event.inputs.test_flags }}
working-directory: win\build
shell: msys2 {0}
run: |
echo TESTFLAGS=$TESTFLAGS
make -s test
linux:
if: ${{ github.event.inputs.platform == 'linux' || github.event.inputs.platform == 'all' }}
runs-on: ubuntu-26.04
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Configure with ${{ github.event.inputs.linux_compiler }}
env:
ERROR_ON_FAILURES: 1
CC: ${{ github.event.inputs.linux_compiler }}
working-directory: unix
run: |
mkdir build
cd build
echo CC=$CC
../configure || (cat config.log && exit 1)
- name: Compile
working-directory: unix/build
run: |
make -s
- name: Run tests
if: ${{ inputs.run_tests != 'false' }}
env:
ERROR_ON_FAILURES: 1
TESTFLAGS: ${{ github.event.inputs.test_flags }}
working-directory: unix/build
run: |
echo TESTFLAGS=$TESTFLAGS
make -s test
macos:
if: ${{ github.event.inputs.platform == 'macos' || github.event.inputs.platform == 'all' }}
runs-on: macos-26
steps:
- name: Checkout repository
uses: actions/checkout@v7
with:
fetch-depth: 0
ref: ${{ github.ref }}
- name: Configure
env:
ERROR_ON_FAILURES: 1
working-directory: unix
run: |
mkdir build
cd build
../configure --enable-framework || (cat config.log && exit 1)
make -s
- name: Compile
working-directory: unix/build
run: |
make -s
- name: Run tests
if: ${{ inputs.run_tests != 'false' }}
env:
ERROR_ON_FAILURES: 1
TESTFLAGS: ${{ github.event.inputs.test_flags }}
working-directory: unix/build
run: |
echo TESTFLAGS=$TESTFLAGS
make -s test
-7
View File
@@ -1,7 +0,0 @@
puts exe:\t[info nameofexecutable]
puts ver:\t[info patchlevel]
catch {
puts build:\t[tcl::build-info]
}
puts lib:\t[info library]
puts plat:\t[lsort -dictionary -stride 2 [array get tcl_platform]]
+16 -71
View File
@@ -1,109 +1,54 @@
name: Linux
on:
push:
branches:
- "main"
- "core-9-1-branch"
tags:
- "core-*"
workflow_dispatch:
on: [push]
permissions:
contents: read
jobs:
plan:
runs-on: ubuntu-26.04
outputs:
gcc: ${{ steps.matrix.outputs.gcc }}
steps:
- name: Select build matrix based on branch name
id: matrix
run: |
(
echo gcc=$(jq -nc '{config: (if env.IsMatched == "true" then env.FULL else env.PARTIAL end) | fromjson }' )
) | tee -a $GITHUB_OUTPUT
env:
IsMatched: ${{ github.ref_name == 'main' || github.ref_name == 'core-9-1-branch' }}
# DO NOT CHANGE THESE MATRIX SPECS; IT AFFECTS OUR COST CONTROLS
FULL: >
[
"",
"CFLAGS=-DTCL_NO_DEPRECATED=1",
"--disable-shared",
"--disable-zipfs",
"--enable-symbols",
"--enable-symbols=mem",
"--enable-symbols=all",
"CFLAGS=-ftrapv",
"CFLAGS=-m32 CPPFLAGS=-m32 LDFLAGS=-m32 --disable-64bit"
]
PARTIAL: >
[
"",
"--enable-symbols=all",
"CFLAGS=-m32 CPPFLAGS=-m32 LDFLAGS=-m32 --disable-64bit"
]
gcc:
needs: plan
runs-on: ubuntu-26.04
runs-on: ubuntu-22.04
strategy:
matrix: ${{ fromJson(needs.plan.outputs.gcc) }}
matrix:
cfgopt:
- ""
- "CFLAGS=-DTCL_UTF_MAX=3"
- "CFLAGS=-DTCL_NO_DEPRECATED=1"
- "--disable-shared"
- "--enable-symbols"
- "--enable-symbols=mem"
- "--enable-symbols=all"
defaults:
run:
shell: bash
working-directory: unix
steps:
- name: Checkout
uses: actions/checkout@v7
timeout-minutes: 5
- name: Install 32-bit dependencies if needed
# Duplicated from above
if: ${{ matrix.config == 'CFLAGS=-m32 CPPFLAGS=-m32 LDFLAGS=-m32 --disable-64bit' }}
run: |
sudo apt-get update
sudo apt-get install gcc-multilib libc6-dev-i386
uses: actions/checkout@v3
- name: Prepare
run: |
touch tclStubInit.c tclOOStubInit.c tclOOScript.h
working-directory: generic
- name: Configure ${{ matrix.config }}
- name: Configure ${{ matrix.cfgopt }}
run: |
mkdir "${HOME}/install dir"
./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 1)
env:
CFGOPT: ${{ matrix.config }}
timeout-minutes: 5
CFGOPT: ${{ matrix.cfgopt }}
- name: Build
run: |
make -j4 all
timeout-minutes: 5
make all
- name: Build Test Harness
run: |
make -j4 tcltest
timeout-minutes: 5
- name: Info
run: |
ulimit -a || echo 'get limit failed'
make runtest SCRIPT=../.github/workflows/info.tcl || echo 'get info failed'
make tcltest
- name: Run Tests
run: |
echo "::add-matcher::.github/tcltest.json"
make test
echo "::remove-matcher::.github/tcltest.json"
env:
ERROR_ON_FAILURES: 1
CI: 1
timeout-minutes: 30
- name: Test-Drive Installation
run: |
make install
timeout-minutes: 5
- name: Create Distribution Package
if: ${{ matrix.config == '' }}
run: |
make dist
timeout-minutes: 5
- name: Convert Documentation to HTML
if: ${{ matrix.config == '' }}
run: |
make html-tcl
timeout-minutes: 5
+17 -61
View File
@@ -1,110 +1,66 @@
name: macOS
on:
push:
branches:
- "main"
- "core-9-1-branch"
tags:
- "core-*"
workflow_dispatch:
on: [push]
permissions:
contents: read
jobs:
plan:
runs-on: ubuntu-26.04
outputs:
clang: ${{ steps.matrix.outputs.clang }}
steps:
- name: Select build matrix based on branch name
id: matrix
run: |
(
echo clang=$(jq -nc '{config: (if env.IsMatched == "true" then env.FULL else env.PARTIAL end) | fromjson }' )
) | tee -a $GITHUB_OUTPUT
env:
IsMatched: ${{ github.ref_name == 'main' || github.ref_name == 'core-9-1-branch' }}
# DO NOT CHANGE THIS MATRIX SPEC; IT AFFECTS OUR COST CONTROLS
FULL: >
[
"",
"--disable-shared",
"--disable-zipfs",
"--enable-symbols",
"--enable-symbols=mem",
"--enable-symbols=all"
]
PARTIAL: >
[
"",
"--enable-symbols=all"
]
xcode:
runs-on: macos-26
runs-on: macos-11
defaults:
run:
shell: bash
working-directory: macosx
steps:
- name: Checkout
uses: actions/checkout@v7
timeout-minutes: 5
uses: actions/checkout@v3
- name: Prepare
run: |
touch tclStubInit.c tclOOStubInit.c tclOOScript.h
working-directory: generic
- name: Build
run: make -j4 all
run: make all
env:
CFLAGS: -arch x86_64 -arch arm64
timeout-minutes: 15
- name: Run Tests
run: |
echo "::add-matcher::.github/tcltest.json"
make -j4 test styles=develop
run: make test styles=develop
env:
ERROR_ON_FAILURES: 1
MAC_CI: 1
timeout-minutes: 30
clang:
runs-on: macos-26
needs: plan
runs-on: macos-11
strategy:
matrix: ${{ fromJson(needs.plan.outputs.clang) }}
matrix:
cfgopt:
- ""
- "--disable-shared"
- "--enable-symbols"
- "--enable-symbols=mem"
- "--enable-symbols=all"
defaults:
run:
shell: bash
working-directory: unix
steps:
- name: Checkout
uses: actions/checkout@v7
timeout-minutes: 5
uses: actions/checkout@v3
- name: Prepare
run: |
touch tclStubInit.c tclOOStubInit.c tclOOScript.h
mkdir "$HOME/install dir"
working-directory: generic
- name: Configure ${{ matrix.config }}
- name: Configure ${{ matrix.cfgopt }}
# Note that macOS is always a 64 bit platform
run: ./configure --enable-dtrace --enable-framework ${CFGOPT} "--prefix=$HOME/install" || (cat config.log && exit 1)
env:
CFLAGS: -arch x86_64 -arch arm64
CFGOPT: ${{ matrix.config }}
timeout-minutes: 5
CFGOPT: ${{ matrix.cfgopt }}
- name: Build
run: |
make -j4 all tcltest
make all tcltest
env:
CFLAGS: -arch x86_64 -arch arm64
timeout-minutes: 15
- name: Info
run: |
ulimit -a || echo 'get limit failed'
make runtest SCRIPT=../.github/workflows/info.tcl || echo 'get info failed'
- name: Run Tests
run: |
echo "::add-matcher::.github/tcltest.json"
make test
env:
ERROR_ON_FAILURES: 1
MAC_CI: 1
timeout-minutes: 30
+15 -113
View File
@@ -1,25 +1,17 @@
name: Build Binaries
on:
push:
branches:
- "main"
- "core-9-1-branch"
tags:
- "core-*"
workflow_dispatch:
on: [push]
permissions:
contents: read
jobs:
linux:
name: Linux
runs-on: ubuntu-26.04
runs-on: ubuntu-20.04
defaults:
run:
shell: bash
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v3
- name: Prepare
run: |
touch generic/tclStubInit.c generic/tclOOStubInit.c
@@ -41,39 +33,31 @@ jobs:
chmod +x tclsh${TCL_PATCHLEVEL}_snapshot
tar -cf tclsh${TCL_PATCHLEVEL}_snapshot.tar tclsh${TCL_PATCHLEVEL}_snapshot
working-directory: 1dist
- name: Info
run: |
ulimit -a || echo 'get limit failed'
echo 'puts exe:\t[info nameofexecutable]\nver:\t[info patchlevel]\t[if {![catch tcl::build-info ret]} {set ret}]\nlib:\t[info library]\nplat:\t[lsort -dictionary -stride 2 [array get tcl_platform]]' | make runtest || echo 'get info failed'
- name: Upload
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v3
with:
name: Tclsh ${{ env.TCL_PATCHLEVEL }} Linux single-file build (snapshot)
path: 1dist/*.tar
id: upload
outputs:
url: ${{ steps.upload.outputs.artifact-url }}
macos:
name: macOS
runs-on: macos-26
runs-on: macos-11
defaults:
run:
shell: bash
timeout-minutes: 10
steps:
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v3
- name: Checkout create-dmg
uses: actions/checkout@v7
uses: actions/checkout@v3
with:
repository: create-dmg/create-dmg
ref: v1.2.2
ref: v1.0.8
path: create-dmg
- name: Prepare
run: |
mkdir 1dist
touch generic/tclStubInit.c generic/tclOOStubInit.c || true
wget https://github.com/culler/macher/releases/download/v1.8/macher
wget https://github.com/culler/macher/releases/download/v1.3/macher
sudo cp macher /usr/local/bin
sudo chmod a+x /usr/local/bin/macher
echo "VER_PATH=$(cd tools; pwd)/addVerToFile.tcl" >> $GITHUB_ENV
@@ -84,8 +68,8 @@ jobs:
working-directory: unix
- name: Build
run: |
make -j4 tclsh
make -j4 shell SCRIPT="$VER_PATH $GITHUB_ENV"
make tclsh
make shell SCRIPT="$VER_PATH $GITHUB_ENV"
echo "TCL_BIN=`pwd`/tclsh" >> $GITHUB_ENV
echo "TCL_ZIP=`pwd`/`echo libtcl*.zip`" >> $GITHUB_ENV
working-directory: unix
@@ -111,25 +95,17 @@ jobs:
"Tcl-$TCL_PATCHLEVEL-(snapshot).dmg" \
"contents/"
working-directory: 1dist
- name: Info
run: |
ulimit -a || echo 'get limit failed'
echo 'puts exe:\t[info nameofexecutable]\nver:\t[info patchlevel]\t[if {![catch tcl::build-info ret]} {set ret}]\nlib:\t[info library]\nplat:\t[lsort -dictionary -stride 2 [array get tcl_platform]]' | make runtest || echo 'get info failed'
- name: Upload
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v3
with:
name: Tclsh ${{ env.TCL_PATCHLEVEL }} macOS single-file build (snapshot)
path: 1dist/*.dmg
id: upload
outputs:
url: ${{ steps.upload.outputs.artifact-url }}
win:
name: Windows
runs-on: windows-2025-vs2026
runs-on: windows-2019
defaults:
run:
shell: msys2 {0}
timeout-minutes: 10
env:
CC: gcc
CFGOPT: --disable-symbols --disable-shared
@@ -140,7 +116,7 @@ jobs:
msystem: UCRT64
install: git mingw-w64-ucrt-x86_64-toolchain make zip
- name: Checkout
uses: actions/checkout@v7
uses: actions/checkout@v3
- name: Prepare
run: |
touch generic/tclStubInit.c generic/tclOOStubInit.c
@@ -163,82 +139,8 @@ jobs:
run: |
cp ../win/tclsh*.exe tclsh${TCL_PATCHLEVEL}_snapshot.exe
working-directory: 1dist
- name: Info
run: |
ulimit -a || echo 'get limit failed'
echo 'puts exe:\t[info nameofexecutable]\nver:\t[info patchlevel]\t[if {![catch tcl::build-info ret]} {set ret}]\nlib:\t[info library]\nplat:\t[lsort -dictionary -stride 2 [array get tcl_platform]]' | make runtest || echo 'get info failed'
- name: Upload
uses: actions/upload-artifact@v7
uses: actions/upload-artifact@v3
with:
name: Tclsh ${{ env.TCL_PATCHLEVEL }} Windows single-file build (snapshot)
path: '1dist/*_snapshot.exe'
id: upload
outputs:
url: ${{ steps.upload.outputs.artifact-url }}
combine:
needs:
- linux
- macos
- win
name: Combine Artifacts (prototype)
runs-on: ubuntu-26.04
defaults:
run:
shell: bash
timeout-minutes: 10
env:
# See also
# https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/store-information-in-variables
REMOTE_PATH: ${{ vars.PUBLISH_DROP_PATH }}/data-${{ github.sha }}
steps:
- name: Make directory
run: |
mkdir data
- name: Get Linux build
uses: actions/download-artifact@v8
with:
path: data
# Can't download by artifact ID; stupid missing feature!
merge-multiple: true
- name: Check data downloaded
run: |
ls -AlR
working-directory: data
- name: Transfer built files
# https://github.com/marketplace/actions/rsync-deployments-action
uses: burnett01/rsync-deployments@9.0.1
id: rsync
if: false # Disabled... for now
with:
# I don't know what the right switches are here, BTW
switches: -avzr
path: data/
remote_path: ${{ env.REMOTE_PATH }}
remote_host: ${{ vars.PUBLISH_HOST }}
remote_user: ${{ vars.PUBLISH_USER }}
remote_key: ${{ secrets.DEPLOY_HOST_KEY }}
# MUST be a literal passwordless key
- name: Publish files
# https://github.com/marketplace/actions/ssh-remote-commands
uses: appleboy/ssh-action@v1.2.5
id: ssh
if: steps.rsync.outcome == 'success'
with:
host: ${{ vars.PUBLISH_HOST }}
username: ${{ vars.PUBLISH_USER }}
key: ${{ secrets.DEPLOY_HOST_KEY }}
script: |
${{ vars.PUBLISHER_SCRIPT }} ${{ env.REMOTE_PATH }} ${{ github.ref_type }} ${{ github.ref_name }}
- name: Report what would be done
if: steps.rsync.outcome == 'skipped'
env:
SWITCHES: -av
LOCAL_PATH: data/
REMOTE_HOST: ${{ vars.PUBLISH_HOST }}
REMOTE_USER: ${{ vars.PUBLISH_USER }}
REMOTE_SCRIPT: |
${{ vars.PUBLISHER_SCRIPT }} ${{ env.REMOTE_PATH }} ${{ github.ref_type }} ${{ github.ref_name }}
run: |
echo "would run: rsync $SWITCHES $LOCAL_PATH $REMOTE_USER@$REMOTE_HOST:$REMOTE_PATH"
echo "would run: ssh $REMOTE_USER@$REMOTE_HOST $REMOTE_SCRIPT"
# Consider https://github.com/marketplace/actions/slack-notify maybe?
+37 -102
View File
@@ -1,155 +1,90 @@
name: Windows
on:
push:
branches:
- "main"
- "core-9-1-branch"
tags:
- "core-*"
workflow_dispatch:
on: [push]
permissions:
contents: read
env:
ERROR_ON_FAILURES: 1
jobs:
plan:
runs-on: ubuntu-26.04
outputs:
msvc: ${{ steps.matrix.outputs.msvc }}
gcc: ${{ steps.matrix.outputs.gcc }}
steps:
- name: Select build matrix based on branch name
id: matrix
run: |
(
echo msvc=$(jq -nc '{arch: ["x64"], config: (if env.IsMatched == "true" then env.MSVC_FULL else env.MSVC_PARTIAL end) | fromjson }' )
echo gcc=$(jq -nc '{config: (if env.IsMatched == "true" then env.GCC_FULL else env.GCC_PARTIAL end) | fromjson }' )
) | tee -a $GITHUB_OUTPUT
env:
IsMatched: ${{ github.ref_name == 'main' || github.ref_name == 'core-9-1-branch' }}
# DO NOT CHANGE THESE MATRIX SPECS; IT AFFECTS OUR COST CONTROLS
MSVC_FULL: >
[
"",
"CHECKS=nodep",
"OPTS=static",
"OPTS=noembed",
"OPTS=symbols",
"OPTS=symbols STATS=compdbg,memdbg"
]
MSVC_PARTIAL: >
[
"",
"OPTS=symbols STATS=compdbg,memdbg"
]
GCC_FULL: >
[
"",
"CFLAGS=-DTCL_NO_DEPRECATED=1",
"--disable-shared",
"--disable-zipfs",
"--enable-symbols",
"--enable-symbols=mem",
"--enable-symbols=all"
]
GCC_PARTIAL: >
[
"",
"--disable-shared",
"--enable-symbols=all"
]
msvc:
runs-on: windows-2025-vs2026
needs: plan
runs-on: windows-2022
defaults:
run:
shell: powershell
working-directory: win
strategy:
matrix: ${{ fromJson(needs.plan.outputs.msvc) }}
matrix:
cfgopt:
- ""
- "OPTS=utf16"
- "CHECKS=nodep"
- "OPTS=static"
- "OPTS=symbols"
- "OPTS=symbols STATS=compdbg,memdbg"
# Using powershell means we need to explicitly stop on failure
steps:
- name: Checkout
uses: actions/checkout@v7
timeout-minutes: 5
uses: actions/checkout@v3
- name: Init MSVC
shell: cmd
uses: ilammy/msvc-dev-cmd@v1
- name: Build ${{ matrix.cfgopt }}
run: |
for /f "usebackq tokens=*" %%i in (`vswhere -latest -property installationPath`) do set "VS_PATH=%%i"
call "%VS_PATH%\VC\Auxiliary\Build\vcvarsall.bat" ${{ matrix.arch }}
set | findstr /i "^VC ^VCTools ^Windows ^Universal ^INCLUDE ^LIB ^PATH ^DevEnv" >> %GITHUB_ENV%
- name: Build ${{ matrix.config }}
run: |
&nmake -f makefile.vc ${{ matrix.config }} all
&nmake -f makefile.vc ${{ matrix.cfgopt }} all
if ($lastexitcode -ne 0) {
throw "nmake exit code: $lastexitcode"
}
timeout-minutes: 5
- name: Build Test Harness ${{ matrix.config }}
- name: Build Test Harness ${{ matrix.cfgopt }}
run: |
&nmake -f makefile.vc ${{ matrix.config }} tcltest
&nmake -f makefile.vc ${{ matrix.cfgopt }} tcltest
if ($lastexitcode -ne 0) {
throw "nmake exit code: $lastexitcode"
}
timeout-minutes: 5
- name: Run Tests ${{ matrix.config }}
- name: Run Tests ${{ matrix.cfgopt }}
run: |
Write-Output "::add-matcher::.github/tcltest.json"
&nmake -f makefile.vc ${{ matrix.config }} test
&nmake -f makefile.vc ${{ matrix.cfgopt }} test
if ($lastexitcode -ne 0) {
throw "nmake exit code: $lastexitcode"
}
timeout-minutes: 30
env:
ERROR_ON_FAILURES: 1
gcc:
runs-on: windows-2025-vs2026
needs: plan
runs-on: windows-2022
defaults:
run:
shell: msys2 {0}
working-directory: win
strategy:
matrix: ${{ fromJson(needs.plan.outputs.gcc) }}
matrix:
cfgopt:
- ""
- "CFLAGS=-DTCL_UTF_MAX=3"
- "CFLAGS=-DTCL_NO_DEPRECATED=1"
- "--disable-shared"
- "--enable-symbols"
- "--enable-symbols=mem"
- "--enable-symbols=all"
# Using powershell means we need to explicitly stop on failure
steps:
- name: Install MSYS2
uses: msys2/setup-msys2@v2
with:
msystem: MINGW64
install: git mingw-w64-x86_64-toolchain make
timeout-minutes: 10
- name: Checkout
uses: actions/checkout@v7
timeout-minutes: 5
uses: actions/checkout@v3
- name: Prepare
run: |
touch tclStubInit.c tclOOStubInit.c tclOOScript.h
mkdir "${HOME}/install dir"
working-directory: generic
- name: Configure ${{ matrix.config }}
- name: Configure ${{ matrix.cfgopt }}
run: |
./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 1)
env:
CFGOPT: --enable-64bit ${{ matrix.config }}
timeout-minutes: 5
CFGOPT: --enable-64bit ${{ matrix.cfgopt }}
- name: Build
run: make -j4 all
timeout-minutes: 5
run: make all
- name: Build Test Harness
run: make -j4 tcltest
timeout-minutes: 5
- name: Info
run: |
ulimit -a || echo 'get limit failed'
make runtest SCRIPT=../.github/workflows/info.tcl || echo 'get info failed'
run: make tcltest
- name: Run Tests
run: |
echo "::add-matcher::.github/tcltest.json"
make test
timeout-minutes: 30
env:
ERROR_ON_FAILURES: 1
- name: Install
run: make install
timeout-minutes: 5
run: make test
# If you add builds with Wine, be sure to define the environment variable
# CI_USING_WINE when running them so that broken tests know not to run.
-4
View File
@@ -53,18 +53,14 @@ libtommath/*.tex
macosx/configure
unix/autoMkindex.tcl
unix/dltest.marker
unix/dltest/embtest
unix/tcl.pc
unix/tclIndex
unix/pkgs8/*
unix/pkgs/*
win/Debug*
win/Release*
win/*.manifest
win/pkgs8/*
win/pkgs/*
win/coffbase.txt
win/tcl.hpj
win/tcl.pc
win/nmakehlp.out
win/nmhlp-out.txt
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>tcl9.1</name>
<name>tcl9</name>
<comment></comment>
<projects>
</projects>
+401
View File
@@ -0,0 +1,401 @@
language: c
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- binutils-mingw-w64-i686
- binutils-mingw-w64-x86-64
- gcc-mingw-w64
- gcc-mingw-w64-base
- gcc-mingw-w64-i686
- gcc-mingw-w64-x86-64
- gcc-multilib
jobs:
include:
# Testing on Linux GCC
- name: "Linux/GCC/Shared"
os: linux
dist: focal
compiler: gcc
env:
- BUILD_DIR=unix
- name: "Linux/GCC/Shared: UTF_MAX=3"
os: linux
dist: focal
compiler: gcc
env:
- BUILD_DIR=unix
- CFGOPT="CFLAGS=-DTCL_UTF_MAX=3"
- name: "Linux/GCC/Shared: NO_DEPRECATED"
os: linux
dist: focal
compiler: gcc
env:
- BUILD_DIR=unix
- CFGOPT="CFLAGS=-DTCL_NO_DEPRECATED=1"
- name: "Linux/GCC/Static"
os: linux
dist: focal
compiler: gcc
env:
- CFGOPT="--disable-shared"
- BUILD_DIR=unix
- name: "Linux/GCC/Debug"
os: linux
dist: focal
compiler: gcc
env:
- BUILD_DIR=unix
- CFGOPT="--enable-symbols"
- name: "Linux/GCC/Mem-Debug"
os: linux
dist: focal
compiler: gcc
env:
- BUILD_DIR=unix
- CFGOPT="--enable-symbols=mem"
# Newer/Older versions of GCC
- name: "Linux/GCC 10/Shared"
os: linux
dist: focal
compiler: gcc-10
addons:
apt:
packages:
- g++-10
env:
- BUILD_DIR=unix
- name: "Linux/GCC 5/Shared"
os: linux
dist: bionic
compiler: gcc-5
addons:
apt:
packages:
- g++-5
env:
- BUILD_DIR=unix
# Testing on Linux Clang
- name: "Linux/Clang/Shared"
os: linux
dist: focal
compiler: clang
env:
- BUILD_DIR=unix
- name: "Linux/Clang/Static"
os: linux
dist: focal
compiler: clang
env:
- CFGOPT="--disable-shared"
- BUILD_DIR=unix
- name: "Linux/Clang/Debug"
os: linux
dist: focal
compiler: clang
env:
- BUILD_DIR=unix
- CFGOPT="--enable-symbols"
- name: "Linux/Clang/Mem-Debug"
os: linux
dist: focal
compiler: clang
env:
- BUILD_DIR=unix
- CFGOPT="--enable-symbols=mem"
# Testing on Mac, various styles
- name: "macOS/Clang/Xcode 12/Shared"
os: osx
osx_image: xcode12.2
env:
- BUILD_DIR=macosx
install: []
script: &mactest
- make all
# The styles=develop avoids some weird problems on OSX
- make test styles=develop
- name: "macOS/Clang/Xcode 12/Shared/Unix-like"
os: osx
osx_image: xcode12.2
env:
- BUILD_DIR=unix
- CFGOPT="--enable-dtrace"
- name: "macOS/Clang/Xcode 12/Shared/libtommath"
os: osx
osx_image: xcode12.2
env:
- BUILD_DIR=macosx
install: []
script: *mactest
addons:
homebrew:
packages:
- libtommath
# Newer MacOS versions
- name: "macOS/Clang/Xcode 12/Universal Apps/Shared"
os: osx
osx_image: xcode12u
env:
- BUILD_DIR=macosx
install: []
script: *mactest
# Older MacOS versions
- name: "macOS/Clang/Xcode 11/Shared"
os: osx
osx_image: xcode11.7
env:
- BUILD_DIR=macosx
install: []
script: *mactest
- name: "macOS/Clang/Xcode 10/Shared"
os: osx
osx_image: xcode10.3
env:
- BUILD_DIR=macosx
install: []
script: *mactest
- name: "macOS/Clang/Xcode 9/Shared"
os: osx
osx_image: xcode9.4
env:
- BUILD_DIR=macosx
install: []
script: *mactest
- name: "macOS/Clang/Xcode 8/Shared"
os: osx
osx_image: xcode8.3
env:
- BUILD_DIR=macosx
install: []
script: *mactest
# Test with mingw-w64 cross-compile
# Doesn't run tests because wine is only an imperfect Windows emulation
- name: "Linux-cross-Windows/GCC/Shared/no test"
os: linux
dist: focal
compiler: x86_64-w64-mingw32-gcc
env:
- BUILD_DIR=win
- CFGOPT="--host=x86_64-w64-mingw32 --enable-64bit"
script: &crosstest
- make all tcltest
# Include a high visibility marker that tests are skipped outright
- >
echo "`tput setaf 3`SKIPPED TEST: CROSS COMPILING`tput sgr0`"
# Test with mingw-w64 (32 bit) cross-compile
# Doesn't run tests because wine is only an imperfect Windows emulation
- name: "Linux-cross-Windows-32/GCC/Shared/no test"
os: linux
dist: focal
compiler: i686-w64-mingw32-gcc
env:
- BUILD_DIR=win
- CFGOPT=--host=i686-w64-mingw32
script: *crosstest
# Test on Windows with MSVC native
- name: "Windows/MSVC/Shared"
os: windows
compiler: cl
env: &vcenv
- BUILD_DIR=win
- VCDIR="/C/Program Files (x86)/Microsoft Visual Studio/2017/BuildTools/VC/Auxiliary/Build"
before_install: &vcpreinst
- touch generic/tclStubInit.c generic/tclOOStubInit.c generic/tclOOScript.h
- PATH="$PATH:$VCDIR"
- cd ${BUILD_DIR}
install: []
script:
- cmd.exe //C vcvarsall.bat x64 '&&' nmake '-f' makefile.vc all tcltest
- cmd.exe //C vcvarsall.bat x64 '&&' nmake '-f' makefile.vc test
- name: "Windows/MSVC/Shared: NO_DEPRECATED"
os: windows
compiler: cl
env: *vcenv
before_install: *vcpreinst
install: []
script:
- cmd.exe //C vcvarsall.bat x64 '&&' nmake 'CHECKS=nodep' '-f' makefile.vc all tcltest
- cmd.exe //C vcvarsall.bat x64 '&&' nmake 'CHECKS=nodep' '-f' makefile.vc test
- name: "Windows/MSVC/Static"
os: windows
compiler: cl
env: *vcenv
before_install: *vcpreinst
install: []
script:
- cmd.exe //C vcvarsall.bat x64 '&&' nmake 'OPTS=static' '-f' makefile.vc all tcltest
- cmd.exe //C vcvarsall.bat x64 '&&' nmake 'OPTS=static' '-f' makefile.vc test
- name: "Windows/MSVC/Debug"
os: windows
compiler: cl
env: *vcenv
before_install: *vcpreinst
install: []
script:
- cmd.exe //C vcvarsall.bat x64 '&&' nmake 'OPTS=symbols' '-f' makefile.vc all tcltest
- cmd.exe //C vcvarsall.bat x64 '&&' nmake 'OPTS=symbols' '-f' makefile.vc test
- name: "Windows/MSVC/Mem-Debug"
os: windows
compiler: cl
env: *vcenv
before_install: *vcpreinst
install: []
script:
- cmd.exe //C vcvarsall.bat x64 '&&' nmake 'STATS=memdbg' '-f' makefile.vc all tcltest
- cmd.exe //C vcvarsall.bat x64 '&&' nmake 'STATS=memdbg' '-f' makefile.vc test
# Test on Windows with MSVC native (32-bit)
- name: "Windows/MSVC-x86/Shared"
os: windows
compiler: cl
env: *vcenv
before_install: *vcpreinst
install: []
script:
- cmd.exe //C vcvarsall.bat x86 '&&' nmake '-f' makefile.vc all tcltest
- cmd.exe //C vcvarsall.bat x86 '&&' nmake '-f' makefile.vc test
- name: "Windows/MSVC-x86/Shared: NO_DEPRECATED"
os: windows
compiler: cl
env: *vcenv
before_install: *vcpreinst
install: []
script:
- cmd.exe //C vcvarsall.bat x86 '&&' nmake 'CHECKS=nodep' '-f' makefile.vc all tcltest
- cmd.exe //C vcvarsall.bat x86 '&&' nmake 'CHECKS=nodep' '-f' makefile.vc test
- name: "Windows/MSVC-x86/Static"
os: windows
compiler: cl
env: *vcenv
before_install: *vcpreinst
install: []
script:
- cmd.exe //C vcvarsall.bat x86 '&&' nmake 'OPTS=static' '-f' makefile.vc all tcltest
- cmd.exe //C vcvarsall.bat x86 '&&' nmake 'OPTS=static' '-f' makefile.vc test
- name: "Windows/MSVC-x86/Debug"
os: windows
compiler: cl
env: *vcenv
before_install: *vcpreinst
install: []
script:
- cmd.exe //C vcvarsall.bat x86 '&&' nmake 'OPTS=symbols' '-f' makefile.vc all tcltest
- cmd.exe //C vcvarsall.bat x86 '&&' nmake 'OPTS=symbols' '-f' makefile.vc test
- name: "Windows/MSVC-x86/Mem-Debug"
os: windows
compiler: cl
env: *vcenv
before_install: *vcpreinst
install: []
script:
- cmd.exe //C vcvarsall.bat x86 '&&' nmake 'STATS=memdbg' '-f' makefile.vc all tcltest
- cmd.exe //C vcvarsall.bat x86 '&&' nmake 'STATS=memdbg' '-f' makefile.vc test
# Test on Windows with GCC native
- name: "Windows/GCC/Shared"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="--enable-64bit"
before_install: &makepreinst
- touch generic/tclStubInit.c generic/tclOOStubInit.c generic/tclOOScript.h
- choco install -y make zip
- cd ${BUILD_DIR}
- name: "Windows/GCC/Shared: UTF_MAX=3"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="--enable-64bit CFLAGS=-DTCL_UTF_MAX=3"
before_install: *makepreinst
- name: "Windows/GCC/Shared: NO_DEPRECATED"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="--enable-64bit CFLAGS=-DTCL_NO_DEPRECATED=1"
before_install: *makepreinst
- name: "Windows/GCC/Static"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="--enable-64bit --disable-shared"
before_install: *makepreinst
- name: "Windows/GCC/Debug"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="--enable-64bit --enable-symbols"
before_install: *makepreinst
- name: "Windows/GCC/Mem-Debug"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="--enable-64bit --enable-symbols=mem"
before_install: *makepreinst
# Test on Windows with GCC native (32-bit)
- name: "Windows/GCC-x86/Shared"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
before_install: *makepreinst
- name: "Windows/GCC-x86/Shared: UTF_MAX=3"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="CFLAGS=-DTCL_UTF_MAX=3"
before_install: *makepreinst
- name: "Windows/GCC-x86/Shared: NO_DEPRECATED"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="CFLAGS=-DTCL_NO_DEPRECATED=1"
before_install: *makepreinst
- name: "Windows/GCC-x86/Static"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="--disable-shared"
before_install: *makepreinst
- name: "Windows/GCC-x86/Debug"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="--enable-symbols"
before_install: *makepreinst
- name: "Windows/GCC-x86/Mem-Debug"
os: windows
compiler: gcc
env:
- BUILD_DIR=win
- CFGOPT="--enable-symbols=mem"
before_install: *makepreinst
# "make dist" only
- name: "Linux: make dist"
os: linux
dist: focal
compiler: gcc
env:
- BUILD_DIR=unix
script:
- make dist
before_install:
- touch generic/tclStubInit.c generic/tclOOStubInit.c generic/tclOOScript.h
- cd ${BUILD_DIR}
install:
- mkdir "$HOME/install dir"
- ./configure ${CFGOPT} "--prefix=$HOME/install dir" || (cat config.log && exit 1)
before_script:
- export ERROR_ON_FAILURES=1
script:
- make all tcltest || echo "Something wrong, maybe a hickup, let's try again"
- make test
- make install
+8856
View File
File diff suppressed because it is too large Load Diff
+2634
View File
File diff suppressed because it is too large Load Diff
+2539
View File
File diff suppressed because it is too large Load Diff
+3629
View File
File diff suppressed because it is too large Load Diff
+4741
View File
File diff suppressed because it is too large Load Diff
+3349
View File
File diff suppressed because it is too large Load Diff
+4619
View File
File diff suppressed because it is too large Load Diff
+3822
View File
File diff suppressed because it is too large Load Diff
+5921
View File
File diff suppressed because it is too large Load Diff
+3796
View File
File diff suppressed because it is too large Load Diff
+33 -18
View File
@@ -1,19 +1,24 @@
# README: Tcl
This is the **Tcl 9.1b1** source distribution.
This is the **Tcl 9.0a4** source distribution.
You can get any source release of Tcl from [our distribution
site](https://sourceforge.net/projects/tcl/files/Tcl/).
9.1 (in development, daily build)
[![Build Status](https://github.com/tcltk/tcl/actions/workflows/linux-build.yml/badge.svg?branch=main)](https://github.com/tcltk/tcl/actions/workflows/linux-build.yml?query=branch%3Amain)
[![Build Status](https://github.com/tcltk/tcl/actions/workflows/win-build.yml/badge.svg?branch=main)](https://github.com/tcltk/tcl/actions/workflows/win-build.yml?query=branch%3Amain)
[![Build Status](https://github.com/tcltk/tcl/actions/workflows/mac-build.yml/badge.svg?branch=main)](https://github.com/tcltk/tcl/actions/workflows/mac-build.yml?query=branch%3Amain)
8.6 (production release, daily build)
[![Build Status](https://github.com/tcltk/tcl/workflows/Linux/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22Linux%22+branch%3Acore-8-6-branch)
[![Build Status](https://github.com/tcltk/tcl/workflows/Windows/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22Windows%22+branch%3Acore-8-6-branch)
[![Build Status](https://github.com/tcltk/tcl/workflows/macOS/badge.svg?branch=core-8-6-branch)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22macOS%22+branch%3Acore-8-6-branch)
<br>
9.0 (production release, daily build)
[![Build Status](https://github.com/tcltk/tcl/actions/workflows/linux-build.yml/badge.svg?branch=core-9-0-branch)](https://github.com/tcltk/tcl/actions/workflows/linux-build.yml?query=branch%3Acore-9-0-branch)
[![Build Status](https://github.com/tcltk/tcl/actions/workflows/win-build.yml/badge.svg?branch=core-9-0-branch)](https://github.com/tcltk/tcl/actions/workflows/win-build.yml?query=branch%3Acore-9-0-branch)
[![Build Status](https://github.com/tcltk/tcl/actions/workflows/mac-build.yml/badge.svg?branch=core-9-0-branch)](https://github.com/tcltk/tcl/actions/workflows/mac-build.yml?query=branch%3Acore-9-0-branch)
8.7 (in development, daily build))
[![Build Status](https://github.com/tcltk/tcl/workflows/Linux/badge.svg?branch=core-8-branch)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22Linux%22+branch%3Acore-8-branch)
[![Build Status](https://github.com/tcltk/tcl/workflows/Windows/badge.svg?branch=core-8-branch)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22Windows%22+branch%3Acore-8-branch)
[![Build Status](https://github.com/tcltk/tcl/workflows/macOS/badge.svg?branch=core-8-branch)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22macOS%22+branch%3Acore-8-branch)
<br>
9.0 (in development, daily build))
[![Build Status](https://github.com/tcltk/tcl/workflows/Linux/badge.svg?branch=main)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22Linux%22+branch%3Amain)
[![Build Status](https://github.com/tcltk/tcl/workflows/Windows/badge.svg?branch=main)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22Windows%22+branch%3Amain)
[![Build Status](https://github.com/tcltk/tcl/workflows/macOS/badge.svg?branch=main)](https://github.com/tcltk/tcl/actions?query=workflow%3A%22macOS%22+branch%3Amain)
## Contents
1. [Introduction](#intro)
@@ -31,7 +36,7 @@ site](https://sourceforge.net/projects/tcl/files/Tcl/).
Tcl provides a powerful platform for creating integration applications that
tie together diverse applications, protocols, devices, and frameworks.
When paired with the Tk toolkit, Tcl provides the fastest and most powerful
way to create GUI applications that run on PCs, Unix, and macOS.
way to create GUI applications that run on PCs, Unix, and Mac OS X.
Tcl can also be used for a variety of web-related tasks and for creating
powerful command languages for applications.
@@ -51,7 +56,7 @@ and selling it either in whole or in part. See the file
## <a id="doc">2.</a> Documentation
Extensive documentation is available on our website.
The home page for this release, including new features, is
[here](https://www.tcl-lang.org/software/tcltk/9.1.html).
[here](https://www.tcl-lang.org/software/tcltk/9.0.html).
Detailed release notes can be found at the
[file distributions page](https://sourceforge.net/projects/tcl/files/Tcl/)
by clicking on the relevant version.
@@ -61,10 +66,10 @@ Xchange](https://www.tcl-lang.org/about/).
There have been many Tcl books on the market. Many are mentioned in
[the Wiki](https://wiki.tcl-lang.org/_/ref?N=25206).
The complete set of reference manual entries for Tcl 9.1 is [online,
here](https://www.tcl-lang.org/man/tcl9.1/).
The complete set of reference manual entries for Tcl 9.0 is [online,
here](https://www.tcl-lang.org/man/tcl9.0/).
### <a id="doc.unix"></a> Unix man pages
### <a id="doc.unix">2a.</a> Unix Documentation
The `doc` subdirectory in this release contains a complete set of
reference manual entries for Tcl. Files with extension "`.1`" are for
programs (for example, `tclsh.1`); files with extension "`.3`" are for C
@@ -82,17 +87,27 @@ normal "man" mechanisms, such as
man Tcl
### <a id="doc.win">2b.</a> Windows Documentation
The "doc" subdirectory in this release contains a complete set of Windows
help files for Tcl. Once you install this Tcl release, a shortcut to the
Windows help Tcl documentation will appear in the "Start" menu:
Start | Programs | Tcl | Tcl Help
## <a id="build">3.</a> Compiling and installing Tcl
There are brief notes in the `unix/README`, `win/README`, and `macosx/README`
about compiling on these different platforms. There is additional information
about building Tcl from sources
[online](https://www.tcl-lang.org/doc/howto/compile.html).
## <a id="news">4.</a> News feeds
## <a id="devtools">4.</a> Development tools
ActiveState produces a high-quality set of commercial quality development
tools that is available to accelerate your Tcl application development.
Tcl Dev Kit builds on the earlier TclPro toolset and provides a debugger,
static code checker, single-file wrapping utility, bytecode compiler, and
more. More information can be found at
You can keep up with the latest happenings in the Tcl world via
[fosstodon](https://fosstodon.org/@tcl_tk) or
[X](https://twitter.com/TclLang) feeds.
https://www.activestate.com/products/tcl/
## <a id="complangtcl">5.</a> Tcl newsgroup
There is a USENET newsgroup, "`comp.lang.tcl`", intended for the exchange of
+9466
View File
File diff suppressed because it is too large Load Diff
-69
View File
@@ -1,69 +0,0 @@
The source code for Tcl is managed by fossil. Tcl developers coordinate all
changes to the Tcl source code at
> [Tcl Source Code](https://core.tcl-lang.org/tcl/timeline)
Release Tcl 9.1b1 arises from the check-in with tag `core-9-1-b1`.
Highlighted differences between Tcl 9.1 and Tcl 9.0 are summarized below,
with focus on changes important to programmers using the Tcl library and
writing Tcl scripts.
# New commands and options
- [New options `-backslashes`, `-commands` and `-variables` for `subst` command](https://core.tcl-lang.org/tips/doc/trunk/tip/712.md)
- [New command `unicode` for Unicode normalization](https://core.tcl-lang.org/tips/doc/trunk/tip/726.md)
- [New `timer` command, switch to monotonic clock and microsecond resolution](https://core.tcl-lang.org/tips/doc/trunk/tip/723.md)
- [Remove `expr` behavior from `lseq`](https://core.tcl-lang.org/tips/doc/trunk/tip/746.md) *Incompatibility*
- [File paths are now treated as case-insensitive on MacOS](https://core.tcl-lang.org/tcl/tktview/e6ca0b1b) *Incompatibility*
- New command `tcl::registry` as a synonym for the `registry` command without needing
the registry package to be loaded. The registry module is now part of the core
Tcl DLL in all build configurations.
- [New `lfilter` command for selecting items from a list](https://core.tcl-lang.org/tips/doc/trunk/tip/735.md)
- [Many new functions from C99](https://core.tcl-lang.org/tips/doc/trunk/tip/745.md), specifically: `acosh()`, `asinh()`, `atanh()`, `cbrt()`, `copysign()`, `dim()`, `erf()`, `erfc()`, `exp2()`, `expm1()`, `fma()`, `gamma()`, `ldexp()`, `lgamma()`, `log1p()`, `log2()`, `logb()`, `nextafter()`, `remainder()`, `signbit()`, and `trunc()`, and (for functions that return multiple values in their C99 API) the commands: `divmod`, `frexp`, `modf`, and `remquo`. (See [this page](https://en.cppreference.com/w/c/numeric/math.html) for more information about these functions; the Tcl functions are _intentionally_ only thin wrappers around the functions in the C99 standard.)
- [New `switch` option `-integer` to compare values as integers](https://core.tcl-lang.org/tips/doc/trunk/tip/730.md)
- [Reading and writing of child interpreter variables](https://core.tcl-lang.org/tips/doc/trunk/tip/728.md)
- [Updated Tcl Bytecode opcodes](https://core.tcl-lang.org/tips/doc/trunk/tip/720.md)
- New `tcltest::configure` option `-iterations` to control number of iterations of each test.
# New public C API
- [`Tcl_IsEmpty()` &mdash; checks if the string representation of a value would be the empty string](https://core.tcl-lang.org/tips/doc/trunk/tip/711.md)
- [`Tcl_GetEncodingNameForUser()` &mdash; returns name of encoding from user settings](https://core.tcl-lang.org/tips/doc/trunk/tip/716.md)
- [`Tcl_AttemptCreateHashEntry()` &mdash; version of `Tcl_CreateHashEntry()` that returns NULL instead of panic'ing on memory allocation errors](https://core.tcl-lang.org/tips/doc/trunk/tip/717.md)
- [`Tcl_ListObjRange()`, `Tcl_ListObjRepeat()`, `Tcl_ListObjReverse()` &mdash; C API for new list operations](https://core.tcl-lang.org/tips/doc/trunk/tip/649.md)
- [`Tcl_UtfToNormalized()`, `Tcl_UtfToNormalizedDString()` &mdash; C API for Unicode normalization](https://core.tcl-lang.org/tips/doc/trunk/tip/726.md)
- [`Tcl_UtfToExternalEx()` and `Tcl_ExternalToUtfEx()` &mdash; C encoding API supporting output buffers larger than INT_MAX](https://core.tcl-lang.org/tips/doc/trunk/tip/737.md)
- [New API for monotonic clock and microseconds resolution](https://core.tcl-lang.org/tips/doc/trunk/tip/723.md)
- [Windows `auto_execok` enhancements and `exec` search reform](https://core.tcl-lang.org/tips/doc/trunk/tip/753.md)
- [New timer API using long long in stead of Tcl_Time](https://core.tcl-lang.org/tips/doc/trunk/tip/752.md)
# Changes in interpreter initialization
- [Custom applications must call Tcl\_FindExecutable or TclZipfs_AppHook to initialize Tcl](https://core.tcl-lang.org/tips/doc/trunk/tip/732.md) *Potential incompatibility*
- [Search path for locating Tcl core script and encodings is changed](https://core.tcl-lang.org/tips/doc/trunk/tip/732.md) *Potential incompatibility*
- [`Tcl_RegisterPostInitProc` callback for post-initialization of interpreters](https://core.tcl-lang.org/tips/doc/trunk/tip/755.md)
# Performance
- [Memory efficient internal representations](https://core.tcl-lang.org/tcl/wiki?name=New+abstract+list+representations)
for list operations on large lists.
- [Continued 64-bit capacity: Command line arguments larger than 2Gb](https://core.tcl-lang.org/tips/doc/trunk/tip/626.md)
- [Support for long paths on Windows](https://core.tcl-lang.org/tips/doc/trunk/tip/744.md)
- [Faster UTF-8 encoding and I/O](https://core.tcl-lang.org/tcl/wiki?name=Faster+UTF+encoding)
- Faster interpreter creation
# Bug fixes
- [Inconsistent `glob` matching on MacOS](https://core.tcl-lang.org/tcl/tktview/e6ca0b1b)
- [`file normalize` does not uniquely identify a file on MacOS](https://core.tcl-lang.org/tcl/tktview/10890417)
- [Inconsistencies between `cd` and `file normalize` for volume-relative paths on Windows](https://core.tcl-lang.org/tcl/tktview/bca391ab)
- [Tcl cannot run from an arbitrary build directory with --disable-zipfs](https://core.tcl-lang.org/tcl/tktview/006bef5d)
- [Crash on finalization with an active thread running.](https://core.tcl-lang.org/tcl/tktview/e55a589d)
- [Crash on use-after-free in Windows socket thread.](https://core.tcl-lang.org/tcl/tktview/06f19cc4)
# Updated bundled packages, libraries, standards, data
- Unicode 18.0.0 (draft)
- platorm 1.2b1
+21
View File
@@ -0,0 +1,21 @@
/*
* dirent.h --
*
* This file is a replacement for <dirent.h> in systems that
* support the old BSD-style <sys/dir.h> with a "struct direct".
*
* Copyright (c) 1991 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _DIRENT
#define _DIRENT
#include <sys/dir.h>
#define dirent direct
#endif /* _DIRENT */
+53
View File
@@ -0,0 +1,53 @@
/*
* dirent.h --
*
* Declarations of a library of directory-reading procedures
* in the POSIX style ("struct dirent").
*
* Copyright (c) 1991 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _DIRENT
#define _DIRENT
/*
* Dirent structure, which holds information about a single
* directory entry.
*/
#define MAXNAMLEN 255
#define DIRBLKSIZ 512
struct dirent {
long d_ino; /* Inode number of entry */
short d_reclen; /* Length of this record */
short d_namlen; /* Length of string in d_name */
char d_name[MAXNAMLEN + 1]; /* Name must be no longer than this */
};
/*
* State that keeps track of the reading of a directory (clients
* should never look inside this structure; the fields should
* only be accessed by the library procedures).
*/
typedef struct _dirdesc {
int dd_fd;
long dd_loc;
long dd_size;
char dd_buf[DIRBLKSIZ];
} DIR;
/*
* Procedures defined for reading directories:
*/
extern void closedir (DIR *dirp);
extern DIR * opendir (char *name);
extern struct dirent * readdir (DIR *dirp);
#endif /* _DIRENT */
+19 -19
View File
@@ -43,32 +43,32 @@ TCL_DECLARE_MUTEX(netdbMutex)
static size_t
strlcpy(char *dst, const char *src, size_t siz)
{
char *d = dst;
const char *s = src;
size_t n = siz;
char *d = dst;
const char *s = src;
size_t n = siz;
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0) {
do {
if ((*d++ = *s++) == 0)
break;
} while (--n != 0);
}
/* Copy as many bytes as will fit */
if (n != 0 && --n != 0) {
do {
if ((*d++ = *s++) == 0)
break;
} while (--n != 0);
}
/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0) {
if (siz != 0)
*d = '\0'; /* NUL-terminate dst */
while (*s++)
;
}
/* Not enough room in dst, add NUL and traverse rest of src */
if (n == 0) {
if (siz != 0)
*d = '\0'; /* NUL-terminate dst */
while (*s++)
;
}
return(s - src - 1); /* count does not include NUL */
return(s - src - 1); /* count does not include NUL */
}
#endif
int fake_getnameinfo(const struct sockaddr *sa, size_t salen, char *host,
size_t hostlen, char *serv, size_t servlen, int flags)
size_t hostlen, char *serv, size_t servlen, int flags)
{
struct sockaddr_in *sin = (struct sockaddr_in *)sa;
struct hostent *hp;
+1 -1
View File
@@ -4,7 +4,7 @@
* This file provides the gettimeofday function on systems
* that only have the System V ftime function.
*
* Copyright © 1995 Sun Microsystems, Inc.
* Copyright (c) 1995 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
+64
View File
@@ -0,0 +1,64 @@
/*
* memcmp.c --
*
* Source code for the "memcmp" library routine.
*
* Copyright (c) 1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tclPort.h"
/*
* Here is the prototype just in case it is not included in tclPort.h.
*/
int memcmp(const void *s1, const void *s2, size_t n);
/*
*----------------------------------------------------------------------
*
* memcmp --
*
* Compares two bytes sequences.
*
* Results:
* Compares its arguments, looking at the first n bytes (each interpreted
* as an unsigned char), and returns an integer less than, equal to, or
* greater than 0, according as s1 is less than, equal to, or greater
* than s2 when taken to be unsigned 8 bit numbers.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
int
memcmp(
const void *s1, /* First string. */
const void *s2, /* Second string. */
size_t n) /* Length to compare. */
{
const unsigned char *ptr1 = (const unsigned char *) s1;
const unsigned char *ptr2 = (const unsigned char *) s2;
for ( ; n-- ; ptr1++, ptr2++) {
unsigned char u1 = *ptr1, u2 = *ptr2;
if (u1 != u2) {
return (u1-u2);
}
}
return 0;
}
/*
* Local Variables:
* mode: c
* c-basic-offset: 4
* fill-column: 78
* End:
*/
+1 -1
View File
@@ -3,7 +3,7 @@
*
* Source code for the "mkstemp" library routine.
*
* Copyright © 2009 Donal K. Fellows
* Copyright (c) 2009 Donal K. Fellows
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
+110
View File
@@ -0,0 +1,110 @@
/*
* opendir.c --
*
* This file provides dirent-style directory-reading procedures for V7
* Unix systems that don't have such procedures. The origin of this code
* is unclear, but it seems to have come originally from Larry Wall.
*/
#include "tclInt.h"
#undef DIRSIZ
#define DIRSIZ(dp) \
((sizeof(struct dirent) - (MAXNAMLEN+1)) + (((dp)->d_namlen+1 + 3) &~ 3))
/*
* open a directory.
*/
DIR *
opendir(
char *name)
{
DIR *dirp;
int fd;
const char *myname;
myname = ((*name == '\0') ? "." : name);
if ((fd = open(myname, 0, 0)) == -1) {
return NULL;
}
dirp = (DIR *) Tcl_Alloc(sizeof(DIR));
if (dirp == NULL) {
/* unreachable? */
close(fd);
return NULL;
}
dirp->dd_fd = fd;
dirp->dd_loc = 0;
return dirp;
}
/*
* read an old style directory entry and present it as a new one
*/
#ifndef pyr
#define ODIRSIZ 14
struct olddirect {
ino_t od_ino;
char od_name[ODIRSIZ];
};
#else /* a Pyramid in the ATT universe */
#define ODIRSIZ 248
struct olddirect {
long od_ino;
short od_fill1, od_fill2;
char od_name[ODIRSIZ];
};
#endif
/*
* get next entry in a directory.
*/
struct dirent *
readdir(
DIR *dirp)
{
struct olddirect *dp;
static struct dirent dir;
for (;;) {
if (dirp->dd_loc == 0) {
dirp->dd_size = read(dirp->dd_fd, dirp->dd_buf, DIRBLKSIZ);
if (dirp->dd_size <= 0) {
return NULL;
}
}
if (dirp->dd_loc >= dirp->dd_size) {
dirp->dd_loc = 0;
continue;
}
dp = (struct olddirect *)(dirp->dd_buf + dirp->dd_loc);
dirp->dd_loc += sizeof(struct olddirect);
if (dp->od_ino == 0) {
continue;
}
dir.d_ino = dp->od_ino;
strncpy(dir.d_name, dp->od_name, ODIRSIZ);
dir.d_name[ODIRSIZ] = '\0'; /* insure null termination */
dir.d_namlen = strlen(dir.d_name);
dir.d_reclen = DIRSIZ(&dir);
return &dir;
}
}
/*
* close a directory.
*/
void
closedir(
DIR *dirp)
{
close(dirp->dd_fd);
dirp->dd_fd = -1;
dirp->dd_loc = 0;
Tcl_Free(dirp);
}
+919
View File
@@ -0,0 +1,919 @@
/* A portable stdint.h
****************************************************************************
* BSD License:
****************************************************************************
*
* Copyright (c) 2005-2016 Paul Hsieh
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* 1. Redistributions of source code must retain the above copyright
* 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.
* 3. The name of the author may not be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
* NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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.
*
****************************************************************************
*
* Version 0.1.16.0
*
* The ANSI C standard committee, for the C99 standard, specified the
* inclusion of a new standard include file called stdint.h. This is
* a very useful and long desired include file which contains several
* very precise definitions for integer scalar types that is critically
* important for making several classes of applications portable
* including cryptography, hashing, variable length integer libraries
* and so on. But for most developers its likely useful just for
* programming sanity.
*
* The problem is that some compiler vendors chose to ignore the C99
* standard and some older compilers have no opportunity to be updated.
* Because of this situation, simply including stdint.h in your code
* makes it unportable.
*
* So that's what this file is all about. It's an attempt to build a
* single universal include file that works on as many platforms as
* possible to deliver what stdint.h is supposed to. Even compilers
* that already come with stdint.h can use this file instead without
* any loss of functionality. A few things that should be noted about
* this file:
*
* 1) It is not guaranteed to be portable and/or present an identical
* interface on all platforms. The extreme variability of the
* ANSI C standard makes this an impossibility right from the
* very get go. Its really only meant to be useful for the vast
* majority of platforms that possess the capability of
* implementing usefully and precisely defined, standard sized
* integer scalars. Systems which are not intrinsically 2s
* complement may produce invalid constants.
*
* 2) There is an unavoidable use of non-reserved symbols.
*
* 3) Other standard include files are invoked.
*
* 4) This file may come in conflict with future platforms that do
* include stdint.h. The hope is that one or the other can be
* used with no real difference.
*
* 5) In the current version, if your platform can't represent
* int32_t, int16_t and int8_t, it just dumps out with a compiler
* error.
*
* 6) 64 bit integers may or may not be defined. Test for their
* presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
* Note that this is different from the C99 specification which
* requires the existence of 64 bit support in the compiler. If
* this is not defined for your platform, yet it is capable of
* dealing with 64 bits then it is because this file has not yet
* been extended to cover all of your system's capabilities.
*
* 7) (u)intptr_t may or may not be defined. Test for its presence
* with the test: #ifdef PTRDIFF_MAX. If this is not defined
* for your platform, then it is because this file has not yet
* been extended to cover all of your system's capabilities, not
* because its optional.
*
* 8) The following might not been defined even if your platform is
* capable of defining it:
*
* WCHAR_MIN
* WCHAR_MAX
* (u)int64_t
* PTRDIFF_MIN
* PTRDIFF_MAX
* (u)intptr_t
*
* 9) The following have not been defined:
*
* WINT_MIN
* WINT_MAX
*
* 10) The criteria for defining (u)int_least(*)_t isn't clear,
* except for systems which don't have a type that precisely
* defined 8, 16, or 32 bit types (which this include file does
* not support anyways). Default definitions have been given.
*
* 11) The criteria for defining (u)int_fast(*)_t isn't something I
* would trust to any particular compiler vendor or the ANSI C
* committee. It is well known that "compatible systems" are
* commonly created that have very different performance
* characteristics from the systems they are compatible with,
* especially those whose vendors make both the compiler and the
* system. Default definitions have been given, but its strongly
* recommended that users never use these definitions for any
* reason (they do *NOT* deliver any serious guarantee of
* improved performance -- not in this file, nor any vendor's
* stdint.h).
*
* 12) The following macros:
*
* PRINTF_INTMAX_MODIFIER
* PRINTF_INT64_MODIFIER
* PRINTF_INT32_MODIFIER
* PRINTF_INT16_MODIFIER
* PRINTF_LEAST64_MODIFIER
* PRINTF_LEAST32_MODIFIER
* PRINTF_LEAST16_MODIFIER
* PRINTF_INTPTR_MODIFIER
*
* are strings which have been defined as the modifiers required
* for the "d", "u" and "x" printf formats to correctly output
* (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
* (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
* PRINTF_INTPTR_MODIFIER is not defined for some systems which
* provide their own stdint.h. PRINTF_INT64_MODIFIER is not
* defined if INT64_MAX is not defined. These are an extension
* beyond what C99 specifies must be in stdint.h.
*
* In addition, the following macros are defined:
*
* PRINTF_INTMAX_HEX_WIDTH
* PRINTF_INT64_HEX_WIDTH
* PRINTF_INT32_HEX_WIDTH
* PRINTF_INT16_HEX_WIDTH
* PRINTF_INT8_HEX_WIDTH
* PRINTF_INTMAX_DEC_WIDTH
* PRINTF_INT64_DEC_WIDTH
* PRINTF_INT32_DEC_WIDTH
* PRINTF_INT16_DEC_WIDTH
* PRINTF_UINT8_DEC_WIDTH
* PRINTF_UINTMAX_DEC_WIDTH
* PRINTF_UINT64_DEC_WIDTH
* PRINTF_UINT32_DEC_WIDTH
* PRINTF_UINT16_DEC_WIDTH
* PRINTF_UINT8_DEC_WIDTH
*
* Which specifies the maximum number of characters required to
* print the number of that type in either hexadecimal or decimal.
* These are an extension beyond what C99 specifies must be in
* stdint.h.
*
* Compilers tested (all with 0 warnings at their highest respective
* settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
* bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
* .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
*
* This file should be considered a work in progress. Suggestions for
* improvements, especially those which increase coverage are strongly
* encouraged.
*
* Acknowledgements
*
* The following people have made significant contributions to the
* development and testing of this file:
*
* Chris Howie
* John Steele Scott
* Dave Thorup
* John Dill
* Florian Wobbe
* Christopher Sean Morrison
* Mikkel Fahnoe Jorgensen
*
*/
#include <stddef.h>
#include <limits.h>
#include <signal.h>
/*
* For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
* do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
*/
#if ((defined(__SUNPRO_C) && __SUNPRO_C >= 0x570) || (defined(_MSC_VER) && _MSC_VER >= 1600) || (defined(__STDC__) && __STDC__ && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (__GNUC__ > 3 || defined(_STDINT_H) || defined(_STDINT_H_) || defined (__UINT_FAST64_TYPE__)) )) && !defined (_PSTDINT_H_INCLUDED)
#include <stdint.h>
#define _PSTDINT_H_INCLUDED
# if defined(__GNUC__) && (defined(__x86_64__) || defined(__ppc64__)) && !(defined(__APPLE__) && defined(__MACH__))
# ifndef PRINTF_INT64_MODIFIER
# define PRINTF_INT64_MODIFIER "l"
# endif
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER ""
# endif
# else
# ifndef PRINTF_INT64_MODIFIER
# define PRINTF_INT64_MODIFIER "ll"
# endif
# ifndef PRINTF_INT32_MODIFIER
# if (UINT_MAX == UINT32_MAX)
# define PRINTF_INT32_MODIFIER ""
# else
# define PRINTF_INT32_MODIFIER "l"
# endif
# endif
# endif
# ifndef PRINTF_INT16_MODIFIER
# define PRINTF_INT16_MODIFIER "h"
# endif
# ifndef PRINTF_INTMAX_MODIFIER
# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
# endif
# ifndef PRINTF_INT64_HEX_WIDTH
# define PRINTF_INT64_HEX_WIDTH "16"
# endif
# ifndef PRINTF_UINT64_HEX_WIDTH
# define PRINTF_UINT64_HEX_WIDTH "16"
# endif
# ifndef PRINTF_INT32_HEX_WIDTH
# define PRINTF_INT32_HEX_WIDTH "8"
# endif
# ifndef PRINTF_UINT32_HEX_WIDTH
# define PRINTF_UINT32_HEX_WIDTH "8"
# endif
# ifndef PRINTF_INT16_HEX_WIDTH
# define PRINTF_INT16_HEX_WIDTH "4"
# endif
# ifndef PRINTF_UINT16_HEX_WIDTH
# define PRINTF_UINT16_HEX_WIDTH "4"
# endif
# ifndef PRINTF_INT8_HEX_WIDTH
# define PRINTF_INT8_HEX_WIDTH "2"
# endif
# ifndef PRINTF_UINT8_HEX_WIDTH
# define PRINTF_UINT8_HEX_WIDTH "2"
# endif
# ifndef PRINTF_INT64_DEC_WIDTH
# define PRINTF_INT64_DEC_WIDTH "19"
# endif
# ifndef PRINTF_UINT64_DEC_WIDTH
# define PRINTF_UINT64_DEC_WIDTH "20"
# endif
# ifndef PRINTF_INT32_DEC_WIDTH
# define PRINTF_INT32_DEC_WIDTH "10"
# endif
# ifndef PRINTF_UINT32_DEC_WIDTH
# define PRINTF_UINT32_DEC_WIDTH "10"
# endif
# ifndef PRINTF_INT16_DEC_WIDTH
# define PRINTF_INT16_DEC_WIDTH "5"
# endif
# ifndef PRINTF_UINT16_DEC_WIDTH
# define PRINTF_UINT16_DEC_WIDTH "5"
# endif
# ifndef PRINTF_INT8_DEC_WIDTH
# define PRINTF_INT8_DEC_WIDTH "3"
# endif
# ifndef PRINTF_UINT8_DEC_WIDTH
# define PRINTF_UINT8_DEC_WIDTH "3"
# endif
# ifndef PRINTF_INTMAX_HEX_WIDTH
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
# endif
# ifndef PRINTF_UINTMAX_HEX_WIDTH
# define PRINTF_UINTMAX_HEX_WIDTH PRINTF_UINT64_HEX_WIDTH
# endif
# ifndef PRINTF_INTMAX_DEC_WIDTH
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
# endif
# ifndef PRINTF_UINTMAX_DEC_WIDTH
# define PRINTF_UINTMAX_DEC_WIDTH PRINTF_UINT64_DEC_WIDTH
# endif
/*
* Something really weird is going on with Open Watcom. Just pull some of
* these duplicated definitions from Open Watcom's stdint.h file for now.
*/
# if defined (__WATCOMC__) && __WATCOMC__ >= 1250
# if !defined (INT64_C)
# define INT64_C(x) (x + (INT64_MAX - INT64_MAX))
# endif
# if !defined (UINT64_C)
# define UINT64_C(x) (x + (UINT64_MAX - UINT64_MAX))
# endif
# if !defined (INT32_C)
# define INT32_C(x) (x + (INT32_MAX - INT32_MAX))
# endif
# if !defined (UINT32_C)
# define UINT32_C(x) (x + (UINT32_MAX - UINT32_MAX))
# endif
# if !defined (INT16_C)
# define INT16_C(x) (x)
# endif
# if !defined (UINT16_C)
# define UINT16_C(x) (x)
# endif
# if !defined (INT8_C)
# define INT8_C(x) (x)
# endif
# if !defined (UINT8_C)
# define UINT8_C(x) (x)
# endif
# if !defined (UINT64_MAX)
# define UINT64_MAX 18446744073709551615ULL
# endif
# if !defined (INT64_MAX)
# define INT64_MAX 9223372036854775807LL
# endif
# if !defined (UINT32_MAX)
# define UINT32_MAX 4294967295UL
# endif
# if !defined (INT32_MAX)
# define INT32_MAX 2147483647L
# endif
# if !defined (INTMAX_MAX)
# define INTMAX_MAX INT64_MAX
# endif
# if !defined (INTMAX_MIN)
# define INTMAX_MIN INT64_MIN
# endif
# endif
#endif
/*
* I have no idea what is the truly correct thing to do on older Solaris.
* From some online discussions, this seems to be what is being
* recommended. For people who actually are developing on older Solaris,
* what I would like to know is, does this define all of the relevant
* macros of a complete stdint.h? Remember, in pstdint.h 64 bit is
* considered optional.
*/
#if (defined(__SUNPRO_C) && __SUNPRO_C >= 0x420) && !defined(_PSTDINT_H_INCLUDED)
#include <sys/inttypes.h>
#define _PSTDINT_H_INCLUDED
#endif
#ifndef _PSTDINT_H_INCLUDED
#define _PSTDINT_H_INCLUDED
#ifndef SIZE_MAX
# define SIZE_MAX ((size_t)-1)
#endif
/*
* Deduce the type assignments from limits.h under the assumption that
* integer sizes in bits are powers of 2, and follow the ANSI
* definitions.
*/
#ifndef UINT8_MAX
# define UINT8_MAX 0xff
#endif
#if !defined(uint8_t) && !defined(_UINT8_T) && !defined(vxWorks)
# if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
typedef unsigned char uint8_t;
# define UINT8_C(v) ((uint8_t) v)
# else
# error "Platform not supported"
# endif
#endif
#ifndef INT8_MAX
# define INT8_MAX 0x7f
#endif
#ifndef INT8_MIN
# define INT8_MIN INT8_C(0x80)
#endif
#if !defined(int8_t) && !defined(_INT8_T) && !defined(vxWorks)
# if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
typedef signed char int8_t;
# define INT8_C(v) ((int8_t) v)
# else
# error "Platform not supported"
# endif
#endif
#ifndef UINT16_MAX
# define UINT16_MAX 0xffff
#endif
#if !defined(uint16_t) && !defined(_UINT16_T) && !defined(vxWorks)
#if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
typedef unsigned int uint16_t;
# ifndef PRINTF_INT16_MODIFIER
# define PRINTF_INT16_MODIFIER ""
# endif
# define UINT16_C(v) ((uint16_t) (v))
#elif (USHRT_MAX == UINT16_MAX)
typedef unsigned short uint16_t;
# define UINT16_C(v) ((uint16_t) (v))
# ifndef PRINTF_INT16_MODIFIER
# define PRINTF_INT16_MODIFIER "h"
# endif
#else
#error "Platform not supported"
#endif
#endif
#ifndef INT16_MAX
# define INT16_MAX 0x7fff
#endif
#ifndef INT16_MIN
# define INT16_MIN INT16_C(0x8000)
#endif
#if !defined(int16_t) && !defined(_INT16_T) && !defined(vxWorks)
#if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
typedef signed int int16_t;
# define INT16_C(v) ((int16_t) (v))
# ifndef PRINTF_INT16_MODIFIER
# define PRINTF_INT16_MODIFIER ""
# endif
#elif (SHRT_MAX == INT16_MAX)
typedef signed short int16_t;
# define INT16_C(v) ((int16_t) (v))
# ifndef PRINTF_INT16_MODIFIER
# define PRINTF_INT16_MODIFIER "h"
# endif
#else
#error "Platform not supported"
#endif
#endif
#ifndef UINT32_MAX
# define UINT32_MAX (0xffffffffUL)
#endif
#if !defined(uint32_t) && !defined(_UINT32_T) && !defined(vxWorks)
#if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
typedef unsigned long uint32_t;
# define UINT32_C(v) v ## UL
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER "l"
# endif
#elif (UINT_MAX == UINT32_MAX)
typedef unsigned int uint32_t;
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER ""
# endif
# define UINT32_C(v) v ## U
#elif (USHRT_MAX == UINT32_MAX)
typedef unsigned short uint32_t;
# define UINT32_C(v) ((unsigned short) (v))
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER ""
# endif
#else
#error "Platform not supported"
#endif
#endif
#ifndef INT32_MAX
# define INT32_MAX (0x7fffffffL)
#endif
#ifndef INT32_MIN
# define INT32_MIN INT32_C(0x80000000)
#endif
#if !defined(int32_t) && !defined(_INT32_T) && !defined(vxWorks)
#if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
typedef signed long int32_t;
# define INT32_C(v) v ## L
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER "l"
# endif
#elif (INT_MAX == INT32_MAX)
typedef signed int int32_t;
# define INT32_C(v) v
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER ""
# endif
#elif (SHRT_MAX == INT32_MAX)
typedef signed short int32_t;
# define INT32_C(v) ((short) (v))
# ifndef PRINTF_INT32_MODIFIER
# define PRINTF_INT32_MODIFIER ""
# endif
#else
#error "Platform not supported"
#endif
#endif
/*
* The macro stdint_int64_defined is temporarily used to record
* whether or not 64 integer support is available. It must be
* defined for any 64 integer extensions for new platforms that are
* added.
*/
#undef stdint_int64_defined
#if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
# if (__STDC__ && __STDC_VERSION__ >= 199901L) || defined (S_SPLINT_S)
# define stdint_int64_defined
typedef long long int64_t;
typedef unsigned long long uint64_t;
# define UINT64_C(v) v ## ULL
# define INT64_C(v) v ## LL
# ifndef PRINTF_INT64_MODIFIER
# define PRINTF_INT64_MODIFIER "ll"
# endif
# endif
#endif
#if !defined (stdint_int64_defined)
# if defined(__GNUC__) && !defined(vxWorks)
# define stdint_int64_defined
__extension__ typedef long long int64_t;
__extension__ typedef unsigned long long uint64_t;
# define UINT64_C(v) v ## ULL
# define INT64_C(v) v ## LL
# ifndef PRINTF_INT64_MODIFIER
# define PRINTF_INT64_MODIFIER "ll"
# endif
# elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
# define stdint_int64_defined
typedef long long int64_t;
typedef unsigned long long uint64_t;
# define UINT64_C(v) v ## ULL
# define INT64_C(v) v ## LL
# ifndef PRINTF_INT64_MODIFIER
# define PRINTF_INT64_MODIFIER "ll"
# endif
# elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
# define stdint_int64_defined
typedef __int64 int64_t;
typedef unsigned __int64 uint64_t;
# define UINT64_C(v) v ## UI64
# define INT64_C(v) v ## I64
# ifndef PRINTF_INT64_MODIFIER
# define PRINTF_INT64_MODIFIER "I64"
# endif
# endif
#endif
#if !defined (LONG_LONG_MAX) && defined (INT64_C)
# define LONG_LONG_MAX INT64_C (9223372036854775807)
#endif
#ifndef ULONG_LONG_MAX
# define ULONG_LONG_MAX UINT64_C (18446744073709551615)
#endif
#if !defined (INT64_MAX) && defined (INT64_C)
# define INT64_MAX INT64_C (9223372036854775807)
#endif
#if !defined (INT64_MIN) && defined (INT64_C)
# define INT64_MIN INT64_C (-9223372036854775808)
#endif
#if !defined (UINT64_MAX) && defined (INT64_C)
# define UINT64_MAX UINT64_C (18446744073709551615)
#endif
/*
* Width of hexadecimal for number field.
*/
#ifndef PRINTF_INT64_HEX_WIDTH
# define PRINTF_INT64_HEX_WIDTH "16"
#endif
#ifndef PRINTF_INT32_HEX_WIDTH
# define PRINTF_INT32_HEX_WIDTH "8"
#endif
#ifndef PRINTF_INT16_HEX_WIDTH
# define PRINTF_INT16_HEX_WIDTH "4"
#endif
#ifndef PRINTF_INT8_HEX_WIDTH
# define PRINTF_INT8_HEX_WIDTH "2"
#endif
#ifndef PRINTF_INT64_DEC_WIDTH
# define PRINTF_INT64_DEC_WIDTH "19"
#endif
#ifndef PRINTF_INT32_DEC_WIDTH
# define PRINTF_INT32_DEC_WIDTH "10"
#endif
#ifndef PRINTF_INT16_DEC_WIDTH
# define PRINTF_INT16_DEC_WIDTH "5"
#endif
#ifndef PRINTF_INT8_DEC_WIDTH
# define PRINTF_INT8_DEC_WIDTH "3"
#endif
#ifndef PRINTF_UINT64_DEC_WIDTH
# define PRINTF_UINT64_DEC_WIDTH "20"
#endif
#ifndef PRINTF_UINT32_DEC_WIDTH
# define PRINTF_UINT32_DEC_WIDTH "10"
#endif
#ifndef PRINTF_UINT16_DEC_WIDTH
# define PRINTF_UINT16_DEC_WIDTH "5"
#endif
#ifndef PRINTF_UINT8_DEC_WIDTH
# define PRINTF_UINT8_DEC_WIDTH "3"
#endif
/*
* Ok, lets not worry about 128 bit integers for now. Moore's law says
* we don't need to worry about that until about 2040 at which point
* we'll have bigger things to worry about.
*/
#ifdef stdint_int64_defined
typedef int64_t intmax_t;
typedef uint64_t uintmax_t;
# define INTMAX_MAX INT64_MAX
# define INTMAX_MIN INT64_MIN
# define UINTMAX_MAX UINT64_MAX
# define UINTMAX_C(v) UINT64_C(v)
# define INTMAX_C(v) INT64_C(v)
# ifndef PRINTF_INTMAX_MODIFIER
# define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
# endif
# ifndef PRINTF_INTMAX_HEX_WIDTH
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
# endif
# ifndef PRINTF_INTMAX_DEC_WIDTH
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
# endif
#else
typedef int32_t intmax_t;
typedef uint32_t uintmax_t;
# define INTMAX_MAX INT32_MAX
# define UINTMAX_MAX UINT32_MAX
# define UINTMAX_C(v) UINT32_C(v)
# define INTMAX_C(v) INT32_C(v)
# ifndef PRINTF_INTMAX_MODIFIER
# define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
# endif
# ifndef PRINTF_INTMAX_HEX_WIDTH
# define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
# endif
# ifndef PRINTF_INTMAX_DEC_WIDTH
# define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
# endif
#endif
/*
* Because this file currently only supports platforms which have
* precise powers of 2 as bit sizes for the default integers, the
* least definitions are all trivial. Its possible that a future
* version of this file could have different definitions.
*/
#ifndef stdint_least_defined
typedef int8_t int_least8_t;
typedef uint8_t uint_least8_t;
typedef int16_t int_least16_t;
typedef uint16_t uint_least16_t;
typedef int32_t int_least32_t;
typedef uint32_t uint_least32_t;
# define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
# define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
# define UINT_LEAST8_MAX UINT8_MAX
# define INT_LEAST8_MAX INT8_MAX
# define UINT_LEAST16_MAX UINT16_MAX
# define INT_LEAST16_MAX INT16_MAX
# define UINT_LEAST32_MAX UINT32_MAX
# define INT_LEAST32_MAX INT32_MAX
# define INT_LEAST8_MIN INT8_MIN
# define INT_LEAST16_MIN INT16_MIN
# define INT_LEAST32_MIN INT32_MIN
# ifdef stdint_int64_defined
typedef int64_t int_least64_t;
typedef uint64_t uint_least64_t;
# define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
# define UINT_LEAST64_MAX UINT64_MAX
# define INT_LEAST64_MAX INT64_MAX
# define INT_LEAST64_MIN INT64_MIN
# endif
#endif
#undef stdint_least_defined
/*
* The ANSI C committee has defined *int*_fast*_t types as well. This,
* of course, defies rationality -- you can't know what will be fast
* just from the type itself. Even for a given architecture, compatible
* implementations might have different performance characteristics.
* Developers are warned to stay away from these types when using this
* or any other stdint.h.
*/
typedef int_least8_t int_fast8_t;
typedef uint_least8_t uint_fast8_t;
typedef int_least16_t int_fast16_t;
typedef uint_least16_t uint_fast16_t;
typedef int_least32_t int_fast32_t;
typedef uint_least32_t uint_fast32_t;
#define UINT_FAST8_MAX UINT_LEAST8_MAX
#define INT_FAST8_MAX INT_LEAST8_MAX
#define UINT_FAST16_MAX UINT_LEAST16_MAX
#define INT_FAST16_MAX INT_LEAST16_MAX
#define UINT_FAST32_MAX UINT_LEAST32_MAX
#define INT_FAST32_MAX INT_LEAST32_MAX
#define INT_FAST8_MIN INT_LEAST8_MIN
#define INT_FAST16_MIN INT_LEAST16_MIN
#define INT_FAST32_MIN INT_LEAST32_MIN
#ifdef stdint_int64_defined
typedef int_least64_t int_fast64_t;
typedef uint_least64_t uint_fast64_t;
# define UINT_FAST64_MAX UINT_LEAST64_MAX
# define INT_FAST64_MAX INT_LEAST64_MAX
# define INT_FAST64_MIN INT_LEAST64_MIN
#endif
#undef stdint_int64_defined
/*
* Whatever piecemeal, per compiler thing we can do about the wchar_t
* type limits.
*/
#if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__) && !defined(vxWorks)
# include <wchar.h>
# ifndef WCHAR_MIN
# define WCHAR_MIN 0
# endif
# ifndef WCHAR_MAX
# define WCHAR_MAX ((wchar_t)-1)
# endif
#endif
/*
* Whatever piecemeal, per compiler/platform thing we can do about the
* (u)intptr_t types and limits.
*/
#if (defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)) || defined (_UINTPTR_T)
# define STDINT_H_UINTPTR_T_DEFINED
#endif
#ifndef STDINT_H_UINTPTR_T_DEFINED
# if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64) || defined (__ppc64__)
# define stdint_intptr_bits 64
# elif defined (__WATCOMC__) || defined (__TURBOC__)
# if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
# define stdint_intptr_bits 16
# else
# define stdint_intptr_bits 32
# endif
# elif defined (__i386__) || defined (_WIN32) || defined (WIN32) || defined (__ppc64__)
# define stdint_intptr_bits 32
# elif defined (__INTEL_COMPILER)
/* TODO -- what did Intel do about x86-64? */
# else
/* #error "This platform might not be supported yet" */
# endif
# ifdef stdint_intptr_bits
# define stdint_intptr_glue3_i(a,b,c) a##b##c
# define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
# ifndef PRINTF_INTPTR_MODIFIER
# define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
# endif
# ifndef PTRDIFF_MAX
# define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
# endif
# ifndef PTRDIFF_MIN
# define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
# endif
# ifndef UINTPTR_MAX
# define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
# endif
# ifndef INTPTR_MAX
# define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
# endif
# ifndef INTPTR_MIN
# define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
# endif
# ifndef INTPTR_C
# define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
# endif
# ifndef UINTPTR_C
# define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
# endif
typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;
# else
/* TODO -- This following is likely wrong for some platforms, and does
nothing for the definition of uintptr_t. */
typedef ptrdiff_t intptr_t;
# endif
# define STDINT_H_UINTPTR_T_DEFINED
#endif
/*
* Assumes sig_atomic_t is signed and we have a 2s complement machine.
*/
#ifndef SIG_ATOMIC_MAX
# define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
#endif
#endif
#if defined (__TEST_PSTDINT_FOR_CORRECTNESS)
/*
* Please compile with the maximum warning settings to make sure macros are
* not defined more than once.
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#define glue3_aux(x,y,z) x ## y ## z
#define glue3(x,y,z) glue3_aux(x,y,z)
#define DECLU(bits) glue3(uint,bits,_t) glue3(u,bits,) = glue3(UINT,bits,_C) (0);
#define DECLI(bits) glue3(int,bits,_t) glue3(i,bits,) = glue3(INT,bits,_C) (0);
#define DECL(us,bits) glue3(DECL,us,) (bits)
#define TESTUMAX(bits) glue3(u,bits,) = ~glue3(u,bits,); if (glue3(UINT,bits,_MAX) != glue3(u,bits,)) printf ("Something wrong with UINT%d_MAX\n", bits)
#define REPORTERROR(msg) { err_n++; if (err_first <= 0) err_first = __LINE__; printf msg; }
#define X_SIZE_MAX ((size_t)-1)
int main () {
int err_n = 0;
int err_first = 0;
DECL(I,8)
DECL(U,8)
DECL(I,16)
DECL(U,16)
DECL(I,32)
DECL(U,32)
#ifdef INT64_MAX
DECL(I,64)
DECL(U,64)
#endif
intmax_t imax = INTMAX_C(0);
uintmax_t umax = UINTMAX_C(0);
char str0[256], str1[256];
sprintf (str0, "%" PRINTF_INT32_MODIFIER "d", INT32_C(2147483647));
if (0 != strcmp (str0, "2147483647")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
if (atoi(PRINTF_INT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_INT32_DEC_WIDTH : %s\n", PRINTF_INT32_DEC_WIDTH));
sprintf (str0, "%" PRINTF_INT32_MODIFIER "u", UINT32_C(4294967295));
if (0 != strcmp (str0, "4294967295")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str0));
if (atoi(PRINTF_UINT32_DEC_WIDTH) != (int) strlen(str0)) REPORTERROR (("Something wrong with PRINTF_UINT32_DEC_WIDTH : %s\n", PRINTF_UINT32_DEC_WIDTH));
#ifdef INT64_MAX
sprintf (str1, "%" PRINTF_INT64_MODIFIER "d", INT64_C(9223372036854775807));
if (0 != strcmp (str1, "9223372036854775807")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
if (atoi(PRINTF_INT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_INT64_DEC_WIDTH : %s, %d\n", PRINTF_INT64_DEC_WIDTH, (int) strlen(str1)));
sprintf (str1, "%" PRINTF_INT64_MODIFIER "u", UINT64_C(18446744073709550591));
if (0 != strcmp (str1, "18446744073709550591")) REPORTERROR (("Something wrong with PRINTF_INT32_MODIFIER : %s\n", str1));
if (atoi(PRINTF_UINT64_DEC_WIDTH) != (int) strlen(str1)) REPORTERROR (("Something wrong with PRINTF_UINT64_DEC_WIDTH : %s, %d\n", PRINTF_UINT64_DEC_WIDTH, (int) strlen(str1)));
#endif
sprintf (str0, "%d %x\n", 0, ~0);
sprintf (str1, "%d %x\n", i8, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i8 : %s\n", str1));
sprintf (str1, "%u %x\n", u8, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u8 : %s\n", str1));
sprintf (str1, "%d %x\n", i16, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i16 : %s\n", str1));
sprintf (str1, "%u %x\n", u16, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u16 : %s\n", str1));
sprintf (str1, "%" PRINTF_INT32_MODIFIER "d %x\n", i32, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i32 : %s\n", str1));
sprintf (str1, "%" PRINTF_INT32_MODIFIER "u %x\n", u32, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with u32 : %s\n", str1));
#ifdef INT64_MAX
sprintf (str1, "%" PRINTF_INT64_MODIFIER "d %x\n", i64, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with i64 : %s\n", str1));
#endif
sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "d %x\n", imax, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with imax : %s\n", str1));
sprintf (str1, "%" PRINTF_INTMAX_MODIFIER "u %x\n", umax, ~0);
if (0 != strcmp (str0, str1)) REPORTERROR (("Something wrong with umax : %s\n", str1));
TESTUMAX(8);
TESTUMAX(16);
TESTUMAX(32);
#ifdef INT64_MAX
TESTUMAX(64);
#endif
#define STR(v) #v
#define Q(v) printf ("sizeof " STR(v) " = %u\n", (unsigned) sizeof (v));
if (err_n) {
printf ("pstdint.h is not correct. Please use sizes below to correct it:\n");
}
Q(int)
Q(unsigned)
Q(long int)
Q(short int)
Q(int8_t)
Q(int16_t)
Q(int32_t)
#ifdef INT64_MAX
Q(int64_t)
#endif
#if UINT_MAX < X_SIZE_MAX
printf ("UINT_MAX < X_SIZE_MAX\n");
#else
printf ("UINT_MAX >= X_SIZE_MAX\n");
#endif
printf ("%" PRINTF_INT64_MODIFIER "u vs %" PRINTF_INT64_MODIFIER "u\n", UINT_MAX, X_SIZE_MAX);
return EXIT_SUCCESS;
}
#endif
+39
View File
@@ -0,0 +1,39 @@
/*
* stdlib.h --
*
* Declares facilities exported by the "stdlib" portion of the C library.
* This file isn't complete in the ANSI-C sense; it only declares things
* that are needed by Tcl. This file is needed even on many systems with
* their own stdlib.h (e.g. SunOS) because not all stdlib.h files declare
* all the procedures needed here (such as strtol/strtoul).
*
* Copyright (c) 1991 The Regents of the University of California.
* Copyright (c) 1994-1998 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _STDLIB
#define _STDLIB
extern void abort(void);
extern double atof(const char *string);
extern int atoi(const char *string);
extern long atol(const char *string);
extern void * calloc(unsigned long numElements, unsigned long size);
extern void exit(int status);
extern void free(void *blockPtr);
extern char * getenv(const char *name);
extern void * malloc(unsigned long numBytes);
extern void qsort(void *base, unsigned long n, unsigned long size, int (*compar)(
const void *element1, const void *element2));
extern void * realloc(void *ptr, unsigned long numBytes);
extern char * realpath(const char *path, char *resolved_path);
extern int mkstemps(char *templ, int suffixlen);
extern int mkstemp(char *templ);
extern char * mkdtemp(char *templ);
extern long strtol(const char *string, char **endPtr, int base);
extern unsigned long strtoul(const char *string, char **endPtr, int base);
#endif /* _STDLIB */
+53
View File
@@ -0,0 +1,53 @@
/*
* string.h --
*
* Declarations of ANSI C library procedures for string handling.
*
* Copyright (c) 1991-1993 The Regents of the University of California.
* Copyright (c) 1994-1996 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#ifndef _STRING
#define _STRING
/*
* The following #include is needed to define size_t. (This used to include
* sys/stdtypes.h but that doesn't exist on older versions of SunOS, e.g.
* 4.0.2, so I'm trying sys/types.h now.... hopefully it exists everywhere)
*/
#include <sys/types.h>
extern void * memchr(const void *s, int c, size_t n);
extern int memcmp(const void *s1, const void *s2, size_t n);
extern void * memcpy(void *t, const void *f, size_t n);
#ifdef NO_MEMMOVE
#define memmove(d,s,n) (bcopy((s), (d), (n)))
#else
extern char * memmove(void *t, const void *f, size_t n);
#endif
extern void * memset(void *s, int c, size_t n);
extern int strcasecmp(const char *s1, const char *s2);
extern char * strcat(char *dst, const char *src);
extern char * strchr(const char *string, int c);
extern int strcmp(const char *s1, const char *s2);
extern char * strcpy(char *dst, const char *src);
extern size_t strcspn(const char *string, const char *chars);
extern char * strdup(const char *string);
extern char * strerror(int error);
extern size_t strlen(const char *string);
extern int strncasecmp(const char *s1, const char *s2, size_t n);
extern char * strncat(char *dst, const char *src, size_t numChars);
extern int strncmp(const char *s1, const char *s2, size_t nChars);
extern char * strncpy(char *dst, const char *src, size_t numChars);
extern char * strpbrk(const char *string, const char *chars);
extern char * strrchr(const char *string, int c);
extern size_t strspn(const char *string, const char *chars);
extern char * strstr(const char *string, const char *substring);
extern char * strtok(char *s, const char *delim);
#endif /* _STRING */
+2 -2
View File
@@ -3,8 +3,8 @@
*
* Source code for the "strncasecmp" library routine.
*
* Copyright © 1988-1993 The Regents of the University of California.
* Copyright © 1995-1996 Sun Microsystems, Inc.
* Copyright (c) 1988-1993 The Regents of the University of California.
* Copyright (c) 1995-1996 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
+70
View File
@@ -0,0 +1,70 @@
/*
* strstr.c --
*
* Source code for the "strstr" library routine.
*
* Copyright (c) 1988-1993 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tcl.h"
#ifndef NULL
#define NULL 0
#endif
/*
*----------------------------------------------------------------------
*
* strstr --
*
* Locate the first instance of a substring in a string.
*
* Results:
* If string contains substring, the return value is the location of the
* first matching instance of substring in string. If string doesn't
* contain substring, the return value is 0. Matching is done on an exact
* character-for-character basis with no wildcards or special characters.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
char *
strstr(
const char *string, /* String to search. */
const char *substring) /* Substring to try to find in string. */
{
const char *a, *b;
/*
* First scan quickly through the two strings looking for a
* single-character match. When it's found, then compare the rest of the
* substring.
*/
b = substring;
if (*b == 0) {
return (char *)string;
}
for ( ; *string != 0; string += 1) {
if (*string != *b) {
continue;
}
a = string;
while (1) {
if (*b == 0) {
return (char *)string;
}
if (*a++ != *b++) {
break;
}
}
b = substring;
}
return NULL;
}
+77
View File
@@ -0,0 +1,77 @@
/*
* strtol.c --
*
* Source code for the "strtol" library procedure.
*
* Copyright (c) 1988 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tclInt.h"
/*
*----------------------------------------------------------------------
*
* strtol --
*
* Convert an ASCII string into an integer.
*
* Results:
* The return value is the integer equivalent of string. If endPtr is
* non-NULL, then *endPtr is filled in with the character after the last
* one that was part of the integer. If string doesn't contain a valid
* integer value, then zero is returned and *endPtr is set to string.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
long int
strtol(
const char *string, /* String of ASCII digits, possibly preceded
* by white space. For bases greater than 10,
* either lower- or upper-case digits may be
* used. */
char **endPtr, /* Where to store address of terminating
* character, or NULL. */
int base) /* Base for conversion. Must be less than 37.
* If 0, then the base is chosen from the
* leading characters of string: "0x" means
* hex, "0" means octal, anything else means
* decimal. */
{
const char *p;
long result;
/*
* Skip any leading blanks.
*/
p = string;
while (isspace(UCHAR(*p))) {
p += 1;
}
/*
* Check for a sign.
*/
if (*p == '-') {
p += 1;
result = -(strtoul(p, endPtr, base));
} else {
if (*p == '+') {
p += 1;
}
result = strtoul(p, endPtr, base);
}
if ((result == 0) && (endPtr != 0) && (*endPtr == p)) {
*endPtr = (char *) string;
}
return result;
}
+214
View File
@@ -0,0 +1,214 @@
/*
* strtoul.c --
*
* Source code for the "strtoul" library procedure.
*
* Copyright (c) 1988 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
*/
#include "tclInt.h"
/*
* The table below is used to convert from ASCII digits to a numerical
* equivalent. It maps from '0' through 'z' to integers (100 for non-digit
* characters).
*/
static const char cvtIn[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, /* '0' - '9' */
100, 100, 100, 100, 100, 100, 100, /* punctuation */
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 'A' - 'Z' */
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35,
100, 100, 100, 100, 100, 100, /* punctuation */
10, 11, 12, 13, 14, 15, 16, 17, 18, 19, /* 'a' - 'z' */
20, 21, 22, 23, 24, 25, 26, 27, 28, 29,
30, 31, 32, 33, 34, 35};
/*
*----------------------------------------------------------------------
*
* strtoul --
*
* Convert an ASCII string into an integer.
*
* Results:
* The return value is the integer equivalent of string. If endPtr is
* non-NULL, then *endPtr is filled in with the character after the last
* one that was part of the integer. If string doesn't contain a valid
* integer value, then zero is returned and *endPtr is set to string.
*
* Side effects:
* None.
*
*----------------------------------------------------------------------
*/
unsigned long int
strtoul(
const char *string, /* String of ASCII digits, possibly preceded
* by white space. For bases greater than 10,
* either lower- or upper-case digits may be
* used. */
char **endPtr, /* Where to store address of terminating
* character, or NULL. */
int base) /* Base for conversion. Must be less than 37.
* If 0, then the base is chosen from the
* leading characters of string: "0x" means
* hex, "0" means octal, anything else means
* decimal. */
{
const char *p;
unsigned long int result = 0;
unsigned digit;
int anyDigits = 0;
int negative=0;
int overflow=0;
/*
* Skip any leading blanks.
*/
p = string;
while (isspace(UCHAR(*p))) {
p += 1;
}
if (*p == '-') {
negative = 1;
p += 1;
} else {
if (*p == '+') {
p += 1;
}
}
/*
* If no base was provided, pick one from the leading characters of the
* string.
*/
if (base == 0) {
if (*p == '0') {
p += 1;
if ((*p == 'x') || (*p == 'X')) {
p += 1;
base = 16;
} else {
/*
* Must set anyDigits here, otherwise "0" produces a "no
* digits" error.
*/
anyDigits = 1;
base = 8;
}
} else {
base = 10;
}
} else if (base == 16) {
/*
* Skip a leading "0x" from hex numbers.
*/
if ((p[0] == '0') && ((p[1] == 'x') || (p[1] == 'X'))) {
p += 2;
}
}
/*
* Sorry this code is so messy, but speed seems important. Do different
* things for base 8, 10, 16, and other.
*/
if (base == 8) {
unsigned long maxres = ULONG_MAX >> 3;
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > 7) {
break;
}
if (result > maxres) { overflow = 1; }
result = (result << 3);
if (digit > (ULONG_MAX - result)) { overflow = 1; }
result += digit;
anyDigits = 1;
}
} else if (base == 10) {
unsigned long maxres = ULONG_MAX / 10;
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > 9) {
break;
}
if (result > maxres) { overflow = 1; }
result *= 10;
if (digit > (ULONG_MAX - result)) { overflow = 1; }
result += digit;
anyDigits = 1;
}
} else if (base == 16) {
unsigned long maxres = ULONG_MAX >> 4;
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > ('z' - '0')) {
break;
}
digit = cvtIn[digit];
if (digit > 15) {
break;
}
if (result > maxres) { overflow = 1; }
result = (result << 4);
if (digit > (ULONG_MAX - result)) { overflow = 1; }
result += digit;
anyDigits = 1;
}
} else if (base >= 2 && base <= 36) {
unsigned long maxres = ULONG_MAX / base;
for ( ; ; p += 1) {
digit = *p - '0';
if (digit > ('z' - '0')) {
break;
}
digit = cvtIn[digit];
if (digit >= ( (unsigned) base )) {
break;
}
if (result > maxres) { overflow = 1; }
result *= base;
if (digit > (ULONG_MAX - result)) { overflow = 1; }
result += digit;
anyDigits = 1;
}
}
/*
* See if there were any digits at all.
*/
if (!anyDigits) {
p = string;
}
if (endPtr != 0) {
/* unsafe, but required by the strtoul prototype */
*endPtr = (char *) p;
}
if (overflow) {
errno = ERANGE;
return ULONG_MAX;
}
if (negative) {
return -result;
}
return result;
}
+3 -7
View File
@@ -5,8 +5,8 @@
* that don't have waitpid but do have wait3. This code is based on a
* prototype version written by Mark Diekhans and Karl Lehenbauer.
*
* Copyright © 1993 The Regents of the University of California.
* Copyright © 1994 Sun Microsystems, Inc.
* Copyright (c) 1993 The Regents of the University of California.
* Copyright (c) 1994 Sun Microsystems, Inc.
*
* See the file "license.terms" for information on usage and redistribution of
* this file, and for a DISCLAIMER OF ALL WARRANTIES.
@@ -156,11 +156,7 @@ waitpid(
goto waitAgain;
}
}
waitPtr = (WaitInfo *) Tcl_AttemptAlloc(sizeof(WaitInfo));
if (!waitPtr) {
errno = ENOMEM;
return -1;
}
waitPtr = (WaitInfo *) Tcl_Alloc(sizeof(WaitInfo));
waitPtr->pid = result;
waitPtr->status = status;
waitPtr->nextPtr = deadList;
-134
View File
@@ -1,134 +0,0 @@
# Copied from https://github.com/bazelbuild/bazel-central-registry/tree/main/modules/zlib/1.3.1.bcr.4/patches
# Adapted from https://github.com/protocolbuffers/protobuf/blob/master/third_party/zlib.BUILD
# Copyright 2008 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
# met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# * 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.
# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 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.
#
# Code generated by the Protocol Buffer compiler is owned by the owner
# of the input file used when generating it. This code is not
# standalone and requires a support library to be linked with it. This
# support library is itself covered by the above license.
load("@rules_cc//cc:defs.bzl", "cc_library")
load("@rules_license//rules:license.bzl", "license")
package(
default_applicable_licenses = [":license"],
)
license(
name = "license",
license_kinds = ["@rules_license//licenses/spdx:Zlib"],
license_text = "LICENSE",
)
exports_files([
"LICENSE",
])
_ZLIB_HEADERS = [
"crc32.h",
"deflate.h",
"gzguts.h",
"inffast.h",
"inffixed.h",
"inflate.h",
"inftrees.h",
"trees.h",
"zconf.h",
"zlib.h",
"zutil.h",
]
_ZLIB_PREFIXED_HEADERS = ["zlib/include/" + hdr for hdr in _ZLIB_HEADERS]
# In order to limit the damage from the `includes` propagation
# via `:zlib`, copy the public headers to a subdirectory and
# expose those.
genrule(
name = "copy_public_headers",
srcs = _ZLIB_HEADERS,
outs = _ZLIB_PREFIXED_HEADERS,
cmd_bash = "cp $(SRCS) $(@D)/zlib/include/",
cmd_bat = " && ".join(
["@copy /Y \"$(location %s)\" \"$(@D)\\zlib\\include\\\" >NUL" %
s for s in _ZLIB_HEADERS],
),
)
config_setting(
name = "mingw_gcc_compiler",
flag_values = {
"@bazel_tools//tools/cpp:compiler": "mingw-gcc",
},
visibility = [":__subpackages__"],
)
cc_library(
name = "z",
srcs = [
"adler32.c",
"compress.c",
"crc32.c",
"deflate.c",
"gzclose.c",
"gzlib.c",
"gzread.c",
"gzwrite.c",
"infback.c",
"inffast.c",
"inflate.c",
"inftrees.c",
"trees.c",
"uncompr.c",
"zutil.c",
# Include the un-prefixed headers in srcs to work
# around the fact that zlib isn't consistent in its
# choice of <> or "" delimiter when including itself.
] + _ZLIB_HEADERS,
hdrs = _ZLIB_PREFIXED_HEADERS,
copts = select({
":mingw_gcc_compiler": [
"-fpermissive",
],
"@platforms//os:windows": [],
"//conditions:default": [
"-Wno-deprecated-non-prototype",
"-Wno-unused-variable",
"-Wno-implicit-function-declaration",
],
}),
includes = ["zlib/include/"],
visibility = ["//visibility:public"],
)
alias(
name = "zlib",
actual = ":z",
visibility = ["//visibility:public"],
)
+147 -244
View File
@@ -1,126 +1,96 @@
cmake_minimum_required(VERSION 3.12...3.31)
cmake_minimum_required(VERSION 2.4.4)
set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS ON)
project(
zlib
LANGUAGES C
VERSION 1.3.2
HOMEPAGE_URL "https://zlib.net/"
DESCRIPTION "a general-purpose lossless data-compression library")
project(zlib C)
# ============================================================================
# CPack
# ============================================================================
set(CPACK_PACKAGE_VENDOR "zlib-Project")
set(CPACK_PACKAGE_DESCRIPTION_FILE ${zlib_SOURCE_DIR}/README)
set(CPACK_RESOURCE_FILE_LICENSE ${zlib_SOURCE_DIR}/LICENSE)
set(CPACK_RESOURCE_FILE_README ${zlib_SOURCE_DIR}/README)
set(VERSION "1.2.13")
# ============================================================================
# configuration
# ============================================================================
set(INSTALL_BIN_DIR "${CMAKE_INSTALL_PREFIX}/bin" CACHE PATH "Installation directory for executables")
set(INSTALL_LIB_DIR "${CMAKE_INSTALL_PREFIX}/lib" CACHE PATH "Installation directory for libraries")
set(INSTALL_INC_DIR "${CMAKE_INSTALL_PREFIX}/include" CACHE PATH "Installation directory for headers")
set(INSTALL_MAN_DIR "${CMAKE_INSTALL_PREFIX}/share/man" CACHE PATH "Installation directory for manual pages")
set(INSTALL_PKGCONFIG_DIR "${CMAKE_INSTALL_PREFIX}/share/pkgconfig" CACHE PATH "Installation directory for pkgconfig (.pc) files")
option(ZLIB_BUILD_TESTING "Enable Zlib Examples as tests" ON)
option(ZLIB_BUILD_SHARED "Enable building zlib shared library" ON)
option(ZLIB_BUILD_STATIC "Enable building zlib static library" ON)
option(ZLIB_INSTALL "Enable installation of zlib" ON)
option(ZLIB_PREFIX "prefix for all types and library functions, see zconf.h.in"
OFF)
mark_as_advanced(ZLIB_PREFIX)
get_property(IS_MULTI GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
if(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
message(STATUS "No CMAKE_BUILD_TYPE set -- using Release")
set(CMAKE_BUILD_TYPE Release)
endif(NOT DEFINED CMAKE_BUILD_TYPE AND NOT IS_MULTI)
include(CheckCSourceCompiles)
include(CheckTypeSize)
include(CheckFunctionExists)
include(CheckIncludeFile)
include(CMakePackageConfigHelpers)
include(CheckTypeSize)
include(CPack)
include(GNUInstallDirs)
include(CheckCSourceCompiles)
enable_testing()
set(CPACK_INCLUDED TRUE)
if(NOT ZLIB_CONF_WRITTEN)
set(Z_PREFIX ${ZLIB_PREFIX})
set(CONF_OUT_FILE ${zlib_BINARY_DIR}/zconf.h.cmakein)
file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT LIMIT 245)
file(WRITE ${CONF_OUT_FILE} ${ZCONF_CONTENT})
file(APPEND ${CONF_OUT_FILE} "#cmakedefine Z_PREFIX 1\n")
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_STDARG_H 1\n")
file(APPEND ${CONF_OUT_FILE} "#cmakedefine HAVE_UNISTD_H 1\n")
file(READ ${zlib_SOURCE_DIR}/zconf.h ZCONF_CONTENT OFFSET 244)
set(FIRST_ITEM TRUE)
foreach(item IN LISTS ZCONF_CONTENT)
if(FIRST_ITEM)
string(APPEND OUT_CONTENT ${item})
set(FIRST_ITEM FALSE)
else(FIRST_ITEM)
string(APPEND OUT_CONTENT "\;" ${item})
endif(FIRST_ITEM)
endforeach(item IN LISTS ${ZCONF_CONTENT})
file(APPEND ${CONF_OUT_FILE} ${OUT_CONTENT})
set(ZLIB_CONF_WRITTEN
TRUE
CACHE BOOL "zconf.h.cmakein was created")
mark_as_advanced(ZLIB_CONF_WRITTEN)
endif(NOT ZLIB_CONF_WRITTEN)
check_include_file(sys/types.h HAVE_SYS_TYPES_H)
check_include_file(stdint.h HAVE_STDINT_H)
check_include_file(stddef.h HAVE_STDDEF_H)
#
# Check to see if we have large file support
#
set(CMAKE_REQUIRED_DEFINITIONS -D_LARGEFILE64_SOURCE=1)
# We add these other definitions here because CheckTypeSize.cmake
# in CMake 2.4.x does not automatically do so and we want
# compatibility with CMake 2.4.x.
if(HAVE_SYS_TYPES_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_SYS_TYPES_H)
endif()
if(HAVE_STDINT_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDINT_H)
endif()
if(HAVE_STDDEF_H)
list(APPEND CMAKE_REQUIRED_DEFINITIONS -DHAVE_STDDEF_H)
endif()
check_type_size(off64_t OFF64_T)
unset(CMAKE_REQUIRED_DEFINITIONS) # clear variable
if(HAVE_OFF64_T)
add_definitions(-D_LARGEFILE64_SOURCE=1)
endif()
set(CMAKE_REQUIRED_DEFINITIONS) # clear variable
#
# Check for fseeko
#
check_function_exists(fseeko HAVE_FSEEKO)
#
# Check for stdarg.h
#
check_include_file(stdarg.h HAVE_STDARG_H)
if(NOT HAVE_FSEEKO)
add_definitions(-DNO_FSEEKO)
endif()
#
# Check for unistd.h
#
check_include_file(unistd.h HAVE_UNISTD_H)
check_include_file(unistd.h Z_HAVE_UNISTD_H)
#
# Check visibility attribute is supported
#
if(MSVC)
set(CMAKE_REQUIRED_FLAGS "-WX")
else(MSVC)
set(CMAKE_REQUIRED_FLAGS "-Werror")
endif(MSVC)
set(CMAKE_DEBUG_POSTFIX "d")
add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
add_definitions(-D_CRT_NONSTDC_NO_DEPRECATE)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
endif()
check_c_source_compiles(
"
#include <stdlib.h>
static void f(void) __attribute__ ((visibility(\"hidden\")));
int main(void) {return 0;}
"
HAVE___ATTR__VIS_HIDDEN)
if(NOT CMAKE_CURRENT_SOURCE_DIR STREQUAL CMAKE_CURRENT_BINARY_DIR)
# If we're doing an out of source build and the user has a zconf.h
# in their source tree...
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h)
message(STATUS "Renaming")
message(STATUS " ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h")
message(STATUS "to 'zconf.h.included' because this file is included with zlib")
message(STATUS "but CMake generates it automatically in the build directory.")
file(RENAME ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.included)
endif()
endif()
unset(CMAKE_COMPILE_FLAGS)
set(ZLIB_PC ${zlib_BINARY_DIR}/zlib.pc)
configure_file(${zlib_SOURCE_DIR}/zlib.pc.cmakein ${ZLIB_PC} @ONLY)
configure_file(${zlib_BINARY_DIR}/zconf.h.cmakein ${zlib_BINARY_DIR}/zconf.h)
set(ZLIB_PC ${CMAKE_CURRENT_BINARY_DIR}/zlib.pc)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zlib.pc.cmakein
${ZLIB_PC} @ONLY)
configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/zconf.h.cmakein
${CMAKE_CURRENT_BINARY_DIR}/zconf.h @ONLY)
include_directories(${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_SOURCE_DIR})
# ============================================================================
#============================================================================
# zlib
# ============================================================================
set(ZLIB_PUBLIC_HDRS ${zlib_BINARY_DIR}/zconf.h zlib.h)
#============================================================================
set(ZLIB_PUBLIC_HDRS
${CMAKE_CURRENT_BINARY_DIR}/zconf.h
zlib.h
)
set(ZLIB_PRIVATE_HDRS
crc32.h
deflate.h
@@ -130,8 +100,8 @@ set(ZLIB_PRIVATE_HDRS
inflate.h
inftrees.h
trees.h
zutil.h)
zutil.h
)
set(ZLIB_SRCS
adler32.c
compress.c
@@ -147,164 +117,97 @@ set(ZLIB_SRCS
inffast.c
trees.c
uncompr.c
zutil.c)
zutil.c
)
if(WIN32)
set(zlib_static_suffix "s")
set(CMAKE_DEBUG_POSTFIX "d")
endif(WIN32)
if(NOT MINGW)
set(ZLIB_DLL_SRCS
win32/zlib1.rc # If present will override custom build rule below.
)
endif()
if(ZLIB_BUILD_SHARED)
add_library(
zlib SHARED ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS}
$<$<OR:$<BOOL:${WIN32}>,$<BOOL:${CYGWIN}>>:win32/zlib1.rc>)
add_library(ZLIB::ZLIB ALIAS zlib)
target_include_directories(
zlib
PUBLIC $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
$<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_definitions(
zlib
PRIVATE ZLIB_BUILD
$<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
set(INSTALL_VERSION ${zlib_VERSION})
# parse the full version number from zlib.h and include in ZLIB_FULL_VERSION
file(READ ${CMAKE_CURRENT_SOURCE_DIR}/zlib.h _zlib_h_contents)
string(REGEX REPLACE ".*#define[ \t]+ZLIB_VERSION[ \t]+\"([-0-9A-Za-z.]+)\".*"
"\\1" ZLIB_FULL_VERSION ${_zlib_h_contents})
if(NOT CYGWIN)
set_target_properties(zlib PROPERTIES SOVERSION ${zlib_VERSION_MAJOR}
VERSION ${INSTALL_VERSION})
endif(NOT CYGWIN)
if(MINGW)
# This gets us DLL resource information when compiling on MinGW.
if(NOT CMAKE_RC_COMPILER)
set(CMAKE_RC_COMPILER windres.exe)
endif()
set_target_properties(
zlib
PROPERTIES DEFINE_SYMBOL ZLIB_DLL
EXPORT_NAME ZLIB
OUTPUT_NAME z)
if(UNIX
AND NOT APPLE
AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX)
AND NOT (CMAKE_SYSTEM_NAME STREQUAL SunOS))
# On unix-like platforms the library is almost always called libz
set_target_properties(
zlib
PROPERTIES LINK_FLAGS
"-Wl,--version-script,\"${zlib_SOURCE_DIR}/zlib.map\"")
endif(
UNIX
AND NOT APPLE
AND NOT (CMAKE_SYSTEM_NAME STREQUAL AIX)
AND NOT (CMAKE_SYSTEM_NAME STREQUAL SunOS))
endif(ZLIB_BUILD_SHARED)
add_custom_command(OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
COMMAND ${CMAKE_RC_COMPILER}
-D GCC_WINDRES
-I ${CMAKE_CURRENT_SOURCE_DIR}
-I ${CMAKE_CURRENT_BINARY_DIR}
-o ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj
-i ${CMAKE_CURRENT_SOURCE_DIR}/win32/zlib1.rc)
set(ZLIB_DLL_SRCS ${CMAKE_CURRENT_BINARY_DIR}/zlib1rc.obj)
endif(MINGW)
if(ZLIB_BUILD_STATIC)
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS}
${ZLIB_PRIVATE_HDRS})
add_library(ZLIB::ZLIBSTATIC ALIAS zlibstatic)
target_include_directories(
zlibstatic
PUBLIC $<BUILD_INTERFACE:${zlib_BINARY_DIR}>
$<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_definitions(
zlibstatic
PRIVATE ZLIB_BUILD
$<$<BOOL:NOT:${HAVE_FSEEKO}>:NO_FSEEKO>
$<$<BOOL:${HAVE___ATTR__VIS_HIDDEN}>:HAVE_HIDDEN>
$<$<BOOL:${MSVC}>:_CRT_SECURE_NO_DEPRECATE>
$<$<BOOL:${MSVC}>:_CRT_NONSTDC_NO_DEPRECATE>
PUBLIC $<$<BOOL:${HAVE_OFF64_T}>:_LARGEFILE64_SOURCE=1>)
set_target_properties(
zlibstatic PROPERTIES EXPORT_NAME ZLIBSTATIC OUTPUT_NAME
z${zlib_static_suffix})
endif(ZLIB_BUILD_STATIC)
add_library(zlib SHARED ${ZLIB_SRCS} ${ZLIB_DLL_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
add_library(zlibstatic STATIC ${ZLIB_SRCS} ${ZLIB_PUBLIC_HDRS} ${ZLIB_PRIVATE_HDRS})
set_target_properties(zlib PROPERTIES DEFINE_SYMBOL ZLIB_DLL)
set_target_properties(zlib PROPERTIES SOVERSION 1)
if(ZLIB_INSTALL)
if(ZLIB_BUILD_SHARED)
install(
TARGETS zlib
COMPONENT Runtime
EXPORT zlibSharedExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT zlibSharedExport
FILE ZLIB-shared.cmake
NAMESPACE ZLIB::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
if(NOT CYGWIN)
# This property causes shared libraries on Linux to have the full version
# encoded into their final filename. We disable this on Cygwin because
# it causes cygz-${ZLIB_FULL_VERSION}.dll to be created when cygz.dll
# seems to be the default.
#
# This has no effect with MSVC, on that platform the version info for
# the DLL comes from the resource file win32/zlib1.rc
set_target_properties(zlib PROPERTIES VERSION ${ZLIB_FULL_VERSION})
endif()
if(MSVC)
install(
FILES $<TARGET_PDB_FILE:zlib>
COMPONENT Runtime
DESTINATION ${CMAKE_INSTALL_BINDIR}
CONFIGURATIONS Debug OR RelWithDebInfo
OPTIONAL)
endif(MSVC)
endif(ZLIB_BUILD_SHARED)
if(UNIX)
# On unix-like platforms the library is almost always called libz
set_target_properties(zlib zlibstatic PROPERTIES OUTPUT_NAME z)
if(NOT APPLE)
set_target_properties(zlib PROPERTIES LINK_FLAGS "-Wl,--version-script,\"${CMAKE_CURRENT_SOURCE_DIR}/zlib.map\"")
endif()
elseif(BUILD_SHARED_LIBS AND WIN32)
# Creates zlib1.dll when building shared library version
set_target_properties(zlib PROPERTIES SUFFIX "1.dll")
endif()
if(ZLIB_BUILD_STATIC)
install(
TARGETS zlibstatic
COMPONENT Development
EXPORT zlibStaticExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}"
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT zlibStaticExport
FILE ZLIB-static.cmake
NAMESPACE ZLIB::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
endif(ZLIB_BUILD_STATIC)
if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL )
install(TARGETS zlib zlibstatic
RUNTIME DESTINATION "${INSTALL_BIN_DIR}"
ARCHIVE DESTINATION "${INSTALL_LIB_DIR}"
LIBRARY DESTINATION "${INSTALL_LIB_DIR}" )
endif()
if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL )
install(FILES ${ZLIB_PUBLIC_HDRS} DESTINATION "${INSTALL_INC_DIR}")
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
install(FILES zlib.3 DESTINATION "${INSTALL_MAN_DIR}/man3")
endif()
if(NOT SKIP_INSTALL_FILES AND NOT SKIP_INSTALL_ALL )
install(FILES ${ZLIB_PC} DESTINATION "${INSTALL_PKGCONFIG_DIR}")
endif()
configure_package_config_file(
${zlib_SOURCE_DIR}/zlibConfig.cmake.in
${zlib_BINARY_DIR}/ZLIBConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
#============================================================================
# Example binaries
#============================================================================
write_basic_package_version_file(
"${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake"
VERSION "${zlib_VERSION}"
COMPATIBILITY AnyNewerVersion)
add_executable(example test/example.c)
target_link_libraries(example zlib)
add_test(example example)
install(FILES ${zlib_BINARY_DIR}/ZLIBConfig.cmake
${zlib_BINARY_DIR}/ZLIBConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/zlib)
install(
FILES ${ZLIB_PUBLIC_HDRS}
COMPONENT Development
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
install(
FILES zlib.3
COMPONENT Docs
DESTINATION "${CMAKE_INSTALL_MANDIR}/man3")
install(
FILES LICENSE
doc/algorithm.txt
doc/crc-doc.1.0.pdf
doc/rfc1950.txt
doc/rfc1951.txt
doc/rfc1952.txt
doc/txtvsbin.txt
COMPONENT Docs
DESTINATION "${CMAKE_INSTALL_DOCDIR}/zlib")
install(
FILES ${ZLIB_PC}
COMPONENT Development
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif(ZLIB_INSTALL)
add_executable(minigzip test/minigzip.c)
target_link_libraries(minigzip zlib)
# ============================================================================
# Tests
# ============================================================================
if(ZLIB_BUILD_TESTING)
enable_testing()
add_subdirectory(test)
endif(ZLIB_BUILD_TESTING)
if(HAVE_OFF64_T)
add_executable(example64 test/example.c)
target_link_libraries(example64 zlib)
set_target_properties(example64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
add_test(example64 example64)
add_subdirectory(contrib)
add_executable(minigzip64 test/minigzip.c)
target_link_libraries(minigzip64 zlib)
set_target_properties(minigzip64 PROPERTIES COMPILE_FLAGS "-D_FILE_OFFSET_BITS=64")
endif()
+1 -80
View File
@@ -1,85 +1,6 @@
ChangeLog file for zlib
Changes in 1.3.2 (17 Feb 2026)
- Continued rewrite of CMake build [Vollstrecker]
- Various portability improvements
- Various github workflow additions and improvements
- Check for negative lengths in crc32_combine functions
- Copy only the initialized window contents in inflateCopy
- Prevent the use of insecure functions without an explicit request
- Add compressBound_z and deflateBound_z functions for large values
- Use atomics to build inflate fixed tables once
- Add definition of ZLIB_INSECURE to build tests with c89 and c94
- Add --undefined option to ./configure for UBSan checker
- Copy only the initialized deflate state in deflateCopy
- Zero inflate state on allocation
- Remove untgz from contrib
- Add _z versions of the compress and uncompress functions
- Vectorize the CRC-32 calculation on the s390x
- Set bit 11 of the zip header flags in minizip if UTF-8
- Update OS/400 support
- Add a test to configure to check for a working compiler
- Check for invalid NULL pointer inputs to zlib operations
- Add --mandir to ./configure to specify manual directory
- Add LICENSE.Info-Zip to contrib/minizip
- Remove vstudio projects in lieu of cmake-generated projects
- Replace strcpy() with memcpy() in contrib/minizip
Changes in 1.3.1.2 (8 Dec 2025)
- Improve portability to RISC OS
- Permit compiling contrib/minizip/unzip.c with decryption
- Enable build of shared library on AIX
- Make deflateBound() more conservative and handle Z_STREAM_END
- Add zipAlreadyThere() to minizip zip.c to help avoid duplicates
- Make z_off_t 64 bits by default
- Add deflateUsed() function to get the used bits in the last byte
- Avoid out-of-bounds pointer arithmetic in inflateCopy()
- Add Haiku to configure for proper LDSHARED settings
- Add Bazel targets
- Complete rewrite of CMake build [Vollstrecker]
- Clarify the use of errnum in gzerror()
- Note that gzseek() requests are deferred until the next operation
- Note the use of gzungetc() to run a deferred seek while reading
- Fix bug in inflatePrime() for 16-bit ints
- Add a "G" option to force gzip, disabling transparency in gzread()
- Improve the discrimination between trailing garbage and bad gzip
- Allow gzflush() to write empty gzip members
- Remove redundant frees of point list on error in examples/zran.c
- Clarify the use of inflateGetHeader()
- Update links to the RFCs
- Return all available uncompressed data on error in gzread.c
- Support non-blocking devices in the gz* routines
- Various other small improvements
Changes in 1.3.1 (22 Jan 2024)
- Reject overflows of zip header fields in minizip
- Fix bug in inflateSync() for data held in bit buffer
- Add LIT_MEM define to use more memory for a small deflate speedup
- Fix decision on the emission of Zip64 end records in minizip
- Add bounds checking to ERR_MSG() macro, used by zError()
- Neutralize zip file traversal attacks in miniunz
- Fix a bug in ZLIB_DEBUG compiles in check_match()
- Various portability and appearance improvements
Changes in 1.3 (18 Aug 2023)
- Remove K&R function definitions and zlib2ansi
- Fix bug in deflateBound() for level 0 and memLevel 9
- Fix bug when gzungetc() is used immediately after gzopen()
- Fix bug when using gzflush() with a very small buffer
- Fix crash when gzsetparams() attempted for transparent write
- Fix test/example.c to work with FORCE_STORED
- Rewrite of zran in examples (see zran.c version history)
- Fix minizip to allow it to open an empty zip file
- Fix reading disk number start on zip64 files in minizip
- Fix logic error in minizip argument processing
- Add minizip testing to Makefile
- Read multiple bytes instead of byte-by-byte in minizip unzip.c
- Add memory sanitizer to configure (--memory)
- Various portability improvements
- Various documentation improvements
- Various spelling and typo corrections
Changes in 1.2.13 (13 Oct 2022)
- Fix configure issue that discarded provided CC definition
- Correct incorrect inputs provided to the CRC functions
@@ -1524,7 +1445,7 @@ Changes in 0.99 (27 Jan 96)
- fix typo in Make_vms.com (f$trnlnm -> f$getsyi)
- in fcalloc, normalize pointer if size > 65520 bytes
- don't use special fcalloc for 32 bit Borland C++
- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc.
- use STDC instead of __GO32__ to avoid redeclaring exit, calloc, etc...
- use Z_BINARY instead of BINARY
- document that gzclose after gzdopen will close the file
- allow "a" as mode in gzopen
+23 -26
View File
@@ -3,8 +3,8 @@
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
http://zlib.net/ which may have more recent information.
The lastest zlib FAQ is at http://zlib.net/zlib_faq.html
1. Is zlib Y2K-compliant?
@@ -14,12 +14,13 @@ The latest zlib FAQ is at https://zlib.net/zlib_faq.html
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.
file win32/DLL_FAQ.txt in the zlib distribution. Pointers to the
precompiled DLL are found in the zlib web site at http://zlib.net/ .
3. Where can I get a Visual Basic interface to zlib?
See
* https://zlib.net/nelson/
* http://marknelson.us/1997/01/01/zlib-engine/
* win32/DLL_FAQ.txt in the zlib distribution
4. compress() returns Z_BUF_ERROR.
@@ -38,7 +39,7 @@ The latest zlib FAQ is at https://zlib.net/zlib_faq.html
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
strm.avail_out returns with zero. See http://zlib.net/zlib_how.html for a
heavily annotated example.
6. Where's the zlib documentation (man pages, etc.)?
@@ -109,8 +110,8 @@ The latest zlib FAQ is at https://zlib.net/zlib_faq.html
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/ .
Yes. See http://www.pdflib.com/ . To modify PDF forms, see
http://sourceforge.net/projects/acroformtool/ .
17. Why am I getting this "register_frame_info not found" error on Solaris?
@@ -156,10 +157,6 @@ The latest zlib FAQ is at https://zlib.net/zlib_faq.html
library memory allocation routines by default. zlib's *Init* functions
allow for the application to provide custom memory allocation routines.
If the non-default BUILDFIXED or DYNAMIC_CRC_TABLE defines are used on a
system without atomics (e.g. pre-C11), then inflate() and crc32() will not
be thread safe.
Of course, you should only operate on any given zlib or gzip stream from a
single thread at a time.
@@ -239,7 +236,7 @@ The latest zlib FAQ is at https://zlib.net/zlib_faq.html
As far as we know, no. In fact, that was originally the whole point behind
zlib. Look here for some more information:
https://web.archive.org/web/20180729212847/http://www.gzip.org/#faq11
http://www.gzip.org/#faq11
32. Can zlib work with greater than 4 GB of data?
@@ -262,20 +259,20 @@ The latest zlib FAQ is at https://zlib.net/zlib_faq.html
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(), which requires that ZLIB_INSECURE
be defined, 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().
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 good portable implementation in stb_sprintf.h here:
find a portable implementation here:
https://github.com/nothings/stb
http://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
@@ -287,7 +284,7 @@ The latest zlib FAQ is at https://zlib.net/zlib_faq.html
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/ .
page for links: http://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?
@@ -318,9 +315,9 @@ The latest zlib FAQ is at https://zlib.net/zlib_faq.html
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
encryption, use GnuPG, http://www.gnupg.org/ , which already includes zlib
compression. For PKZIP compatible "encryption", look at
https://infozip.sourceforge.net/
http://www.info-zip.org/
39. What's the difference between the "gzip" and "deflate" HTTP 1.1 encodings?
+2 -1
View File
@@ -21,11 +21,12 @@ zlib.pc.cmakein zlib.pc template for cmake
zlib2ansi perl script to convert source files for C++ compilation
amiga/ makefiles for Amiga SAS C
as400/ makefiles for AS/400
doc/ documentation for formats and algorithms
msdos/ makefiles for MSDOS
nintendods/ makefile for Nintendo DS
old/ makefiles for various architectures and zlib documentation
files that have not yet been updated for zlib 1.2.x
os400/ makefiles for OS/400
qnx/ makefiles for QNX
watcom/ makefiles for OpenWatcom
win32/ makefiles for Windows
-22
View File
@@ -1,22 +0,0 @@
Copyright notice:
(C) 1995-2026 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.
Jean-loup Gailly Mark Adler
jloup@gzip.org madler@alumni.caltech.edu
-9
View File
@@ -1,9 +0,0 @@
module(
name = "zlib",
version = "0.0.0",
compatibility_level = 1,
)
bazel_dep(name = "platforms", version = "0.0.10")
bazel_dep(name = "rules_cc", version = "0.0.16")
bazel_dep(name = "rules_license", version = "1.0.0")
+24 -46
View File
@@ -1,5 +1,5 @@
# Makefile for zlib
# Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler
# Copyright (C) 1995-2017 Jean-loup Gailly, Mark Adler
# For conditions of distribution and use, see copyright notice in zlib.h
# To compile and test, type:
@@ -13,8 +13,6 @@
# make install prefix=$HOME
CC=cc
GCOV=GCOV
LLVM_GCOV_FLAG=LLMV_GCOV_FLAG
CFLAGS=-O
#CFLAGS=-O -DMAX_WBITS=14 -DMAX_MEM_LEVEL=7
@@ -24,14 +22,13 @@ CFLAGS=-O
SFLAGS=-O
LDFLAGS=
TEST_LIBS=-L. libz.a
TEST_LDFLAGS=$(LDFLAGS) -L. libz.a
LDSHARED=$(CC)
CPP=$(CC) -E
VGFMAFLAG=
STATICLIB=libz.a
SHAREDLIB=libz.so
SHAREDLIBV=libz.so.1.3.2
SHAREDLIBV=libz.so.1.2.13
SHAREDLIBM=libz.so.1
LIBS=$(STATICLIB) $(SHAREDLIBV)
@@ -115,16 +112,16 @@ test64: all64
fi
@rm -f tmp64_$$
infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h $(SRCDIR)inflate.h $(SRCDIR)inftrees.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -coverage -o $@ $(SRCDIR)test/infcover.c
infcover.o: $(SRCDIR)test/infcover.c $(SRCDIR)zlib.h zconf.h
$(CC) $(CFLAGS) $(ZINCOUT) -c -o $@ $(SRCDIR)test/infcover.c
infcover: infcover.o libz.a
$(CC) $(CFLAGS) -coverage -o $@ infcover.o libz.a
$(CC) $(CFLAGS) -o $@ infcover.o libz.a
cover: infcover
rm -f *.gcda
${QEMU_RUN} ./infcover
${GCOV} ${LLVM_GCOV_FLAG} inf*.c -o ./infcover.gcda
gcov inf*.c
libz.a: $(OBJS)
$(AR) $(ARFLAGS) $@ $(OBJS)
@@ -161,9 +158,6 @@ adler32.o: $(SRCDIR)adler32.c
crc32.o: $(SRCDIR)crc32.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)crc32.c
crc32_vx.o: $(SRCDIR)contrib/crc32vx/crc32_vx.c
$(CC) $(CFLAGS) $(VGFMAFLAG) $(ZINC) -c -o $@ $(SRCDIR)contrib/crc32vx/crc32_vx.c
deflate.o: $(SRCDIR)deflate.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)deflate.c
@@ -182,7 +176,7 @@ inftrees.o: $(SRCDIR)inftrees.c
trees.o: $(SRCDIR)trees.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)trees.c
zutil.o: $(SRCDIR)zutil.c $(SRCDIR)gzguts.h
zutil.o: $(SRCDIR)zutil.c
$(CC) $(CFLAGS) $(ZINC) -c -o $@ $(SRCDIR)zutil.c
compress.o: $(SRCDIR)compress.c
@@ -214,11 +208,6 @@ crc32.lo: $(SRCDIR)crc32.c
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/crc32.o $(SRCDIR)crc32.c
-@mv objs/crc32.o $@
crc32_vx.lo: $(SRCDIR)contrib/crc32vx/crc32_vx.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(VGFMAFLAG) $(ZINC) -DPIC -c -o objs/crc32_vx.o $(SRCDIR)contrib/crc32vx/crc32_vx.c
-@mv objs/crc32_vx.o $@
deflate.lo: $(SRCDIR)deflate.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/deflate.o $(SRCDIR)deflate.c
@@ -249,7 +238,7 @@ trees.lo: $(SRCDIR)trees.c
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/trees.o $(SRCDIR)trees.c
-@mv objs/trees.o $@
zutil.lo: $(SRCDIR)zutil.c $(SRCDIR)gzguts.h
zutil.lo: $(SRCDIR)zutil.c
-@mkdir objs 2>/dev/null || test -d objs
$(CC) $(SFLAGS) $(ZINC) -DPIC -c -o objs/zutil.o $(SRCDIR)zutil.c
-@mv objs/zutil.o $@
@@ -285,7 +274,7 @@ gzwrite.lo: $(SRCDIR)gzwrite.c
-@mv objs/gzwrite.o $@
placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a $(SRCDIR)zlib.map
placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a
$(LDSHARED) $(SFLAGS) -o $@ $(PIC_OBJS) $(LDSHAREDLIBC) $(LDFLAGS)
rm -f $(SHAREDLIB) $(SHAREDLIBM)
ln -s $@ $(SHAREDLIB)
@@ -293,10 +282,10 @@ placebo $(SHAREDLIBV): $(PIC_OBJS) libz.a $(SRCDIR)zlib.map
-@rmdir objs
example$(EXE): example.o $(STATICLIB)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ example.o $(TEST_LIBS)
$(CC) $(CFLAGS) -o $@ example.o $(TEST_LDFLAGS)
minigzip$(EXE): minigzip.o $(STATICLIB)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip.o $(TEST_LIBS)
$(CC) $(CFLAGS) -o $@ minigzip.o $(TEST_LDFLAGS)
examplesh$(EXE): example.o $(SHAREDLIBV)
$(CC) $(CFLAGS) -o $@ example.o $(LDFLAGS) -L. $(SHAREDLIBV)
@@ -305,10 +294,10 @@ minigzipsh$(EXE): minigzip.o $(SHAREDLIBV)
$(CC) $(CFLAGS) -o $@ minigzip.o $(LDFLAGS) -L. $(SHAREDLIBV)
example64$(EXE): example64.o $(STATICLIB)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ example64.o $(TEST_LIBS)
$(CC) $(CFLAGS) -o $@ example64.o $(TEST_LDFLAGS)
minigzip64$(EXE): minigzip64.o $(STATICLIB)
$(CC) $(CFLAGS) $(LDFLAGS) -o $@ minigzip64.o $(TEST_LIBS)
$(CC) $(CFLAGS) -o $@ minigzip64.o $(TEST_LDFLAGS)
install-libs: $(LIBS)
-@if [ ! -d $(DESTDIR)$(exec_prefix) ]; then mkdir -p $(DESTDIR)$(exec_prefix); fi
@@ -360,25 +349,18 @@ docs: zlib.3.pdf
zlib.3.pdf: $(SRCDIR)zlib.3
groff -mandoc -f H -T ps $(SRCDIR)zlib.3 | ps2pdf - $@
# zconf.h.cmakein: $(SRCDIR)zconf.h.in
# -@ TEMPFILE=zconfh_$$; \
# echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
# sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\
# touch -r $(SRCDIR)zconf.h.in $@ &&\
# rm $$TEMPFILE
#
zconf.h.cmakein: $(SRCDIR)zconf.h.in
-@ TEMPFILE=zconfh_$$; \
echo "/#define ZCONF_H/ a\\\\\n#cmakedefine Z_PREFIX\\\\\n#cmakedefine Z_HAVE_UNISTD_H\n" >> $$TEMPFILE &&\
sed -f $$TEMPFILE $(SRCDIR)zconf.h.in > $@ &&\
touch -r $(SRCDIR)zconf.h.in $@ &&\
rm $$TEMPFILE
zconf: $(SRCDIR)zconf.h.in
cp -p $(SRCDIR)zconf.h.in zconf.h
minizip-test: static
cd contrib/minizip && { CC="$(CC)" CFLAGS="$(CFLAGS)" $(MAKE) test ; cd ../.. ; }
minizip-clean:
cd contrib/minizip && { $(MAKE) clean ; cd ../.. ; }
mostlyclean: clean
clean: minizip-clean
clean:
rm -f *.o *.lo *~ \
example$(EXE) minigzip$(EXE) examplesh$(EXE) minigzipsh$(EXE) \
example64$(EXE) minigzip64$(EXE) \
@@ -390,7 +372,7 @@ clean: minizip-clean
rm -f contrib/infback9/*.gcda contrib/infback9/*.gcno contrib/infback9/*.gcov
maintainer-clean: distclean
distclean: clean zconf # zconf.h.cmakein
distclean: clean zconf zconf.h.cmakein
rm -f Makefile zlib.pc configure.log
-@rm -f .DS_Store
@if [ -f Makefile.in ]; then \
@@ -401,8 +383,7 @@ distclean: clean zconf # zconf.h.cmakein
tags:
etags $(SRCDIR)*.[ch]
adler32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
adler32.o zutil.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
gzclose.o gzlib.o gzread.o gzwrite.o: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
compress.o example.o minigzip.o uncompr.o: $(SRCDIR)zlib.h zconf.h
crc32.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h
@@ -411,10 +392,8 @@ infback.o inflate.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.
inffast.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.o: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
crc32_vx.o: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)contrib/crc32vx/crc32_vx_hooks.h
adler32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
adler32.lo zutil.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h
gzclose.lo gzlib.lo gzread.lo gzwrite.lo: $(SRCDIR)zlib.h zconf.h $(SRCDIR)gzguts.h
compress.lo example.lo minigzip.lo uncompr.lo: $(SRCDIR)zlib.h zconf.h
crc32.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)crc32.h
@@ -423,4 +402,3 @@ infback.lo inflate.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftree
inffast.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h $(SRCDIR)inflate.h $(SRCDIR)inffast.h
inftrees.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)inftrees.h
trees.lo: $(SRCDIR)deflate.h $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)trees.h
crc32_vx.lo: $(SRCDIR)zutil.h $(SRCDIR)zlib.h zconf.h $(SRCDIR)contrib/crc32vx/crc32_vx_hooks.h
+21 -18
View File
@@ -1,10 +1,10 @@
ZLIB DATA COMPRESSION LIBRARY
zlib 1.3.2 is a general purpose data compression library. All the code is
thread safe (though see the FAQ for caveats). The data format used by the zlib
library is described by RFCs (Request for Comments) 1950 to 1952 at
https://datatracker.ietf.org/doc/html/rfc1950 (zlib format), rfc1951 (deflate
format) and rfc1952 (gzip format).
zlib 1.2.13 is a general purpose data compression library. All the code is
thread safe. The data format used by the zlib library is described by RFCs
(Request for Comments) 1950 to 1952 in the files
http://tools.ietf.org/html/rfc1950 (zlib format), rfc1951 (deflate format) and
rfc1952 (gzip format).
All functions of the compression library are documented in the file zlib.h
(volunteer to write man pages welcome, contact zlib@gzip.org). A usage example
@@ -21,31 +21,32 @@ make_vms.com.
Questions about zlib should be sent to <zlib@gzip.org>, or to Gilles Vollant
<info@winimage.com> for the Windows DLL version. The zlib home page is
https://zlib.net/ . Before reporting a problem, please check this site to
http://zlib.net/ . Before reporting a problem, please check this site to
verify that you have the latest version of zlib; otherwise get the latest
version and check whether the problem still exists or not.
PLEASE read the zlib FAQ https://zlib.net/zlib_faq.html before asking for help.
PLEASE read the zlib FAQ http://zlib.net/zlib_faq.html before asking for help.
Mark Nelson <markn@ieee.org> wrote an article about zlib for the Jan. 1997
issue of Dr. Dobb's Journal; a copy of the article is available at
https://zlib.net/nelson/ .
http://marknelson.us/1997/01/01/zlib-engine/ .
The changes made in version 1.3.2 are documented in the file ChangeLog.
The changes made in version 1.2.13 are documented in the file ChangeLog.
Unsupported third party contributions are provided in directory contrib/ .
zlib is available in Java using the java.util.zip package. Follow the API
Documentation link at: https://docs.oracle.com/search/?q=java.util.zip .
zlib is available in Java using the java.util.zip package, documented at
http://java.sun.com/developer/technicalArticles/Programming/compression/ .
A Perl interface to zlib and bzip2 written by Paul Marquess <pmqs@cpan.org>
can be found at https://github.com/pmqs/IO-Compress .
A Perl interface to zlib written by Paul Marquess <pmqs@cpan.org> is available
at CPAN (Comprehensive Perl Archive Network) sites, including
http://search.cpan.org/~pmqs/IO-Compress-Zlib/ .
A Python interface to zlib written by A.M. Kuchling <amk@amk.ca> is
available in Python 1.5 and later versions, see
https://docs.python.org/3/library/zlib.html .
http://docs.python.org/library/zlib.html .
zlib is built into tcl: https://wiki.tcl-lang.org/page/zlib .
zlib is built into tcl: http://wiki.tcl.tk/4610 .
An experimental package to read and write files in .zip format, written on top
of zlib by Gilles Vollant <info@winimage.com>, is available in the
@@ -63,13 +64,15 @@ Notes for some targets:
- zlib doesn't work with gcc 2.6.3 on a DEC 3000/300LX under OSF/1 2.1 it works
when compiled with cc.
- On Digital Unix 4.0D (formerly OSF/1) on AlphaServer, the cc option -std1 is
- On Digital Unix 4.0D (formely OSF/1) on AlphaServer, the cc option -std1 is
necessary to get gzprintf working correctly. This is done by configure.
- zlib doesn't work on HP-UX 9.05 with some versions of /bin/cc. It works with
other compilers. Use "make test" to check your compiler.
- For PalmOs, see https://palmzlib.sourceforge.net/
- gzdopen is not supported on RISCOS or BEOS.
- For PalmOs, see http://palmzlib.sourceforge.net/
Acknowledgments:
@@ -81,7 +84,7 @@ Acknowledgments:
Copyright notice:
(C) 1995-2026 Jean-loup Gailly and Mark Adler
(C) 1995-2022 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
-79
View File
@@ -1,79 +0,0 @@
# For building with cmake at least version 3.12 (minizip 3.12) is needed
In most cases the usual
cmake -S . -B build -D CMAKE_BUILD_TYPE=Release
will create everything you need, however if you want something off default you can adjust several options fit your needs.
Every option is list below (excluding the cmake-standard options), they can be set via cmake-gui or on cmdline with
-D<option>=ON/OFF
## ZLIB-options with defaults ##
ZLIB_BUILD_TESTING=ON -- Enable Zlib Examples as tests
ZLIB_BUILD_SHARED=ON -- Enable building zlib shared library
ZLIB_BUILD_STATIC=ON -- Enable building zlib static library
ZLIB_BUILD_MINIZIP=ON -- Enable building libminizip contrib library
If this option is turned on, additional options are available from minizip (see below)
ZLIB_INSTALL=ON -- Enable installation of zlib
ZLIB_PREFIX=OFF -- prefix for all types and library functions, see zconf.h.in
This option is only on windows available and may/will be turned off and removed somewhen in the future.
If you rely cmake for finding and using zlib, this can be turned off, as `zlib1.dll` will never be used.
## minizip-options with defaults ##
MINIZIP_BUILD_SHARED=ON -- Enable building minizip shared library
MINIZIP_BUILD_STATIC=ON -- Enable building minizip static library
MINIZIP_BUILD_TESTING=ON -- Enable testing of minizip
MINIZIP_ENABLE_BZIP2=ON -- Build minizip withj bzip2 support
A usable installation of bzip2 is needed or config will fail. Turn this option of in this case.
MINIZIP_INSTALL=ON -- Enable installation of minizip
This option is only available on mingw as they tend to name this lib different. Maybe this will also be
removed in the future as. If you rely cmake for finding and using zlib, this can be turned off, as
the other file will never be used.
## Using the libs ##
To pull in what you need it's enough to just write
find_package(ZLIB CONFIG)
or
find_package(minizip CONFIG)
in your CMakeLists.txt, however it is advised to specify what you really want via:
find_package(ZLIB CONFIG COMPONENTS shared static REQUIRED)
or
find_package(minizip CONFIG COMPONENTS shared static REQUIRED)
As it's possible to only build the shared or the static lib, you can make sure that everything you need
is found. If no COMPONENTS are requested, everything needs to be found to satisfy your request. If the
libraries are optional in you project, you can omit the REQUIRED and check yourself if the targets you
want to link against are created.
When you search for minizip, it will search zlib for you, so only one of both is needed.
## Imported targets ##
When found the following targets are created for you:
ZLIB::ZLIB and ZLIB::ZLIBSTATIC -- for zlib
MINIZIP::minizip and MINIZIP::minizipstatic -- for minizip
+27 -5
View File
@@ -7,6 +7,8 @@
#include "zutil.h"
local uLong adler32_combine_ OF((uLong adler1, uLong adler2, z_off64_t len2));
#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 */
@@ -58,7 +60,11 @@
#endif
/* ========================================================================= */
uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
uLong ZEXPORT adler32_z(adler, buf, len)
uLong adler;
const Bytef *buf;
z_size_t len;
{
unsigned long sum2;
unsigned n;
@@ -125,12 +131,20 @@ uLong ZEXPORT adler32_z(uLong adler, const Bytef *buf, z_size_t len) {
}
/* ========================================================================= */
uLong ZEXPORT adler32(uLong adler, const Bytef *buf, uInt len) {
uLong ZEXPORT adler32(adler, buf, len)
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) {
local uLong adler32_combine_(adler1, adler2, len2)
uLong adler1;
uLong adler2;
z_off64_t len2;
{
unsigned long sum1;
unsigned long sum2;
unsigned rem;
@@ -155,10 +169,18 @@ local uLong adler32_combine_(uLong adler1, uLong adler2, z_off64_t len2) {
}
/* ========================================================================= */
uLong ZEXPORT adler32_combine(uLong adler1, uLong adler2, z_off_t len2) {
uLong ZEXPORT adler32_combine(adler1, adler2, len2)
uLong adler1;
uLong adler2;
z_off_t len2;
{
return adler32_combine_(adler1, adler2, len2);
}
uLong ZEXPORT adler32_combine64(uLong adler1, uLong adler2, z_off64_t len2) {
uLong ZEXPORT adler32_combine64(adler1, adler2, len2)
uLong adler1;
uLong adler2;
z_off64_t len2;
{
return adler32_combine_(adler1, adler2, len2);
}
+24 -37
View File
@@ -1,5 +1,5 @@
/* compress.c -- compress a memory buffer
* Copyright (C) 1995-2026 Jean-loup Gailly, Mark Adler
* Copyright (C) 1995-2005, 2014, 2016 Jean-loup Gailly, Mark Adler
* For conditions of distribution and use, see copyright notice in zlib.h
*/
@@ -18,19 +18,18 @@
compress2 returns Z_OK if success, Z_MEM_ERROR if there was not enough
memory, Z_BUF_ERROR if there was not enough room in the output buffer,
Z_STREAM_ERROR if the level parameter is invalid.
The _z versions of the functions take size_t length arguments.
*/
int ZEXPORT compress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
z_size_t sourceLen, int level) {
int ZEXPORT compress2(dest, destLen, source, sourceLen, level)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
int level;
{
z_stream stream;
int err;
const uInt max = (uInt)-1;
z_size_t left;
if ((sourceLen > 0 && source == NULL) ||
destLen == NULL || (*destLen > 0 && dest == NULL))
return Z_STREAM_ERROR;
uLong left;
left = *destLen;
*destLen = 0;
@@ -49,38 +48,29 @@ int ZEXPORT compress2_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
do {
if (stream.avail_out == 0) {
stream.avail_out = left > (z_size_t)max ? max : (uInt)left;
stream.avail_out = left > (uLong)max ? max : (uInt)left;
left -= stream.avail_out;
}
if (stream.avail_in == 0) {
stream.avail_in = sourceLen > (z_size_t)max ? max :
(uInt)sourceLen;
stream.avail_in = sourceLen > (uLong)max ? max : (uInt)sourceLen;
sourceLen -= stream.avail_in;
}
err = deflate(&stream, sourceLen ? Z_NO_FLUSH : Z_FINISH);
} while (err == Z_OK);
*destLen = (z_size_t)(stream.next_out - dest);
*destLen = stream.total_out;
deflateEnd(&stream);
return err == Z_STREAM_END ? Z_OK : err;
}
int ZEXPORT compress2(Bytef *dest, uLongf *destLen, const Bytef *source,
uLong sourceLen, int level) {
int ret;
z_size_t got = *destLen;
ret = compress2_z(dest, &got, source, sourceLen, level);
*destLen = (uLong)got;
return ret;
}
/* ===========================================================================
*/
int ZEXPORT compress_z(Bytef *dest, z_size_t *destLen, const Bytef *source,
z_size_t sourceLen) {
return compress2_z(dest, destLen, source, sourceLen,
Z_DEFAULT_COMPRESSION);
}
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
uLong sourceLen) {
int ZEXPORT compress(dest, destLen, source, sourceLen)
Bytef *dest;
uLongf *destLen;
const Bytef *source;
uLong sourceLen;
{
return compress2(dest, destLen, source, sourceLen, Z_DEFAULT_COMPRESSION);
}
@@ -88,12 +78,9 @@ int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source,
If the default memLevel or windowBits for deflateInit() is changed, then
this function needs to be updated.
*/
z_size_t ZEXPORT compressBound_z(z_size_t sourceLen) {
z_size_t bound = sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
(sourceLen >> 25) + 13;
return bound < sourceLen ? (z_size_t)-1 : bound;
}
uLong ZEXPORT compressBound(uLong sourceLen) {
z_size_t bound = compressBound_z(sourceLen);
return (uLong)bound != bound ? (uLong)-1 : (uLong)bound;
uLong ZEXPORT compressBound(sourceLen)
uLong sourceLen;
{
return sourceLen + (sourceLen >> 12) + (sourceLen >> 14) +
(sourceLen >> 25) + 13;
}
+51 -207
View File
@@ -25,7 +25,7 @@ if test $SRCDIR = "."; then
ZINCOUT="-I."
SRCDIR=""
else
ZINC='-I. -include zconf.h'
ZINC='-include zconf.h'
ZINCOUT='-I. -I$(SRCDIR)'
SRCDIR="$SRCDIR/"
fi
@@ -44,8 +44,9 @@ STATICLIB=libz.a
# extract zlib version numbers from zlib.h
VER=`sed -n -e '/VERSION "/s/.*"\(.*\)".*/\1/p' < ${SRCDIR}zlib.h`
VER3=`echo ${VER}|sed -n -e 's/\([0-9]\{1,\}\(\\.[0-9]\{1,\}\)\{1,2\}\).*/\1/p'`
VER1=`echo ${VER}|sed -n -e 's/\([0-9]\{1,\}\)\\..*/\1/p'`
VER3=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\\.[0-9]*\).*/\1/p' < ${SRCDIR}zlib.h`
VER2=`sed -n -e '/VERSION "/s/.*"\([0-9]*\\.[0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
VER1=`sed -n -e '/VERSION "/s/.*"\([0-9]*\)\\..*/\1/p' < ${SRCDIR}zlib.h`
# establish commands for library building
if "${CROSS_PREFIX}ar" --version >/dev/null 2>/dev/null || test $? -lt 126; then
@@ -87,15 +88,9 @@ zprefix=0
zconst=0
build64=0
gcc=0
clang=0
warn=0
debug=0
address=0
memory=0
undefined=0
insecure=0
unknown=0
enable_crcvx=1
sanitize=0
old_cc="$CC"
old_cflags="$CFLAGS"
OBJC='$(OBJZ) $(OBJG)'
@@ -107,7 +102,7 @@ leave()
if test "$*" != "0"; then
echo "** $0 aborting." | tee -a configure.log
fi
rm -rf $test.[co] $test $test$shared_ext $test.gcno $test.dSYM ./--version
rm -f $test.[co] $test $test$shared_ext $test.gcno ./--version
echo -------------------- >> configure.log
echo >> configure.log
echo >> configure.log
@@ -121,49 +116,38 @@ case "$1" in
-h* | --help)
echo 'usage:' | tee -a configure.log
echo ' configure [--const] [--zprefix] [--prefix=PREFIX] [--eprefix=EXPREFIX]' | tee -a configure.log
echo ' [--insecure] [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
echo ' [--includedir=INCLUDEDIR] [--mandir=MANDIR]' | tee -a configure.log
echo ' [--archs="-arch i386 -arch x86_64"] [--disable-crcvx]' | tee -a configure.log
echo ' [--static] [--64] [--libdir=LIBDIR] [--sharedlibdir=LIBDIR]' | tee -a configure.log
echo ' [--includedir=INCLUDEDIR] [--archs="-arch i386 -arch x86_64"]' | tee -a configure.log
exit 0 ;;
-p*=* | --prefix=*) prefix=`echo $1 | sed 's/[^=]*=//'`; shift ;;
-e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/[^=]*=//'`; shift ;;
-l*=* | --libdir=*) libdir=`echo $1 | sed 's/[^=]*=//'`; shift ;;
--sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/[^=]*=//'`; shift ;;
-i*=* | --includedir=*) includedir=`echo $1 | sed 's/[^=]*=//'`;shift ;;
-m*=* | --mandir=*) mandir=`echo $1 | sed 's/[^=]*=//'`;shift ;;
-u*=* | --uname=*) uname=`echo $1 | sed 's/[^=]*=//'`;shift ;;
-p*=* | --prefix=*) prefix=`echo $1 | sed 's/.*=//'`; shift ;;
-e*=* | --eprefix=*) exec_prefix=`echo $1 | sed 's/.*=//'`; shift ;;
-l*=* | --libdir=*) libdir=`echo $1 | sed 's/.*=//'`; shift ;;
--sharedlibdir=*) sharedlibdir=`echo $1 | sed 's/.*=//'`; shift ;;
-i*=* | --includedir=*) includedir=`echo $1 | sed 's/.*=//'`;shift ;;
-u*=* | --uname=*) uname=`echo $1 | sed 's/.*=//'`;shift ;;
-p* | --prefix) prefix="$2"; shift; shift ;;
-e* | --eprefix) exec_prefix="$2"; shift; shift ;;
-l* | --libdir) libdir="$2"; shift; shift ;;
--sharedlibdir) sharedlibdir="$2"; shift; shift ;;
-i* | --includedir) includedir="$2"; shift; shift ;;
-m* | --mandir) mandir="$2"; shift; shift ;;
-u* | --uname) uname="$2"; shift; shift ;;
-s* | --shared | --enable-shared) shared=1; shift ;;
-t | --static | --disable-shared) shared=0; shift ;;
-t | --static) shared=0; shift ;;
--solo) solo=1; shift ;;
--cover) cover=1; shift ;;
-z* | --zprefix) zprefix=1; shift ;;
-6* | --64) build64=1; shift ;;
-a*=* | --archs=*) ARCHS=`echo $1 | sed 's/[^=]*=//'`; shift ;;
-a* | --archs) ARCHS="$2"; shift; shift ;;
-a*=* | --archs=*) ARCHS=`echo $1 | sed 's/.*=//'`; shift ;;
--sysconfdir=*) echo "ignored option: --sysconfdir" | tee -a configure.log; shift ;;
--localstatedir=*) echo "ignored option: --localstatedir" | tee -a configure.log; shift ;;
-c* | --const) zconst=1; shift ;;
-w* | --warn) warn=$((warn + 1)); shift ;;
-w* | --warn) warn=1; shift ;;
-d* | --debug) debug=1; shift ;;
--sanitize) address=1; shift ;;
--address) address=1; shift ;;
--memory) memory=1; shift ;;
--undefined) undefined=1; shift ;;
--insecure) insecure=1; shift ;;
--disable-crcvx) enable_crcvx=0; shift ;;
*) unknown=1; echo "unknown option ignored: $1" | tee -a configure.log; shift;;
--sanitize) sanitize=1; shift ;;
*)
echo "unknown option: $1" | tee -a configure.log
echo "$0 --help for help" | tee -a configure.log
leave 1;;
esac
done
if test $unknown -eq 1; then
echo "$0 --help for help" | tee -a configure.log
fi
# temporary file name
test=ztest$$
@@ -198,88 +182,37 @@ else
fi
case "$cc" in
*gcc*) gcc=1
GCOV="gcov" ;;
*clang*) gcc=1
clang=1 ;;
*gcc*) gcc=1 ;;
*clang*) gcc=1 ;;
esac
case `$cc -v 2>&1` in
*gcc*) gcc=1
GCOV="gcov" ;;
*clang*) gcc=1
clang=1 ;;
*gcc*) gcc=1 ;;
*clang*) gcc=1 ;;
esac
if test $cover -eq 1; then
if test "$clang" -eq 1; then
if test "$cc" = "clang"; then
if command -v llvm-cov >/dev/null 2>&1; then
GCOV="llvm-cov"
LLVM_GCOV_FLAG="gcov"
GCOV="llvm-cov"
LLVM_GCOV_FLAG="gcov"
echo "Using ${GCOV} for coverage"
else
cover=0
GCOV=""
LLVM_GCOV_FLAG=""
echo "Deactivating cover as no suitable gcov can be found"
fi
else
clangV=`echo "$cc" | sed -e 's/^.*-//'`
if command -v llvm-cov-${clangV} >/dev/null 2>&1; then
GCOV="llvm-cov-${clangV}"
LLVM_GCOV_FLAG="gcov"
echo "Using ${GCOV} for coverage"
else
cover=0
GCOV=""
LLVM_GCOV_FLAG=""
echo "Deactivating cover as no suitable gcov can be found"
fi
fi
fi
fi
show $cc -c $test.c
if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
echo ... using gcc >> configure.log
CC="$cc"
CFLAGS="${CFLAGS--O3} -fPIC"
SFLAGS="${CFLAGS--O3}"
CFLAGS="${CFLAGS--O3}"
SFLAGS="${CFLAGS--O3} -fPIC"
if test "$ARCHS"; then
CFLAGS="${CFLAGS} ${ARCHS}"
SFLAGS="${SFLAGS} ${ARCHS}"
LDFLAGS="${LDFLAGS} ${ARCHS}"
fi
if test $build64 -eq 1; then
CFLAGS="${CFLAGS} -m64"
SFLAGS="${SFLAGS} -m64"
fi
if test "$warn" -ge 1; then
CFLAGS="${CFLAGS} -Wall -Wextra"
if test "$warn" -ge 2; then
CFLAGS="${CFLAGS} -Wconversion -Wshadow -Wundef"
if test "$warn" -eq 1; then
if test "$zconst" -eq 1; then
CFLAGS="${CFLAGS} -Wall -Wextra -Wcast-qual -DZLIB_CONST"
else
CFLAGS="${CFLAGS} -Wall -Wextra"
fi
fi
if test "$zconst" -eq 1; then
if test "$warn" -ge 1; then
CFLAGS="${CFLAGS} -Wcast-qual"
fi
CFLAGS="${CFLAGS} -DZLIB_CONST"
fi
if test $address -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=address -fno-omit-frame-pointer"
fi
if test $memory -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=memory -fno-omit-frame-pointer"
fi
if test $undefined -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=undefined -fno-omit-frame-pointer"
fi
if test $insecure -eq 1; then
CFLAGS="${CFLAGS} -DZLIB_INSECURE"
SFLAGS="${SFLAGS} -DZLIB_INSECURE"
if test $sanitize -eq 1; then
CFLAGS="${CFLAGS} -g -fsanitize=address"
fi
if test $debug -eq 1; then
CFLAGS="${CFLAGS} -DZLIB_DEBUG"
@@ -289,7 +222,7 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
uname=`(uname -s || echo unknown) 2>/dev/null`
fi
case "$uname" in
Linux* | linux* | *-linux* | GNU | GNU/* | solaris* | Haiku)
Linux* | linux* | *-linux* | GNU | GNU/* | solaris*)
case "$mname" in
*sparc*)
LDFLAGS="${LDFLAGS} -Wl,--no-warn-rwx-segments" ;;
@@ -320,7 +253,6 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
SHAREDLIB='libz.sl' ;;
esac ;;
AIX*)
LDSHARED=${LDSHARED-"$cc -shared"}
LDFLAGS="${LDFLAGS} -Wl,-brtl" ;;
Darwin* | darwin* | *-darwin*)
shared_ext='.dylib'
@@ -328,9 +260,7 @@ if test "$gcc" -eq 1 && ($cc -c $test.c) >> configure.log 2>&1; then
SHAREDLIBV=libz.$VER$shared_ext
SHAREDLIBM=libz.$VER1$shared_ext
LDSHARED=${LDSHARED-"$cc -dynamiclib -install_name $libdir/$SHAREDLIBM -compatibility_version $VER1 -current_version $VER3"}
if "${CROSS_PREFIX}libtool" -V 2>&1 | grep Apple > /dev/null; then
AR="${CROSS_PREFIX}libtool"
elif libtool -V 2>&1 | grep Apple > /dev/null; then
if libtool -V 2>&1 | grep Apple > /dev/null; then
AR="libtool"
else
AR="/usr/bin/libtool"
@@ -426,12 +356,7 @@ else
AIX*) # Courtesy of dbakker@arrayasolutions.com
SFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
CFLAGS=${CFLAGS-"-O -qmaxmem=8192"}
LDSHARED=${LDSHARED-"xlc -G"}
if test $build64 -eq 1; then
CFLAGS="${CFLAGS} -q64"
SFLAGS="${SFLAGS} -q64"
ARFLAGS="-X64 ${ARFLAGS}"
fi ;;
LDSHARED=${LDSHARED-"xlc -G"} ;;
# send working options for other systems to zlib@gzip.org
*) SFLAGS=${CFLAGS-"-O"}
CFLAGS=${CFLAGS-"-O"}
@@ -492,13 +417,6 @@ tryboth()
cat > $test.c << EOF
int foo() { return 0; }
EOF
echo "Checking for compiler..." >> configure.log
if try $CC -c $test.c; then
:
else
echo "Missing or broken C compiler." | tee -a configure.log
leave 1
fi
echo "Checking for obsessive-compulsive compiler options..." >> configure.log
if try $CC -c $CFLAGS $test.c; then
:
@@ -517,8 +435,8 @@ EOF
if test $shared -eq 1; then
echo Checking for shared library support... | tee -a configure.log
# we must test in two steps (cc then ld), required at least on SunOS 4.x
if try $CC -c $SFLAGS $test.c &&
try $LDSHARED $SFLAGS $LDFLAGS -o $test$shared_ext $test.o; then
if try $CC -w -c $SFLAGS $test.c &&
try $LDSHARED $SFLAGS -o $test$shared_ext $test.o; then
echo Building shared library $SHAREDLIBV with $CC. | tee -a configure.log
elif test -z "$old_cc" -a -z "$old_cflags"; then
echo No shared library support. | tee -a configure.log
@@ -580,7 +498,7 @@ int main(void) {
}
EOF
fi
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
if try $CC $CFLAGS -o $test $test.c; then
sizet=`./$test`
echo "Checking for a pointer-size integer type..." $sizet"." | tee -a configure.log
CFLAGS="${CFLAGS} -DNO_SIZE_T=${sizet}"
@@ -614,7 +532,7 @@ int main(void) {
return 0;
}
EOF
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
if try $CC $CFLAGS -o $test $test.c; then
echo "Checking for fseeko... Yes." | tee -a configure.log
else
CFLAGS="${CFLAGS} -DNO_FSEEKO"
@@ -631,7 +549,7 @@ cat > $test.c <<EOF
#include <errno.h>
int main() { return strlen(strerror(errno)); }
EOF
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
if try $CC $CFLAGS -o $test $test.c; then
echo "Checking for strerror... Yes." | tee -a configure.log
else
CFLAGS="${CFLAGS} -DNO_STRERROR"
@@ -650,7 +568,7 @@ cat > $test.c <<EOF
int main() { return 0; }
EOF
if try $CC -c $CFLAGS $test.c; then
sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/ HAVE_UNISTD_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h
sed < zconf.h "/^#ifdef HAVE_UNISTD_H.* may be/s/def HAVE_UNISTD_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
mv zconf.temp.h zconf.h
echo "Checking for unistd.h... Yes." | tee -a configure.log
else
@@ -665,7 +583,7 @@ cat > $test.c <<EOF
int main() { return 0; }
EOF
if try $CC -c $CFLAGS $test.c; then
sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/ HAVE_STDARG_H-0\(.*\) may be/ 1\1 was/" > zconf.temp.h
sed < zconf.h "/^#ifdef HAVE_STDARG_H.* may be/s/def HAVE_STDARG_H\(.*\) may be/ 1\1 was/" > zconf.temp.h
mv zconf.temp.h zconf.h
echo "Checking for stdarg.h... Yes." | tee -a configure.log
else
@@ -693,6 +611,7 @@ fi
# if code coverage testing was requested, use older gcc if defined, e.g. "gcc-4.2" on Mac OS X
if test $cover -eq 1; then
CFLAGS="${CFLAGS} -fprofile-arcs -ftest-coverage"
if test -n "$GCC_CLASSIC"; then
CC=$GCC_CLASSIC
fi
@@ -737,7 +656,7 @@ int main()
return (mytest("Hello%d\n", 1));
}
EOF
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
if try $CC $CFLAGS -o $test $test.c; then
echo "Checking for vsnprintf() in stdio.h... Yes." | tee -a configure.log
echo >> configure.log
@@ -777,10 +696,7 @@ EOF
echo " WARNING: vsnprintf() not found, falling back to vsprintf(). zlib" | tee -a configure.log
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
echo " vulnerabilities." | tee -a configure.log
if test $insecure -ne 1; then
echo " The --insecure option must be provided to ./configure in order to" | tee -a configure.log
echo " compile using the insecure vsprintf() function." | tee -a configure.log
fi
echo >> configure.log
cat >$test.c <<EOF
#include <stdio.h>
@@ -830,7 +746,7 @@ int main()
}
EOF
if try $CC $CFLAGS $LDFLAGS -o $test $test.c; then
if try $CC $CFLAGS -o $test $test.c; then
echo "Checking for snprintf() in stdio.h... Yes." | tee -a configure.log
echo >> configure.log
@@ -864,10 +780,7 @@ EOF
echo " WARNING: snprintf() not found, falling back to sprintf(). zlib" | tee -a configure.log
echo " can build but will be open to possible buffer-overflow security" | tee -a configure.log
echo " vulnerabilities." | tee -a configure.log
if test $insecure -ne 1; then
echo " The --insecure option must be provided to ./configure in order to" | tee -a configure.log
echo " compile using the insecure sprintf() function." | tee -a configure.log
fi
echo >> configure.log
cat >$test.c <<EOF
#include <stdio.h>
@@ -915,70 +828,6 @@ EOF
fi
fi
# check for ibm s390x build
HAVE_S390X=0
cat > $test.c << EOF
#ifndef __s390x__
#error
#endif
EOF
if try $CC -c $CFLAGS $test.c; then
echo "Checking for s390x build ... Yes." | tee -a configure.log
HAVE_S390X=1
else
echo "Checking for s390x build ... No." | tee -a configure.log
fi
# check for ibm s390x vx vector extensions
HAVE_S390X_VX=0
if test $HAVE_S390X -eq 1 && test $enable_crcvx -eq 1 ; then
# preset the compiler specific flags
if test $clang -eq 1; then
VGFMAFLAG=-fzvector
else
VGFMAFLAG=-mzarch
fi
cat > $test.c <<EOF
#ifndef __s390x__
#error
#endif
#include <vecintrin.h>
int main(void) {
unsigned long long a __attribute__((vector_size(16))) = { 0 };
unsigned long long b __attribute__((vector_size(16))) = { 0 };
unsigned char c __attribute__((vector_size(16))) = { 0 };
c = vec_gfmsum_accum_128(a, b, c);
return c[0];
}
EOF
# cflags already contains a valid march
if try $CC -c $CFLAGS $VGFMAFLAG $test.c; then
echo "Checking for s390x vx vector extension ... Yes." | tee -a configure.log
HAVE_S390X_VX=1
# or set march for our compile units
elif try $CC -c $CFLAGS $VGFMAFLAG -march=z13 $test.c; then
echo "Checking for s390x vx vector extension (march=z13) ... Yes." | tee -a configure.log
HAVE_S390X_VX=1
VGFMAFLAG="$VGFMAFLAG -march=z13"
# else we are not on s390x
else
echo "Checking for s390x vx vector extension ... No." | tee -a configure.log
fi
# prepare compiling for s390x
if test $HAVE_S390X_VX -eq 1; then
CFLAGS="$CFLAGS -DHAVE_S390X_VX"
SFLAGS="$SFLAGS -DHAVE_S390X_VX"
OBJC="$OBJC crc32_vx.o"
PIC_OBJC="$PIC_OBJC crc32_vx.lo"
else
# target has no vx extension
VGFMAFLAG=""
fi
fi
# show the results in the log
echo >> configure.log
echo ALL = $ALL >> configure.log
@@ -1010,15 +859,10 @@ echo mandir = $mandir >> configure.log
echo prefix = $prefix >> configure.log
echo sharedlibdir = $sharedlibdir >> configure.log
echo uname = $uname >> configure.log
echo HAVE_S390X = $HAVE_S390X >> configure.log
echo HAVE_S390X_VX = $HAVE_S390X_VX >> configure.log
echo VGFMAFLAG = $VGFMAFLAG >> configure.log
# update Makefile with the configure results
# udpate Makefile with the configure results
sed < ${SRCDIR}Makefile.in "
/^CC *=/s#=.*#=$CC#
/^GCOV *=/s#=.*#=$GCOV#
/^LLVM_GCOV_FLAG *=/s#=.*#=$LLVM_GCOV_FLAG#
/^CFLAGS *=/s#=.*#=$CFLAGS#
/^SFLAGS *=/s#=.*#=$SFLAGS#
/^LDFLAGS *=/s#=.*#=$LDFLAGS#
-61
View File
@@ -1,61 +0,0 @@
function(zlib_add_contrib_lib name description dir)
option(ZLIB_BUILD_${name} "Enable building of ${description}" OFF)
if(ZLIB_BUILD_${name})
if(NOT DEFINED ZLIB_${name}_BUILD_SHARED)
set(ZLIB_${name}_BUILD_SHARED ${ZLIB_BUILD_SHARED} CACHE BOOL "")
endif(NOT DEFINED ZLIB_${name}_BUILD_SHARED)
if(NOT DEFINED ZLIB_${name}_BUILD_STATIC)
set(ZLIB_${name}_BUILD_STATIC ${ZLIB_BUILD_STATIC} CACHE BOOL "")
endif(NOT DEFINED ZLIB_${name}_BUILD_STATIC)
if(NOT DEFINED ZLIB_${name}_BUILD_TESTING)
set(ZLIB_${name}_BUILD_TESTING ${ZLIB_BUILD_TESTING} CACHE BOOL "")
endif(NOT DEFINED ZLIB_${name}_BUILD_TESTING)
if(NOT DEFINED ZLIB_${name}_INSTALL)
set(ZLIB_${name}_INSTALL ${ZLIB_INSTALL} CACHE BOOL "")
endif(NOT DEFINED ZLIB_${name}_INSTALL)
add_subdirectory(${dir}/)
endif(ZLIB_BUILD_${name})
endfunction(zlib_add_contrib_lib name description dir)
function(zlib_add_contrib_feature name description dir)
if(ARGC EQUAL 4)
set(default_on ${ARGV3})
else()
set(default_on Off)
endif()
option(ZLIB_WITH_${name}
"Enable build ${description}"
${default_on})
if(ZLIB_WITH_${name})
add_subdirectory(${dir}/)
endif(ZLIB_WITH_${name})
endfunction(zlib_add_contrib_feature name description dir)
zlib_add_contrib_feature("GVMAT64"
"of an optimized longest_match for 32 bits x86_64"
gcc_gvmat64)
zlib_add_contrib_feature(INFBACK9 "with support for method 9 deflate" infback9)
zlib_add_contrib_feature(CRC32VX "with S390X-CRC32VX implementation" crc32vx)
zlib_add_contrib_lib(ADA "Ada bindings" ada)
zlib_add_contrib_lib(BLAST "blast binary" blast)
zlib_add_contrib_lib(IOSTREAM3 "IOStream C++ bindings V3" iostream3)
zlib_add_contrib_lib(MINIZIP "minizip library" minizip)
zlib_add_contrib_lib(PUFF "puff decompress library" puff)
if(WIN32)
zlib_add_contrib_lib(TESTZLIB "testzlib binary" testzlib)
if (ZLIB_BUILD_ZLIB1_DLL)
add_subdirectory(zlib1-dll/)
endif (ZLIB_BUILD_ZLIB1_DLL)
option(ZLIB_BUILD_ZLIB1_DLL "Build the legacy zlib + minizip DLL" OFF)
endif(WIN32)
+8 -8
View File
@@ -6,7 +6,7 @@ for help about these, not the zlib authors. Thanks.
ada/ by Dmitriy Anisimkov <anisimkov@yahoo.com>
Support for Ada
See https://zlib-ada.sourceforge.net/
See http://zlib-ada.sourceforge.net/
blast/ by Mark Adler <madler@alumni.caltech.edu>
Decompressor for output of PKWare Data Compression Library (DCL)
@@ -37,7 +37,7 @@ iostream3/ by Ludwig Schwardt <schwardt@sun.ac.za>
minizip/ by Gilles Vollant <info@winimage.com>
Mini zip and unzip based on zlib
Includes Zip64 support by Mathias Svensson <mathias@result42.com>
See https://www.winimage.com/zLibDll/minizip.html
See http://www.winimage.com/zLibDll/minizip.html
pascal/ by Bob Dellaca <bobdl@xtra.co.nz> et al.
Support for Pascal
@@ -46,12 +46,12 @@ puff/ by Mark Adler <madler@alumni.caltech.edu>
Small, low memory usage inflate. Also serves to provide an
unambiguous description of the deflate format.
crc32vx/ by Ilya Leoshkevich <iii@linux.ibm.com>
Hardware-accelerated CRC32 on IBM Z with Z13 VX extension.
testzlib/ by Gilles Vollant <info@winimage.com>
Example of the use of zlib
zlib1-dll/
by @Vollstrecker on github.com
Build the legacy zlib1.dll with zlib and minizip.
untgz/ by Pedro A. Aranda Gutierrez <paag@tid.es>
A very simple tar.gz file extractor using zlib
vstudio/ by Gilles Vollant <info@winimage.com>
Building a minizip-enhanced zlib with Microsoft Visual Studio
Includes vc11 from kreuzerkrieg and vc12 from davispuh
-217
View File
@@ -1,217 +0,0 @@
cmake_minimum_required(VERSION 3.12...3.31)
set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
project(
zlibAda
VERSION 1.0.0
LANGUAGES C ADA
DESCRIPTION "A library for creating zipfiles based in zlib"
HOMEPAGE_URL "https://www.zlib.net")
option(ZLIB_ADA_BUILD_SHARED "Enable building ada bindings shared library" ON)
option(ZLIB_ADA_BUILD_STATIC "Enable building ada bindings static library" ON)
option(ZLIB_ADA_BUILD_TESTING "Enable building tests for ada bindings library" ON)
if(WIN32 OR CYGWIN)
set(zlib_Ada_static_suffix "s")
set(CMAKE_DEBUG_POSTFIX "d")
endif(WIN32 OR CYGWIN)
if(NOT DEFINED ZLIB_BUILD_ADA)
if(ZLIB_ADA_BUILD_SHARED)
list(APPEND REQUIRED_COMPONENTS "shared")
endif(ZLIB_ADA_BUILD_SHARED)
if(ZLIB_ADA_BUILD_STATIC)
list(APPEND REQUIRED_COMPONENTS "static")
endif(ZLIB_ADA_BUILD_STATIC)
find_package(ZLIB REQUIRED COMPONENTS ${REQUIRED_COMPONENTS} CONFIG)
endif(NOT DEFINED ZLIB_BUILD_ADA)
function(ZLIB_ADA_findTestEnv testName)
set(testEnv "PATH=")
if(MSVC OR MINGW)
set(separator "\\\;")
else()
set(separator ":")
endif()
string(APPEND testEnv "$<TARGET_FILE_DIR:ZLIB::ZLIB>${separator}")
string(APPEND testEnv "$ENV{PATH}")
set_tests_properties(${testName} PROPERTIES ENVIRONMENT "${testEnv}")
endfunction(ZLIB_ADA_findTestEnv testName)
if(ZLIB_ADA_BUILD_SHARED)
ada_add_library(zlib_ada_Ada SHARED
zlib-thin.adb
zlib.adb)
set_target_properties(zlib_ada_Ada
PROPERTIES OUTPUT_NAME zlib-ada)
target_link_libraries(zlib_ada_Ada
INTERFACE ZLIB::ZLIB)
ada_add_library(zlib_ada_streams SHARED
zlib-streams.adb)
target_link_libraries(zlib_ada_streams
PUBLIC
zlib_ada_Ada)
ada_find_ali(zlib_ada_streams)
if(ZLIB_ADA_BUILD_TESTING)
enable_testing()
ada_add_executable(zlib_ada_test test.adb)
target_link_libraries(zlib_ada_test
PRIVATE
zlib_ada_Ada
zlib_ada_streams)
ada_find_ali(zlib_ada_test)
add_test(NAME zlib_ada_ada-test COMMAND zlib_ada_test)
set_tests_properties(zlib_ada_ada-test PROPERTIES FIXTURES_REQUIRED zlib_ada_cleanup)
if(MSVC
OR MSYS
OR MINGW
OR CYGWIN)
zlib_ada_findtestenv(zlib_ada_ada-test)
endif(
MSVC
OR MSYS
OR MINGW
OR CYGWIN)
ada_add_executable(zlib_ada_buffer_demo buffer_demo.adb)
target_link_libraries(zlib_ada_buffer_demo
PRIVATE
zlib_ada_Ada)
ada_find_ali(zlib_ada_buffer_demo)
add_test(NAME zlib_ada_buffer-demo COMMAND zlib_ada_buffer_demo)
if(MSVC
OR MSYS
OR MINGW
OR CYGWIN)
zlib_ada_findtestenv(zlib_ada_buffer-demo)
endif(
MSVC
OR MSYS
OR MINGW
OR CYGWIN)
ada_add_executable(zlib_ada_mtest mtest.adb)
target_link_libraries(zlib_ada_mtest
PRIVATE
zlib_ada_Ada)
ada_find_ali(zlib_ada_mtest)
#Not adding test as this is an endless-loop
ada_add_executable(zlib_ada_read read.adb)
target_link_libraries(zlib_ada_read
PRIVATE
zlib_ada_Ada)
ada_find_ali(zlib_ada_read)
add_test(NAME zlib_ada_read COMMAND zlib_ada_read)
if(MSVC
OR MSYS
OR MINGW
OR CYGWIN)
zlib_ada_findtestenv(zlib_ada_read)
endif(
MSVC
OR MSYS
OR MINGW
OR CYGWIN)
endif(ZLIB_ADA_BUILD_TESTING)
endif(ZLIB_ADA_BUILD_SHARED)
if(ZLIB_ADA_BUILD_STATIC)
ada_add_library(zlib_ada_AdaStatic STATIC
zlib-thin.adb
zlib.adb)
target_link_libraries(zlib_ada_AdaStatic
INTERFACE ZLIB::ZLIBSTATIC)
set_target_properties(zlib_ada_AdaStatic
PROPERTIES OUTPUT_NAME zlib-ada${zlib_Ada_static_suffix})
ada_add_library(zlib_ada_streamsStatic STATIC
zlib-streams.adb)
target_link_libraries(zlib_ada_streamsStatic
PUBLIC
zlib_ada_AdaStatic)
ada_find_ali(zlib_ada_streamsStatic)
if(ZLIB_ADA_BUILD_TESTING)
enable_testing()
ada_add_executable(zlib_ada_testStatic test.adb)
target_link_libraries(zlib_ada_testStatic
PRIVATE
zlib_ada_AdaStatic
zlib_ada_streamsStatic)
ada_find_ali(zlib_ada_testStatic)
add_test(NAME zlib_ada_testStatic COMMAND zlib_ada_testStatic)
set_tests_properties(zlib_ada_testStatic PROPERTIES FIXTURES_REQUIRED zlib_ada_cleanup)
ada_add_executable(zlib_ada_buffer-demoStatic buffer_demo.adb)
target_link_libraries(zlib_ada_buffer-demoStatic
PRIVATE
zlib_ada_AdaStatic)
ada_find_ali(zlib_ada_buffer-demoStatic)
add_test(NAME zlib_ada_buffer-demoStatic COMMAND zlib_ada_buffer-demoStatic)
ada_add_executable(zlib_ada_mtestStatic mtest.adb)
target_link_libraries(zlib_ada_mtestStatic
PRIVATE
zlib_ada_AdaStatic)
ada_find_ali(zlib_ada_mtestStatic)
# Not adding test as this is an endless-loop
ada_add_executable(zlib_ada_readStatic read.adb)
target_link_libraries(zlib_ada_readStatic
PRIVATE
zlib_ada_AdaStatic)
ada_find_ali(zlib_ada_readStatic)
add_test(NAME zlib_ada_readStatic COMMAND zlib_ada_readStatic)
endif(ZLIB_ADA_BUILD_TESTING)
endif(ZLIB_ADA_BUILD_STATIC)
if(ZLIB_ADA_BUILD_TESTING)
add_test(NAME zlib_ada_cleanup COMMAND ${CMAKE_COMMAND} -E rm ${CMAKE_CURRENT_BINARY_DIR}/testzlib.in
${CMAKE_CURRENT_BINARY_DIR}/testzlib.out ${CMAKE_CURRENT_BINARY_DIR}/testzlib.zlb)
set_tests_properties(zlib_ada_cleanup PROPERTIES FIXTURES_CLEANUP zlib_ada_cleanup)
endif(ZLIB_ADA_BUILD_TESTING)
@@ -1,23 +0,0 @@
set(CMAKE_ADA_COMPILER "@CMAKE_ADA_COMPILER@")
set(CMAKE_ADA_COMPILER_ARG1 "@CMAKE_ADA_COMPILER_ARG1@")
set(CMAKE_ADA_COMPILER_ID "@CMAKE_ADA_COMPILER_ID@")
set(CMAKE_ADA_COMPILER_VERSION "@CMAKE_ADA_COMPILER_VERSION@")
set(CMAKE_ADA_PLATFORM_ID "@CMAKE_ADA_PLATFORM_ID@")
set(CMAKE_AR "@CMAKE_AR@")
#set(CMAKE_RANLIB "@CMAKE_RANLIB@")
#set(CMAKE_LINKER "@CMAKE_LINKER@")
set(CMAKE_ADA_COMPILER_LOADED TRUE)
set(CMAKE_ADA_COMPILER_WORKS @CMAKE_ADA_COMPILER_WORKS@)
#set(CMAKE_ADA_ABI_COMPILED @CMAKE_ADA_ABI_COMPILED@)
set(CMAKE_ADA_COMPILER_ENV_VAR "ADA")
set(CMAKE_ADA_COMPILER_ID_RUN TRUE)
set(CMAKE_ADA_SOURCE_FILE_EXTENSIONS adb;ADB)
set(CMAKE_ADA_IGNORE_EXTENSIONS ;o;O;obj;OBJ;ali)
set(CMAKE_ADA_BINDER_HELPER "@CMAKE_ADA_BINDER_HELPER@")
set(CMAKE_ADA_COMPILER_HELPER "@CMAKE_ADA_COMPILER_HELPER@")
set(CMAKE_ADA_EXE_LINK_HELPER "@CMAKE_ADA_EXE_LINK_HELPER@")
set(CMAKE_ADA_SHARED_LINK_HELPER "@CMAKE_ADA_SHARED_LINK_HELPER@")
set(CMAKE_ADA_STATIC_LINK_HELPER "@CMAKE_ADA_STATIC_LINK_HELPER@")
@@ -1,133 +0,0 @@
include(CMakeLanguageInformation)
set(CMAKE_ADA_OUTPUT_EXTENSION .o)
set(CMAKE_ADA_OUTPUT_EXTENSION_REPLACE TRUE)
if(CMAKE_USER_MAKE_RULES_OVERRIDE)
include(${CMAKE_USER_MAKE_RULES_OVERRIDE} RESULT_VARIABLE _override)
set(CMAKE_USER_MAKE_RULES_OVERRIDE "${_override}")
endif(CMAKE_USER_MAKE_RULES_OVERRIDE)
if(CMAKE_USER_MAKE_RULES_OVERRIDE_ADA)
include(${CMAKE_USER_MAKE_RULES_OVERRIDE_ADA} RESULT_VARIABLE _override)
set(CMAKE_USER_MAKE_RULES_OVERRIDE_ADA "${_override}")
endif(CMAKE_USER_MAKE_RULES_OVERRIDE_ADA)
set(CMAKE_ADA_FLAGS_INIT "$ENV{ADAFLAGS} ${CMAKE_ADA_FLAGS_INIT}")
string(APPEND CMAKE_ADA_FLAGS_INIT " ")
string(APPEND CMAKE_ADA_FLAGS_DEBUG_INIT " -g")
string(APPEND CMAKE_ADA_FLAGS_MINSIZEREL_INIT " -Os")
string(APPEND CMAKE_ADA_FLAGS_RELEASE_INIT " -O3")
string(APPEND CMAKE_ADA_FLAGS_RELWITHDEBINFO_INIT " -O2 -g")
cmake_initialize_per_config_variable(CMAKE_ADA_FLAGS "Flags used by the Ada compiler")
if(CMAKE_ADA_STANDARD_LIBRARIES_INIT)
set(CMAKE_ADA_STANDARD_LIBRARIES
"${CMAKE_ADA_STANDARD_LIBRARIES_INIT}"
CACHE
STRING "Libraries linked by default with all Ada applications.")
mark_as_advanced(CMAKE_ADA_STANDARD_LIBRARIES)
endif(CMAKE_ADA_STANDARD_LIBRARIES_INIT)
if(NOT CMAKE_ADA_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_ADA_COMPILER_LAUNCHER})
set(CMAKE_ADA_COMPILER_LAUNCHER
"$ENV{CMAKE_ADA_COMPILER_LAUNCHER}"
CACHE
STRING "Compiler launcher for Ada.")
endif(NOT CMAKE_ADA_COMPILER_LAUNCHER AND DEFINED ENV{CMAKE_ADA_COMPILER_LAUNCHER})
if(NOT CMAKE_ADA_LINKER_LAUNCHER AND DEFINED ENV{CMAKE_ADA_LINKER_LAUNCHER})
set(CMAKE_ADA_LINKER_LAUNCHER
"$ENV{CMAKE_ADA_LINKER_LAUNCHER}"
CACHE
STRING "Linker launcher for Ada.")
endif(NOT CMAKE_ADA_LINKER_LAUNCHER AND DEFINED ENV{CMAKE_ADA_LINKER_LAUNCHER})
include(CMakeCommonLanguageInclude)
_cmake_common_language_platform_flags(ADA)
if(NOT CMAKE_ADA_CREATE_SHARED_LIBRARY)
set(CMAKE_ADA_CREATE_SHARED_LIBRARY
"${CMAKE_ADA_BINDER_HELPER} <CMAKE_ADA_COMPILER> <OBJECTS> FLAGS <FLAGS> <LINK_FLAGS>"
"${CMAKE_ADA_SHARED_LINK_HELPER} <CMAKE_ADA_COMPILER> <TARGET> <OBJECTS> <LINK_LIBRARIES>")
endif(NOT CMAKE_ADA_CREATE_SHARED_LIBRARY)
if(NOT CMAKE_ADA_CREATE_STATIC_LIBRARY)
set(CMAKE_ADA_CREATE_STATIC_LIBRARY
"${CMAKE_ADA_STATIC_LINK_HELPER} ${CMAKE_AR} <TARGET> <OBJECTS>")
endif(NOT CMAKE_ADA_CREATE_STATIC_LIBRARY)
if(NOT CMAKE_ADA_COMPILE_OBJECT)
set(CMAKE_ADA_COMPILE_OBJECT
"${CMAKE_ADA_COMPILER_HELPER} <CMAKE_ADA_COMPILER> <OBJECT_DIR> <SOURCE> <FLAGS>")
endif(NOT CMAKE_ADA_COMPILE_OBJECT)
if(NOT CMAKE_ADA_LINK_EXECUTABLE)
set(CMAKE_ADA_LINK_EXECUTABLE
"${CMAKE_ADA_BINDER_HELPER} <CMAKE_ADA_COMPILER> <OBJECTS> FLAGS <FLAGS> <LINK_FLAGS>"
"${CMAKE_ADA_EXE_LINK_HELPER} <CMAKE_ADA_COMPILER> <TARGET> <FLAGS> <CMAKE_C_LINK_FLAGS> <LINK_FLAGS> OBJ <OBJECTS> LIBS <LINK_LIBRARIES>")
endif(NOT CMAKE_ADA_LINK_EXECUTABLE)
function(ada_add_executable)
if(ARGC GREATER 1)
math(EXPR last_index "${ARGC} - 1")
foreach(source RANGE 1 ${last_index})
list(APPEND SOURCES ${ARGV${source}})
string(REPLACE ".adb" "" ali "${ARGV${source}}")
set(clean_file "CMakeFiles/${ARGV0}.dir/${ali}.ali")
list(APPEND CLEAN_FILES ${clean_file})
list(APPEND CLEAN_FILES b~${ali}.adb)
list(APPEND CLEAN_FILES b~${ali}.ads)
list(APPEND CLEAN_FILES b~${ali}.ali)
list(APPEND CLEAN_FILES b~${ali}.o)
endforeach(source RANGE 1 ${ARGC})
add_executable(${ARGV0} ${ARGV1} ${SOURCES})
set_target_properties(${ARGV0}
PROPERTIES
ADDITIONAL_CLEAN_FILES "${CLEAN_FILES}")
endif(ARGC GREATER 1)
endfunction(ada_add_executable)
function(ada_add_library)
if(ARGC GREATER 2)
math(EXPR last_index "${ARGC} - 1")
foreach(source RANGE 2 ${last_index})
list(APPEND SOURCES ${ARGV${source}})
string(REPLACE ".adb" "" ali "${ARGV${source}}")
set(clean_file "CMakeFiles/${ARGV0}.dir/${ali}.ali")
list(APPEND CLEAN_FILES ${clean_file})
list(APPEND CLEAN_FILES b~${ali}.adb)
list(APPEND CLEAN_FILES b~${ali}.ads)
list(APPEND CLEAN_FILES b~${ali}.ali)
list(APPEND CLEAN_FILES b~${ali}.o)
endforeach(source RANGE 2 ${ARGC})
add_library(${ARGV0} ${ARGV1} ${SOURCES})
set_target_properties(${ARGV0}
PROPERTIES
ADDITIONAL_CLEAN_FILES "${CLEAN_FILES};dummylib.adb;dummylib.ali;dummylib.o"
ALI_FLAG "-aO${CMAKE_CURRENT_BINARY_DIR}/CMakeFiles/${ARGV0}.dir/")
endif(ARGC GREATER 2)
endfunction(ada_add_library)
function(ada_find_ali)
get_target_property(link_libs ${ARGV0} LINK_LIBRARIES)
foreach(lib IN LISTS link_libs)
get_target_property(ali ${lib} ALI_FLAG)
string(APPEND FLAGS ${ali} " ")
unset(ali)
endforeach(lib IN LISTS link_libs)
set_target_properties(${ARGV0}
PROPERTIES
LINK_FLAGS ${FLAGS})
endfunction(ada_find_ali)
set(CMAKE_ADA_INFORMATION_LOADED TRUE)
@@ -1,33 +0,0 @@
include(${CMAKE_ROOT}/Modules/CMakeDetermineCompiler.cmake)
# Load system-specific compiler preferences for this language.
include(Platform/${CMAKE_SYSTEM_NAME}-Determine-Ada OPTIONAL)
include(Platform/${CMAKE_SYSTEM_NAME}-Ada OPTIONAL)
if(NOT CMAKE_ADA_COMPILER_NAMES)
set(CMAKE_ADA_COMPILER_NAMES gnat)
foreach(ver RANGE 11 99)
list(APPEND CMAKE_ADA_COMPILER_NAMES gnat-${ver})
endforeach(ver RANGE 11 99)
endif(NOT CMAKE_ADA_COMPILER_NAMES)
if(NOT CMAKE_ADA_COMPILER)
set(CMAKE_ADA_COMPILER_INIT NOTFOUND)
_cmake_find_compiler(ADA)
else(NOT CMAKE_REAL_ADA_COMPILER)
_cmake_find_compiler_path(ADA)
endif(NOT CMAKE_ADA_COMPILER)
mark_as_advanced(CMAKE_ADA_COMPILER)
set(CMAKE_ADA_COMPILER_ID "GNU")
set(CMAKE_ADA_BINDER_HELPER "${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/binder_helper.cmake")
set(CMAKE_ADA_COMPILER_HELPER "${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/compile_helper.cmake")
set(CMAKE_ADA_EXE_LINK_HELPER "${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/exe_link_helper.cmake")
set(CMAKE_ADA_SHARED_LINK_HELPER "${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/shared_link_helper.cmake")
set(CMAKE_ADA_STATIC_LINK_HELPER "${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/cmake/static_link_helper.cmake")
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/CMakeADACompiler.cmake.in
${CMAKE_PLATFORM_INFO_DIR}/CMakeADACompiler.cmake
@ONLY)
@@ -1,46 +0,0 @@
include(CMakeTestCompilerCommon)
unset(CMAKE_ADA_COMPILER_WORKS CACHE)
if(NOT CMAKE_ADA_COMPILER_WORKS)
PrintTestCompilerStatus("ADA" "")
set(_ADA_TEST_FILE "${CMAKE_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/CMakeTmp/main.adb")
file(WRITE ${_ADA_TEST_FILE}
"with Ada.Text_IO; use Ada.Text_IO;\n"
"\n"
"procedure main is\n"
"begin\n"
"Put_Line(\"Hello, World!\");\n"
"end Main;\n")
try_compile(CMAKE_ADA_COMPILER_WORKS ${CMAKE_BINARY_DIR}
${_ADA_TEST_FILE}
OUTPUT_VARIABLE __CMAKE_ADA_COMPILER_OUTPUT)
set(CMAKE_ADA_COMPILER_WORKS ${CMAKE_ADA_COMPILER_WORKS})
unset(CMAKE_ADA_COMPILER_WORKS CACHE)
set(ADA_TEST_WAS_RUN TRUE)
endif(NOT CMAKE_ADA_COMPILER_WORKS)
if(NOT CMAKE_ADA_COMPILER_WORKS)
PrintTestCompilerStatus("ADA" " -- broken")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determining if the Ada compiler works failed with "
"the following output:\n${__CMAKE_ADA_COMPILER_OUTPUT}\n\n")
message(FATAL_ERROR "The Ada compiler \"${CMAKE_ADA_COMPILER}\" "
"is not able to compile a simple test program.\nIt fails "
"with the following output:\n ${__CMAKE_ADA_COMPILER_OUTPUT}\n\n"
"CMake will not be able to correctly generate this project.")
else(NOT CMAKE_ADA_COMPILER_WORKS)
if(ADA_TEST_WAS_RUN)
PrintTestCompilerStatus("ADA" " -- works")
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining if the Ada compiler works passed with "
"the following output:\n${__CMAKE_ADA_COMPILER_OUTPUT}\n\n")
endif(ADA_TEST_WAS_RUN)
endif(NOT CMAKE_ADA_COMPILER_WORKS)
unset(__CMAKE_ADA_COMPILER_OUTPUT)
@@ -1,47 +0,0 @@
#CMAKE_ARGV0 = /path/to/cmake
#CMAKE_ARGV1 = -P
#CMAKE_ARGV2 = path/to/this/file
#CMAKE_ARGV3 = binder
#CMAKE_ARGV4 = ali
if(NOT CMAKE_ARGV3)
message(FATAL_ERROR "binder not set")
endif(NOT CMAKE_ARGV3)
string(REPLACE ".o" ".ali" ALI ${CMAKE_ARGV4})
set (REACHED_FLAGS FALSE)
#iterate over additional objects, only the main one is needed
foreach(arg RANGE 5 ${CMAKE_ARGC})
if(CMAKE_ARGV${arg} STREQUAL FLAGS)
set(REACHED_FLAGS TRUE)
continue()
endif(CMAKE_ARGV${arg} STREQUAL FLAGS)
string(SUBSTRING "${CMAKE_ARGV${arg}}" 0 2 start)
if(start STREQUAL "-O")
continue()
endif(start STREQUAL "-O")
if(REACHED_FLAGS)
list(APPEND FLAGS ${CMAKE_ARGV${arg}})
endif(REACHED_FLAGS)
endforeach(arg RANGE 5 CMAKE_ARGC)
#first see if there is a main function
execute_process(COMMAND ${CMAKE_ARGV3} bind ${ALI} ${FLAGS}
RESULT_VARIABLE MAIN_RESULT
OUTPUT_VARIABLE dont_care
ERROR_VARIABLE ERROR)
if(MAIN_RESULT)
execute_process(COMMAND ${CMAKE_ARGV3} bind -n ${ALI} ${FLAGS}
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE dont_care
ERROR_VARIABLE ERROR)
endif(MAIN_RESULT)
if(RESULT)
message(FATAL_ERROR ${RESULT} ${ERROR})
endif(RESULT)
@@ -1,32 +0,0 @@
#CMAKE_ARGV0 = /path/to/cmake
#CMAKE_ARGV1 = -P
#CMAKE_ARGV2 = path/to/this/file
#CMAKE_ARGV3 = compiler
#CMAKE_ARGV4 = OBJECT-DIR
#CMAKE_ARGV5 = source-file
if(NOT CMAKE_ARGV3)
message(FATAL_ERROR "compiler not set")
endif(NOT CMAKE_ARGV3)
if(NOT CMAKE_ARGV4)
message(FATAL_ERROR "object dir not set")
endif(NOT CMAKE_ARGV4)
if(NOT CMAKE_ARGV5)
message(FATAL_ERROR "source not set")
endif(NOT CMAKE_ARGV5)
foreach(arg RANGE 6 ${CMAKE_ARGC})
list(APPEND FLAGS "${CMAKE_ARGV${arg}}")
endforeach(arg RANGE 6 ${CMAKE_ARGC})
execute_process(COMMAND ${CMAKE_ARGV3} compile ${FLAGS} ${CMAKE_ARGV5}
WORKING_DIRECTORY ${CMAKE_ARGV4}
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE dont_care
ERROR_VARIABLE ERROR)
if(RESULT)
message(FATAL_ERROR ${RESULT} ${ERROR})
endif(RESULT)
@@ -1,53 +0,0 @@
#CMAKE_ARGV0 = /path/to/cmake
#CMAKE_ARGV1 = -P
#CMAKE_ARGV2 = path/to/this/file
#CMAKE_ARGV3 = linker
#CMAKE_ARGV4 = output-name
#CMAKE_ARGV5...CMAKE_AGVN = OBJECTS
#CMAKE_ARGVN+1 = LIBS
#CMAKE_ARGVN+2...CMAKE_ARGVM libraries
if(NOT CMAKE_ARGV3)
message(FATAL_ERROR "linker not set")
endif(NOT CMAKE_ARGV3)
set(REACHED_LIBS FALSE)
set(REACHED_OBJ FALSE)
foreach(arg RANGE 5 ${CMAKE_ARGC})
if(CMAKE_ARGV${arg} STREQUAL LIBS)
set(REACHED_LIBS TRUE)
set(REACHED_OBJ FALSE)
continue()
endif(CMAKE_ARGV${arg} STREQUAL LIBS)
if(CMAKE_ARGV${arg} STREQUAL OBJ)
set(REACHED_LIBS FALSE)
set(REACHED_OBJ TRUE)
continue()
endif(CMAKE_ARGV${arg} STREQUAL OBJ)
if(CMAKE_ARGC EQUAL arg)
continue()
endif(CMAKE_ARGC EQUAL arg)
if(REACHED_LIBS)
list(APPEND LIBS "${CMAKE_ARGV${arg}}")
elseif(REACHED_OBJ AND NOT ALI)
string(REPLACE ".o" ".ali" ALI "${CMAKE_ARGV${arg}}")
else(REACHED_LIBS)
string(SUBSTRING "${CMAKE_ARGV${arg}}" 0 3 start)
if(NOT start STREQUAL -aO)
list(APPEND FLAGS "${CMAKE_ARGV${arg}}")
endif(NOT start STREQUAL -aO)
endif(REACHED_LIBS)
endforeach(arg RANGE 5 ${CMAKE_ARGC})
execute_process(COMMAND ${CMAKE_ARGV3} link ${ALI} -o ${CMAKE_ARGV4} ${FLAGS} ${OTHER_OBJECTS} ${LIBS}
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE dont_care
ERROR_VARIABLE ERROR)
if(RESULT)
message(FATAL_ERROR ${RESULT} ${ERROR})
endif(RESULT)
@@ -1,52 +0,0 @@
#CMAKE_ARGV0 = /path/to/cmake
#CMAKE_ARGV1 = -P
#CMAKE_ARGV2 = path/to/this/file
#CMAKE_ARGV3 = linker
#CMAKE_ARGV4 = output-name
#CMAKE_ARGV5...CMAKE_AGVN = OBJECTS
#CMAKE_ARGVN+1 = LIBS
#CMAKE_ARGVN+2...CMAKE_ARGVM libraries
if(NOT CMAKE_ARGV3)
message(FATAL_ERROR "linker not set")
endif(NOT CMAKE_ARGV3)
set(REACHED_FILES FALSE)
foreach(arg RANGE 5 ${CMAKE_ARGC})
if(CMAKE_ARGV${arg} STREQUAL "LIBS")
set(REACHED_FILES TRUE)
continue()
endif(CMAKE_ARGV${arg} STREQUAL "LIBS")
if(CMAKE_ARGC EQUAL arg)
continue()
endif(CMAKE_ARGC EQUAL arg)
if(REACHED_LIBS)
list(APPEND LIBS "${CMAKE_ARGV${arg}} ")
else(REACHED_LIBS)
list(APPEND OBJECT_FILES "${CMAKE_ARGV${arg}}")
endif(REACHED_LIBS)
endforeach(arg RANGE 5 ${CMAKE_ARGC})
file(WRITE dummylib.adb
"procedure dummylib is\n"
"begin\n"
" null;\n"
"end;\n")
execute_process(COMMAND ${CMAKE_ARGV3} compile -fPIC dummylib.adb
OUTPUT_VARIABLE dont_care
ERROR_VARIABLE ERROR)
execute_process(COMMAND ${CMAKE_ARGV3} bind -n dummylib.ali
OUTPUT_VARIABLE dont_care
ERROR_VARIABLE ERROR)
execute_process(COMMAND ${CMAKE_ARGV3} link -shared dummylib.ali -o ${CMAKE_ARGV4} ${OBJECT_FILES} ${LIBS}
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE dont_care
ERROR_VARIABLE ERROR)
if(RESULT)
message(FATAL_ERROR ${RESULT} ${ERROR})
endif(RESULT)
@@ -1,25 +0,0 @@
#CMAKE_ARGV0 = /path/to/cmake
#CMAKE_ARGV1 = -P
#CMAKE_ARGV2 = path/to/this/file
#CMAKE_ARGV3 = path/to/ar
#CMAKE_ARGV4 = output-name
#CMAKE_ARGV5...CMAKE_AGVN = OBJECTS
if(NOT CMAKE_ARGV3)
message(FATAL_ERROR "linker not set")
endif(NOT CMAKE_ARGV3)
foreach(arg RANGE 5 ${CMAKE_ARGC})
if(NOT CMAKE_ARGC EQUAL arg)
list(APPEND OBJECT_FILES "${CMAKE_ARGV${arg}}")
endif(NOT CMAKE_ARGC EQUAL arg)
endforeach(arg RANGE 6 ${CMAKE_ARGC})
execute_process(COMMAND ${CMAKE_ARGV3} rcs ${CMAKE_ARGV4} ${OBJECT_FILES}
RESULT_VARIABLE RESULT
OUTPUT_VARIABLE dont_care
ERROR_VARIABLE ERROR)
if(RESULT)
message(FATAL_ERROR ${RESULT} ${ERROR})
endif(RESULT)
+4 -4
View File
@@ -2,14 +2,14 @@
Release 1.3
ZLib.Ada is a thick binding interface to the popular ZLib data
compression library, available at https://zlib.net/.
compression library, available at http://www.gzip.org/zlib/.
It provides Ada-style access to the ZLib C library.
Here are the main changes since ZLib.Ada 1.2:
- Attention: ZLib.Read generic routine have a initialization requirement
for Read_Last parameter now. It is a bit incompatible with previous version,
- Attension: ZLib.Read generic routine have a initialization requirement
for Read_Last parameter now. It is a bit incompartible with previous version,
but extends functionality, we could use new parameters Allow_Read_Some and
Flush now.
@@ -59,7 +59,7 @@ the main functionality of ZLib.Ada.
The routines from the package specifications are commented.
Homepage: https://zlib-ada.sourceforge.net/
Homepage: http://zlib-ada.sourceforge.net/
Author: Dmitriy Anisimkov <anisimkov@yahoo.com>
Contributors: Pascal Obry <pascal@obry.org>, Steve Sangwine <sjs@essex.ac.uk>
+2 -2
View File
@@ -65,12 +65,12 @@ procedure Test is
Time_Stamp : Ada.Calendar.Time;
procedure Generate_File;
-- Generate file of specified size with some random data.
-- Generate file of spetsified size with some random data.
-- The random data is repeatable, for the good compression.
procedure Compare_Streams
(Left, Right : in out Root_Stream_Type'Class);
-- The procedure comparing data in 2 streams.
-- The procedure compearing data in 2 streams.
-- It is for compare data before and after compression/decompression.
procedure Compare_Files (Left, Right : String);
+1 -1
View File
@@ -62,7 +62,7 @@ package ZLib.Streams is
:= Default_Buffer_Size;
Write_Buffer_Size : in Ada.Streams.Stream_Element_Offset
:= Default_Buffer_Size);
-- Create the Compression/Decompression stream.
-- Create the Comression/Decompression stream.
-- If mode is In_Stream then Write operation is disabled.
-- If mode is Out_Stream then Read operation is disabled.
+1 -2
View File
@@ -12,8 +12,7 @@ package body ZLib.Thin is
ZLIB_VERSION : constant Chars_Ptr := zlibVersion;
Dummy : Z_Stream;
Z_Stream_Size : constant Int := Dummy'Size / System.Storage_Unit;
Z_Stream_Size : constant Int := Z_Stream'Size / System.Storage_Unit;
--------------
-- Avail_In --
+1 -1
View File
@@ -204,7 +204,7 @@ package body ZLib is
end if;
-- We allow ZLib to make header only in case of default header type.
-- Otherwise we would either do header by ourselves, or do not do
-- Otherwise we would either do header by ourselfs, or do not do
-- header at all.
if Header = None or else Header = GZip then
+1 -1
View File
@@ -114,7 +114,7 @@ package ZLib is
-- Compression strategy constants --
------------------------------------
-- RLE strategy could be used only in version 1.2.0 and later.
-- RLE stategy could be used only in version 1.2.0 and later.
Filtered : constant Strategy_Type;
Huffman_Only : constant Strategy_Type;
+3 -3
View File
@@ -145,7 +145,7 @@ LastMatchGood:
movl %eax, %ebx
LookaheadLess: movl %ebx, nicematch(%esp)
/* Bytef *scan = s->window + s->strstart; */
/* register Bytef *scan = s->window + s->strstart; */
movl dsWindow(%edx), %esi
movl %esi, window(%esp)
@@ -181,8 +181,8 @@ LimitPositive:
addl %eax, %esi
movl %esi, windowbestlen(%esp)
/* ush scan_start = *(ushf*)scan; */
/* ush scan_end = *(ushf*)(scan+best_len-1); */
/* register ush scan_start = *(ushf*)scan; */
/* register ush scan_end = *(ushf*)(scan+best_len-1); */
/* Posf *prev = s->prev; */
movzwl (%edi), %ebx
-166
View File
@@ -1,166 +0,0 @@
cmake_minimum_required(VERSION 3.12...3.31)
project(
blast
VERSION 1.3.0
LANGUAGES C
DESCRIPTION "A library for creating zipfiles based in zlib"
HOMEPAGE_URL "https://www.zlib.net")
option(ZLIB_BLAST_BUILD_SHARED "Enable building blast shared library" ON)
option(ZLIB_BLAST_BUILD_STATIC "Enable building blast static library" ON)
option(ZLIB_BLAST_BUILD_TESTING "Enable building tests for blast" ON)
option(ZLIB_BLAST_INSTALL "Enable installation of blast" ON)
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
if(WIN32 OR CYGWIN)
set(zlibblast_static_suffix "s")
set(CMAKE_DEBUG_POSTFIX "d")
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
endif(WIN32 OR CYGWIN)
function(blast_findTestEnv testName)
set(testEnv "PATH=")
if(MSVC OR MINGW)
set(separator "\\\;")
else()
set(separator ":")
endif()
string(APPEND testEnv "$<TARGET_FILE_DIR:BLAST::BLAST>${separator}")
string(APPEND testEnv "$ENV{PATH}")
set_tests_properties(${testName} PROPERTIES ENVIRONMENT "${testEnv}")
endfunction(blast_findTestEnv testName)
if(ZLIB_BLAST_BUILD_SHARED)
add_library(zlib_blast_blast SHARED
blast.c
blast.h)
add_library(BLAST::BLAST ALIAS zlib_blast_blast)
if(NOT CYGWIN)
set_target_properties(zlib_blast_blast
PROPERTIES
SOVERSION ${blast_VERSION_MAJOR}
VERSION ${blast_VERSION})
endif(NOT CYGWIN)
set_target_properties(zlib_blast_blast
PROPERTIES
EXPORT_NAME BLAST
OUTPUT_NAME blast)
if(ZLIB_BLAST_BUILD_TESTING)
enable_testing()
add_executable(zlib_blast_blast-test blast-test.c)
target_link_libraries(zlib_blast_blast-test PRIVATE zlib_blast_blast)
add_test(NAME zlib_blast_blast-test
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/tester.cmake
"$<TARGET_FILE:zlib_blast_blast-test>"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}")
if(MSVC
OR MSYS
OR MINGW
OR CYGWIN)
blast_findtestenv(zlib_blast_blast-test)
endif(
MSVC
OR MSYS
OR MINGW
OR CYGWIN)
endif(ZLIB_BLAST_BUILD_TESTING)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
add_library(zlib_blast_blastStatic STATIC
blast.c
blast.h)
add_library(BLAST::BLASTSTATIC ALIAS zlib_blast_blastStatic)
set_target_properties(zlib_blast_blastStatic
PROPERTIES
EXPORT_NAME BLASTSTATIC
OUTPUT_NAME blast${zlibblast_static_suffix})
if(ZLIB_BLAST_BUILD_TESTING)
enable_testing()
add_executable(zlib_blast_testStatic blast-test.c)
target_link_libraries(zlib_blast_testStatic
PRIVATE zlib_blast_blastStatic)
add_test(NAME zlib_blast_testStatic
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_SOURCE_DIR}/tester.cmake
"$<TARGET_FILE:zlib_blast_testStatic>"
"${CMAKE_CURRENT_SOURCE_DIR}"
"${CMAKE_CURRENT_BINARY_DIR}")
endif(ZLIB_BLAST_BUILD_TESTING)
endif(ZLIB_BLAST_BUILD_STATIC)
if(ZLIB_BLAST_BUILD_TESTING)
add_subdirectory(test)
endif(ZLIB_BLAST_BUILD_TESTING)
if(ZLIB_BLAST_INSTALL)
if(ZLIB_BLAST_BUILD_SHARED)
install(
TARGETS zlib_blast_blast
COMPONENT Runtime
EXPORT zlibBlastSharedExport
RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}"
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT zlibBlastSharedExport
FILE blast-shared.cmake
NAMESPACE BLAST::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/blast)
if(MSVC)
install(
FILES $<TARGET_PDB_FILE:zlib_blast_blast>
COMPONENT Development
DESTINATION ${CMAKE_INSTALL_BINDIR}
CONFIGURATIONS Debug OR RelWithDebInfo
OPTIONAL)
endif(MSVC)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
install(
TARGETS zlib_blast_blastStatic
COMPONENT Development
EXPORT zlibBlastStaticExport
ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")
install(
EXPORT zlibBlastStaticExport
FILE blast-static.cmake
NAMESPACE BLAST::
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/blast)
endif(ZLIB_BLAST_BUILD_STATIC)
configure_package_config_file(
${blast_SOURCE_DIR}/blastConfig.cmake.in
${blast_BINARY_DIR}/blastConfig.cmake
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/blast)
write_basic_package_version_file(
"${blast_BINARY_DIR}/blastConfigVersion.cmake"
VERSION "${blast_VERSION}"
COMPATIBILITY AnyNewerVersion)
install(FILES ${blast_BINARY_DIR}/blastConfig.cmake
${blast_BINARY_DIR}/blastConfigVersion.cmake
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/blast)
install(
FILES blast.h
COMPONENT Development
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}")
endif(ZLIB_BLAST_INSTALL)
+5 -11
View File
@@ -1,14 +1,8 @@
all: test
blast: blast.c blast.h
cc -DTEST -o blast blast.c
libblast.so: blast.c blast.h
cc -o libblast.so -shared blast.c
blast-test: libblast.so
cc -o blast-test.o -c blast-test.c
cc -o blast-test blast-test.o libblast.so
test: blast-test
LD_LIBRARY_PATH=./ ./blast-test < test.pk | cmp - test.txt
test: blast
blast < test.pk | cmp - test.txt
clean:
rm -f libblast.so blast-test blast-test.o
rm -f blast blast.o
-42
View File
@@ -1,42 +0,0 @@
#include "blast.h" /* prototype for blast() */
/* Example of how to use blast() */
#include <stdio.h>
#include <stdlib.h>
#define CHUNK 16384
local unsigned inf(void *how, unsigned char **buf)
{
static unsigned char hold[CHUNK];
*buf = hold;
return fread(hold, 1, CHUNK, (FILE *)how);
}
local int outf(void *how, unsigned char *buf, unsigned len)
{
return fwrite(buf, 1, len, (FILE *)how) != len;
}
/* Decompress a PKWare Compression Library stream from stdin to stdout */
int main(void)
{
int ret;
unsigned left;
/* decompress to stdout */
left = 0;
ret = blast(inf, stdin, outf, stdout, &left, NULL);
if (ret != 0)
fprintf(stderr, "blast error: %d\n", ret);
/* count any leftover bytes */
while (getchar() != EOF)
left++;
if (left)
fprintf(stderr, "blast warning: %u unused bytes of input\n", left);
/* return blast() error code */
return ret;
}
+44
View File
@@ -33,6 +33,7 @@
#include <setjmp.h> /* for setjmp(), longjmp(), and jmp_buf */
#include "blast.h" /* prototype for blast() */
#define local static /* for local function definitions */
#define MAXBITS 13 /* maximum code length */
#define MAXWIN 4096 /* maximum window size */
@@ -420,3 +421,46 @@ int blast(blast_in infun, void *inhow, blast_out outfun, void *outhow,
err = 1;
return err;
}
#ifdef TEST
/* Example of how to use blast() */
#include <stdio.h>
#include <stdlib.h>
#define CHUNK 16384
local unsigned inf(void *how, unsigned char **buf)
{
static unsigned char hold[CHUNK];
*buf = hold;
return fread(hold, 1, CHUNK, (FILE *)how);
}
local int outf(void *how, unsigned char *buf, unsigned len)
{
return fwrite(buf, 1, len, (FILE *)how) != len;
}
/* Decompress a PKWare Compression Library stream from stdin to stdout */
int main(void)
{
int ret;
unsigned left;
/* decompress to stdout */
left = 0;
ret = blast(inf, stdin, outf, stdout, &left, NULL);
if (ret != 0)
fprintf(stderr, "blast error: %d\n", ret);
/* count any leftover bytes */
while (getchar() != EOF)
left++;
if (left)
fprintf(stderr, "blast warning: %u unused bytes of input\n", left);
/* return blast() error code */
return ret;
}
#endif
-1
View File
@@ -21,7 +21,6 @@
Mark Adler madler@alumni.caltech.edu
*/
#define local static /* for local function definitions */
/*
* blast() decompresses the PKWare Data Compression Library (DCL) compressed
@@ -1,18 +0,0 @@
@PACKAGE_INIT@
set(_blast_supported_components "shared" "static")
if(blast_FIND_COMPONENTS)
foreach(_comp ${blast_FIND_COMPONENTS})
if(NOT _comp IN_LIST _blast_supported_components)
set(blast_FOUND False)
set(blast_NOT_FOUND_MESSAGE "Unsupported component: ${_comp}")
endif(NOT _comp IN_LIST _blast_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/blast-${_comp}.cmake")
endforeach(_comp ${blast_FIND_COMPONENTS})
else(blast_FIND_COMPONENTS)
foreach(_component_config IN LISTS _blast_supported_components)
include("${CMAKE_CURRENT_LIST_DIR}/blast-${_component_config}.cmake")
endforeach(_component_config IN LISTS _blast_supported_components)
endif(blast_FIND_COMPONENTS)
@@ -1,193 +0,0 @@
# if we are built from with zlib, use this path's)
if(DEFINED ZLIB_BUILD_BLAST)
set(WORK_DIR ${zlib_BINARY_DIR})
set(inst_setup zlib_install)
else(DEFINED ZLIB_BUILD_BLAST)
set(WORK_DIR ${blast_BINARY_DIR})
set(inst_setup zlib_blast_install)
set(ZLIB_ARG "-DZLIB_DIR=${ZLIB_DIR}")
add_test(
NAME zlib_blast_install
COMMAND ${CMAKE_COMMAND} --install ${blast_BINARY_DIR} --prefix
${CMAKE_CURRENT_BINARY_DIR}/test_install --config $<CONFIG>
WORKING_DIRECTORY ${blast_BINARY_DIR})
set_tests_properties(zlib_blast_install
PROPERTIES
FIXTURES_SETUP zlib_blast_install)
endif(DEFINED ZLIB_BUILD_BLAST)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test/CMakeLists.txt @ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/add_subdirectory_exclude_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test/CMakeLists.txt
@ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_no_components_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test/CMakeLists.txt
@ONLY)
configure_file(
${CMAKE_CURRENT_SOURCE_DIR}/find_package_wrong_components_test.cmake.in
${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test/CMakeLists.txt
@ONLY)
# CMAKE_GENERATOR_PLATFORM doesn't work in the if
set(GENERATOR ${CMAKE_GENERATOR_PLATFORM})
if(GENERATOR)
set(PLATFORM "-A ${GENERATOR}")
endif(GENERATOR)
#
# findpackage_test
#
add_test(
NAME zlib_blast_find_package_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_test)
add_test(
NAME zlib_blast_find_package_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/findpackage_test_build)
set_tests_properties(
zlib_blast_find_package_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP blast_fp_config)
set_tests_properties(zlib_blast_find_package_build
PROPERTIES
FIXTURES_REQUIRED blast_fp_config)
#
# add_subdirectory_test
#
add_test(
NAME zlib_blast_add_subdirectory_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test)
add_test(
NAME zlib_blast_add_subdirectory_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_test_build)
set_tests_properties(
zlib_blast_add_subdirectory_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP blast_as_config)
set_tests_properties(zlib_blast_add_subdirectory_build
PROPERTIES
FIXTURES_REQUIRED blast_as_config)
#
# add_subdirectory_exclude_test
#
add_test(
NAME zlib_blast_add_subdirectory_exclude_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG>
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test)
add_test(
NAME zlib_blast_add_subdirectory_exclude_build
COMMAND ${CMAKE_COMMAND} --build . --config $<CONFIG>
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}/add_subdirectory_exclude_test_build)
set_tests_properties(zlib_blast_add_subdirectory_exclude_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
FIXTURES_SETUP blast_asx_config)
set_tests_properties(zlib_blast_add_subdirectory_exclude_build
PROPERTIES
FIXTURES_REQUIRED blast_asx_config)
#
# findpackage_no_components_test
#
add_test(
NAME zlib_blast_find_package_no_components_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_no_components_test)
set_tests_properties(
zlib_blast_find_package_no_components_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup})
if(NOT ZLIB_BLAST_BUILD_SHARED OR NOT ZLIB_BLAST_BUILD_STATIC)
set_tests_properties(zlib_blast_find_package_no_components_configure
PROPERTIES
WILL_FAIL TRUE)
endif(NOT ZLIB_BLAST_BUILD_SHARED OR NOT ZLIB_BLAST_BUILD_STATIC)
#
# findpackage_wrong_components_test
#
add_test(
NAME zlib_blast_find_package_wrong_components_configure
COMMAND
${CMAKE_COMMAND} ${PLATFORM}
-B${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test_build
-DCMAKE_BUILD_TYPE=$<CONFIG> -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS}
-DCMAKE_INSTALL_PREFIX=${WORK_DIR}/test/test_install ${ZLIB_ARG}
--fresh
-G "${CMAKE_GENERATOR}"
-S${CMAKE_CURRENT_BINARY_DIR}/findpackage_wrong_components_test)
set_tests_properties(zlib_blast_find_package_wrong_components_configure
PROPERTIES
FIXTURES_REQUIRED ${inst_setup}
WILL_FAIL TRUE)
@@ -1,27 +0,0 @@
cmake_minimum_required(VERSION 3.12...3.31)
project(
blast_find_package
LANGUAGES C
VERSION @blast_VERSION@)
option(ZLIB_BLAST_BUILD_SHARED "" @ZLIB_BLAST_BUILD_SHARED@)
option(ZLIB_BLAST_BUILD_STATIC "" @ZLIB_BLAST_BUILD_STATIC@)
option(ZLIB_BLAST_BUILD_TESTING "" @ZLIB_BLAST_BUILD_TESTING@)
add_subdirectory(@blast_SOURCE_DIR@
${CMAKE_CURRENT_BINARY_DIR}/blast
EXCLUDE_FROM_ALL)
set(BLAST_SRCS
@blast_SOURCE_DIR@/blast-test.c)
if(ZLIB_BLAST_BUILD_SHARED)
add_executable(test_example ${BLAST_SRCS})
target_link_libraries(test_example BLAST::BLAST)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
add_executable(test_example_static ${BLAST_SRCS})
target_link_libraries(test_example_static BLAST::BLASTSTATIC)
endif(ZLIB_BLAST_BUILD_STATIC)
@@ -1,25 +0,0 @@
cmake_minimum_required(VERSION 3.12...3.31)
project(
blast_find_package
LANGUAGES C
VERSION @blast_VERSION@)
option(ZLIB_BLAST_BUILD_SHARED "" @ZLIB_BLAST_BUILD_SHARED@)
option(ZLIB_BLAST_BUILD_STATIC "" @ZLIB_BLAST_BUILD_STATIC@)
option(ZLIB_BLAST_BUILD_TESTING "" @ZLIB_BLAST_BUILD_TESTING@)
add_subdirectory(@blast_SOURCE_DIR@ ${CMAKE_CURRENT_BINARY_DIR}/blast)
set(BLAST_SRCS
@blast_SOURCE_DIR@/blast-test.c)
if(ZLIB_BLAST_BUILD_SHARED)
add_executable(test_example ${BLAST_SRCS})
target_link_libraries(test_example BLAST::BLAST)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
add_executable(test_example_static ${BLAST_SRCS})
target_link_libraries(test_example_static BLAST::BLASTSTATIC)
endif(ZLIB_BLAST_BUILD_STATIC)
@@ -1,24 +0,0 @@
cmake_minimum_required(VERSION 3.12...3.31)
project(
blast_find_package
LANGUAGES C
VERSION @blast_VERSION@)
option(ZLIB_BLAST_BUILD_SHARED "" @ZLIB_BLAST_BUILD_SHARED@)
option(ZLIB_BLAST_BUILD_STATIC "" @ZLIB_BLAST_BUILD_STATIC@)
find_package(blast REQUIRED CONFIG)
set(BLAST_SRCS
@blast_SOURCE_DIR@/blast-test.c)
if(ZLIB_BLAST_BUILD_SHARED)
add_executable(test_example ${BLAST_SRCS})
target_link_libraries(test_example BLAST::BLAST)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
add_executable(test_example_static ${BLAST_SRCS})
target_link_libraries(test_example_static BLAST::BLASTSTATIC)
endif(ZLIB_BLAST_BUILD_STATIC)
@@ -1,24 +0,0 @@
cmake_minimum_required(VERSION 3.12...3.31)
project(
blast_find_package
LANGUAGES C
VERSION @blast_VERSION@)
option(ZLIB_BLAST_BUILD_SHARED "" @ZLIB_BLAST_BUILD_SHARED@)
option(ZLIB_BLAST_BUILD_STATIC "" @ZLIB_BLAST_BUILD_STATIC@)
set(BLAST_SRCS
@blast_SOURCE_DIR@/blast-test.c)
if(ZLIB_BLAST_BUILD_SHARED)
find_package(blast REQUIRED COMPONENTS shared CONFIG)
add_executable(test_example ${BLAST_SRCS})
target_link_libraries(test_example BLAST::BLAST)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
find_package(blast REQUIRED COMPONENTS static CONFIG)
add_executable(test_example_static ${BLAST_SRCS})
target_link_libraries(test_example_static BLAST::BLASTSTATIC)
endif(ZLIB_BLAST_BUILD_STATIC)
@@ -1,24 +0,0 @@
cmake_minimum_required(VERSION 3.12...3.31)
project(
blast_find_package
LANGUAGES C
VERSION @blast_VERSION@)
option(ZLIB_BLAST_BUILD_SHARED "" @ZLIB_BLAST_BUILD_SHARED@)
option(ZLIB_BLAST_BUILD_STATIC "" @ZLIB_BLAST_BUILD_STATIC@)
find_package(blast REQUIRED COMPONENTS wrong CONFIG)
set(BLAST_SRCS
@blast_SOURCE_DIR@/blast-test.c)
if(ZLIB_BLAST_BUILD_SHARED)
add_executable(test_example ${BLAST_SRCS})
target_link_libraries(test_example BLAST::BLAST)
endif(ZLIB_BLAST_BUILD_SHARED)
if(ZLIB_BLAST_BUILD_STATIC)
add_executable(test_example_static ${BLAST_SRCS})
target_link_libraries(test_example_static BLAST::BLASTSTATIC)
endif(ZLIB_BLAST_BUILD_STATIC)
-28
View File
@@ -1,28 +0,0 @@
cmake_minimum_required(VERSION 3.12...3.31)
#CMAKE_ARGV0 = ${CMAKE_COMMAND}
#CMAKE_ARGV1 = -P
#CMAKE_ARGV2 = ${CMAKE_CURRENT_SOURCE_DIR}/tester.cmake
#CMAKE_ARGV3 = "$<TARGET_FILE:blast-test>"
#CMAKE_ARGV4 = "${CMAKE_CURRENT_SOURCE_DIR}"
#CMAKE_ARGV5 = "${CMAKE_CURRENT_BINARY_DIR}")
execute_process(COMMAND ${CMAKE_ARGV3}
INPUT_FILE "${CMAKE_ARGV4}/test.pk"
OUTPUT_FILE "${CMAKE_ARGV5}/output.txt"
RESULT_VARIABLE RESULT)
if(RESULT)
message(FATAL_ERROR "Command exitited with: ${RESULT}")
endif(RESULT)
execute_process(COMMAND ${CMAKE_ARGV0} -E compare_files
"${CMAKE_ARGV4}/test.txt"
"${CMAKE_ARGV5}/output.txt"
RESULT_VARIABLE RESULT)
file(REMOVE "${CMAKE_ARGV5}/output.txt")
if(RESULT)
message(FATAL_ERROR "Files differ")
endif(RESULT)
@@ -1,67 +0,0 @@
# check if we compile for IBM s390x
#
CHECK_C_SOURCE_COMPILES("
#ifndef __s390x__
#error
#endif
int main() {return 0;}
" HAS_S390X_SUPPORT)
#
# Check for IBM S390X - VX extensions
#
if(ZLIB_WITH_CRC32VX AND HAS_S390X_SUPPORT)
# preset the compiler specific flags
if (CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(VGFMAFLAG "-fzvector")
else()
set(VGFMAFLAG "-mzarch")
endif(CMAKE_C_COMPILER_ID STREQUAL "Clang")
set(S390X_VX_TEST
"#ifndef __s390x__ \n\
#error \n\
#endif \n\
#include <vecintrin.h> \n\
int main(void) { \
unsigned long long a __attribute__((vector_size(16))) = { 0 }; \
unsigned long long b __attribute__((vector_size(16))) = { 0 }; \
unsigned char c __attribute__((vector_size(16))) = { 0 }; \
c = vec_gfmsum_accum_128(a, b, c); \
return c[0]; \
}")
# cflags already contains a valid march
set(CMAKE_REQUIRED_FLAGS "${VGFMAFLAG}")
check_c_source_compiles("${S390X_VX_TEST}" HAS_S390X_VX_SUPPORT)
unset(CMAKE_REQUIRED_FLAGS)
# or set march for our compile units
if(NOT HAS_S390X_VX_SUPPORT)
set(CMAKE_REQUIRED_FLAGS "${VGFMAFLAG} -march=z13")
check_c_source_compiles("${S390X_VX_TEST}" HAS_Z13_S390X_VX_SUPPORT)
unset(CMAKE_REQUIRED_FLAGS )
list(APPEND VGFMAFLAG "-march=z13")
endif(NOT HAS_S390X_VX_SUPPORT)
# prepare compiling for s390x
if(HAS_S390X_VX_SUPPORT OR HAS_Z13_S390X_VX_SUPPORT)
if(ZLIB_BUILD_SHARED)
target_sources(zlib
PRIVATE
crc32_vx.c
crc32_vx_hooks.h)
target_compile_definitions(zlib PUBLIC -DHAVE_S390X_VX=1)
endif(ZLIB_BUILD_SHARED)
if(ZLIB_BUILD_STATIC)
target_sources(zlibstatic
PRIVATE
crc32_vx.c
crc32_vx_hooks.h)
target_compile_definitions(zlibstatic PUBLIC -DHAVE_S390X_VX=1)
endif(ZLIB_BUILD_STATIC)
set_source_files_properties(
crc32_vx.c
PROPERTIES COMPILE_OPTIONS "${VGFMAFLAG}")
endif(HAS_S390X_VX_SUPPORT OR HAS_Z13_S390X_VX_SUPPORT)
endif(ZLIB_WITH_CRC32VX AND HAS_S390X_SUPPORT)
-9
View File
@@ -1,9 +0,0 @@
IBM Z mainframes starting from version z13 provide vector instructions, which
allows vectorization of crc32. This extension is build by default when targeting
ibm s390x. However this extension can disabled if desired:
# for configure build
$ ./configure --disable-crcvx
# for cmake build
$ cmake .. -DZLIB_CRC32VX=off
-254
View File
@@ -1,254 +0,0 @@
/*
* Hardware-accelerated CRC-32 variants for Linux on z Systems
*
* Use the z/Architecture Vector Extension Facility to accelerate the
* computing of bitreflected CRC-32 checksums.
*
* This CRC-32 implementation algorithm is bitreflected and processes
* the least-significant bit first (Little-Endian).
*
* This code was originally written by Hendrik Brueckner
* <brueckner@linux.vnet.ibm.com> for use in the Linux kernel and has been
* relicensed under the zlib license.
*/
#define Z_ONCE
#include "../../zutil.h"
#include "crc32_vx_hooks.h"
#include <stdint.h>
#include <stdio.h>
#include <vecintrin.h>
#include <sys/auxv.h>
#ifdef __clang__
# if ((__clang_major__ == 18) || (__clang_major__ == 19 && (__clang_minor__ < 1 || (__clang_minor__ == 1 && __clang_patchlevel__ < 2))))
# error crc32_vx optimizations are broken due to compiler bug in Clang versions: 18.0.0 <= clang_version < 19.1.2. \
Either disable the zlib crc32_vx optimization, or switch to another compiler/compiler version.
# endif
#endif
#define VX_MIN_LEN 64
#define VX_ALIGNMENT 16L
#define VX_ALIGN_MASK (VX_ALIGNMENT - 1)
typedef unsigned char uv16qi __attribute__((vector_size(16)));
typedef unsigned int uv4si __attribute__((vector_size(16)));
typedef unsigned long long uv2di __attribute__((vector_size(16)));
local uint32_t crc32_le_vgfm_16(uint32_t crc, const unsigned char *buf, size_t len) {
/*
* The CRC-32 constant block contains reduction constants to fold and
* process particular chunks of the input data stream in parallel.
*
* For the CRC-32 variants, the constants are precomputed according to
* these definitions:
*
* R1 = [(x4*128+32 mod P'(x) << 32)]' << 1
* R2 = [(x4*128-32 mod P'(x) << 32)]' << 1
* R3 = [(x128+32 mod P'(x) << 32)]' << 1
* R4 = [(x128-32 mod P'(x) << 32)]' << 1
* R5 = [(x64 mod P'(x) << 32)]' << 1
* R6 = [(x32 mod P'(x) << 32)]' << 1
*
* The bitreflected Barret reduction constant, u', is defined as
* the bit reversal of floor(x**64 / P(x)).
*
* where P(x) is the polynomial in the normal domain and the P'(x) is the
* polynomial in the reversed (bitreflected) domain.
*
* CRC-32 (IEEE 802.3 Ethernet, ...) polynomials:
*
* P(x) = 0x04C11DB7
* P'(x) = 0xEDB88320
*/
const uv16qi perm_le2be = {15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; /* BE->LE mask */
const uv2di r2r1 = {0x1C6E41596, 0x154442BD4}; /* R2, R1 */
const uv2di r4r3 = {0x0CCAA009E, 0x1751997D0}; /* R4, R3 */
const uv2di r5 = {0, 0x163CD6124}; /* R5 */
const uv2di ru_poly = {0, 0x1F7011641}; /* u' */
const uv2di crc_poly = {0, 0x1DB710641}; /* P'(x) << 1 */
/*
* Load the initial CRC value.
*
* The CRC value is loaded into the rightmost word of the
* vector register and is later XORed with the LSB portion
* of the loaded input data.
*/
uv2di v0 = {0, 0};
v0 = (uv2di)vec_insert(crc, (uv4si)v0, 3);
/* Load a 64-byte data chunk and XOR with CRC */
uv2di v1 = vec_perm(((uv2di *)buf)[0], ((uv2di *)buf)[0], perm_le2be);
uv2di v2 = vec_perm(((uv2di *)buf)[1], ((uv2di *)buf)[1], perm_le2be);
uv2di v3 = vec_perm(((uv2di *)buf)[2], ((uv2di *)buf)[2], perm_le2be);
uv2di v4 = vec_perm(((uv2di *)buf)[3], ((uv2di *)buf)[3], perm_le2be);
v1 ^= v0;
buf += 64;
len -= 64;
while (len >= 64) {
/* Load the next 64-byte data chunk */
uv16qi part1 = vec_perm(((uv16qi *)buf)[0], ((uv16qi *)buf)[0], perm_le2be);
uv16qi part2 = vec_perm(((uv16qi *)buf)[1], ((uv16qi *)buf)[1], perm_le2be);
uv16qi part3 = vec_perm(((uv16qi *)buf)[2], ((uv16qi *)buf)[2], perm_le2be);
uv16qi part4 = vec_perm(((uv16qi *)buf)[3], ((uv16qi *)buf)[3], perm_le2be);
/*
* Perform a GF(2) multiplication of the doublewords in V1 with
* the R1 and R2 reduction constants in V0. The intermediate result
* is then folded (accumulated) with the next data chunk in PART1 and
* stored in V1. Repeat this step for the register contents
* in V2, V3, and V4 respectively.
*/
v1 = (uv2di)vec_gfmsum_accum_128(r2r1, v1, part1);
v2 = (uv2di)vec_gfmsum_accum_128(r2r1, v2, part2);
v3 = (uv2di)vec_gfmsum_accum_128(r2r1, v3, part3);
v4 = (uv2di)vec_gfmsum_accum_128(r2r1, v4, part4);
buf += 64;
len -= 64;
}
/*
* Fold V1 to V4 into a single 128-bit value in V1. Multiply V1 with R3
* and R4 and accumulating the next 128-bit chunk until a single 128-bit
* value remains.
*/
v1 = (uv2di)vec_gfmsum_accum_128(r4r3, v1, (uv16qi)v2);
v1 = (uv2di)vec_gfmsum_accum_128(r4r3, v1, (uv16qi)v3);
v1 = (uv2di)vec_gfmsum_accum_128(r4r3, v1, (uv16qi)v4);
while (len >= 16) {
/* Load next data chunk */
v2 = vec_perm(*(uv2di *)buf, *(uv2di *)buf, perm_le2be);
/* Fold next data chunk */
v1 = (uv2di)vec_gfmsum_accum_128(r4r3, v1, (uv16qi)v2);
buf += 16;
len -= 16;
}
/*
* Set up a vector register for byte shifts. The shift value must
* be loaded in bits 1-4 in byte element 7 of a vector register.
* Shift by 8 bytes: 0x40
* Shift by 4 bytes: 0x20
*/
uv16qi v9 = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
v9 = vec_insert((unsigned char)0x40, v9, 7);
/*
* Prepare V0 for the next GF(2) multiplication: shift V0 by 8 bytes
* to move R4 into the rightmost doubleword and set the leftmost
* doubleword to 0x1.
*/
v0 = vec_srb(r4r3, (uv2di)v9);
v0[0] = 1;
/*
* Compute GF(2) product of V1 and V0. The rightmost doubleword
* of V1 is multiplied with R4. The leftmost doubleword of V1 is
* multiplied by 0x1 and is then XORed with rightmost product.
* Implicitly, the intermediate leftmost product becomes padded
*/
v1 = (uv2di)vec_gfmsum_128(v0, v1);
/*
* Now do the final 32-bit fold by multiplying the rightmost word
* in V1 with R5 and XOR the result with the remaining bits in V1.
*
* To achieve this by a single VGFMAG, right shift V1 by a word
* and store the result in V2 which is then accumulated. Use the
* vector unpack instruction to load the rightmost half of the
* doubleword into the rightmost doubleword element of V1; the other
* half is loaded in the leftmost doubleword.
* The vector register with CONST_R5 contains the R5 constant in the
* rightmost doubleword and the leftmost doubleword is zero to ignore
* the leftmost product of V1.
*/
v9 = vec_insert((unsigned char)0x20, v9, 7);
v2 = vec_srb(v1, (uv2di)v9);
v1 = vec_unpackl((uv4si)v1); /* Split rightmost doubleword */
v1 = (uv2di)vec_gfmsum_accum_128(r5, v1, (uv16qi)v2);
/*
* Apply a Barret reduction to compute the final 32-bit CRC value.
*
* The input values to the Barret reduction are the degree-63 polynomial
* in V1 (R(x)), degree-32 generator polynomial, and the reduction
* constant u. The Barret reduction result is the CRC value of R(x) mod
* P(x).
*
* The Barret reduction algorithm is defined as:
*
* 1. T1(x) = floor( R(x) / x^32 ) GF2MUL u
* 2. T2(x) = floor( T1(x) / x^32 ) GF2MUL P(x)
* 3. C(x) = R(x) XOR T2(x) mod x^32
*
* Note: The leftmost doubleword of vector register containing
* CONST_RU_POLY is zero and, thus, the intermediate GF(2) product
* is zero and does not contribute to the final result.
*/
/* T1(x) = floor( R(x) / x^32 ) GF2MUL u */
v2 = vec_unpackl((uv4si)v1);
v2 = (uv2di)vec_gfmsum_128(ru_poly, v2);
/*
* Compute the GF(2) product of the CRC polynomial with T1(x) in
* V2 and XOR the intermediate result, T2(x), with the value in V1.
* The final result is stored in word element 2 of V2.
*/
v2 = vec_unpackl((uv4si)v2);
v2 = (uv2di)vec_gfmsum_accum_128(crc_poly, v2, (uv16qi)v1);
return ((uv4si)v2)[2];
}
local unsigned long s390_crc32_vx(unsigned long crc, const unsigned char FAR *buf, z_size_t len)
{
uintptr_t prealign, aligned, remaining;
if (buf == Z_NULL) return 0UL;
if (len < VX_MIN_LEN + VX_ALIGN_MASK)
return crc32_z(crc, buf, len);
if ((uintptr_t)buf & VX_ALIGN_MASK) {
prealign = VX_ALIGNMENT - ((uintptr_t)buf & VX_ALIGN_MASK);
len -= prealign;
crc = crc32_z(crc, buf, prealign);
buf += prealign;
}
aligned = len & ~VX_ALIGN_MASK;
remaining = len & VX_ALIGN_MASK;
crc = crc32_le_vgfm_16(crc ^ 0xffffffff, buf, (size_t)aligned) ^ 0xffffffff;
if (remaining)
crc = crc32_z(crc, buf + aligned, remaining);
return crc;
}
local z_once_t s390_crc32_made = Z_ONCE_INIT;
local void s390_crc32_setup() {
unsigned long hwcap = getauxval(AT_HWCAP);
if (hwcap & HWCAP_S390_VX)
crc32_z_hook = s390_crc32_vx;
else
crc32_z_hook = crc32_z;
}
local unsigned long s390_crc32_init(unsigned long crc, const unsigned char FAR *buf, z_size_t len)
{
z_once(&s390_crc32_made,s390_crc32_setup);
return crc32_z_hook(crc, buf, len);
}
ZLIB_INTERNAL unsigned long (*crc32_z_hook)(unsigned long crc, const unsigned char FAR *buf, z_size_t len) = s390_crc32_init;
@@ -1,9 +0,0 @@
#ifndef CRC32_VX_HOOKS_H
#define CRC32_VX_HOOKS_H
/**
* CRC HOOKS
*/
ZLIB_INTERNAL extern unsigned long (*crc32_z_hook)(unsigned long crc, const unsigned char FAR *buf, z_size_t len);
#endif /* CRC32_VX_HOOKS_H */
+1 -1
View File
@@ -152,7 +152,7 @@ procedure DecompressToUserBuf(const InBuf: Pointer; InBytes: Integer;
const OutBuf: Pointer; BufSize: Integer);
const
zlib_version = '1.3.2';
zlib_version = '1.2.13';
type
EZlibError = class(Exception);
@@ -1,202 +1,202 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace DotZLib
{
#region ChecksumGeneratorBase
/// <summary>
/// Implements the common functionality needed for all <see cref="ChecksumGenerator"/>s
/// </summary>
/// <example></example>
public abstract class ChecksumGeneratorBase : ChecksumGenerator
{
/// <summary>
/// The value of the current checksum
/// </summary>
protected uint _current;
/// <summary>
/// Initializes a new instance of the checksum generator base - the current checksum is
/// set to zero
/// </summary>
public ChecksumGeneratorBase()
{
_current = 0;
}
/// <summary>
/// Initializes a new instance of the checksum generator base with a specified value
/// </summary>
/// <param name="initialValue">The value to set the current checksum to</param>
public ChecksumGeneratorBase(uint initialValue)
{
_current = initialValue;
}
/// <summary>
/// Resets the current checksum to zero
/// </summary>
public void Reset() { _current = 0; }
/// <summary>
/// Gets the current checksum value
/// </summary>
public uint Value { get { return _current; } }
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
/// <remarks>All the other <c>Update</c> methods are implemented in terms of this one.
/// This is therefore the only method a derived class has to implement</remarks>
public abstract void Update(byte[] data, int offset, int count);
/// <summary>
/// Updates the current checksum with an array of bytes.
/// </summary>
/// <param name="data">The data to update the checksum with</param>
public void Update(byte[] data)
{
Update(data, 0, data.Length);
}
/// <summary>
/// Updates the current checksum with the data from a string
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks>
public void Update(string data)
{
Update(Encoding.UTF8.GetBytes(data));
}
/// <summary>
/// Updates the current checksum with the data from a string, using a specific encoding
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <param name="encoding">The encoding to use</param>
public void Update(string data, Encoding encoding)
{
Update(encoding.GetBytes(data));
}
}
#endregion
#region CRC32
/// <summary>
/// Implements a CRC32 checksum generator
/// </summary>
public sealed class CRC32Checksum : ChecksumGeneratorBase
{
#region DLL imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern uint crc32(uint crc, int data, uint length);
#endregion
/// <summary>
/// Initializes a new instance of the CRC32 checksum generator
/// </summary>
public CRC32Checksum() : base() {}
/// <summary>
/// Initializes a new instance of the CRC32 checksum generator with a specified value
/// </summary>
/// <param name="initialValue">The value to set the current checksum to</param>
public CRC32Checksum(uint initialValue) : base(initialValue) {}
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
public override void Update(byte[] data, int offset, int count)
{
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned);
try
{
_current = crc32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count);
}
finally
{
hData.Free();
}
}
}
#endregion
#region Adler
/// <summary>
/// Implements a checksum generator that computes the Adler checksum on data
/// </summary>
public sealed class AdlerChecksum : ChecksumGeneratorBase
{
#region DLL imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern uint adler32(uint adler, int data, uint length);
#endregion
/// <summary>
/// Initializes a new instance of the Adler checksum generator
/// </summary>
public AdlerChecksum() : base() {}
/// <summary>
/// Initializes a new instance of the Adler checksum generator with a specified value
/// </summary>
/// <param name="initialValue">The value to set the current checksum to</param>
public AdlerChecksum(uint initialValue) : base(initialValue) {}
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
public override void Update(byte[] data, int offset, int count)
{
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned);
try
{
_current = adler32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count);
}
finally
{
hData.Free();
}
}
}
#endregion
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Runtime.InteropServices;
using System.Text;
namespace DotZLib
{
#region ChecksumGeneratorBase
/// <summary>
/// Implements the common functionality needed for all <see cref="ChecksumGenerator"/>s
/// </summary>
/// <example></example>
public abstract class ChecksumGeneratorBase : ChecksumGenerator
{
/// <summary>
/// The value of the current checksum
/// </summary>
protected uint _current;
/// <summary>
/// Initializes a new instance of the checksum generator base - the current checksum is
/// set to zero
/// </summary>
public ChecksumGeneratorBase()
{
_current = 0;
}
/// <summary>
/// Initializes a new instance of the checksum generator basewith a specified value
/// </summary>
/// <param name="initialValue">The value to set the current checksum to</param>
public ChecksumGeneratorBase(uint initialValue)
{
_current = initialValue;
}
/// <summary>
/// Resets the current checksum to zero
/// </summary>
public void Reset() { _current = 0; }
/// <summary>
/// Gets the current checksum value
/// </summary>
public uint Value { get { return _current; } }
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
/// <remarks>All the other <c>Update</c> methods are implmeneted in terms of this one.
/// This is therefore the only method a derived class has to implement</remarks>
public abstract void Update(byte[] data, int offset, int count);
/// <summary>
/// Updates the current checksum with an array of bytes.
/// </summary>
/// <param name="data">The data to update the checksum with</param>
public void Update(byte[] data)
{
Update(data, 0, data.Length);
}
/// <summary>
/// Updates the current checksum with the data from a string
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks>
public void Update(string data)
{
Update(Encoding.UTF8.GetBytes(data));
}
/// <summary>
/// Updates the current checksum with the data from a string, using a specific encoding
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <param name="encoding">The encoding to use</param>
public void Update(string data, Encoding encoding)
{
Update(encoding.GetBytes(data));
}
}
#endregion
#region CRC32
/// <summary>
/// Implements a CRC32 checksum generator
/// </summary>
public sealed class CRC32Checksum : ChecksumGeneratorBase
{
#region DLL imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern uint crc32(uint crc, int data, uint length);
#endregion
/// <summary>
/// Initializes a new instance of the CRC32 checksum generator
/// </summary>
public CRC32Checksum() : base() {}
/// <summary>
/// Initializes a new instance of the CRC32 checksum generator with a specified value
/// </summary>
/// <param name="initialValue">The value to set the current checksum to</param>
public CRC32Checksum(uint initialValue) : base(initialValue) {}
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
public override void Update(byte[] data, int offset, int count)
{
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned);
try
{
_current = crc32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count);
}
finally
{
hData.Free();
}
}
}
#endregion
#region Adler
/// <summary>
/// Implements a checksum generator that computes the Adler checksum on data
/// </summary>
public sealed class AdlerChecksum : ChecksumGeneratorBase
{
#region DLL imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern uint adler32(uint adler, int data, uint length);
#endregion
/// <summary>
/// Initializes a new instance of the Adler checksum generator
/// </summary>
public AdlerChecksum() : base() {}
/// <summary>
/// Initializes a new instance of the Adler checksum generator with a specified value
/// </summary>
/// <param name="initialValue">The value to set the current checksum to</param>
public AdlerChecksum(uint initialValue) : base(initialValue) {}
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="NullReferenceException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
public override void Update(byte[] data, int offset, int count)
{
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
GCHandle hData = GCHandle.Alloc(data, GCHandleType.Pinned);
try
{
_current = adler32(_current, hData.AddrOfPinnedObject().ToInt32()+offset, (uint)count);
}
finally
{
hData.Free();
}
}
}
#endregion
}
@@ -1,83 +1,83 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Diagnostics;
namespace DotZLib
{
/// <summary>
/// This class implements a circular buffer
/// </summary>
internal class CircularBuffer
{
#region Private data
private int _capacity;
private int _head;
private int _tail;
private int _size;
private byte[] _buffer;
#endregion
public CircularBuffer(int capacity)
{
Debug.Assert( capacity > 0 );
_buffer = new byte[capacity];
_capacity = capacity;
_head = 0;
_tail = 0;
_size = 0;
}
public int Size { get { return _size; } }
public int Put(byte[] source, int offset, int count)
{
Debug.Assert( count > 0 );
int trueCount = Math.Min(count, _capacity - Size);
for (int i = 0; i < trueCount; ++i)
_buffer[(_tail+i) % _capacity] = source[offset+i];
_tail += trueCount;
_tail %= _capacity;
_size += trueCount;
return trueCount;
}
public bool Put(byte b)
{
if (Size == _capacity) // no room
return false;
_buffer[_tail++] = b;
_tail %= _capacity;
++_size;
return true;
}
public int Get(byte[] destination, int offset, int count)
{
int trueCount = Math.Min(count,Size);
for (int i = 0; i < trueCount; ++i)
destination[offset + i] = _buffer[(_head+i) % _capacity];
_head += trueCount;
_head %= _capacity;
_size -= trueCount;
return trueCount;
}
public int Get()
{
if (Size == 0)
return -1;
int result = (int)_buffer[_head++ % _capacity];
--_size;
return result;
}
}
}
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Diagnostics;
namespace DotZLib
{
/// <summary>
/// This class implements a circular buffer
/// </summary>
internal class CircularBuffer
{
#region Private data
private int _capacity;
private int _head;
private int _tail;
private int _size;
private byte[] _buffer;
#endregion
public CircularBuffer(int capacity)
{
Debug.Assert( capacity > 0 );
_buffer = new byte[capacity];
_capacity = capacity;
_head = 0;
_tail = 0;
_size = 0;
}
public int Size { get { return _size; } }
public int Put(byte[] source, int offset, int count)
{
Debug.Assert( count > 0 );
int trueCount = Math.Min(count, _capacity - Size);
for (int i = 0; i < trueCount; ++i)
_buffer[(_tail+i) % _capacity] = source[offset+i];
_tail += trueCount;
_tail %= _capacity;
_size += trueCount;
return trueCount;
}
public bool Put(byte b)
{
if (Size == _capacity) // no room
return false;
_buffer[_tail++] = b;
_tail %= _capacity;
++_size;
return true;
}
public int Get(byte[] destination, int offset, int count)
{
int trueCount = Math.Min(count,Size);
for (int i = 0; i < trueCount; ++i)
destination[offset + i] = _buffer[(_head+i) % _capacity];
_head += trueCount;
_head %= _capacity;
_size -= trueCount;
return trueCount;
}
public int Get()
{
if (Size == 0)
return -1;
int result = (int)_buffer[_head++ % _capacity];
--_size;
return result;
}
}
}
+198 -198
View File
@@ -1,198 +1,198 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements the common functionality needed for all <see cref="Codec"/>s
/// </summary>
public abstract class CodecBase : Codec, IDisposable
{
#region Data members
/// <summary>
/// Instance of the internal zlib buffer structure that is
/// passed to all functions in the zlib dll
/// </summary>
internal ZStream _ztream = new ZStream();
/// <summary>
/// True if the object instance has been disposed, false otherwise
/// </summary>
protected bool _isDisposed = false;
/// <summary>
/// The size of the internal buffers
/// </summary>
protected const int kBufferSize = 16384;
private byte[] _outBuffer = new byte[kBufferSize];
private byte[] _inBuffer = new byte[kBufferSize];
private GCHandle _hInput;
private GCHandle _hOutput;
private uint _checksum = 0;
#endregion
/// <summary>
/// Initializes a new instance of the <c>CodeBase</c> class.
/// </summary>
public CodecBase()
{
try
{
_hInput = GCHandle.Alloc(_inBuffer, GCHandleType.Pinned);
_hOutput = GCHandle.Alloc(_outBuffer, GCHandleType.Pinned);
}
catch (Exception)
{
CleanUp(false);
throw;
}
}
#region Codec Members
/// <summary>
/// Occurs when more processed data are available.
/// </summary>
public event DataAvailableHandler DataAvailable;
/// <summary>
/// Fires the <see cref="DataAvailable"/> event
/// </summary>
protected void OnDataAvailable()
{
if (_ztream.total_out > 0)
{
if (DataAvailable != null)
DataAvailable( _outBuffer, 0, (int)_ztream.total_out);
resetOutput();
}
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
public void Add(byte[] data)
{
Add(data,0,data.Length);
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
/// <remarks>This must be implemented by a derived class</remarks>
public abstract void Add(byte[] data, int offset, int count);
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
/// <remarks>This must be implemented by a derived class</remarks>
public abstract void Finish();
/// <summary>
/// Gets the checksum of the data that has been added so far
/// </summary>
public uint Checksum { get { return _checksum; } }
#endregion
#region Destructor & IDisposable stuff
/// <summary>
/// Destroys this instance
/// </summary>
~CodecBase()
{
CleanUp(false);
}
/// <summary>
/// Releases any unmanaged resources and calls the <see cref="CleanUp()"/> method of the derived class
/// </summary>
public void Dispose()
{
CleanUp(true);
}
/// <summary>
/// Performs any codec specific cleanup
/// </summary>
/// <remarks>This must be implemented by a derived class</remarks>
protected abstract void CleanUp();
// performs the release of the handles and calls the derived CleanUp()
private void CleanUp(bool isDisposing)
{
if (!_isDisposed)
{
CleanUp();
if (_hInput.IsAllocated)
_hInput.Free();
if (_hOutput.IsAllocated)
_hOutput.Free();
_isDisposed = true;
}
}
#endregion
#region Helper methods
/// <summary>
/// Copies a number of bytes to the internal codec buffer - ready for processing
/// </summary>
/// <param name="data">The byte array that contains the data to copy</param>
/// <param name="startIndex">The index of the first byte to copy</param>
/// <param name="count">The number of bytes to copy from <c>data</c></param>
protected void copyInput(byte[] data, int startIndex, int count)
{
Array.Copy(data, startIndex, _inBuffer,0, count);
_ztream.next_in = _hInput.AddrOfPinnedObject();
_ztream.total_in = 0;
_ztream.avail_in = (uint)count;
}
/// <summary>
/// Resets the internal output buffers to a known state - ready for processing
/// </summary>
protected void resetOutput()
{
_ztream.total_out = 0;
_ztream.avail_out = kBufferSize;
_ztream.next_out = _hOutput.AddrOfPinnedObject();
}
/// <summary>
/// Updates the running checksum property
/// </summary>
/// <param name="newSum">The new checksum value</param>
protected void setChecksum(uint newSum)
{
_checksum = newSum;
}
#endregion
}
}
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements the common functionality needed for all <see cref="Codec"/>s
/// </summary>
public abstract class CodecBase : Codec, IDisposable
{
#region Data members
/// <summary>
/// Instance of the internal zlib buffer structure that is
/// passed to all functions in the zlib dll
/// </summary>
internal ZStream _ztream = new ZStream();
/// <summary>
/// True if the object instance has been disposed, false otherwise
/// </summary>
protected bool _isDisposed = false;
/// <summary>
/// The size of the internal buffers
/// </summary>
protected const int kBufferSize = 16384;
private byte[] _outBuffer = new byte[kBufferSize];
private byte[] _inBuffer = new byte[kBufferSize];
private GCHandle _hInput;
private GCHandle _hOutput;
private uint _checksum = 0;
#endregion
/// <summary>
/// Initializes a new instance of the <c>CodeBase</c> class.
/// </summary>
public CodecBase()
{
try
{
_hInput = GCHandle.Alloc(_inBuffer, GCHandleType.Pinned);
_hOutput = GCHandle.Alloc(_outBuffer, GCHandleType.Pinned);
}
catch (Exception)
{
CleanUp(false);
throw;
}
}
#region Codec Members
/// <summary>
/// Occurs when more processed data are available.
/// </summary>
public event DataAvailableHandler DataAvailable;
/// <summary>
/// Fires the <see cref="DataAvailable"/> event
/// </summary>
protected void OnDataAvailable()
{
if (_ztream.total_out > 0)
{
if (DataAvailable != null)
DataAvailable( _outBuffer, 0, (int)_ztream.total_out);
resetOutput();
}
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
public void Add(byte[] data)
{
Add(data,0,data.Length);
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
/// <remarks>This must be implemented by a derived class</remarks>
public abstract void Add(byte[] data, int offset, int count);
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
/// <remarks>This must be implemented by a derived class</remarks>
public abstract void Finish();
/// <summary>
/// Gets the checksum of the data that has been added so far
/// </summary>
public uint Checksum { get { return _checksum; } }
#endregion
#region Destructor & IDisposable stuff
/// <summary>
/// Destroys this instance
/// </summary>
~CodecBase()
{
CleanUp(false);
}
/// <summary>
/// Releases any unmanaged resources and calls the <see cref="CleanUp()"/> method of the derived class
/// </summary>
public void Dispose()
{
CleanUp(true);
}
/// <summary>
/// Performs any codec specific cleanup
/// </summary>
/// <remarks>This must be implemented by a derived class</remarks>
protected abstract void CleanUp();
// performs the release of the handles and calls the dereived CleanUp()
private void CleanUp(bool isDisposing)
{
if (!_isDisposed)
{
CleanUp();
if (_hInput.IsAllocated)
_hInput.Free();
if (_hOutput.IsAllocated)
_hOutput.Free();
_isDisposed = true;
}
}
#endregion
#region Helper methods
/// <summary>
/// Copies a number of bytes to the internal codec buffer - ready for proccesing
/// </summary>
/// <param name="data">The byte array that contains the data to copy</param>
/// <param name="startIndex">The index of the first byte to copy</param>
/// <param name="count">The number of bytes to copy from <c>data</c></param>
protected void copyInput(byte[] data, int startIndex, int count)
{
Array.Copy(data, startIndex, _inBuffer,0, count);
_ztream.next_in = _hInput.AddrOfPinnedObject();
_ztream.total_in = 0;
_ztream.avail_in = (uint)count;
}
/// <summary>
/// Resets the internal output buffers to a known state - ready for processing
/// </summary>
protected void resetOutput()
{
_ztream.total_out = 0;
_ztream.avail_out = kBufferSize;
_ztream.next_out = _hOutput.AddrOfPinnedObject();
}
/// <summary>
/// Updates the running checksum property
/// </summary>
/// <param name="newSum">The new checksum value</param>
protected void setChecksum(uint newSum)
{
_checksum = newSum;
}
#endregion
}
}
+106 -106
View File
@@ -1,106 +1,106 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements a data compressor, using the deflate algorithm in the ZLib dll
/// </summary>
public sealed class Deflater : CodecBase
{
#region Dll imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
private static extern int deflateInit_(ref ZStream sz, int level, string vs, int size);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int deflate(ref ZStream sz, int flush);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int deflateReset(ref ZStream sz);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int deflateEnd(ref ZStream sz);
#endregion
/// <summary>
/// Constructs an new instance of the <c>Deflater</c>
/// </summary>
/// <param name="level">The compression level to use for this <c>Deflater</c></param>
public Deflater(CompressLevel level) : base()
{
int retval = deflateInit_(ref _ztream, (int)level, Info.Version, Marshal.SizeOf(_ztream));
if (retval != 0)
throw new ZLibException(retval, "Could not initialize deflater");
resetOutput();
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
public override void Add(byte[] data, int offset, int count)
{
if (data == null) throw new ArgumentNullException();
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
int total = count;
int inputIndex = offset;
int err = 0;
while (err >= 0 && inputIndex < total)
{
copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
while (err >= 0 && _ztream.avail_in > 0)
{
err = deflate(ref _ztream, (int)FlushTypes.None);
if (err == 0)
while (_ztream.avail_out == 0)
{
OnDataAvailable();
err = deflate(ref _ztream, (int)FlushTypes.None);
}
inputIndex += (int)_ztream.total_in;
}
}
setChecksum( _ztream.adler );
}
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
public override void Finish()
{
int err;
do
{
err = deflate(ref _ztream, (int)FlushTypes.Finish);
OnDataAvailable();
}
while (err == 0);
setChecksum( _ztream.adler );
deflateReset(ref _ztream);
resetOutput();
}
/// <summary>
/// Closes the internal zlib deflate stream
/// </summary>
protected override void CleanUp() { deflateEnd(ref _ztream); }
}
}
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements a data compressor, using the deflate algorithm in the ZLib dll
/// </summary>
public sealed class Deflater : CodecBase
{
#region Dll imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
private static extern int deflateInit_(ref ZStream sz, int level, string vs, int size);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int deflate(ref ZStream sz, int flush);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int deflateReset(ref ZStream sz);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int deflateEnd(ref ZStream sz);
#endregion
/// <summary>
/// Constructs an new instance of the <c>Deflater</c>
/// </summary>
/// <param name="level">The compression level to use for this <c>Deflater</c></param>
public Deflater(CompressLevel level) : base()
{
int retval = deflateInit_(ref _ztream, (int)level, Info.Version, Marshal.SizeOf(_ztream));
if (retval != 0)
throw new ZLibException(retval, "Could not initialize deflater");
resetOutput();
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
public override void Add(byte[] data, int offset, int count)
{
if (data == null) throw new ArgumentNullException();
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
int total = count;
int inputIndex = offset;
int err = 0;
while (err >= 0 && inputIndex < total)
{
copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
while (err >= 0 && _ztream.avail_in > 0)
{
err = deflate(ref _ztream, (int)FlushTypes.None);
if (err == 0)
while (_ztream.avail_out == 0)
{
OnDataAvailable();
err = deflate(ref _ztream, (int)FlushTypes.None);
}
inputIndex += (int)_ztream.total_in;
}
}
setChecksum( _ztream.adler );
}
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
public override void Finish()
{
int err;
do
{
err = deflate(ref _ztream, (int)FlushTypes.Finish);
OnDataAvailable();
}
while (err == 0);
setChecksum( _ztream.adler );
deflateReset(ref _ztream);
resetOutput();
}
/// <summary>
/// Closes the internal zlib deflate stream
/// </summary>
protected override void CleanUp() { deflateEnd(ref _ztream); }
}
}
+288 -288
View File
@@ -1,288 +1,288 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace DotZLib
{
#region Internal types
/// <summary>
/// Defines constants for the various flush types used with zlib
/// </summary>
internal enum FlushTypes
{
None, Partial, Sync, Full, Finish, Block
}
#region ZStream structure
// internal mapping of the zlib zstream structure for marshalling
[StructLayoutAttribute(LayoutKind.Sequential, Pack=4, Size=0, CharSet=CharSet.Ansi)]
internal struct ZStream
{
public IntPtr next_in;
public uint avail_in;
public uint total_in;
public IntPtr next_out;
public uint avail_out;
public uint total_out;
[MarshalAs(UnmanagedType.LPStr)]
string msg;
uint state;
uint zalloc;
uint zfree;
uint opaque;
int data_type;
public uint adler;
uint reserved;
}
#endregion
#endregion
#region Public enums
/// <summary>
/// Defines constants for the available compression levels in zlib
/// </summary>
public enum CompressLevel : int
{
/// <summary>
/// The default compression level with a reasonable compromise between compression and speed
/// </summary>
Default = -1,
/// <summary>
/// No compression at all. The data are passed straight through.
/// </summary>
None = 0,
/// <summary>
/// The maximum compression rate available.
/// </summary>
Best = 9,
/// <summary>
/// The fastest available compression level.
/// </summary>
Fastest = 1
}
#endregion
#region Exception classes
/// <summary>
/// The exception that is thrown when an error occurs on the zlib dll
/// </summary>
public class ZLibException : ApplicationException
{
/// <summary>
/// Initializes a new instance of the <see cref="ZLibException"/> class with a specified
/// error message and error code
/// </summary>
/// <param name="errorCode">The zlib error code that caused the exception</param>
/// <param name="msg">A message that (hopefully) describes the error</param>
public ZLibException(int errorCode, string msg) : base(String.Format("ZLib error {0} {1}", errorCode, msg))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ZLibException"/> class with a specified
/// error code
/// </summary>
/// <param name="errorCode">The zlib error code that caused the exception</param>
public ZLibException(int errorCode) : base(String.Format("ZLib error {0}", errorCode))
{
}
}
#endregion
#region Interfaces
/// <summary>
/// Declares methods and properties that enables a running checksum to be calculated
/// </summary>
public interface ChecksumGenerator
{
/// <summary>
/// Gets the current value of the checksum
/// </summary>
uint Value { get; }
/// <summary>
/// Clears the current checksum to 0
/// </summary>
void Reset();
/// <summary>
/// Updates the current checksum with an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
void Update(byte[] data);
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="ArgumentNullException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
void Update(byte[] data, int offset, int count);
/// <summary>
/// Updates the current checksum with the data from a string
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks>
void Update(string data);
/// <summary>
/// Updates the current checksum with the data from a string, using a specific encoding
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <param name="encoding">The encoding to use</param>
void Update(string data, Encoding encoding);
}
/// <summary>
/// Represents the method that will be called from a codec when new data
/// are available.
/// </summary>
/// <paramref name="data">The byte array containing the processed data</paramref>
/// <paramref name="startIndex">The index of the first processed byte in <c>data</c></paramref>
/// <paramref name="count">The number of processed bytes available</paramref>
/// <remarks>On return from this method, the data may be overwritten, so grab it while you can.
/// You cannot assume that startIndex will be zero.
/// </remarks>
public delegate void DataAvailableHandler(byte[] data, int startIndex, int count);
/// <summary>
/// Declares methods and events for implementing compressors/decompressors
/// </summary>
public interface Codec
{
/// <summary>
/// Occurs when more processed data are available.
/// </summary>
event DataAvailableHandler DataAvailable;
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
void Add(byte[] data);
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
void Add(byte[] data, int offset, int count);
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
void Finish();
/// <summary>
/// Gets the checksum of the data that has been added so far
/// </summary>
uint Checksum { get; }
}
#endregion
#region Classes
/// <summary>
/// Encapsulates general information about the ZLib library
/// </summary>
public class Info
{
#region DLL imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern uint zlibCompileFlags();
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern string zlibVersion();
#endregion
#region Private stuff
private uint _flags;
// helper function that unpacks a bitsize mask
private static int bitSize(uint bits)
{
switch (bits)
{
case 0: return 16;
case 1: return 32;
case 2: return 64;
}
return -1;
}
#endregion
/// <summary>
/// Constructs an instance of the <c>Info</c> class.
/// </summary>
public Info()
{
_flags = zlibCompileFlags();
}
/// <summary>
/// True if the library is compiled with debug info
/// </summary>
public bool HasDebugInfo { get { return 0 != (_flags & 0x100); } }
/// <summary>
/// True if the library is compiled with assembly optimizations
/// </summary>
public bool UsesAssemblyCode { get { return 0 != (_flags & 0x200); } }
/// <summary>
/// Gets the size of the unsigned int that was compiled into Zlib
/// </summary>
public int SizeOfUInt { get { return bitSize(_flags & 3); } }
/// <summary>
/// Gets the size of the unsigned long that was compiled into Zlib
/// </summary>
public int SizeOfULong { get { return bitSize((_flags >> 2) & 3); } }
/// <summary>
/// Gets the size of the pointers that were compiled into Zlib
/// </summary>
public int SizeOfPointer { get { return bitSize((_flags >> 4) & 3); } }
/// <summary>
/// Gets the size of the z_off_t type that was compiled into Zlib
/// </summary>
public int SizeOfOffset { get { return bitSize((_flags >> 6) & 3); } }
/// <summary>
/// Gets the version of ZLib as a string, e.g. "1.2.1"
/// </summary>
public static string Version { get { return zlibVersion(); } }
}
#endregion
}
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.IO;
using System.Runtime.InteropServices;
using System.Text;
namespace DotZLib
{
#region Internal types
/// <summary>
/// Defines constants for the various flush types used with zlib
/// </summary>
internal enum FlushTypes
{
None, Partial, Sync, Full, Finish, Block
}
#region ZStream structure
// internal mapping of the zlib zstream structure for marshalling
[StructLayoutAttribute(LayoutKind.Sequential, Pack=4, Size=0, CharSet=CharSet.Ansi)]
internal struct ZStream
{
public IntPtr next_in;
public uint avail_in;
public uint total_in;
public IntPtr next_out;
public uint avail_out;
public uint total_out;
[MarshalAs(UnmanagedType.LPStr)]
string msg;
uint state;
uint zalloc;
uint zfree;
uint opaque;
int data_type;
public uint adler;
uint reserved;
}
#endregion
#endregion
#region Public enums
/// <summary>
/// Defines constants for the available compression levels in zlib
/// </summary>
public enum CompressLevel : int
{
/// <summary>
/// The default compression level with a reasonable compromise between compression and speed
/// </summary>
Default = -1,
/// <summary>
/// No compression at all. The data are passed straight through.
/// </summary>
None = 0,
/// <summary>
/// The maximum compression rate available.
/// </summary>
Best = 9,
/// <summary>
/// The fastest available compression level.
/// </summary>
Fastest = 1
}
#endregion
#region Exception classes
/// <summary>
/// The exception that is thrown when an error occurs on the zlib dll
/// </summary>
public class ZLibException : ApplicationException
{
/// <summary>
/// Initializes a new instance of the <see cref="ZLibException"/> class with a specified
/// error message and error code
/// </summary>
/// <param name="errorCode">The zlib error code that caused the exception</param>
/// <param name="msg">A message that (hopefully) describes the error</param>
public ZLibException(int errorCode, string msg) : base(String.Format("ZLib error {0} {1}", errorCode, msg))
{
}
/// <summary>
/// Initializes a new instance of the <see cref="ZLibException"/> class with a specified
/// error code
/// </summary>
/// <param name="errorCode">The zlib error code that caused the exception</param>
public ZLibException(int errorCode) : base(String.Format("ZLib error {0}", errorCode))
{
}
}
#endregion
#region Interfaces
/// <summary>
/// Declares methods and properties that enables a running checksum to be calculated
/// </summary>
public interface ChecksumGenerator
{
/// <summary>
/// Gets the current value of the checksum
/// </summary>
uint Value { get; }
/// <summary>
/// Clears the current checksum to 0
/// </summary>
void Reset();
/// <summary>
/// Updates the current checksum with an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
void Update(byte[] data);
/// <summary>
/// Updates the current checksum with part of an array of bytes
/// </summary>
/// <param name="data">The data to update the checksum with</param>
/// <param name="offset">Where in <c>data</c> to start updating</param>
/// <param name="count">The number of bytes from <c>data</c> to use</param>
/// <exception cref="ArgumentException">The sum of offset and count is larger than the length of <c>data</c></exception>
/// <exception cref="ArgumentNullException"><c>data</c> is a null reference</exception>
/// <exception cref="ArgumentOutOfRangeException">Offset or count is negative.</exception>
void Update(byte[] data, int offset, int count);
/// <summary>
/// Updates the current checksum with the data from a string
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <remarks>The characters in the string are converted by the UTF-8 encoding</remarks>
void Update(string data);
/// <summary>
/// Updates the current checksum with the data from a string, using a specific encoding
/// </summary>
/// <param name="data">The string to update the checksum with</param>
/// <param name="encoding">The encoding to use</param>
void Update(string data, Encoding encoding);
}
/// <summary>
/// Represents the method that will be called from a codec when new data
/// are available.
/// </summary>
/// <paramref name="data">The byte array containing the processed data</paramref>
/// <paramref name="startIndex">The index of the first processed byte in <c>data</c></paramref>
/// <paramref name="count">The number of processed bytes available</paramref>
/// <remarks>On return from this method, the data may be overwritten, so grab it while you can.
/// You cannot assume that startIndex will be zero.
/// </remarks>
public delegate void DataAvailableHandler(byte[] data, int startIndex, int count);
/// <summary>
/// Declares methods and events for implementing compressors/decompressors
/// </summary>
public interface Codec
{
/// <summary>
/// Occurs when more processed data are available.
/// </summary>
event DataAvailableHandler DataAvailable;
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
void Add(byte[] data);
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
void Add(byte[] data, int offset, int count);
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
void Finish();
/// <summary>
/// Gets the checksum of the data that has been added so far
/// </summary>
uint Checksum { get; }
}
#endregion
#region Classes
/// <summary>
/// Encapsulates general information about the ZLib library
/// </summary>
public class Info
{
#region DLL imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern uint zlibCompileFlags();
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern string zlibVersion();
#endregion
#region Private stuff
private uint _flags;
// helper function that unpacks a bitsize mask
private static int bitSize(uint bits)
{
switch (bits)
{
case 0: return 16;
case 1: return 32;
case 2: return 64;
}
return -1;
}
#endregion
/// <summary>
/// Constructs an instance of the <c>Info</c> class.
/// </summary>
public Info()
{
_flags = zlibCompileFlags();
}
/// <summary>
/// True if the library is compiled with debug info
/// </summary>
public bool HasDebugInfo { get { return 0 != (_flags & 0x100); } }
/// <summary>
/// True if the library is compiled with assembly optimizations
/// </summary>
public bool UsesAssemblyCode { get { return 0 != (_flags & 0x200); } }
/// <summary>
/// Gets the size of the unsigned int that was compiled into Zlib
/// </summary>
public int SizeOfUInt { get { return bitSize(_flags & 3); } }
/// <summary>
/// Gets the size of the unsigned long that was compiled into Zlib
/// </summary>
public int SizeOfULong { get { return bitSize((_flags >> 2) & 3); } }
/// <summary>
/// Gets the size of the pointers that were compiled into Zlib
/// </summary>
public int SizeOfPointer { get { return bitSize((_flags >> 4) & 3); } }
/// <summary>
/// Gets the size of the z_off_t type that was compiled into Zlib
/// </summary>
public int SizeOfOffset { get { return bitSize((_flags >> 6) & 3); } }
/// <summary>
/// Gets the version of ZLib as a string, e.g. "1.2.1"
/// </summary>
public static string Version { get { return zlibVersion(); } }
}
#endregion
}
+301 -301
View File
@@ -1,301 +1,301 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements a compressed <see cref="Stream"/>, in GZip (.gz) format.
/// </summary>
public class GZipStream : Stream, IDisposable
{
#region Dll Imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
private static extern IntPtr gzopen(string name, string mode);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int gzclose(IntPtr gzFile);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int gzwrite(IntPtr gzFile, int data, int length);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int gzread(IntPtr gzFile, int data, int length);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int gzgetc(IntPtr gzFile);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int gzputc(IntPtr gzFile, int c);
#endregion
#region Private data
private IntPtr _gzFile;
private bool _isDisposed = false;
private bool _isWriting;
#endregion
#region Constructors
/// <summary>
/// Creates a new file as a writeable GZipStream
/// </summary>
/// <param name="fileName">The name of the compressed file to create</param>
/// <param name="level">The compression level to use when adding data</param>
/// <exception cref="ZLibException">If an error occurred in the internal zlib function</exception>
public GZipStream(string fileName, CompressLevel level)
{
_isWriting = true;
_gzFile = gzopen(fileName, String.Format("wb{0}", (int)level));
if (_gzFile == IntPtr.Zero)
throw new ZLibException(-1, "Could not open " + fileName);
}
/// <summary>
/// Opens an existing file as a readable GZipStream
/// </summary>
/// <param name="fileName">The name of the file to open</param>
/// <exception cref="ZLibException">If an error occurred in the internal zlib function</exception>
public GZipStream(string fileName)
{
_isWriting = false;
_gzFile = gzopen(fileName, "rb");
if (_gzFile == IntPtr.Zero)
throw new ZLibException(-1, "Could not open " + fileName);
}
#endregion
#region Access properties
/// <summary>
/// Returns true of this stream can be read from, false otherwise
/// </summary>
public override bool CanRead
{
get
{
return !_isWriting;
}
}
/// <summary>
/// Returns false.
/// </summary>
public override bool CanSeek
{
get
{
return false;
}
}
/// <summary>
/// Returns true if this tsream is writeable, false otherwise
/// </summary>
public override bool CanWrite
{
get
{
return _isWriting;
}
}
#endregion
#region Destructor & IDispose stuff
/// <summary>
/// Destroys this instance
/// </summary>
~GZipStream()
{
cleanUp(false);
}
/// <summary>
/// Closes the external file handle
/// </summary>
public void Dispose()
{
cleanUp(true);
}
// Does the actual closing of the file handle.
private void cleanUp(bool isDisposing)
{
if (!_isDisposed)
{
gzclose(_gzFile);
_isDisposed = true;
}
}
#endregion
#region Basic reading and writing
/// <summary>
/// Attempts to read a number of bytes from the stream.
/// </summary>
/// <param name="buffer">The destination data buffer</param>
/// <param name="offset">The index of the first destination byte in <c>buffer</c></param>
/// <param name="count">The number of bytes requested</param>
/// <returns>The number of bytes read</returns>
/// <exception cref="ArgumentNullException">If <c>buffer</c> is null</exception>
/// <exception cref="ArgumentOutOfRangeException">If <c>count</c> or <c>offset</c> are negative</exception>
/// <exception cref="ArgumentException">If <c>offset</c> + <c>count</c> is &gt; buffer.Length</exception>
/// <exception cref="NotSupportedException">If this stream is not readable.</exception>
/// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception>
public override int Read(byte[] buffer, int offset, int count)
{
if (!CanRead) throw new NotSupportedException();
if (buffer == null) throw new ArgumentNullException();
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > buffer.Length) throw new ArgumentException();
if (_isDisposed) throw new ObjectDisposedException("GZipStream");
GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned);
int result;
try
{
result = gzread(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count);
if (result < 0)
throw new IOException();
}
finally
{
h.Free();
}
return result;
}
/// <summary>
/// Attempts to read a single byte from the stream.
/// </summary>
/// <returns>The byte that was read, or -1 in case of error or End-Of-File</returns>
public override int ReadByte()
{
if (!CanRead) throw new NotSupportedException();
if (_isDisposed) throw new ObjectDisposedException("GZipStream");
return gzgetc(_gzFile);
}
/// <summary>
/// Writes a number of bytes to the stream
/// </summary>
/// <param name="buffer"></param>
/// <param name="offset"></param>
/// <param name="count"></param>
/// <exception cref="ArgumentNullException">If <c>buffer</c> is null</exception>
/// <exception cref="ArgumentOutOfRangeException">If <c>count</c> or <c>offset</c> are negative</exception>
/// <exception cref="ArgumentException">If <c>offset</c> + <c>count</c> is &gt; buffer.Length</exception>
/// <exception cref="NotSupportedException">If this stream is not writeable.</exception>
/// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception>
public override void Write(byte[] buffer, int offset, int count)
{
if (!CanWrite) throw new NotSupportedException();
if (buffer == null) throw new ArgumentNullException();
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > buffer.Length) throw new ArgumentException();
if (_isDisposed) throw new ObjectDisposedException("GZipStream");
GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned);
try
{
int result = gzwrite(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count);
if (result < 0)
throw new IOException();
}
finally
{
h.Free();
}
}
/// <summary>
/// Writes a single byte to the stream
/// </summary>
/// <param name="value">The byte to add to the stream.</param>
/// <exception cref="NotSupportedException">If this stream is not writeable.</exception>
/// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception>
public override void WriteByte(byte value)
{
if (!CanWrite) throw new NotSupportedException();
if (_isDisposed) throw new ObjectDisposedException("GZipStream");
int result = gzputc(_gzFile, (int)value);
if (result < 0)
throw new IOException();
}
#endregion
#region Position & length stuff
/// <summary>
/// Not supported.
/// </summary>
/// <param name="value"></param>
/// <exception cref="NotSupportedException">Always thrown</exception>
public override void SetLength(long value)
{
throw new NotSupportedException();
}
/// <summary>
/// Not supported.
/// </summary>
/// <param name="offset"></param>
/// <param name="origin"></param>
/// <returns></returns>
/// <exception cref="NotSupportedException">Always thrown</exception>
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotSupportedException();
}
/// <summary>
/// Flushes the <c>GZipStream</c>.
/// </summary>
/// <remarks>In this implementation, this method does nothing. This is because excessive
/// flushing may degrade the achievable compression rates.</remarks>
public override void Flush()
{
// left empty on purpose
}
/// <summary>
/// Gets/sets the current position in the <c>GZipStream</c>. Not supported.
/// </summary>
/// <remarks>In this implementation this property is not supported</remarks>
/// <exception cref="NotSupportedException">Always thrown</exception>
public override long Position
{
get
{
throw new NotSupportedException();
}
set
{
throw new NotSupportedException();
}
}
/// <summary>
/// Gets the size of the stream. Not supported.
/// </summary>
/// <remarks>In this implementation this property is not supported</remarks>
/// <exception cref="NotSupportedException">Always thrown</exception>
public override long Length
{
get
{
throw new NotSupportedException();
}
}
#endregion
}
}
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.IO;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements a compressed <see cref="Stream"/>, in GZip (.gz) format.
/// </summary>
public class GZipStream : Stream, IDisposable
{
#region Dll Imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
private static extern IntPtr gzopen(string name, string mode);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int gzclose(IntPtr gzFile);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int gzwrite(IntPtr gzFile, int data, int length);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int gzread(IntPtr gzFile, int data, int length);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int gzgetc(IntPtr gzFile);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int gzputc(IntPtr gzFile, int c);
#endregion
#region Private data
private IntPtr _gzFile;
private bool _isDisposed = false;
private bool _isWriting;
#endregion
#region Constructors
/// <summary>
/// Creates a new file as a writeable GZipStream
/// </summary>
/// <param name="fileName">The name of the compressed file to create</param>
/// <param name="level">The compression level to use when adding data</param>
/// <exception cref="ZLibException">If an error occurred in the internal zlib function</exception>
public GZipStream(string fileName, CompressLevel level)
{
_isWriting = true;
_gzFile = gzopen(fileName, String.Format("wb{0}", (int)level));
if (_gzFile == IntPtr.Zero)
throw new ZLibException(-1, "Could not open " + fileName);
}
/// <summary>
/// Opens an existing file as a readable GZipStream
/// </summary>
/// <param name="fileName">The name of the file to open</param>
/// <exception cref="ZLibException">If an error occurred in the internal zlib function</exception>
public GZipStream(string fileName)
{
_isWriting = false;
_gzFile = gzopen(fileName, "rb");
if (_gzFile == IntPtr.Zero)
throw new ZLibException(-1, "Could not open " + fileName);
}
#endregion
#region Access properties
/// <summary>
/// Returns true of this stream can be read from, false otherwise
/// </summary>
public override bool CanRead
{
get
{
return !_isWriting;
}
}
/// <summary>
/// Returns false.
/// </summary>
public override bool CanSeek
{
get
{
return false;
}
}
/// <summary>
/// Returns true if this tsream is writeable, false otherwise
/// </summary>
public override bool CanWrite
{
get
{
return _isWriting;
}
}
#endregion
#region Destructor & IDispose stuff
/// <summary>
/// Destroys this instance
/// </summary>
~GZipStream()
{
cleanUp(false);
}
/// <summary>
/// Closes the external file handle
/// </summary>
public void Dispose()
{
cleanUp(true);
}
// Does the actual closing of the file handle.
private void cleanUp(bool isDisposing)
{
if (!_isDisposed)
{
gzclose(_gzFile);
_isDisposed = true;
}
}
#endregion
#region Basic reading and writing
/// <summary>
/// Attempts to read a number of bytes from the stream.
/// </summary>
/// <param name="buffer">The destination data buffer</param>
/// <param name="offset">The index of the first destination byte in <c>buffer</c></param>
/// <param name="count">The number of bytes requested</param>
/// <returns>The number of bytes read</returns>
/// <exception cref="ArgumentNullException">If <c>buffer</c> is null</exception>
/// <exception cref="ArgumentOutOfRangeException">If <c>count</c> or <c>offset</c> are negative</exception>
/// <exception cref="ArgumentException">If <c>offset</c> + <c>count</c> is &gt; buffer.Length</exception>
/// <exception cref="NotSupportedException">If this stream is not readable.</exception>
/// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception>
public override int Read(byte[] buffer, int offset, int count)
{
if (!CanRead) throw new NotSupportedException();
if (buffer == null) throw new ArgumentNullException();
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > buffer.Length) throw new ArgumentException();
if (_isDisposed) throw new ObjectDisposedException("GZipStream");
GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned);
int result;
try
{
result = gzread(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count);
if (result < 0)
throw new IOException();
}
finally
{
h.Free();
}
return result;
}
/// <summary>
/// Attempts to read a single byte from the stream.
/// </summary>
/// <returns>The byte that was read, or -1 in case of error or End-Of-File</returns>
public override int ReadByte()
{
if (!CanRead) throw new NotSupportedException();
if (_isDisposed) throw new ObjectDisposedException("GZipStream");
return gzgetc(_gzFile);
}
/// <summary>
/// Writes a number of bytes to the stream
/// </summary>
/// <param name="buffer"></param>
/// <param name="offset"></param>
/// <param name="count"></param>
/// <exception cref="ArgumentNullException">If <c>buffer</c> is null</exception>
/// <exception cref="ArgumentOutOfRangeException">If <c>count</c> or <c>offset</c> are negative</exception>
/// <exception cref="ArgumentException">If <c>offset</c> + <c>count</c> is &gt; buffer.Length</exception>
/// <exception cref="NotSupportedException">If this stream is not writeable.</exception>
/// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception>
public override void Write(byte[] buffer, int offset, int count)
{
if (!CanWrite) throw new NotSupportedException();
if (buffer == null) throw new ArgumentNullException();
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > buffer.Length) throw new ArgumentException();
if (_isDisposed) throw new ObjectDisposedException("GZipStream");
GCHandle h = GCHandle.Alloc(buffer, GCHandleType.Pinned);
try
{
int result = gzwrite(_gzFile, h.AddrOfPinnedObject().ToInt32() + offset, count);
if (result < 0)
throw new IOException();
}
finally
{
h.Free();
}
}
/// <summary>
/// Writes a single byte to the stream
/// </summary>
/// <param name="value">The byte to add to the stream.</param>
/// <exception cref="NotSupportedException">If this stream is not writeable.</exception>
/// <exception cref="ObjectDisposedException">If this stream has been disposed.</exception>
public override void WriteByte(byte value)
{
if (!CanWrite) throw new NotSupportedException();
if (_isDisposed) throw new ObjectDisposedException("GZipStream");
int result = gzputc(_gzFile, (int)value);
if (result < 0)
throw new IOException();
}
#endregion
#region Position & length stuff
/// <summary>
/// Not supported.
/// </summary>
/// <param name="value"></param>
/// <exception cref="NotSupportedException">Always thrown</exception>
public override void SetLength(long value)
{
throw new NotSupportedException();
}
/// <summary>
/// Not suppported.
/// </summary>
/// <param name="offset"></param>
/// <param name="origin"></param>
/// <returns></returns>
/// <exception cref="NotSupportedException">Always thrown</exception>
public override long Seek(long offset, SeekOrigin origin)
{
throw new NotSupportedException();
}
/// <summary>
/// Flushes the <c>GZipStream</c>.
/// </summary>
/// <remarks>In this implementation, this method does nothing. This is because excessive
/// flushing may degrade the achievable compression rates.</remarks>
public override void Flush()
{
// left empty on purpose
}
/// <summary>
/// Gets/sets the current position in the <c>GZipStream</c>. Not suppported.
/// </summary>
/// <remarks>In this implementation this property is not supported</remarks>
/// <exception cref="NotSupportedException">Always thrown</exception>
public override long Position
{
get
{
throw new NotSupportedException();
}
set
{
throw new NotSupportedException();
}
}
/// <summary>
/// Gets the size of the stream. Not suppported.
/// </summary>
/// <remarks>In this implementation this property is not supported</remarks>
/// <exception cref="NotSupportedException">Always thrown</exception>
public override long Length
{
get
{
throw new NotSupportedException();
}
}
#endregion
}
}
+105 -105
View File
@@ -1,105 +1,105 @@
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements a data decompressor, using the inflate algorithm in the ZLib dll
/// </summary>
public class Inflater : CodecBase
{
#region Dll imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
private static extern int inflateInit_(ref ZStream sz, string vs, int size);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int inflate(ref ZStream sz, int flush);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int inflateReset(ref ZStream sz);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int inflateEnd(ref ZStream sz);
#endregion
/// <summary>
/// Constructs an new instance of the <c>Inflater</c>
/// </summary>
public Inflater() : base()
{
int retval = inflateInit_(ref _ztream, Info.Version, Marshal.SizeOf(_ztream));
if (retval != 0)
throw new ZLibException(retval, "Could not initialize inflater");
resetOutput();
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
public override void Add(byte[] data, int offset, int count)
{
if (data == null) throw new ArgumentNullException();
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
int total = count;
int inputIndex = offset;
int err = 0;
while (err >= 0 && inputIndex < total)
{
copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
err = inflate(ref _ztream, (int)FlushTypes.None);
if (err == 0)
while (_ztream.avail_out == 0)
{
OnDataAvailable();
err = inflate(ref _ztream, (int)FlushTypes.None);
}
inputIndex += (int)_ztream.total_in;
}
setChecksum( _ztream.adler );
}
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
public override void Finish()
{
int err;
do
{
err = inflate(ref _ztream, (int)FlushTypes.Finish);
OnDataAvailable();
}
while (err == 0);
setChecksum( _ztream.adler );
inflateReset(ref _ztream);
resetOutput();
}
/// <summary>
/// Closes the internal zlib inflate stream
/// </summary>
protected override void CleanUp() { inflateEnd(ref _ztream); }
}
}
//
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
using System.Diagnostics;
using System.Runtime.InteropServices;
namespace DotZLib
{
/// <summary>
/// Implements a data decompressor, using the inflate algorithm in the ZLib dll
/// </summary>
public class Inflater : CodecBase
{
#region Dll imports
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl, CharSet=CharSet.Ansi)]
private static extern int inflateInit_(ref ZStream sz, string vs, int size);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int inflate(ref ZStream sz, int flush);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int inflateReset(ref ZStream sz);
[DllImport("ZLIB1.dll", CallingConvention=CallingConvention.Cdecl)]
private static extern int inflateEnd(ref ZStream sz);
#endregion
/// <summary>
/// Constructs an new instance of the <c>Inflater</c>
/// </summary>
public Inflater() : base()
{
int retval = inflateInit_(ref _ztream, Info.Version, Marshal.SizeOf(_ztream));
if (retval != 0)
throw new ZLibException(retval, "Could not initialize inflater");
resetOutput();
}
/// <summary>
/// Adds more data to the codec to be processed.
/// </summary>
/// <param name="data">Byte array containing the data to be added to the codec</param>
/// <param name="offset">The index of the first byte to add from <c>data</c></param>
/// <param name="count">The number of bytes to add</param>
/// <remarks>Adding data may, or may not, raise the <c>DataAvailable</c> event</remarks>
public override void Add(byte[] data, int offset, int count)
{
if (data == null) throw new ArgumentNullException();
if (offset < 0 || count < 0) throw new ArgumentOutOfRangeException();
if ((offset+count) > data.Length) throw new ArgumentException();
int total = count;
int inputIndex = offset;
int err = 0;
while (err >= 0 && inputIndex < total)
{
copyInput(data, inputIndex, Math.Min(total - inputIndex, kBufferSize));
err = inflate(ref _ztream, (int)FlushTypes.None);
if (err == 0)
while (_ztream.avail_out == 0)
{
OnDataAvailable();
err = inflate(ref _ztream, (int)FlushTypes.None);
}
inputIndex += (int)_ztream.total_in;
}
setChecksum( _ztream.adler );
}
/// <summary>
/// Finishes up any pending data that needs to be processed and handled.
/// </summary>
public override void Finish()
{
int err;
do
{
err = inflate(ref _ztream, (int)FlushTypes.Finish);
OnDataAvailable();
}
while (err == 0);
setChecksum( _ztream.adler );
inflateReset(ref _ztream);
resetOutput();
}
/// <summary>
/// Closes the internal zlib inflate stream
/// </summary>
protected override void CleanUp() { inflateEnd(ref _ztream); }
}
}
@@ -2,7 +2,7 @@
// © Copyright Henrik Ravn 2004
//
// Use, modification and distribution are subject to the Boost Software License, Version 1.0.
// (See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
// (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//
using System;
@@ -17,7 +17,7 @@ using NUnit.Framework;
// Unit tests for the DotZLib class library
// ----------------------------------------
//
// Use this with NUnit 2 from https://www.nunit.org
// Use this with NUnit 2 from http://www.nunit.org
//
namespace DotZLibTests
@@ -156,7 +156,7 @@ namespace DotZLibTests
public void Info_Version()
{
Info info = new Info();
Assert.AreEqual("1.3.2", Info.Version);
Assert.AreEqual("1.2.13", Info.Version);
Assert.AreEqual(32, info.SizeOfUInt);
Assert.AreEqual(32, info.SizeOfULong);
Assert.AreEqual(32, info.SizeOfPointer);
+2 -2
View File
@@ -36,7 +36,7 @@ Build instructions:
in the same directory as the DotZLib.build file.
You can define 2 properties on the nant command-line to control the build:
debug={true|false} to toggle between release/debug builds (default=true).
nunit={true|false} to include or exclude unit tests (default=true).
nunit={true|false} to include or esclude unit tests (default=true).
Also the target clean will remove binaries.
Output file (DotZLib.dll) will be found in either ./DotZLib/bin/release
or ./DotZLib/bin/debug, depending on whether you are building the release
@@ -55,4 +55,4 @@ Build instructions:
Copyright (c) Henrik Ravn 2004
Use, modification and distribution are subject to the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at https://www.boost.org/LICENSE_1_0.txt)
(See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)

Some files were not shown because too many files have changed in this diff Show More