1
0
mirror of https://git.suyu.dev/suyu/suyu synced 2025-09-16 11:07:58 -05:00

Initial commit

This commit is contained in:
Crimson-Hawk
2024-03-05 16:42:40 +08:00
commit f1e4595ebf
39576 changed files with 7006612 additions and 0 deletions

View File

View File

View File

@@ -0,0 +1,96 @@
* text=auto !eol svneol=native#text/plain
*.gitattributes text svneol=native#text/plain
# Scriptish formats
*.bat text svneol=native#text/plain
*.bsh text svneol=native#text/x-beanshell
*.cgi text svneol=native#text/plain
*.cmd text svneol=native#text/plain
*.js text svneol=native#text/javascript
*.php text svneol=native#text/x-php
*.pl text svneol=native#text/x-perl
*.pm text svneol=native#text/x-perl
*.py text svneol=native#text/x-python
*.sh eol=lf svneol=LF#text/x-sh
configure eol=lf svneol=LF#text/x-sh
# Image formats
*.bmp binary svneol=unset#image/bmp
*.gif binary svneol=unset#image/gif
*.ico binary svneol=unset#image/ico
*.jpeg binary svneol=unset#image/jpeg
*.jpg binary svneol=unset#image/jpeg
*.png binary svneol=unset#image/png
*.tif binary svneol=unset#image/tiff
*.tiff binary svneol=unset#image/tiff
*.svg text svneol=native#image/svg%2Bxml
# Data formats
*.pdf binary svneol=unset#application/pdf
*.avi binary svneol=unset#video/avi
*.doc binary svneol=unset#application/msword
*.dsp text svneol=crlf#text/plain
*.dsw text svneol=crlf#text/plain
*.eps binary svneol=unset#application/postscript
*.gz binary svneol=unset#application/gzip
*.mov binary svneol=unset#video/quicktime
*.mp3 binary svneol=unset#audio/mpeg
*.ppt binary svneol=unset#application/vnd.ms-powerpoint
*.ps binary svneol=unset#application/postscript
*.psd binary svneol=unset#application/photoshop
*.rdf binary svneol=unset#text/rdf
*.rss text svneol=unset#text/xml
*.rtf binary svneol=unset#text/rtf
*.sln text svneol=native#text/plain
*.swf binary svneol=unset#application/x-shockwave-flash
*.tgz binary svneol=unset#application/gzip
*.vcproj text svneol=native#text/xml
*.vcxproj text svneol=native#text/xml
*.vsprops text svneol=native#text/xml
*.wav binary svneol=unset#audio/wav
*.xls binary svneol=unset#application/vnd.ms-excel
*.zip binary svneol=unset#application/zip
# Text formats
.htaccess text svneol=native#text/plain
*.bbk text svneol=native#text/xml
*.cmake text svneol=native#text/plain
*.css text svneol=native#text/css
*.dtd text svneol=native#text/xml
*.htm text svneol=native#text/html
*.html text svneol=native#text/html
*.ini text svneol=native#text/plain
*.log text svneol=native#text/plain
*.mak text svneol=native#text/plain
*.qbk text svneol=native#text/plain
*.rst text svneol=native#text/plain
*.sql text svneol=native#text/x-sql
*.txt text svneol=native#text/plain
*.xhtml text svneol=native#text/xhtml%2Bxml
*.xml text svneol=native#text/xml
*.xsd text svneol=native#text/xml
*.xsl text svneol=native#text/xml
*.xslt text svneol=native#text/xml
*.xul text svneol=native#text/xul
*.yml text svneol=native#text/plain
boost-no-inspect text svneol=native#text/plain
CHANGES text svneol=native#text/plain
COPYING text svneol=native#text/plain
INSTALL text svneol=native#text/plain
Jamfile text svneol=native#text/plain
Jamroot text svneol=native#text/plain
Jamfile.v2 text svneol=native#text/plain
Jamrules text svneol=native#text/plain
Makefile* text svneol=native#text/plain
README text svneol=native#text/plain
TODO text svneol=native#text/plain
# Code formats
*.c text svneol=native#text/plain
*.cpp text svneol=native#text/plain
*.h text svneol=native#text/plain
*.hpp text svneol=native#text/plain
*.ipp text svneol=native#text/plain
*.tpp text svneol=native#text/plain
*.jam text svneol=native#text/plain
*.java text svneol=native#text/plain

View File

@@ -0,0 +1,365 @@
name: CI
on:
pull_request:
push:
branches:
- master
- develop
- feature/**
env:
UBSAN_OPTIONS: print_stacktrace=1
jobs:
posix:
strategy:
fail-fast: false
matrix:
include:
- toolset: gcc-4.8
cxxstd: "03,11"
os: ubuntu-18.04
install: g++-4.8-multilib
address-model: 32,64
- toolset: gcc-5
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: g++-5-multilib
address-model: 32,64
- toolset: gcc-6
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: g++-6-multilib
address-model: 32,64
- toolset: gcc-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: g++-7-multilib
address-model: 32,64
- toolset: gcc-8
cxxstd: "03,11,14,17,2a"
os: ubuntu-18.04
install: g++-8-multilib
address-model: 32,64
- toolset: gcc-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-9-multilib
address-model: 32,64
- toolset: gcc-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: g++-10-multilib
address-model: 32,64
- toolset: gcc-11
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install: g++-11-multilib
address-model: 32,64
- toolset: clang
compiler: clang++-3.9
cxxstd: "03,11,14"
os: ubuntu-18.04
install: clang-3.9
- toolset: clang
compiler: clang++-4.0
cxxstd: "03,11,14"
os: ubuntu-18.04
install: clang-4.0
- toolset: clang
compiler: clang++-5.0
cxxstd: "03,11,14,1z"
os: ubuntu-18.04
install: clang-5.0
- toolset: clang
compiler: clang++-6.0
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-6.0
- toolset: clang
compiler: clang++-7
cxxstd: "03,11,14,17"
os: ubuntu-18.04
install: clang-7
- toolset: clang
compiler: clang++-8
cxxstd: "03,11,14,17"
os: ubuntu-20.04
install: clang-8
- toolset: clang
compiler: clang++-9
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-9
- toolset: clang
compiler: clang++-10
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-10
- toolset: clang
compiler: clang++-11
cxxstd: "03,11,14,17,2a"
os: ubuntu-20.04
install: clang-11
- toolset: clang
compiler: clang++-12
cxxstd: "03,11,14,17,20"
os: ubuntu-20.04
install: clang-12
- toolset: clang
cxxstd: "03,11,14,17,2a"
os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
./bootstrap.sh
./b2 -d0 headers
- name: Create user-config.jam
if: matrix.compiler
run: |
echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam
- name: Run tests
run: |
cd ../boost-root
export ADDRMD=${{matrix.address-model}}
./b2 -j3 libs/$LIBRARY/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} ${ADDRMD:+address-model=$ADDRMD} variant=debug,release
windows:
strategy:
fail-fast: false
matrix:
include:
- toolset: msvc-14.1
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2016
- toolset: msvc-14.2
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2019
- toolset: msvc-14.3
cxxstd: "14,17,latest"
addrmd: 32,64
os: windows-2022
- toolset: gcc
cxxstd: "03,11,14,17,2a"
addrmd: 64
os: windows-2019
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Setup Boost
shell: cmd
run: |
echo GITHUB_REPOSITORY: %GITHUB_REPOSITORY%
for /f %%i in ("%GITHUB_REPOSITORY%") do set LIBRARY=%%~nxi
echo LIBRARY: %LIBRARY%
echo LIBRARY=%LIBRARY%>>%GITHUB_ENV%
echo GITHUB_BASE_REF: %GITHUB_BASE_REF%
echo GITHUB_REF: %GITHUB_REF%
if "%GITHUB_BASE_REF%" == "" set GITHUB_BASE_REF=%GITHUB_REF%
set BOOST_BRANCH=develop
for /f %%i in ("%GITHUB_BASE_REF%") do if "%%~nxi" == "master" set BOOST_BRANCH=master
echo BOOST_BRANCH: %BOOST_BRANCH%
cd ..
git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
xcopy /s /e /q %GITHUB_WORKSPACE% libs\%LIBRARY%\
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" %LIBRARY%
cmd /c bootstrap
b2 -d0 headers
- name: Run tests
shell: cmd
run: |
cd ../boost-root
b2 -j3 libs/%LIBRARY%/test toolset=${{matrix.toolset}} cxxstd=${{matrix.cxxstd}} address-model=${{matrix.addrmd}} variant=debug,release
posix-cmake-subdir:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Use library with add_subdirectory
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_subdir_test
mkdir __build__ && cd __build__
cmake ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-install:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DCMAKE_INSTALL_PREFIX=~/.local ..
- name: Install
run: |
cd ../boost-root/__build__
cmake --build . --target install
- name: Use the installed library
run: |
cd ../boost-root/libs/$LIBRARY/test/cmake_install_test && mkdir __build__ && cd __build__
cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
cmake --build .
ctest --output-on-failure --no-tests=error
posix-cmake-test:
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-18.04
- os: ubuntu-20.04
- os: macos-10.15
runs-on: ${{matrix.os}}
steps:
- uses: actions/checkout@v2
- name: Install packages
if: matrix.install
run: sudo apt install ${{matrix.install}}
- name: Setup Boost
run: |
echo GITHUB_REPOSITORY: $GITHUB_REPOSITORY
LIBRARY=${GITHUB_REPOSITORY#*/}
echo LIBRARY: $LIBRARY
echo "LIBRARY=$LIBRARY" >> $GITHUB_ENV
echo GITHUB_BASE_REF: $GITHUB_BASE_REF
echo GITHUB_REF: $GITHUB_REF
REF=${GITHUB_BASE_REF:-$GITHUB_REF}
REF=${REF#refs/heads/}
echo REF: $REF
BOOST_BRANCH=develop && [ "$REF" == "master" ] && BOOST_BRANCH=master || true
echo BOOST_BRANCH: $BOOST_BRANCH
cd ..
git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
cd boost-root
cp -r $GITHUB_WORKSPACE/* libs/$LIBRARY
git submodule update --init tools/boostdep
python tools/boostdep/depinst/depinst.py --git_args "--jobs 3" $LIBRARY
- name: Configure
run: |
cd ../boost-root
mkdir __build__ && cd __build__
cmake -DBOOST_INCLUDE_LIBRARIES=$LIBRARY -DBUILD_TESTING=ON ..
- name: Build tests
run: |
cd ../boost-root/__build__
cmake --build . --target tests
- name: Run tests
run: |
cd ../boost-root/__build__
ctest --output-on-failure --no-tests=error

View File

@@ -0,0 +1,430 @@
# Copyright 2016-2020 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
language: cpp
dist: xenial
branches:
only:
- master
- develop
- /feature\/.*/
env:
matrix:
- BOGUS_JOB=true
matrix:
exclude:
- env: BOGUS_JOB=true
include:
- os: linux
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
addons:
apt:
packages:
- g++-multilib
- os: linux
arch: arm64
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
- os: linux
arch: ppc64le
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14
- os: linux
arch: s390x
compiler: g++
env: TOOLSET=gcc COMPILER=g++ CXXSTD=03,11,14 ADDRMD=32,64
- os: linux
compiler: g++-4.4
env: TOOLSET=gcc COMPILER=g++-4.4 CXXSTD=98,0x
addons:
apt:
packages:
- g++-4.4
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.6
env: TOOLSET=gcc COMPILER=g++-4.6 CXXSTD=03,0x
addons:
apt:
packages:
- g++-4.6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.7
env: TOOLSET=gcc COMPILER=g++-4.7 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.8
env: TOOLSET=gcc COMPILER=g++-4.8 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-4.9
env: TOOLSET=gcc COMPILER=g++-4.9 CXXSTD=03,11
addons:
apt:
packages:
- g++-4.9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-5
env: TOOLSET=gcc COMPILER=g++-5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-6
env: TOOLSET=gcc COMPILER=g++-6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- g++-6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-7
env: TOOLSET=gcc COMPILER=g++-7 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-8
env: TOOLSET=gcc COMPILER=g++-8 CXXSTD=03,11,14,17
addons:
apt:
packages:
- g++-8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: g++-9
env: TOOLSET=gcc COMPILER=g++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- g++-9
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: bionic
compiler: g++-10
env: UBSAN=1 TOOLSET=gcc COMPILER=g++-10 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1 LINKFLAGS=-fuse-ld=gold
addons:
apt:
packages:
- g++-10
sources:
- ubuntu-toolchain-r-test
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
apt:
packages:
- clang-3.3
- os: linux
dist: trusty
compiler: /usr/bin/clang++
env: TOOLSET=clang COMPILER=/usr/bin/clang++ CXXSTD=03,11
addons:
apt:
packages:
- clang-3.4
- os: linux
compiler: clang++-3.5
env: TOOLSET=clang COMPILER=clang++-3.5 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.5
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.6
env: TOOLSET=clang COMPILER=clang++-3.6 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.6
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.7
env: TOOLSET=clang COMPILER=clang++-3.7 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.7
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.8
env: TOOLSET=clang COMPILER=clang++-3.8 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.8
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-3.9
env: TOOLSET=clang COMPILER=clang++-3.9 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-3.9
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-4.0
env: TOOLSET=clang COMPILER=clang++-4.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-4.0
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-5.0
env: TOOLSET=clang COMPILER=clang++-5.0 CXXSTD=03,11,14,1z
addons:
apt:
packages:
- clang-5.0
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-6.0
env: TOOLSET=clang COMPILER=clang++-6.0 CXXSTD=03,11,14,17
addons:
apt:
packages:
- clang-6.0
sources:
- ubuntu-toolchain-r-test
- os: linux
compiler: clang++-7
env: TOOLSET=clang COMPILER=clang++-7 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-7
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-7
- os: linux
compiler: clang++-8
env: TOOLSET=clang COMPILER=clang++-8 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-8
sources:
- ubuntu-toolchain-r-test
- llvm-toolchain-xenial-8
- os: linux
dist: bionic
compiler: clang++-9
env: TOOLSET=clang COMPILER=clang++-9 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-9
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-9 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: bionic
compiler: clang++-10
env: TOOLSET=clang COMPILER=clang++-10 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-10
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-10 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: bionic
compiler: clang++-11
env: TOOLSET=clang COMPILER=clang++-11 CXXSTD=03,11,14,17,2a
addons:
apt:
packages:
- clang-11
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-11 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: bionic
compiler: clang++-12
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-12 CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- clang-12
sources:
- ubuntu-toolchain-r-test
- sourceline: 'deb https://apt.llvm.org/bionic/ llvm-toolchain-bionic-12 main'
key_url: 'https://apt.llvm.org/llvm-snapshot.gpg.key'
- os: linux
dist: trusty
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,1z UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- os: linux
dist: bionic
compiler: clang++-libc++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++-libc++ CXXSTD=03,11,14,17,2a UBSAN_OPTIONS=print_stacktrace=1
addons:
apt:
packages:
- libc++-dev
- os: osx
osx_image: xcode7.3
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
- os: osx
osx_image: xcode8.3
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
- os: osx
osx_image: xcode9.4
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64
- os: osx
osx_image: xcode10.3
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
- os: osx
osx_image: xcode11.3
compiler: clang++
env: TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z
- os: osx
compiler: clang++
env: UBSAN=1 TOOLSET=clang COMPILER=clang++ CXXSTD=03,11,14,1z ADDRMD=32,64 UBSAN_OPTIONS=print_stacktrace=1
- os: linux
env: CMAKE_TEST=1
script:
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBUILD_TESTING=ON -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=endian ..
- ctest --output-on-failure -R boost_endian
- os: linux
env: CMAKE_SUBDIR_TEST=1
install:
- BOOST_BRANCH=develop
- if [ "$TRAVIS_BRANCH" = "master" ]; then BOOST_BRANCH=master; fi
- git clone -b $BOOST_BRANCH https://github.com/boostorg/assert.git ../assert
- git clone -b $BOOST_BRANCH https://github.com/boostorg/config.git ../config
- git clone -b $BOOST_BRANCH https://github.com/boostorg/core.git ../core
- git clone -b $BOOST_BRANCH https://github.com/boostorg/static_assert.git ../static_assert
- git clone -b $BOOST_BRANCH https://github.com/boostorg/type_traits.git ../type_traits
script:
- cd test/cmake_subdir_test && mkdir __build__ && cd __build__
- cmake ..
- cmake --build .
- cmake --build . --target check
- os: linux
env: CMAKE_INSTALL_TEST=1
script:
- pip install --user cmake
- mkdir __build__ && cd __build__
- cmake -DBOOST_ENABLE_CMAKE=1 -DBoost_VERBOSE=1 -DBOOST_INCLUDE_LIBRARIES=endian -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build . --target install
- cd ../libs/endian/test/cmake_install_test && mkdir __build__ && cd __build__
- cmake -DCMAKE_INSTALL_PREFIX=~/.local ..
- cmake --build .
- cmake --build . --target check
install:
- BOOST_BRANCH=develop && [ "$TRAVIS_BRANCH" == "master" ] && BOOST_BRANCH=master || true
- cd ..
- git clone -b $BOOST_BRANCH --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/boostdep
- cp -r $TRAVIS_BUILD_DIR/* libs/endian
- python tools/boostdep/depinst/depinst.py endian
- ./bootstrap.sh
- ./b2 headers
script:
- |-
echo "using $TOOLSET : : $COMPILER ;" > ~/user-config.jam
- ./b2 -j3 libs/endian/test toolset=$TOOLSET cxxstd=$CXXSTD variant=debug,release ${ADDRMD:+address-model=$ADDRMD} ${UBSAN:+cxxflags=-fsanitize=undefined cxxflags=-fno-sanitize-recover=undefined linkflags=-fsanitize=undefined debug-symbols=on} ${LINKFLAGS:+linkflags=$LINKFLAGS}
notifications:
email:
on_success: always

View File

@@ -0,0 +1,26 @@
# Copyright 2019 Peter Dimov
# Distributed under 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
cmake_minimum_required(VERSION 3.5...3.16)
project(boost_endian VERSION "${BOOST_SUPERPROJECT_VERSION}" LANGUAGES CXX)
add_library(boost_endian INTERFACE)
add_library(Boost::endian ALIAS boost_endian)
target_include_directories(boost_endian INTERFACE include)
target_link_libraries(boost_endian
INTERFACE
Boost::config
Boost::core
Boost::static_assert
Boost::type_traits
)
if(BUILD_TESTING)
add_subdirectory(test)
endif()

View File

@@ -0,0 +1,20 @@
# Boost.Endian
The Endian library provides facilities for dealing with
[endianness](https://en.wikipedia.org/wiki/Endianness).
It's part of Boost since release 1.58.0. See
[the documentation](http://boost.org/libs/endian) for more information.
## Supported compilers
* g++ 4.4 or later
* clang++ 3.3 or later
* Visual Studio 2008 or later
Tested on [Travis](https://travis-ci.org/boostorg/endian/) and
[Appveyor](https://ci.appveyor.com/project/pdimov/endian/).
## License
Distributed under the
[Boost Software License, Version 1.0](http://boost.org/LICENSE_1_0.txt).

View File

@@ -0,0 +1,66 @@
# Copyright 2016-2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# (See accompanying file LICENSE_1_0.txt or copy at http://boost.org/LICENSE_1_0.txt)
version: 1.0.{build}-{branch}
shallow_clone: true
branches:
only:
- master
- develop
- /feature\/.*/
environment:
matrix:
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-9.0,msvc-10.0,msvc-11.0
ADDRMD: 32
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
TOOLSET: msvc-12.0,msvc-14.0
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2017
TOOLSET: msvc-14.1,clang-win
CXXSTD: 14,17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2019
TOOLSET: msvc-14.2
CXXSTD: 14,17
ADDRMD: 32,64
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\cygwin64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
- APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015
ADDPATH: C:\mingw-w64\x86_64-6.3.0-posix-seh-rt_v5-rev1\mingw64\bin;
TOOLSET: gcc
CXXSTD: 03,11,14,1z
install:
- set BOOST_BRANCH=develop
- if "%APPVEYOR_REPO_BRANCH%" == "master" set BOOST_BRANCH=master
- cd ..
- git clone -b %BOOST_BRANCH% --depth 1 https://github.com/boostorg/boost.git boost-root
- cd boost-root
- git submodule update --init tools/boostdep
- xcopy /s /e /q %APPVEYOR_BUILD_FOLDER% libs\endian\
- python tools/boostdep/depinst/depinst.py endian
- cmd /c bootstrap
- b2 -d0 headers
build: off
test_script:
- PATH=%ADDPATH%%PATH%
- if not "%CXXSTD%" == "" set CXXSTD=cxxstd=%CXXSTD%
- if not "%ADDRMD%" == "" set ADDRMD=address-model=%ADDRMD%
- b2 -j3 libs/endian/test toolset=%TOOLSET% %CXXSTD% %ADDRMD% variant=debug,release

View File

@@ -0,0 +1,25 @@
# Build and install benchmark programs
# Copyright Beman Dawes 2013
# Distributed under the Boost Software License, Version 1.0.
# See www.boost.org/LICENSE_1_0.txt
project
: source-location ../test : requirements
<toolset>msvc:<asynch-exceptions>on
<library>/boost/timer//boost_timer
;
SOURCES = speed_test speed_test_functions ;
exe "speed_test"
: $(SOURCES).cpp
: <toolset>gcc:<cxxflags>-march=native
;
exe "loop_time_test"
: loop_time_test.cpp
: <toolset>gcc:<cxxflags>-march=native
;
install bin : speed_test loop_time_test ;

View File

@@ -0,0 +1,12 @@
b2 -a toolset=msvc-14.0 variant=release link=static address-model=64
bin\loop_time_test 1000 >msvc-loop-time.html
msvc-loop-time.html
echo The GCC static build does not work on Windows, probably because of a bjam/b2 bug
b2 -a toolset=gcc-c++11 variant=release link=static address-model=64
bin\loop_time_test 1000 >gcc-loop-time.html
gcc-loop-time.html
rem Copyright Beman Dawes 2015
rem Distributed under the Boost Software License, Version 1.0.
rem See www.boost.org/LICENSE_1_0.txt

View File

@@ -0,0 +1,2 @@
/html/
/pdf/

View File

@@ -0,0 +1,27 @@
# Copyright 2019 Glen Joseph Fernandes
# (glenjofe@gmail.com)
#
# Distributed under the Boost Software License, Version 1.0.
# (http://www.boost.org/LICENSE_1_0.txt)
import asciidoctor ;
html endian.html : endian.adoc ;
install html_ : endian.html : <location>html ;
pdf endian.pdf : endian.adoc ;
explicit endian.pdf ;
install pdf_ : endian.pdf : <location>pdf ;
explicit pdf_ ;
alias boostdoc ;
explicit boostdoc ;
alias boostrelease : html_ ;
explicit boostrelease ;

View File

@@ -0,0 +1,7 @@
<style>
*:not(pre)>code { background: none; color: #600000; }
:not(pre):not([class^=L])>code { background: none; color: #600000; }
table tr.even, table tr.alt, table tr:nth-of-type(even) { background: none; }
</style>

View File

@@ -0,0 +1,39 @@
////
Copyright 2019 Glen Joseph Fernandes
(glenjofe@gmail.com)
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
////
# Boost.Endian: The Boost Endian Library
Beman Dawes
:toc: left
:toclevels: 2
:idprefix:
:listing-caption: Code Example
:docinfo: private-footer
:source-highlighter: rouge
:source-language: c++
:leveloffset: +1
include::endian/overview.adoc[]
include::endian/changelog.adoc[]
include::endian/choosing_approach.adoc[]
include::endian/conversion.adoc[]
include::endian/buffers.adoc[]
include::endian/arithmetic.adoc[]
include::endian/history.adoc[]
:leveloffset: -1
[appendix]
## Copyright and License
This documentation is
* Copyright 2011-2016 Beman Dawes
* Copyright 2019 Peter Dimov
and is distributed under the http://www.boost.org/LICENSE_1_0.txt[Boost Software License, Version 1.0].

View File

@@ -0,0 +1,616 @@
////
Copyright 2011-2016 Beman Dawes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
////
[#arithmetic]
# Endian Arithmetic Types
:idprefix: arithmetic_
## Introduction
Header `boost/endian/arithmetic.hpp` provides integer binary types with
control over byte order, value type, size, and alignment. Typedefs provide
easy-to-use names for common configurations.
These types provide portable byte-holders for integer data, independent of
particular computer architectures. Use cases almost always involve I/O, either
via files or network connections. Although data portability is the primary
motivation, these integer byte-holders may also be used to reduce memory use,
file size, or network activity since they provide binary integer sizes not
otherwise available.
Such integer byte-holder types are traditionally called *endian* types. See the
http://en.wikipedia.org/wiki/Endian[Wikipedia] for a full exploration of
*endianness*, including definitions of *big endian* and *little endian*.
Boost endian integers provide the same full set of {cpp} assignment, arithmetic,
and relational operators as {cpp} standard integral types, with the standard
semantics.
Unary arithmetic operators are `+`, `-`, `~`, `!`, plus both prefix and postfix
`--` and `++`. Binary arithmetic operators are `+`, `+=`, `-`, `-=`, `\*`,
``*=``, `/`, `/=`, `&`, `&=`, `|`, `|=`, `^`, `^=`, `<<`, `<\<=`, `>>`, and
`>>=`. Binary relational operators are `==`, `!=`, `<`, `\<=`, `>`, and `>=`.
Implicit conversion to the underlying value type is provided. An implicit
constructor converting from the underlying value type is provided.
## Example
The `endian_example.cpp` program writes a binary file containing four-byte,
big-endian and little-endian integers:
```
#include <iostream>
#include <cstdio>
#include <boost/endian/arithmetic.hpp>
#include <boost/static_assert.hpp>
using namespace boost::endian;
namespace
{
// This is an extract from a very widely used GIS file format.
// Why the designer decided to mix big and little endians in
// the same file is not known. But this is a real-world format
// and users wishing to write low level code manipulating these
// files have to deal with the mixed endianness.
struct header
{
big_int32_t file_code;
big_int32_t file_length;
little_int32_t version;
little_int32_t shape_type;
};
const char* filename = "test.dat";
}
int main(int, char* [])
{
header h;
BOOST_STATIC_ASSERT(sizeof(h) == 16U); // reality check
h.file_code = 0x01020304;
h.file_length = sizeof(header);
h.version = 1;
h.shape_type = 0x01020304;
// Low-level I/O such as POSIX read/write or <cstdio>
// fread/fwrite is sometimes used for binary file operations
// when ultimate efficiency is important. Such I/O is often
// performed in some C++ wrapper class, but to drive home the
// point that endian integers are often used in fairly
// low-level code that does bulk I/O operations, <cstdio>
// fopen/fwrite is used for I/O in this example.
std::FILE* fi = std::fopen(filename, "wb"); // MUST BE BINARY
if (!fi)
{
std::cout << "could not open " << filename << '\n';
return 1;
}
if (std::fwrite(&h, sizeof(header), 1, fi) != 1)
{
std::cout << "write failure for " << filename << '\n';
return 1;
}
std::fclose(fi);
std::cout << "created file " << filename << '\n';
return 0;
}
```
After compiling and executing `endian_example.cpp`, a hex dump of `test.dat`
shows:
```
01020304 00000010 01000000 04030201
```
Notice that the first two 32-bit integers are big endian while the second two
are little endian, even though the machine this was compiled and run on was
little endian.
## Limitations
Requires `<climits>`, `CHAR_BIT == 8`. If `CHAR_BIT` is some other value,
compilation will result in an `#error`. This restriction is in place because the
design, implementation, testing, and documentation has only considered issues
related to 8-bit bytes, and there have been no real-world use cases presented
for other sizes.
In {cpp}03, `endian_arithmetic` does not meet the requirements for POD types
because it has constructors, private data members, and a base class. This means
that common use cases are relying on unspecified behavior in that the {cpp}
Standard does not guarantee memory layout for non-POD types. This has not been a
problem in practice since all known {cpp} compilers lay out memory as if
`endian` were a POD type. In {cpp}11, it is possible to specify the default
constructor as trivial, and private data members and base classes no longer
disqualify a type from being a POD type. Thus under {cpp}11, `endian_arithmetic`
will no longer be relying on unspecified behavior.
## Feature set
* Big endian| little endian | native endian byte ordering.
* Signed | unsigned
* Unaligned | aligned
* 1-8 byte (unaligned) | 1, 2, 4, 8 byte (aligned)
* Choice of value type
## Enums and typedefs
Two scoped enums are provided:
```
enum class order { big, little, native };
enum class align { no, yes };
```
One class template is provided:
```
template <order Order, typename T, std::size_t n_bits,
align Align = align::no>
class endian_arithmetic;
```
Typedefs, such as `big_int32_t`, provide convenient naming conventions for
common use cases:
[%header,cols=5*]
|===
|Name |Alignment |Endianness |Sign |Sizes in bits (n)
|`big_intN_t` |no |big |signed |8,16,24,32,40,48,56,64
|`big_uintN_t` |no |big |unsigned |8,16,24,32,40,48,56,64
|`little_intN_t` |no |little |signed |8,16,24,32,40,48,56,64
|`little_uintN_t` |no |little |unsigned |8,16,24,32,40,48,56,64
|`native_intN_t` |no |native |signed |8,16,24,32,40,48,56,64
|`native_uintN_t` |no |native |unsigned |8,16,24,32,40,48,56,64
|`big_intN_at` |yes |big |signed |8,16,32,64
|`big_uintN_at` |yes |big |unsigned |8,16,32,64
|`little_intN_at` |yes |little |signed |8,16,32,64
|`little_uintN_at` |yes |little |unsigned |8,16,32,64
|===
The unaligned types do not cause compilers to insert padding bytes in classes
and structs. This is an important characteristic that can be exploited to
minimize wasted space in memory, files, and network transmissions.
CAUTION: Code that uses aligned types is possibly non-portable because
alignment requirements vary between hardware architectures and because
alignment may be affected by compiler switches or pragmas. For example,
alignment of an 64-bit integer may be to a 32-bit boundary on a 32-bit machine.
Furthermore, aligned types are only available on architectures with 8, 16, 32,
and 64-bit integer types.
TIP: Prefer unaligned arithmetic types.
TIP: Protect yourself against alignment ills. For example:
[none]
{blank}::
+
```
static_assert(sizeof(containing_struct) == 12, "sizeof(containing_struct) is wrong");
```
NOTE: One-byte arithmetic types have identical layout on all platforms, so they
never actually reverse endianness. They are provided to enable generic code,
and to improve code readability and searchability.
## Class template `endian_arithmetic`
`endian_arithmetic` is an integer byte-holder with user-specified endianness,
value type, size, and alignment. The usual operations on arithmetic types are
supplied.
### Synopsis
```
#include <boost/endian/buffers.hpp>
namespace boost
{
namespace endian
{
// C++11 features emulated if not available
enum class align { no, yes };
template <order Order, class T, std::size_t n_bits,
align Align = align::no>
class endian_arithmetic
{
public:
typedef T value_type;
// if BOOST_ENDIAN_FORCE_PODNESS is defined && C++11 PODs are not
// available then these two constructors will not be present
endian_arithmetic() noexcept = default;
endian_arithmetic(T v) noexcept;
endian_arithmetic& operator=(T v) noexcept;
operator value_type() const noexcept;
value_type value() const noexcept;
unsigned char* data() noexcept;
unsigned char const* data() const noexcept;
// arithmetic operations
// note that additional operations are provided by the value_type
value_type operator+() const noexcept;
endian_arithmetic& operator+=(value_type y) noexcept;
endian_arithmetic& operator-=(value_type y) noexcept;
endian_arithmetic& operator*=(value_type y) noexcept;
endian_arithmetic& operator/=(value_type y) noexcept;
endian_arithmetic& operator%=(value_type y) noexcept;
endian_arithmetic& operator&=(value_type y) noexcept;
endian_arithmetic& operator|=(value_type y) noexcept;
endian_arithmetic& operator^=(value_type y) noexcept;
endian_arithmetic& operator<<=(value_type y) noexcept;
endian_arithmetic& operator>>=(value_type y) noexcept;
endian_arithmetic& operator++() noexcept;
endian_arithmetic& operator--() noexcept;
endian_arithmetic operator++(int) noexcept;
endian_arithmetic operator--(int) noexcept;
// Stream inserter
template <class charT, class traits>
friend std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const endian_arithmetic& x);
// Stream extractor
template <class charT, class traits>
friend std::basic_istream<charT, traits>&
operator>>(std::basic_istream<charT, traits>& is, endian_arithmetic& x);
};
// typedefs
// unaligned big endian signed integer types
typedef endian_arithmetic<order::big, int_least8_t, 8> big_int8_t;
typedef endian_arithmetic<order::big, int_least16_t, 16> big_int16_t;
typedef endian_arithmetic<order::big, int_least32_t, 24> big_int24_t;
typedef endian_arithmetic<order::big, int_least32_t, 32> big_int32_t;
typedef endian_arithmetic<order::big, int_least64_t, 40> big_int40_t;
typedef endian_arithmetic<order::big, int_least64_t, 48> big_int48_t;
typedef endian_arithmetic<order::big, int_least64_t, 56> big_int56_t;
typedef endian_arithmetic<order::big, int_least64_t, 64> big_int64_t;
// unaligned big endian unsigned integer types
typedef endian_arithmetic<order::big, uint_least8_t, 8> big_uint8_t;
typedef endian_arithmetic<order::big, uint_least16_t, 16> big_uint16_t;
typedef endian_arithmetic<order::big, uint_least32_t, 24> big_uint24_t;
typedef endian_arithmetic<order::big, uint_least32_t, 32> big_uint32_t;
typedef endian_arithmetic<order::big, uint_least64_t, 40> big_uint40_t;
typedef endian_arithmetic<order::big, uint_least64_t, 48> big_uint48_t;
typedef endian_arithmetic<order::big, uint_least64_t, 56> big_uint56_t;
typedef endian_arithmetic<order::big, uint_least64_t, 64> big_uint64_t;
// unaligned big endian floating point types
typedef endian_arithmetic<order::big, float, 32> big_float32_t;
typedef endian_arithmetic<order::big, double, 64> big_float64_t;
// unaligned little endian signed integer types
typedef endian_arithmetic<order::little, int_least8_t, 8> little_int8_t;
typedef endian_arithmetic<order::little, int_least16_t, 16> little_int16_t;
typedef endian_arithmetic<order::little, int_least32_t, 24> little_int24_t;
typedef endian_arithmetic<order::little, int_least32_t, 32> little_int32_t;
typedef endian_arithmetic<order::little, int_least64_t, 40> little_int40_t;
typedef endian_arithmetic<order::little, int_least64_t, 48> little_int48_t;
typedef endian_arithmetic<order::little, int_least64_t, 56> little_int56_t;
typedef endian_arithmetic<order::little, int_least64_t, 64> little_int64_t;
// unaligned little endian unsigned integer types
typedef endian_arithmetic<order::little, uint_least8_t, 8> little_uint8_t;
typedef endian_arithmetic<order::little, uint_least16_t, 16> little_uint16_t;
typedef endian_arithmetic<order::little, uint_least32_t, 24> little_uint24_t;
typedef endian_arithmetic<order::little, uint_least32_t, 32> little_uint32_t;
typedef endian_arithmetic<order::little, uint_least64_t, 40> little_uint40_t;
typedef endian_arithmetic<order::little, uint_least64_t, 48> little_uint48_t;
typedef endian_arithmetic<order::little, uint_least64_t, 56> little_uint56_t;
typedef endian_arithmetic<order::little, uint_least64_t, 64> little_uint64_t;
// unaligned little endian floating point types
typedef endian_arithmetic<order::little, float, 32> little_float32_t;
typedef endian_arithmetic<order::little, double, 64> little_float64_t;
// unaligned native endian signed integer types
typedef endian_arithmetic<order::native, int_least8_t, 8> native_int8_t;
typedef endian_arithmetic<order::native, int_least16_t, 16> native_int16_t;
typedef endian_arithmetic<order::native, int_least32_t, 24> native_int24_t;
typedef endian_arithmetic<order::native, int_least32_t, 32> native_int32_t;
typedef endian_arithmetic<order::native, int_least64_t, 40> native_int40_t;
typedef endian_arithmetic<order::native, int_least64_t, 48> native_int48_t;
typedef endian_arithmetic<order::native, int_least64_t, 56> native_int56_t;
typedef endian_arithmetic<order::native, int_least64_t, 64> native_int64_t;
// unaligned native endian unsigned integer types
typedef endian_arithmetic<order::native, uint_least8_t, 8> native_uint8_t;
typedef endian_arithmetic<order::native, uint_least16_t, 16> native_uint16_t;
typedef endian_arithmetic<order::native, uint_least32_t, 24> native_uint24_t;
typedef endian_arithmetic<order::native, uint_least32_t, 32> native_uint32_t;
typedef endian_arithmetic<order::native, uint_least64_t, 40> native_uint40_t;
typedef endian_arithmetic<order::native, uint_least64_t, 48> native_uint48_t;
typedef endian_arithmetic<order::native, uint_least64_t, 56> native_uint56_t;
typedef endian_arithmetic<order::native, uint_least64_t, 64> native_uint64_t;
// unaligned native endian floating point types
typedef endian_arithmetic<order::native, float, 32> native_float32_t;
typedef endian_arithmetic<order::native, double, 64> native_float64_t;
// aligned big endian signed integer types
typedef endian_arithmetic<order::big, int8_t, 8, align::yes> big_int8_at;
typedef endian_arithmetic<order::big, int16_t, 16, align::yes> big_int16_at;
typedef endian_arithmetic<order::big, int32_t, 32, align::yes> big_int32_at;
typedef endian_arithmetic<order::big, int64_t, 64, align::yes> big_int64_at;
// aligned big endian unsigned integer types
typedef endian_arithmetic<order::big, uint8_t, 8, align::yes> big_uint8_at;
typedef endian_arithmetic<order::big, uint16_t, 16, align::yes> big_uint16_at;
typedef endian_arithmetic<order::big, uint32_t, 32, align::yes> big_uint32_at;
typedef endian_arithmetic<order::big, uint64_t, 64, align::yes> big_uint64_at;
// aligned big endian floating point types
typedef endian_arithmetic<order::big, float, 32, align::yes> big_float32_at;
typedef endian_arithmetic<order::big, double, 64, align::yes> big_float64_at;
// aligned little endian signed integer types
typedef endian_arithmetic<order::little, int8_t, 8, align::yes> little_int8_at;
typedef endian_arithmetic<order::little, int16_t, 16, align::yes> little_int16_at;
typedef endian_arithmetic<order::little, int32_t, 32, align::yes> little_int32_at;
typedef endian_arithmetic<order::little, int64_t, 64, align::yes> little_int64_at;
// aligned little endian unsigned integer types
typedef endian_arithmetic<order::little, uint8_t, 8, align::yes> little_uint8_at;
typedef endian_arithmetic<order::little, uint16_t, 16, align::yes> little_uint16_at;
typedef endian_arithmetic<order::little, uint32_t, 32, align::yes> little_uint32_at;
typedef endian_arithmetic<order::little, uint64_t, 64, align::yes> little_uint64_at;
// aligned little endian floating point types
typedef endian_arithmetic<order::little, float, 32, align::yes> little_float32_at;
typedef endian_arithmetic<order::little, double, 64, align::yes> little_float64_at;
// aligned native endian typedefs are not provided because
// <cstdint> types are superior for that use case
} // namespace endian
} // namespace boost
```
The only supported value of `CHAR_BIT` is 8.
The valid values of `Nbits` are as follows:
* When `sizeof(T)` is 1, `Nbits` shall be 8;
* When `sizeof(T)` is 2, `Nbits` shall be 16;
* When `sizeof(T)` is 4, `Nbits` shall be 24 or 32;
* When `sizeof(T)` is 8, `Nbits` shall be 40, 48, 56, or 64.
Other values of `sizeof(T)` are not supported.
When `Nbits` is equal to `sizeof(T)*8`, `T` must be a standard arithmetic type.
When `Nbits` is less than `sizeof(T)*8`, `T` must be a standard integral type
({cpp}std, [basic.fundamental]) that is not `bool`.
### Members
```
endian_arithmetic() noexcept = default; // C++03: endian(){}
```
[none]
* {blank}
+
Effects:: Constructs an uninitialized object.
```
endian_arithmetic(T v) noexcept;
```
[none]
* {blank}
+
Effects:: See `endian_buffer::endian_buffer(T)`.
```
endian_arithmetic& operator=(T v) noexcept;
```
[none]
* {blank}
+
Effects:: See `endian_buffer::operator=(T)`.
Returns:: `*this`.
```
value_type value() const noexcept;
```
[none]
* {blank}
+
Returns:: See `endian_buffer::value()`.
```
unsigned char* data() noexcept;
```
```
unsigned char const* data() const noexcept;
```
[none]
* {blank}
+
Returns:: See `endian_buffer::data()`.
```
operator T() const noexcept;
```
[none]
* {blank}
+
Returns::
`value()`.
### Other operators
Other operators on endian objects are forwarded to the equivalent operator on
`value_type`.
### Stream inserter
```
template <class charT, class traits>
friend std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os, const endian_arithmetic& x);
```
[none]
* {blank}
+
Returns:: `os << +x`.
[none]
### Stream extractor
```
template <class charT, class traits>
friend std::basic_istream<charT, traits>&
operator>>(std::basic_istream<charT, traits>& is, endian_arithmetic& x);
```
[none]
* {blank}
+
Effects:: As if:
+
```
T i;
if (is >> i)
x = i;
```
Returns:: `is`.
## FAQ
See the <<overview_faq,Overview FAQ>> for a library-wide FAQ.
Why not just use Boost.Serialization?::
Serialization involves a conversion for every object involved in I/O. Endian
integers require no conversion or copying. They are already in the desired
format for binary I/O. Thus they can be read or written in bulk.
Are endian types PODs?::
Yes for {cpp}11. No for {cpp}03, although several
<<arithmetic_compilation,macros>> are available to force PODness in all cases.
What are the implications of endian integer types not being PODs with {cpp}03 compilers?::
They can't be used in unions. Also, compilers aren't required to align or lay
out storage in portable ways, although this potential problem hasn't prevented
use of Boost.Endian with real compilers.
What good is native endianness?::
It provides alignment and size guarantees not available from the built-in
types. It eases generic programming.
Why bother with the aligned endian types?::
Aligned integer operations may be faster (as much as 10 to 20 times faster)
if the endianness and alignment of the type matches the endianness and
alignment requirements of the machine. The code, however, will be somewhat less
portable than with the unaligned types.
Why provide the arithmetic operations?::
Providing a full set of operations reduces program clutter and makes code
both easier to write and to read. Consider incrementing a variable in a record.
It is very convenient to write:
+
```
++record.foo;
```
+
Rather than:
+
```
int temp(record.foo);
++temp;
record.foo = temp;
```
## Design considerations for Boost.Endian types
* Must be suitable for I/O - in other words, must be memcpyable.
* Must provide exactly the size and internal byte ordering specified.
* Must work correctly when the internal integer representation has more bits
that the sum of the bits in the external byte representation. Sign extension
must work correctly when the internal integer representation type has more
bits than the sum of the bits in the external bytes. For example, using
a 64-bit integer internally to represent 40-bit (5 byte) numbers must work for
both positive and negative values.
* Must work correctly (including using the same defined external
representation) regardless of whether a compiler treats char as signed or
unsigned.
* Unaligned types must not cause compilers to insert padding bytes.
* The implementation should supply optimizations with great care. Experience
has shown that optimizations of endian integers often become pessimizations
when changing machines or compilers. Pessimizations can also happen when
changing compiler switches, compiler versions, or CPU models of the same
architecture.
## Experience
Classes with similar functionality have been independently developed by
several Boost programmers and used very successful in high-value, high-use
applications for many years. These independently developed endian libraries
often evolved from C libraries that were also widely used. Endian types have
proven widely useful across a wide range of computer architectures and
applications.
## Motivating use cases
Neil Mayhew writes: "I can also provide a meaningful use-case for this
library: reading TrueType font files from disk and processing the contents. The
data format has fixed endianness (big) and has unaligned values in various
places. Using Boost.Endian simplifies and cleans the code wonderfully."
## {cpp}11
The availability of the {cpp}11
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm[Defaulted
Functions] feature is detected automatically, and will be used if present to
ensure that objects of `class endian_arithmetic` are trivial, and thus PODs.
## Compilation
Boost.Endian is implemented entirely within headers, with no need to link to any
Boost object libraries.
Several macros allow user control over features:
* BOOST_ENDIAN_NO_CTORS causes `class endian_arithmetic` to have no
constructors. The intended use is for compiling user code that must be portable
between compilers regardless of {cpp}11
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm[Defaulted
Functions] support. Use of constructors will always fail,
* BOOST_ENDIAN_FORCE_PODNESS causes BOOST_ENDIAN_NO_CTORS to be defined if
the compiler does not support {cpp}11
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm[Defaulted
Functions]. This is ensures that objects of `class endian_arithmetic` are PODs,
and so can be used in {cpp}03 unions. In {cpp}11, `class endian_arithmetic`
objects are PODs, even though they have constructors, so can always be used in
unions.
## Acknowledgements
Original design developed by Darin Adler based on classes developed by Mark
Borgerding. Four original class templates combined into a single
`endian_arithmetic` class template by Beman Dawes, who put the library together,
provided documentation, added the typedefs, and also added the
`unrolled_byte_loops` sign partial specialization to correctly extend the sign
when cover integer size differs from endian representation size.

View File

@@ -0,0 +1,541 @@
////
Copyright 2011-2016 Beman Dawes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
////
[#buffers]
# Endian Buffer Types
:idprefix: buffers_
## Introduction
The internal byte order of arithmetic types is traditionally called
*endianness*. See the http://en.wikipedia.org/wiki/Endian[Wikipedia] for a full
exploration of *endianness*, including definitions of *big endian* and *little
endian*.
Header `boost/endian/buffers.hpp` provides `endian_buffer`, a portable endian
integer binary buffer class template with control over byte order, value type,
size, and alignment independent of the platform's native endianness. Typedefs
provide easy-to-use names for common configurations.
Use cases primarily involve data portability, either via files or network
connections, but these byte-holders may also be used to reduce memory use, file
size, or network activity since they provide binary numeric sizes not otherwise
available.
Class `endian_buffer` is aimed at users who wish explicit control over when
endianness conversions occur. It also serves as the base class for the
<<arithmetic,endian_arithmetic>> class template, which is aimed at users who
wish fully automatic endianness conversion and direct support for all normal
arithmetic operations.
## Example
The `example/endian_example.cpp` program writes a binary file containing
four-byte, big-endian and little-endian integers:
```
#include <iostream>
#include <cstdio>
#include <boost/endian/buffers.hpp> // see Synopsis below
#include <boost/static_assert.hpp>
using namespace boost::endian;
namespace
{
// This is an extract from a very widely used GIS file format.
// Why the designer decided to mix big and little endians in
// the same file is not known. But this is a real-world format
// and users wishing to write low level code manipulating these
// files have to deal with the mixed endianness.
struct header
{
big_int32_buf_t file_code;
big_int32_buf_t file_length;
little_int32_buf_t version;
little_int32_buf_t shape_type;
};
const char* filename = "test.dat";
}
int main(int, char* [])
{
header h;
BOOST_STATIC_ASSERT(sizeof(h) == 16U); // reality check
h.file_code = 0x01020304;
h.file_length = sizeof(header);
h.version = 1;
h.shape_type = 0x01020304;
// Low-level I/O such as POSIX read/write or <cstdio>
// fread/fwrite is sometimes used for binary file operations
// when ultimate efficiency is important. Such I/O is often
// performed in some C++ wrapper class, but to drive home the
// point that endian integers are often used in fairly
// low-level code that does bulk I/O operations, <cstdio>
// fopen/fwrite is used for I/O in this example.
std::FILE* fi = std::fopen(filename, "wb"); // MUST BE BINARY
if (!fi)
{
std::cout << "could not open " << filename << '\n';
return 1;
}
if (std::fwrite(&h, sizeof(header), 1, fi) != 1)
{
std::cout << "write failure for " << filename << '\n';
return 1;
}
std::fclose(fi);
std::cout << "created file " << filename << '\n';
return 0;
}
```
After compiling and executing `example/endian_example.cpp`, a hex dump of
`test.dat` shows:
```
01020304 00000010 01000000 04030201
```
Notice that the first two 32-bit integers are big endian while the second two
are little endian, even though the machine this was compiled and run on was
little endian.
## Limitations
Requires `<climits>`, `CHAR_BIT == 8`. If `CHAR_BIT` is some other value,
compilation will result in an `#error`. This restriction is in place because the
design, implementation, testing, and documentation has only considered issues
related to 8-bit bytes, and there have been no real-world use cases presented
for other sizes.
In {cpp}03, `endian_buffer` does not meet the requirements for POD types because
it has constructors and a private data member. This means that
common use cases are relying on unspecified behavior in that the {cpp} Standard
does not guarantee memory layout for non-POD types. This has not been a problem
in practice since all known {cpp} compilers lay out memory as if `endian` were
a POD type. In {cpp}11, it is possible to specify the default constructor as
trivial, and private data members and base classes no longer disqualify a type
from being a POD type. Thus under {cpp}11, `endian_buffer` will no longer be
relying on unspecified behavior.
## Feature set
* Big endian| little endian | native endian byte ordering.
* Signed | unsigned
* Unaligned | aligned
* 1-8 byte (unaligned) | 1, 2, 4, 8 byte (aligned)
* Choice of value type
## Enums and typedefs
Two scoped enums are provided:
```
enum class order { big, little, native };
enum class align { no, yes };
```
One class template is provided:
```
template <order Order, typename T, std::size_t Nbits,
align Align = align::no>
class endian_buffer;
```
Typedefs, such as `big_int32_buf_t`, provide convenient naming conventions for
common use cases:
[%header,cols=5*]
|===
|Name |Alignment |Endianness |Sign |Sizes in bits (n)
|`big_intN_buf_t` |no |big |signed |8,16,24,32,40,48,56,64
|`big_uintN_buf_t` |no |big |unsigned |8,16,24,32,40,48,56,64
|`little_intN_buf_t` |no |little |signed |8,16,24,32,40,48,56,64
|`little_uintN_buf_t` |no |little |unsigned |8,16,24,32,40,48,56,64
|`native_intN_buf_t` |no |native |signed |8,16,24,32,40,48,56,64
|`native_uintN_buf_t` |no |native |unsigned |8,16,24,32,40,48,56,64
|`big_intN_buf_at` |yes |big |signed |8,16,32,64
|`big_uintN_buf_at` |yes |big |unsigned |8,16,32,64
|`little_intN_buf_at` |yes |little |signed |8,16,32,64
|`little_uintN_buf_at` |yes |little |unsigned |8,16,32,64
|===
The unaligned types do not cause compilers to insert padding bytes in classes
and structs. This is an important characteristic that can be exploited to
minimize wasted space in memory, files, and network transmissions.
CAUTION: Code that uses aligned types is possibly non-portable because alignment
requirements vary between hardware architectures and because alignment may be
affected by compiler switches or pragmas. For example, alignment of an 64-bit
integer may be to a 32-bit boundary on a 32-bit machine and to a 64-bit boundary
on a 64-bit machine. Furthermore, aligned types are only available on
architectures with 8, 16, 32, and 64-bit integer types.
TIP: Prefer unaligned buffer types.
TIP: Protect yourself against alignment ills. For example:
[none]
{blank}::
+
```
static_assert(sizeof(containing_struct) == 12, "sizeof(containing_struct) is wrong");
```
Note: One-byte big and little buffer types have identical layout on all
platforms, so they never actually reverse endianness. They are provided to
enable generic code, and to improve code readability and searchability.
## Class template `endian_buffer`
An `endian_buffer` is a byte-holder for arithmetic types with
user-specified endianness, value type, size, and alignment.
### Synopsis
```
namespace boost
{
namespace endian
{
// C++11 features emulated if not available
enum class align { no, yes };
template <order Order, class T, std::size_t Nbits,
align Align = align::no>
class endian_buffer
{
public:
typedef T value_type;
endian_buffer() noexcept = default;
explicit endian_buffer(T v) noexcept;
endian_buffer& operator=(T v) noexcept;
value_type value() const noexcept;
unsigned char* data() noexcept;
unsigned char const* data() const noexcept;
private:
unsigned char value_[Nbits / CHAR_BIT]; // exposition only
};
// stream inserter
template <class charT, class traits, order Order, class T,
std::size_t n_bits, align Align>
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os,
const endian_buffer<Order, T, n_bits, Align>& x);
// stream extractor
template <class charT, class traits, order Order, class T,
std::size_t n_bits, align A>
std::basic_istream<charT, traits>&
operator>>(std::basic_istream<charT, traits>& is,
endian_buffer<Order, T, n_bits, Align>& x);
// typedefs
// unaligned big endian signed integer buffers
typedef endian_buffer<order::big, int_least8_t, 8> big_int8_buf_t;
typedef endian_buffer<order::big, int_least16_t, 16> big_int16_buf_t;
typedef endian_buffer<order::big, int_least32_t, 24> big_int24_buf_t;
typedef endian_buffer<order::big, int_least32_t, 32> big_int32_buf_t;
typedef endian_buffer<order::big, int_least64_t, 40> big_int40_buf_t;
typedef endian_buffer<order::big, int_least64_t, 48> big_int48_buf_t;
typedef endian_buffer<order::big, int_least64_t, 56> big_int56_buf_t;
typedef endian_buffer<order::big, int_least64_t, 64> big_int64_buf_t;
// unaligned big endian unsigned integer buffers
typedef endian_buffer<order::big, uint_least8_t, 8> big_uint8_buf_t;
typedef endian_buffer<order::big, uint_least16_t, 16> big_uint16_buf_t;
typedef endian_buffer<order::big, uint_least32_t, 24> big_uint24_buf_t;
typedef endian_buffer<order::big, uint_least32_t, 32> big_uint32_buf_t;
typedef endian_buffer<order::big, uint_least64_t, 40> big_uint40_buf_t;
typedef endian_buffer<order::big, uint_least64_t, 48> big_uint48_buf_t;
typedef endian_buffer<order::big, uint_least64_t, 56> big_uint56_buf_t;
typedef endian_buffer<order::big, uint_least64_t, 64> big_uint64_buf_t;
// unaligned big endian floating point buffers
typedef endian_buffer<order::big, float, 32> big_float32_buf_t;
typedef endian_buffer<order::big, double, 64> big_float64_buf_t;
// unaligned little endian signed integer buffers
typedef endian_buffer<order::little, int_least8_t, 8> little_int8_buf_t;
typedef endian_buffer<order::little, int_least16_t, 16> little_int16_buf_t;
typedef endian_buffer<order::little, int_least32_t, 24> little_int24_buf_t;
typedef endian_buffer<order::little, int_least32_t, 32> little_int32_buf_t;
typedef endian_buffer<order::little, int_least64_t, 40> little_int40_buf_t;
typedef endian_buffer<order::little, int_least64_t, 48> little_int48_buf_t;
typedef endian_buffer<order::little, int_least64_t, 56> little_int56_buf_t;
typedef endian_buffer<order::little, int_least64_t, 64> little_int64_buf_t;
// unaligned little endian unsigned integer buffers
typedef endian_buffer<order::little, uint_least8_t, 8> little_uint8_buf_t;
typedef endian_buffer<order::little, uint_least16_t, 16> little_uint16_buf_t;
typedef endian_buffer<order::little, uint_least32_t, 24> little_uint24_buf_t;
typedef endian_buffer<order::little, uint_least32_t, 32> little_uint32_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 40> little_uint40_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 48> little_uint48_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 56> little_uint56_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 64> little_uint64_buf_t;
// unaligned little endian floating point buffers
typedef endian_buffer<order::little, float, 32> little_float32_buf_t;
typedef endian_buffer<order::little, double, 64> little_float64_buf_t;
// unaligned native endian signed integer types
typedef endian_buffer<order::native, int_least8_t, 8> native_int8_buf_t;
typedef endian_buffer<order::native, int_least16_t, 16> native_int16_buf_t;
typedef endian_buffer<order::native, int_least32_t, 24> native_int24_buf_t;
typedef endian_buffer<order::native, int_least32_t, 32> native_int32_buf_t;
typedef endian_buffer<order::native, int_least64_t, 40> native_int40_buf_t;
typedef endian_buffer<order::native, int_least64_t, 48> native_int48_buf_t;
typedef endian_buffer<order::native, int_least64_t, 56> native_int56_buf_t;
typedef endian_buffer<order::native, int_least64_t, 64> native_int64_buf_t;
// unaligned native endian unsigned integer types
typedef endian_buffer<order::native, uint_least8_t, 8> native_uint8_buf_t;
typedef endian_buffer<order::native, uint_least16_t, 16> native_uint16_buf_t;
typedef endian_buffer<order::native, uint_least32_t, 24> native_uint24_buf_t;
typedef endian_buffer<order::native, uint_least32_t, 32> native_uint32_buf_t;
typedef endian_buffer<order::native, uint_least64_t, 40> native_uint40_buf_t;
typedef endian_buffer<order::native, uint_least64_t, 48> native_uint48_buf_t;
typedef endian_buffer<order::native, uint_least64_t, 56> native_uint56_buf_t;
typedef endian_buffer<order::native, uint_least64_t, 64> native_uint64_buf_t;
// unaligned native endian floating point types
typedef endian_buffer<order::native, float, 32> native_float32_buf_t;
typedef endian_buffer<order::native, double, 64> native_float64_buf_t;
// aligned big endian signed integer buffers
typedef endian_buffer<order::big, int8_t, 8, align::yes> big_int8_buf_at;
typedef endian_buffer<order::big, int16_t, 16, align::yes> big_int16_buf_at;
typedef endian_buffer<order::big, int32_t, 32, align::yes> big_int32_buf_at;
typedef endian_buffer<order::big, int64_t, 64, align::yes> big_int64_buf_at;
// aligned big endian unsigned integer buffers
typedef endian_buffer<order::big, uint8_t, 8, align::yes> big_uint8_buf_at;
typedef endian_buffer<order::big, uint16_t, 16, align::yes> big_uint16_buf_at;
typedef endian_buffer<order::big, uint32_t, 32, align::yes> big_uint32_buf_at;
typedef endian_buffer<order::big, uint64_t, 64, align::yes> big_uint64_buf_at;
// aligned big endian floating point buffers
typedef endian_buffer<order::big, float, 32, align::yes> big_float32_buf_at;
typedef endian_buffer<order::big, double, 64, align::yes> big_float64_buf_at;
// aligned little endian signed integer buffers
typedef endian_buffer<order::little, int8_t, 8, align::yes> little_int8_buf_at;
typedef endian_buffer<order::little, int16_t, 16, align::yes> little_int16_buf_at;
typedef endian_buffer<order::little, int32_t, 32, align::yes> little_int32_buf_at;
typedef endian_buffer<order::little, int64_t, 64, align::yes> little_int64_buf_at;
// aligned little endian unsigned integer buffers
typedef endian_buffer<order::little, uint8_t, 8, align::yes> little_uint8_buf_at;
typedef endian_buffer<order::little, uint16_t, 16, align::yes> little_uint16_buf_at;
typedef endian_buffer<order::little, uint32_t, 32, align::yes> little_uint32_buf_at;
typedef endian_buffer<order::little, uint64_t, 64, align::yes> little_uint64_buf_at;
// aligned little endian floating point buffers
typedef endian_buffer<order::little, float, 32, align::yes> little_float32_buf_at;
typedef endian_buffer<order::little, double, 64, align::yes> little_float64_buf_at;
// aligned native endian typedefs are not provided because
// <cstdint> types are superior for this use case
} // namespace endian
} // namespace boost
```
The expository data member `value_` stores the current value of the
`endian_buffer` object as a sequence of bytes ordered as specified by the
`Order` template parameter. The `CHAR_BIT` macro is defined in `<climits>`.
The only supported value of `CHAR_BIT` is 8.
The valid values of `Nbits` are as follows:
* When `sizeof(T)` is 1, `Nbits` shall be 8;
* When `sizeof(T)` is 2, `Nbits` shall be 16;
* When `sizeof(T)` is 4, `Nbits` shall be 24 or 32;
* When `sizeof(T)` is 8, `Nbits` shall be 40, 48, 56, or 64.
Other values of `sizeof(T)` are not supported.
When `Nbits` is equal to `sizeof(T)*8`, `T` must be a trivially copyable type
(such as `float`) that is assumed to have the same endianness as `uintNbits_t`.
When `Nbits` is less than `sizeof(T)*8`, `T` must be either a standard integral
type ({cpp}std, [basic.fundamental]) or an `enum`.
### Members
```
endian_buffer() noexcept = default;
```
[none]
* {blank}
+
Effects:: Constructs an uninitialized object.
```
explicit endian_buffer(T v) noexcept;
```
[none]
* {blank}
+
Effects:: `endian_store<T, Nbits/8, Order>( value_, v )`.
```
endian_buffer& operator=(T v) noexcept;
```
[none]
* {blank}
+
Effects:: `endian_store<T, Nbits/8, Order>( value_, v )`.
Returns:: `*this`.
```
value_type value() const noexcept;
```
[none]
* {blank}
+
Returns:: `endian_load<T, Nbits/8, Order>( value_ )`.
```
unsigned char* data() noexcept;
```
```
unsigned char const* data() const noexcept;
```
[none]
* {blank}
+
Returns::
A pointer to the first byte of `value_`.
### Non-member functions
```
template <class charT, class traits, order Order, class T,
std::size_t n_bits, align Align>
std::basic_ostream<charT, traits>& operator<<(std::basic_ostream<charT, traits>& os,
const endian_buffer<Order, T, n_bits, Align>& x);
```
[none]
* {blank}
+
Returns:: `os << x.value()`.
```
template <class charT, class traits, order Order, class T,
std::size_t n_bits, align A>
std::basic_istream<charT, traits>& operator>>(std::basic_istream<charT, traits>& is,
endian_buffer<Order, T, n_bits, Align>& x);
```
[none]
* {blank}
+
Effects:: As if:
+
```
T i;
if (is >> i)
x = i;
```
Returns:: `is`.
## FAQ
See the <<overview_faq,Overview FAQ>> for a library-wide FAQ.
Why not just use Boost.Serialization?::
Serialization involves a conversion for every object involved in I/O. Endian
integers require no conversion or copying. They are already in the desired
format for binary I/O. Thus they can be read or written in bulk.
Are endian types PODs?::
Yes for {cpp}11. No for {cpp}03, although several
<<buffers_compilation,macros>> are available to force PODness in all cases.
What are the implications of endian integer types not being PODs with {cpp}03 compilers?::
They can't be used in unions. Also, compilers aren't required to align or lay
out storage in portable ways, although this potential problem hasn't prevented
use of Boost.Endian with real compilers.
What good is native endianness?::
It provides alignment and size guarantees not available from the built-in
types. It eases generic programming.
Why bother with the aligned endian types?::
Aligned integer operations may be faster (as much as 10 to 20 times faster) if
the endianness and alignment of the type matches the endianness and alignment
requirements of the machine. The code, however, is likely to be somewhat less
portable than with the unaligned types.
## Design considerations for Boost.Endian buffers
* Must be suitable for I/O - in other words, must be memcpyable.
* Must provide exactly the size and internal byte ordering specified.
* Must work correctly when the internal integer representation has more bits
that the sum of the bits in the external byte representation. Sign extension
must work correctly when the internal integer representation type has more
bits than the sum of the bits in the external bytes. For example, using
a 64-bit integer internally to represent 40-bit (5 byte) numbers must work for
both positive and negative values.
* Must work correctly (including using the same defined external
representation) regardless of whether a compiler treats char as signed or
unsigned.
* Unaligned types must not cause compilers to insert padding bytes.
* The implementation should supply optimizations with great care. Experience
has shown that optimizations of endian integers often become pessimizations
when changing machines or compilers. Pessimizations can also happen when
changing compiler switches, compiler versions, or CPU models of the same
architecture.
## {cpp}11
The availability of the {cpp}11
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm[Defaulted
Functions] feature is detected automatically, and will be used if present to
ensure that objects of `class endian_buffer` are trivial, and thus
PODs.
## Compilation
Boost.Endian is implemented entirely within headers, with no need to link to
any Boost object libraries.
Several macros allow user control over features:
* `BOOST_ENDIAN_NO_CTORS` causes `class endian_buffer` to have no
constructors. The intended use is for compiling user code that must be
portable between compilers regardless of {cpp}11
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm[Defaulted
Functions] support. Use of constructors will always fail,
* `BOOST_ENDIAN_FORCE_PODNESS` causes `BOOST_ENDIAN_NO_CTORS` to be defined if
the compiler does not support {cpp}11
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2346.htm[Defaulted
Functions]. This is ensures that objects of `class endian_buffer` are PODs, and
so can be used in {cpp}03 unions. In {cpp}11, `class endian_buffer` objects are
PODs, even though they have constructors, so can always be used in unions.

View File

@@ -0,0 +1,41 @@
////
Copyright 2019 Peter Dimov
Distributed under 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
////
[#changelog]
# Revision History
## Changes in 1.75.0
* `endian_arithmetic` no longer inherits from `endian_buffer`
* When `BOOST_ENDIAN_NO_CTORS` is defined, the unaligned `endian_buffer` and
`endian_arithmetic` are {cpp}03 PODs, to enable use of `++__attribute__((packed))++`
## Changes in 1.74.0
* Enabled scoped enumeration types in `endian_reverse`
* Enabled `bool`, `enum`, `float`, `double` in `endian_reverse_inplace`
* Added an overload of `endian_reverse_inplace` for arrays
## Changes in 1.72.0
* Made `endian_reverse`, `conditional_reverse` and `\*\_to_*` `constexpr`
on GCC and Clang
* Added convenience load and store functions
* Added floating point convenience typedefs
* Added a non-const overload of `data()`; changed its return type to `unsigned char*`
* Added `__int128` support to `endian_reverse` when available
* Added a convenience header `boost/endian.hpp`
## Changes in 1.71.0
* Clarified requirements on the value type template parameter
* Added support for `float` and `double` to `endian_buffer` and `endian_arithmetic`
* Added `endian_load`, `endian_store`
* Updated `endian_reverse` to correctly support all non-`bool` integral types
* Moved deprecated names to the deprecated header `endian.hpp`

View File

@@ -0,0 +1,314 @@
////
Copyright 2011-2016 Beman Dawes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
////
[#choosing]
# Choosing between Conversion Functions, Buffer Types, and Arithmetic Types
:idprefix: choosing_
NOTE: Deciding which is the best endianness approach (conversion functions, buffer
types, or arithmetic types) for a particular application involves complex
engineering trade-offs. It is hard to assess those trade-offs without some
understanding of the different interfaces, so you might want to read the
<<conversion,conversion functions>>, <<buffers,buffer types>>, and
<<arithmetic,arithmetic types>> pages before proceeding.
The best approach to endianness for a particular application depends on the
interaction between the application's needs and the characteristics of each of
the three approaches.
*Recommendation:* If you are new to endianness, uncertain, or don't want to
invest the time to study engineering trade-offs, use
<<arithmetic,endian arithmetic types>>. They are safe, easy to use, and easy to
maintain. Use the _<<choosing_anticipating_need,anticipating need>>_ design
pattern locally around performance hot spots like lengthy loops, if needed.
## Background
A dealing with endianness usually implies a program portability or a data
portability requirement, and often both. That means real programs dealing with
endianness are usually complex, so the examples shown here would really be
written as multiple functions spread across multiple translation units. They
would involve interfaces that can not be altered as they are supplied by
third-parties or the standard library.
## Characteristics
The characteristics that differentiate the three approaches to endianness are
the endianness invariants, conversion explicitness, arithmetic operations, sizes
available, and alignment requirements.
### Endianness invariants
*Endian conversion functions* use objects of the ordinary {cpp} arithmetic types
like `int` or `unsigned short` to hold values. That breaks the implicit
invariant that the {cpp} language rules apply. The usual language rules only apply
if the endianness of the object is currently set to the native endianness for
the platform. That can make it very hard to reason about logic flow, and result
in difficult to find bugs.
For example:
```
struct data_t // big endian
{
int32_t v1; // description ...
int32_t v2; // description ...
... additional character data members (i.e. non-endian)
int32_t v3; // description ...
};
data_t data;
read(data);
big_to_native_inplace(data.v1);
big_to_native_inplace(data.v2);
...
++v1;
third_party::func(data.v2);
...
native_to_big_inplace(data.v1);
native_to_big_inplace(data.v2);
write(data);
```
The programmer didn't bother to convert `data.v3` to native endianness because
that member isn't used. A later maintainer needs to pass `data.v3` to the
third-party function, so adds `third_party::func(data.v3);` somewhere deep in
the code. This causes a silent failure because the usual invariant that an
object of type `int32_t` holds a value as described by the {cpp} core language
does not apply.
*Endian buffer and arithmetic types* hold values internally as arrays of
characters with an invariant that the endianness of the array never changes.
That makes these types easier to use and programs easier to maintain.
Here is the same example, using an endian arithmetic type:
```
struct data_t
{
big_int32_t v1; // description ...
big_int32_t v2; // description ...
... additional character data members (i.e. non-endian)
big_int32_t v3; // description ...
};
data_t data;
read(data);
...
++v1;
third_party::func(data.v2);
...
write(data);
```
A later maintainer can add `third_party::func(data.v3)` and it will just-work.
### Conversion explicitness
*Endian conversion functions* and *buffer types* never perform implicit
conversions. This gives users explicit control of when conversion occurs, and
may help avoid unnecessary conversions.
*Endian arithmetic types* perform conversion implicitly. That makes these types
very easy to use, but can result in unnecessary conversions. Failure to hoist
conversions out of inner loops can bring a performance penalty.
### Arithmetic operations
*Endian conversion functions* do not supply arithmetic operations, but this is
not a concern since this approach uses ordinary {cpp} arithmetic types to hold
values.
*Endian buffer types* do not supply arithmetic operations. Although this
approach avoids unnecessary conversions, it can result in the introduction of
additional variables and confuse maintenance programmers.
*Endian arithmetic types* do supply arithmetic operations. They are very easy to
use if lots of arithmetic is involved.
### Sizes
*Endianness conversion functions* only support 1, 2, 4, and 8 byte integers.
That's sufficient for many applications.
*Endian buffer and arithmetic types* support 1, 2, 3, 4, 5, 6, 7, and 8 byte
integers. For an application where memory use or I/O speed is the limiting
factor, using sizes tailored to application needs can be useful.
### Alignments
*Endianness conversion functions* only support aligned integer and
floating-point types. That's sufficient for most applications.
*Endian buffer and arithmetic types* support both aligned and unaligned
integer and floating-point types. Unaligned types are rarely needed, but when
needed they are often very useful and workarounds are painful. For example:
Non-portable code like this:
```
struct S {
uint16_t a; // big endian
uint32_t b; // big endian
} __attribute__ ((packed));
```
Can be replaced with portable code like this:
```
struct S {
big_uint16_ut a;
big_uint32_ut b;
};
```
## Design patterns
Applications often traffic in endian data as records or packets containing
multiple endian data elements. For simplicity, we will just call them records.
If desired endianness differs from native endianness, a conversion has to be
performed. When should that conversion occur? Three design patterns have
evolved.
### Convert only as needed (i.e. lazy)
This pattern defers conversion to the point in the code where the data
element is actually used.
This pattern is appropriate when which endian element is actually used varies
greatly according to record content or other circumstances
[#choosing_anticipating_need]
### Convert in anticipation of need
This pattern performs conversion to native endianness in anticipation of use,
such as immediately after reading records. If needed, conversion to the output
endianness is performed after all possible needs have passed, such as just
before writing records.
One implementation of this pattern is to create a proxy record with endianness
converted to native in a read function, and expose only that proxy to the rest
of the implementation. If a write function, if needed, handles the conversion
from native to the desired output endianness.
This pattern is appropriate when all endian elements in a record are typically
used regardless of record content or other circumstances.
### Convert only as needed, except locally in anticipation of need
This pattern in general defers conversion but for specific local needs does
anticipatory conversion. Although particularly appropriate when coupled with the
endian buffer or arithmetic types, it also works well with the conversion
functions.
Example:
[subs=+quotes]
```
struct data_t
{
big_int32_t v1;
big_int32_t v2;
big_int32_t v3;
};
data_t data;
read(data);
...
++v1;
...
int32_t v3_temp = data.v3; // hoist conversion out of loop
for (int32_t i = 0; i < `large-number`; ++i)
{
... `lengthy computation that accesses v3_temp` ...
}
data.v3 = v3_temp;
write(data);
```
In general the above pseudo-code leaves conversion up to the endian arithmetic
type `big_int32_t`. But to avoid conversion inside the loop, a temporary is
created before the loop is entered, and then used to set the new value of
`data.v3` after the loop is complete.
Question: Won't the compiler's optimizer hoist the conversion out of the loop
anyhow?
Answer: V{cpp} 2015 Preview, and probably others, does not, even for a toy test
program. Although the savings is small (two register `bswap` instructions), the
cost might be significant if the loop is repeated enough times. On the other
hand, the program may be so dominated by I/O time that even a lengthy loop will
be immaterial.
## Use case examples
### Porting endian unaware codebase
An existing codebase runs on big endian systems. It does not currently deal
with endianness. The codebase needs to be modified so it can run on little
endian systems under various operating systems. To ease transition and protect
value of existing files, external data will continue to be maintained as big
endian.
The <<arithmetic,endian arithmetic approach>> is recommended to meet these
needs. A relatively small number of header files dealing with binary I/O layouts
need to change types. For example, `short` or `int16_t` would change to
`big_int16_t`. No changes are required for `.cpp` files.
### Porting endian aware codebase
An existing codebase runs on little-endian Linux systems. It already deals with
endianness via
http://man7.org/linux/man-pages/man3/endian.3.html[Linux provided functions].
Because of a business merger, the codebase has to be quickly modified for
Windows and possibly other operating systems, while still supporting Linux. The
codebase is reliable and the programmers are all well-aware of endian issues.
These factors all argue for an <<conversion, endian conversion approach>> that
just mechanically changes the calls to `htobe32`, etc. to
`boost::endian::native_to_big`, etc. and replaces `<endian.h>` with
`<boost/endian/conversion.hpp>`.
### Reliability and arithmetic-speed
A new, complex, multi-threaded application is to be developed that must run
on little endian machines, but do big endian network I/O. The developers believe
computational speed for endian variable is critical but have seen numerous bugs
result from inability to reason about endian conversion state. They are also
worried that future maintenance changes could inadvertently introduce a lot of
slow conversions if full-blown endian arithmetic types are used.
The <<buffers,endian buffers>> approach is made-to-order for this use case.
### Reliability and ease-of-use
A new, complex, multi-threaded application is to be developed that must run on
little endian machines, but do big endian network I/O. The developers believe
computational speed for endian variables is *not critical* but have seen
numerous bugs result from inability to reason about endian conversion state.
They are also concerned about ease-of-use both during development and long-term
maintenance.
Removing concern about conversion speed and adding concern about ease-of-use
tips the balance strongly in favor the
<<arithmetic,endian arithmetic approach>>.

View File

@@ -0,0 +1,589 @@
////
Copyright 2011-2016 Beman Dawes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
////
[#conversion]
# Endian Conversion Functions
:idprefix: conversion_
## Introduction
Header `boost/endian/conversion.hpp` provides byte order reversal and conversion
functions that convert objects of the built-in integer types between native,
big, or little endian byte ordering. User defined types are also supported.
## Reference
Functions are implemented `inline` if appropriate. For {cpp}03 compilers,
`noexcept` is elided. Boost scoped enum emulation is used so that the library
still works for compilers that do not support scoped enums.
### Definitions
*Endianness* refers to the ordering of bytes within internal or external
integers and other arithmetic data. Most-significant byte first is called
*big endian* ordering. Least-significant byte first is called
*little endian* ordering. Other orderings are possible and some CPU
architectures support both big and little ordering.
NOTE: The names are derived from
http://en.wikipedia.org/wiki/Jonathan_Swift[Jonathan Swift]'s satirical novel
_http://en.wikipedia.org/wiki/Gulliver's_Travels[Gulliver's Travels]_, where
rival kingdoms opened their soft-boiled eggs at different ends. Wikipedia has an
extensive description of https://en.wikipedia.org/wiki/Endianness[Endianness].
The standard integral types ({cpp}std [basic.fundamental]) except `bool` and
the scoped enumeration types ({cpp}std [dcl.enum]) are collectively called the
*endian types*. In the absence of padding bits, which is true on the platforms
supported by the Boost.Endian library, endian types have the property that all
of their bit patterns are valid values, which means that when an object of an
endian type has its constituent bytes reversed, the result is another valid value.
This allows `endian_reverse` to take and return by value.
Other built-in types, such as `bool`, `float`, or unscoped enumerations, do not
have the same property, which means that reversing their constituent bytes may
produce an invalid value, leading to undefined behavior. These types are therefore
disallowed in `endian_reverse`, but are still allowed in `endian_reverse_inplace`.
Even if an object becomes invalid as a result of reversing its bytes, as long as
its value is never read, there would be no undefined behavior.
### Header `<boost/endian/conversion.hpp>` Synopsis
[subs=+quotes]
```
#define BOOST_ENDIAN_INTRINSIC_MSG \
"`message describing presence or absence of intrinsics`"
namespace boost
{
namespace endian
{
enum class order
{
native = `see below`,
big = `see below`,
little = `see below`,
};
// Byte reversal functions
template <class Endian>
Endian endian_reverse(Endian x) noexcept;
template <class EndianReversible>
EndianReversible big_to_native(EndianReversible x) noexcept;
template <class EndianReversible>
EndianReversible native_to_big(EndianReversible x) noexcept;
template <class EndianReversible>
EndianReversible little_to_native(EndianReversible x) noexcept;
template <class EndianReversible>
EndianReversible native_to_little(EndianReversible x) noexcept;
template <order O1, order O2, class EndianReversible>
EndianReversible conditional_reverse(EndianReversible x) noexcept;
template <class EndianReversible>
EndianReversible conditional_reverse(EndianReversible x,
order order1, order order2) noexcept;
// In-place byte reversal functions
template <class EndianReversible>
void endian_reverse_inplace(EndianReversible& x) noexcept;
template<class EndianReversibleInplace, std::size_t N>
void endian_reverse_inplace(EndianReversibleInplace (&x)[N]) noexcept;
template <class EndianReversibleInplace>
void big_to_native_inplace(EndianReversibleInplace& x) noexcept;
template <class EndianReversibleInplace>
void native_to_big_inplace(EndianReversibleInplace& x) noexcept;
template <class EndianReversibleInplace>
void little_to_native_inplace(EndianReversibleInplace& x) noexcept;
template <class EndianReversibleInplace>
void native_to_little_inplace(EndianReversibleInplace& x) noexcept;
template <order O1, order O2, class EndianReversibleInplace>
void conditional_reverse_inplace(EndianReversibleInplace& x) noexcept;
template <class EndianReversibleInplace>
void conditional_reverse_inplace(EndianReversibleInplace& x,
order order1, order order2) noexcept;
// Generic load and store functions
template<class T, std::size_t N, order Order>
T endian_load( unsigned char const * p ) noexcept;
template<class T, std::size_t N, order Order>
void endian_store( unsigned char * p, T const & v ) noexcept;
// Convenience load functions
boost::int16_t load_little_s16( unsigned char const * p ) noexcept;
boost::uint16_t load_little_u16( unsigned char const * p ) noexcept;
boost::int16_t load_big_s16( unsigned char const * p ) noexcept;
boost::uint16_t load_big_u16( unsigned char const * p ) noexcept;
boost::int32_t load_little_s24( unsigned char const * p ) noexcept;
boost::uint32_t load_little_u24( unsigned char const * p ) noexcept;
boost::int32_t load_big_s24( unsigned char const * p ) noexcept;
boost::uint32_t load_big_u24( unsigned char const * p ) noexcept;
boost::int32_t load_little_s32( unsigned char const * p ) noexcept;
boost::uint32_t load_little_u32( unsigned char const * p ) noexcept;
boost::int32_t load_big_s32( unsigned char const * p ) noexcept;
boost::uint32_t load_big_u32( unsigned char const * p ) noexcept;
boost::int64_t load_little_s40( unsigned char const * p ) noexcept;
boost::uint64_t load_little_u40( unsigned char const * p ) noexcept;
boost::int64_t load_big_s40( unsigned char const * p ) noexcept;
boost::uint64_t load_big_u40( unsigned char const * p ) noexcept;
boost::int64_t load_little_s48( unsigned char const * p ) noexcept;
boost::uint64_t load_little_u48( unsigned char const * p ) noexcept;
boost::int64_t load_big_s48( unsigned char const * p ) noexcept;
boost::uint64_t load_big_u48( unsigned char const * p ) noexcept;
boost::int64_t load_little_s56( unsigned char const * p ) noexcept;
boost::uint64_t load_little_u56( unsigned char const * p ) noexcept;
boost::int64_t load_big_s56( unsigned char const * p ) noexcept;
boost::uint64_t load_big_u56( unsigned char const * p ) noexcept;
boost::int64_t load_little_s64( unsigned char const * p ) noexcept;
boost::uint64_t load_little_u64( unsigned char const * p ) noexcept;
boost::int64_t load_big_s64( unsigned char const * p ) noexcept;
boost::uint64_t load_big_u64( unsigned char const * p ) noexcept;
// Convenience store functions
void store_little_s16( unsigned char * p, boost::int16_t v ) noexcept;
void store_little_u16( unsigned char * p, boost::uint16_t v ) noexcept;
void store_big_s16( unsigned char * p, boost::int16_t v ) noexcept;
void store_big_u16( unsigned char * p, boost::uint16_t v ) noexcept;
void store_little_s24( unsigned char * p, boost::int32_t v ) noexcept;
void store_little_u24( unsigned char * p, boost::uint32_t v ) noexcept;
void store_big_s24( unsigned char * p, boost::int32_t v ) noexcept;
void store_big_u24( unsigned char * p, boost::uint32_t v ) noexcept;
void store_little_s32( unsigned char * p, boost::int32_t v ) noexcept;
void store_little_u32( unsigned char * p, boost::uint32_t v ) noexcept;
void store_big_s32( unsigned char * p, boost::int32_t v ) noexcept;
void store_big_u32( unsigned char * p, boost::uint32_t v ) noexcept;
void store_little_s40( unsigned char * p, boost::int64_t v ) noexcept;
void store_little_u40( unsigned char * p, boost::uint64_t v ) noexcept;
void store_big_s40( unsigned char * p, boost::int64_t v ) noexcept;
void store_big_u40( unsigned char * p, boost::uint64_t v ) noexcept;
void store_little_s48( unsigned char * p, boost::int64_t v ) noexcept;
void store_little_u48( unsigned char * p, boost::uint64_t v ) noexcept;
void store_big_s48( unsigned char * p, boost::int64_t v ) noexcept;
void store_big_u48( unsigned char * p, boost::uint64_t v ) noexcept;
void store_little_s56( unsigned char * p, boost::int64_t v ) noexcept;
void store_little_u56( unsigned char * p, boost::uint64_t v ) noexcept;
void store_big_s56( unsigned char * p, boost::int64_t v ) noexcept;
void store_big_u56( unsigned char * p, boost::uint64_t v ) noexcept;
void store_little_s64( unsigned char * p, boost::int64_t v ) noexcept;
void store_little_u64( unsigned char * p, boost::uint64_t v ) noexcept;
void store_big_s64( unsigned char * p, boost::int64_t v ) noexcept;
void store_big_u64( unsigned char * p, boost::uint64_t v ) noexcept;
} // namespace endian
} // namespace boost
```
The values of `order::little` and `order::big` shall not be equal to one
another.
The value of `order::native` shall be:
* equal to `order::big` if the execution environment is big endian, otherwise
* equal to `order::little` if the execution environment is little endian,
otherwise
* unequal to both `order::little` and `order::big`.
### Requirements
#### Template argument requirements
The template definitions in the `boost/endian/conversion.hpp` header refer to
various named requirements whose details are set out in the tables in this
subsection. In these tables, `T` is an object or reference type to be supplied
by a {cpp} program instantiating a template; `x` is a value of type (possibly
`const`) `T`; `mlx` is a modifiable lvalue of type `T`.
[#conversion_endianreversible]
##### EndianReversible requirements (in addition to `CopyConstructible`)
[%header,cols=3*]
|===
|Expression |Return |Requirements
|`endian_reverse(x)` |`T`
a|`T` is an endian type or a class type.
If `T` is an endian type, returns the value of `x` with the order of bytes
reversed.
If `T` is a class type, the function:
* Is expected to be implemented by the user, as a non-member function in the same
namespace as `T` that can be found by argument dependent lookup (ADL);
* Should return the value of `x` with the order of bytes reversed for all data members
of types or arrays of types that meet the `EndianReversible` requirements.
|===
[#conversion_endianreversibleinplace]
##### EndianReversibleInplace requirements
[%header,cols=2*]
|===
|Expression |Requirements
|`endian_reverse_inplace(mlx)`
a|`T` is an integral type, an enumeration type, `float`, `double`, a class type,
or an array type.
If `T` is not a class type or an array type, reverses the order of bytes in `mlx`.
If `T` is a class type, the function:
* Is expected to be implemented by the user, as a non-member function in the same
namespace as `T` that can be found by argument dependent lookup (ADL);
* Should reverse the order of bytes of all data members of `mlx` that have types or
arrays of types that meet the `EndianReversible` or `EndianReversibleInplace`
requirements.
If `T` is an array type, calls `endian_reverse_inplace` on each element.
|===
NOTE: Because there is a function template for `endian_reverse_inplace` that
calls `endian_reverse` for class types, only `endian_reverse` is required for a
user-defined type to meet the `EndianReversibleInplace` requirements. Although
user-defined types are not required to supply an `endian_reverse_inplace` function,
doing so may improve efficiency.
#### Customization points for user-defined types (UDTs)
This subsection describes requirements on the Endian library's implementation.
The library's function templates requiring
`<<conversion_endianreversible,EndianReversible>>` are required to perform
reversal of endianness if needed by making an unqualified call to
`endian_reverse()`.
The library's function templates requiring
`<<conversion_endianreversibleinplace,EndianReversibleInplace>>` are required to
perform reversal of endianness if needed by making an unqualified call to
`endian_reverse_inplace()`.
See `example/udt_conversion_example.cpp` for an example user-defined type.
### Byte Reversal Functions
```
template <class Endian>
Endian endian_reverse(Endian x) noexcept;
```
[none]
* {blank}
+
Requires:: `Endian` must be a standard integral type that is not `bool`,
or a scoped enumeration type.
Returns:: `x`, with the order of its constituent bytes reversed.
```
template <class EndianReversible>
EndianReversible big_to_native(EndianReversible x) noexcept;
```
[none]
* {blank}
+
Returns:: `conditional_reverse<order::big, order::native>(x)`.
```
template <class EndianReversible>
EndianReversible native_to_big(EndianReversible x) noexcept;
```
[none]
* {blank}
+
Returns:: `conditional_reverse<order::native, order::big>(x)`.
```
template <class EndianReversible>
EndianReversible little_to_native(EndianReversible x) noexcept;
```
[none]
* {blank}
+
Returns:: `conditional_reverse<order::little, order::native>(x)`.
```
template <class EndianReversible>
EndianReversible native_to_little(EndianReversible x) noexcept;
```
[none]
* {blank}
+
Returns:: `conditional_reverse<order::native, order::little>(x)`.
```
template <order O1, order O2, class EndianReversible>
EndianReversible conditional_reverse(EndianReversible x) noexcept;
```
[none]
* {blank}
+
Returns:: `x` if `O1 == O2,` otherwise `endian_reverse(x)`.
Remarks:: Whether `x` or `endian_reverse(x)` is to be returned shall be
determined at compile time.
```
template <class EndianReversible>
EndianReversible conditional_reverse(EndianReversible x,
order order1, order order2) noexcept;
```
[none]
* {blank}
+
Returns::
`order1 == order2? x: endian_reverse(x)`.
### In-place Byte Reversal Functions
```
template <class EndianReversible>
void endian_reverse_inplace(EndianReversible& x) noexcept;
```
[none]
* {blank}
+
Effects:: When `EndianReversible` is a class type,
`x = endian_reverse(x);`. When `EndianReversible` is an integral
type, an enumeration type, `float`, or `double`, reverses the
order of the constituent bytes of `x`. Otherwise, the program is
ill-formed.
```
template<class EndianReversibleInplace, std::size_t N>
void endian_reverse_inplace(EndianReversibleInplace (&x)[N]) noexcept;
```
[none]
* {blank}
+
Effects:: Calls `endian_reverse_inplace(x[i])` for `i` from `0` to `N-1`.
```
template <class EndianReversibleInplace>
void big_to_native_inplace(EndianReversibleInplace& x) noexcept;
```
[none]
* {blank}
+
Effects:: `conditional_reverse_inplace<order::big, order::native>(x)`.
```
template <class EndianReversibleInplace>
void native_to_big_inplace(EndianReversibleInplace& x) noexcept;
```
[none]
* {blank}
+
Effects:: `conditional_reverse_inplace<order::native, order::big>(x)`.
```
template <class EndianReversibleInplace>
void little_to_native_inplace(EndianReversibleInplace& x) noexcept;
```
[none]
* {blank}
+
Effects:: `conditional_reverse_inplace<order::little, order::native>(x)`.
```
template <class EndianReversibleInplace>
void native_to_little_inplace(EndianReversibleInplace& x) noexcept;
```
[none]
* {blank}
+
Effects:: `conditional_reverse_inplace<order::native, order::little>(x)`.
```
template <order O1, order O2, class EndianReversibleInplace>
void conditional_reverse_inplace(EndianReversibleInplace& x) noexcept;
```
[none]
* {blank}
+
Effects:: None if `O1 == O2,` otherwise `endian_reverse_inplace(x)`.
Remarks:: Which effect applies shall be determined at compile time.
```
template <class EndianReversibleInplace>
void conditional_reverse_inplace(EndianReversibleInplace& x,
order order1, order order2) noexcept;
```
[none]
* {blank}
+
Effects::
If `order1 == order2` then `endian_reverse_inplace(x)`.
### Generic Load and Store Functions
```
template<class T, std::size_t N, order Order>
T endian_load( unsigned char const * p ) noexcept;
```
[none]
* {blank}
+
Requires:: `sizeof(T)` must be 1, 2, 4, or 8. `N` must be between 1 and
`sizeof(T)`, inclusive. `T` must be trivially copyable. If `N` is not
equal to `sizeof(T)`, `T` must be integral or `enum`.
Effects:: Reads `N` bytes starting from `p`, in forward or reverse order
depending on whether `Order` matches the native endianness or not,
interprets the resulting bit pattern as a value of type `T`, and returns it.
If `sizeof(T)` is bigger than `N`, zero-extends when `T` is unsigned,
sign-extends otherwise.
```
template<class T, std::size_t N, order Order>
void endian_store( unsigned char * p, T const & v ) noexcept;
```
[none]
* {blank}
+
Requires:: `sizeof(T)` must be 1, 2, 4, or 8. `N` must be between 1 and
`sizeof(T)`, inclusive. `T` must be trivially copyable. If `N` is not
equal to `sizeof(T)`, `T` must be integral or `enum`.
Effects:: Writes to `p` the `N` least significant bytes from the object
representation of `v`, in forward or reverse order depending on whether
`Order` matches the native endianness or not.
### Convenience Load Functions
```
inline boost::intM_t load_little_sN( unsigned char const * p ) noexcept;
```
[none]
* {blank}
+
Reads an N-bit signed little-endian integer from `p`.
+
Returns:: `endian_load<boost::intM_t, N/8, order::little>( p )`.
```
inline boost::uintM_t load_little_uN( unsigned char const * p ) noexcept;
```
[none]
* {blank}
+
Reads an N-bit unsigned little-endian integer from `p`.
+
Returns:: `endian_load<boost::uintM_t, N/8, order::little>( p )`.
```
inline boost::intM_t load_big_sN( unsigned char const * p ) noexcept;
```
[none]
* {blank}
+
Reads an N-bit signed big-endian integer from `p`.
+
Returns:: `endian_load<boost::intM_t, N/8, order::big>( p )`.
```
inline boost::uintM_t load_big_uN( unsigned char const * p ) noexcept;
```
[none]
* {blank}
+
Reads an N-bit unsigned big-endian integer from `p`.
+
Returns::
`endian_load<boost::uintM_t, N/8, order::big>( p )`.
### Convenience Store Functions
```
inline void store_little_sN( unsigned char * p, boost::intM_t v ) noexcept;
```
[none]
* {blank}
+
Writes an N-bit signed little-endian integer to `p`.
+
Effects:: `endian_store<boost::intM_t, N/8, order::little>( p, v )`.
```
inline void store_little_uN( unsigned char * p, boost::uintM_t v ) noexcept;
```
[none]
* {blank}
+
Writes an N-bit unsigned little-endian integer to `p`.
+
Effects:: `endian_store<boost::uintM_t, N/8, order::little>( p, v )`.
```
inline void store_big_sN( unsigned char * p, boost::intM_t v ) noexcept;
```
[none]
* {blank}
+
Writes an N-bit signed big-endian integer to `p`.
+
Effects:: `endian_store<boost::intM_t, N/8, order::big>( p, v )`.
```
inline void store_big_uN( unsigned char * p, boost::uintM_t v ) noexcept;
```
[none]
* {blank}
+
Writes an N-bit unsigned big-endian integer to `p`.
+
Effects::
`endian_store<boost::uintM_t, N/8, order::big>( p, v )`.
## FAQ
See the <<overview_faq,Overview FAQ>> for a library-wide FAQ.
Why are both value returning and modify-in-place functions provided?::
Returning the result by value is the standard C and {cpp} idiom for functions
that compute a value from an argument. Modify-in-place functions allow cleaner
code in many real-world endian use cases and are more efficient for user-defined
types that have members such as string data that do not need to be reversed.
Thus both forms are provided.
Why not use the Linux names (htobe16, htole16, be16toh, le16toh, etc.) ?::
Those names are non-standard and vary even between POSIX-like operating
systems. A {cpp} library TS was going to use those names, but found they were
sometimes implemented as macros. Since macros do not respect scoping and
namespace rules, to use them would be very error prone.
## Acknowledgements
Tomas Puverle was instrumental in identifying and articulating the need to
support endian conversion as separate from endian integer types. Phil Endecott
suggested the form of the value returning signatures. Vicente Botet and other
reviewers suggested supporting user defined types. General reverse template
implementation approach using `std::reverse` suggested by Mathias Gaunard.
Portable implementation approach for 16, 32, and 64-bit integers suggested by
tymofey, with avoidance of undefined behavior as suggested by Giovanni Piero
Deretta, and a further refinement suggested by Pyry Jahkola. Intrinsic builtins
implementation approach for 16, 32, and 64-bit integers suggested by several
reviewers, and by David Stone, who provided his Boost licensed macro
implementation that became the starting point for
`boost/endian/detail/intrinsic.hpp`. Pierre Talbot provided the
`int8_t endian_reverse()` and templated `endian_reverse_inplace()`
implementations.

View File

@@ -0,0 +1,167 @@
////
Copyright 2011-2016 Beman Dawes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
////
[#appendix_history]
[appendix]
# History and Acknowledgments
:idprefix: apph_
## History
### Changes requested by formal review
The library was reworked from top to bottom to accommodate changes requested
during the formal review. The issues that were required to be resolved before
a mini-review are shown in *bold* below, with the resolution indicated.
Common use case scenarios should be developed.::
Done. The documentation have been refactored. A page is now devoted to
<<choosing,Choosing the Approach>> to endianness. See
<<choosing_use_cases,Use cases>> for use case scenarios.
Example programs should be developed for the common use case scenarios.::
Done. See <<choosing,Choosing the Approach>>. Example code has been added
throughout.
Documentation should illuminate the differences between endian integer/float type and endian conversion approaches to the common use case scenarios, and provide guidelines for choosing the most appropriate approach in user's applications.::
Done. See <<choosing,Choosing the Approach>>.
Conversion functions supplying results via return should be provided.::
Done. See <<conversion,Conversion Functions>>.
Platform specific performance enhancements such as use of compiler intrinsics or relaxed alignment requirements should be supported.::
Done. Compiler (Clang, GCC, Visual{cpp}, etc.) intrinsics and built-in
functions are used in the implementation where appropriate, as requested. See
<<overview_intrinsic,Built-in support for Intrinsics>>. See
<<overview_timings,Timings for Example 2>> to gauge the impact of intrinsics.
Endian integer (and floating) types should be implemented via the conversion functions. If that can't be done efficiently, consideration should be given to expanding the conversion function signatures to resolve the inefficiencies.::
Done. For the endian types, the implementation uses the endian conversion
functions, and thus the intrinsics, as requested.
Benchmarks that measure performance should be provided. It should be possible to compare platform specific performance enhancements against portable base implementations, and to compare endian integer approaches against endian conversion approaches for the common use case scenarios.::
Done. See <<overview_timings,Timings for Example 2>>. The `endian/test`
directory also contains several additional benchmark and speed test programs.
Float (32-bits) and double (64-bits) should be supported. IEEE 754 is the primary use case.::
Done. The <<buffers,endian buffer types>>,
<<arithmetic,endian arithmetic types>> and
<<conversion,endian conversion functions>> now support 32-bit `(float)`
and 64-bit `(double)` floating point, as requested.
NOTE: This answer is outdated. The support for `float` and `double` was subsequently found
problematic and has been removed. Recently, support for `float` and `double` has
been reinstated for `endian_buffer` and `endian_arithmetic`, but not for the
conversion functions.
Support for user defined types (UDTs) is desirable, and should be provided where there would be no conflict with the other concerns.::
Done. See <<conversion_customization,Customization points for user-defined
types (UDTs)>>.
There is some concern that endian integer/float arithmetic operations might used inadvertently or inappropriately. The impact of adding an endian_buffer class without arithmetic operations should be investigated.::
Done. The endian types have been decomposed into class template
`<<buffers,endian_buffer>>` and class template
`<<arithmetic,endian_arithmetic>>`. Class `endian_buffer` is a public base
class for `endian_arithmetic`, and can also be used by users as a stand-alone
class.
Stream insertion and extraction of the endian integer/float types should be documented and included in the test coverage.::
Done. See <<buffers_stream_inserter,Stream inserter>> and
<<buffers_stream_extractor,Stream extractor>>.
Binary I/O support that was investigated during development of the Endian library should be put up for mini-review for inclusion in the Boost I/O library.::
Not done yet. Will be handled as a separate min-review soon after the Endian
mini-review.
Other requested changes.::
* In addition to the named-endianness conversion functions, functions that
perform compile-time (via template) and run-time (via function argument)
dispatch are now provided.
* `order::native` is now a synonym for `order::big` or `order::little` according
to the endianness of the platform. This reduces the number of template
specializations required.
* Headers have been reorganized to make them easier to read, with a synopsis
at the front and implementation following.
### Other changes since formal review
* Header `boost/endian/endian.hpp` has been renamed to
`boost/endian/arithmetic.hpp`. Headers
`boost/endian/conversion.hpp` and `boost/endian/buffers.hpp` have been added.
Infrastructure file names were changed accordingly.
* The endian arithmetic type aliases have been renamed, using a naming pattern
that is consistent for both integer and floating point, and a consistent set of
aliases supplied for the endian buffer types.
* The unaligned-type alias names still have the `_t` suffix, but the
aligned-type alias names now have an `_at` suffix.
* `endian_reverse()` overloads for `int8_t` and `uint8_t` have been added for
improved generality. (Pierre Talbot)
* Overloads of `endian_reverse_inplace()` have been replaced with a single
`endian_reverse_inplace()` template. (Pierre Talbot)
* For X86 and X64 architectures, which permit unaligned loads and stores,
unaligned little endian buffer and arithmetic types use regular loads and
stores when the size is exact. This makes unaligned little endian buffer and
arithmetic types significantly more efficient on these architectures. (Jeremy
Maitin-Shepard)
* {cpp}11 features affecting interfaces, such as `noexcept`, are now used.
{cpp}03 compilers are still supported.
* Acknowledgements have been updated.
## Compatibility with interim releases
Prior to the official Boost release, class template `endian_arithmetic` has been
used for a decade or more with the same functionality but under the name
`endian`. Other names also changed in the official release. If the macro
`BOOST_ENDIAN_DEPRECATED_NAMES` is defined, those old now deprecated names are
still supported. However, the class template `endian` name is only provided for
compilers supporting {cpp}11 template aliases. For {cpp}03 compilers, the name
will have to be changed to `endian_arithmetic`.
To support backward header compatibility, deprecated header
`boost/endian/endian.hpp` forwards to `boost/endian/arithmetic.hpp`. It requires
`BOOST_ENDIAN_DEPRECATED_NAMES` be defined. It should only be used while
transitioning to the official Boost release of the library as it will be removed
in some future release.
## Future directions
Standardization.::
The plan is to submit Boost.Endian to the {cpp} standards committee for possible
inclusion in a Technical Specification or the {cpp} standard itself.
Specializations for `numeric_limits`.::
Roger Leigh requested that all `boost::endian` types provide `numeric_limits`
specializations.
See https://github.com/boostorg/endian/issues/4[GitHub issue 4].
Character buffer support.::
Peter Dimov pointed out during the mini-review that getting and setting basic
arithmetic types (or `<cstdint>` equivalents) from/to an offset into an array of
unsigned char is a common need. See
http://lists.boost.org/Archives/boost/2015/01/219574.php[Boost.Endian
mini-review posting].
Out-of-range detection.::
Peter Dimov pointed suggested during the mini-review that throwing an exception
on buffer values being out-of-range might be desirable. See the end of
http://lists.boost.org/Archives/boost/2015/01/219659.php[this posting] and
subsequent replies.
## Acknowledgements
Comments and suggestions were received from Adder, Benaka Moorthi, Christopher
Kohlhoff, Cliff Green, Daniel James, Dave Handley, Gennaro Proto, Giovanni Piero
Deretta, Gordon Woodhull, dizzy, Hartmut Kaiser, Howard Hinnant, Jason Newton,
Jeff Flinn, Jeremy Maitin-Shepard, John Filo, John Maddock, Kim Barrett, Marsh
Ray, Martin Bonner, Mathias Gaunard, Matias Capeletto, Neil Mayhew, Nevin Liber,
Olaf van der Spek, Paul Bristow, Peter Dimov, Pierre Talbot, Phil Endecott,
Philip Bennefall, Pyry Jahkola, Rene Rivera, Robert Stewart, Roger Leigh, Roland
Schwarz, Scott McMurray, Sebastian Redl, Tim Blechmann, Tim Moore, tymofey,
Tomas Puverle, Vincente Botet, Yuval Ronen and Vitaly Budovsk. Apologies if
anyone has been missed.
The documentation was converted into Asciidoc format by Glen Fernandes.

View File

@@ -0,0 +1,366 @@
////
Copyright 2011-2016 Beman Dawes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
////
[#overview]
# Overview
:idprefix: overview_
## Abstract
Boost.Endian provides facilities to manipulate the
<<overview_endianness,endianness>> of integers and user-defined types.
* Three approaches to endianness are supported. Each has a long history of
successful use, and each approach has use cases where it is preferred over the
other approaches.
* Primary uses:
** Data portability. The Endian library supports binary data exchange, via
either external media or network transmission, regardless of platform
endianness.
** Program portability. POSIX-based and Windows-based operating systems
traditionally supply libraries with non-portable functions to perform endian
conversion. There are at least four incompatible sets of functions in common
use. The Endian library is portable across all {cpp} platforms.
* Secondary use: Minimizing data size via sizes and/or alignments not supported
by the standard {cpp} integer types.
[#overview_endianness]
## Introduction to endianness
Consider the following code:
```
int16_t i = 0x0102;
FILE * file = fopen("test.bin", "wb"); // binary file!
fwrite(&i, sizeof(int16_t), 1, file);
fclose(file);
```
On OS X, Linux, or Windows systems with an Intel CPU, a hex dump of the
"test.bin" output file produces:
```
0201
```
On OS X systems with a PowerPC CPU, or Solaris systems with a SPARC CPU, a hex
dump of the "test.bin" output file produces:
```
0102
```
What's happening here is that Intel CPUs order the bytes of an integer with the
least-significant byte first, while SPARC CPUs place the most-significant byte
first. Some CPUs, such as the PowerPC, allow the operating system to choose
which ordering applies.
Most-significant-byte-first ordering is traditionally called "big endian"
ordering and least-significant-byte-first is traditionally called
"little-endian" ordering. The names are derived from
http://en.wikipedia.org/wiki/Jonathan_Swift[Jonathan Swift]'s satirical novel
_http://en.wikipedia.org/wiki/Gulliver's_Travels[Gulliver's Travels]_, where
rival kingdoms opened their soft-boiled eggs at different ends.
See Wikipedia's http://en.wikipedia.org/wiki/Endianness[Endianness] article for
an extensive discussion of endianness.
Programmers can usually ignore endianness, except when reading a core dump on
little-endian systems. But programmers have to deal with endianness when
exchanging binary integers and binary floating point values between computer
systems with differing endianness, whether by physical file transfer or over a
network. And programmers may also want to use the library when minimizing either
internal or external data sizes is advantageous.
[#overview_introduction]
## Introduction to the Boost.Endian library
Boost.Endian provides three different approaches to dealing with endianness. All
three approaches support integers and user-define types (UDTs).
Each approach has a long history of successful use, and each approach has use
cases where it is preferred to the other approaches. See
<<choosing,Choosing between Conversion Functions, Buffer Types, and Arithmetic Types>>.
<<conversion,Endian conversion functions>>::
The application uses the built-in integer types to hold values, and calls the
provided conversion functions to convert byte ordering as needed. Both mutating
and non-mutating conversions are supplied, and each comes in unconditional and
conditional variants.
<<buffers, Endian buffer types>>::
The application uses the provided endian buffer types to hold values, and
explicitly converts to and from the built-in integer types. Buffer sizes of 8,
16, 24, 32, 40, 48, 56, and 64 bits (i.e. 1, 2, 3, 4, 5, 6, 7, and 8 bytes) are
provided. Unaligned integer buffer types are provided for all sizes, and aligned
buffer types are provided for 16, 32, and 64-bit sizes. The provided specific
types are typedefs for a generic class template that may be used directly for
less common use cases.
<<arithmetic, Endian arithmetic types>>::
The application uses the provided endian arithmetic types, which supply the same
operations as the built-in {cpp} arithmetic types. All conversions are implicit.
Arithmetic sizes of 8, 16, 24, 32, 40, 48, 56, and 64 bits (i.e. 1, 2, 3, 4, 5,
6, 7, and 8 bytes) are provided. Unaligned integer types are provided for all
sizes and aligned arithmetic types are provided for 16, 32, and 64-bit sizes.
The provided specific types are typedefs for a generic class template that may
be used directly in generic code of for less common use cases.
Boost Endian is a header-only library. {cpp}11 features affecting interfaces,
such as `noexcept`, are used only if available. See
<<overview_cpp03_support,{cpp}03 support for {cpp}11 features>> for details.
[#overview_intrinsics]
## Built-in support for Intrinsics
Most compilers, including GCC, Clang, and Visual {cpp}, supply built-in support
for byte swapping intrinsics. The Endian library uses these intrinsics when
available since they may result in smaller and faster generated code,
particularly for optimized builds.
Defining the macro `BOOST_ENDIAN_NO_INTRINSICS` will suppress use of the
intrinsics. This is useful when a compiler has no intrinsic support or fails to
locate the appropriate header, perhaps because it is an older release or has
very limited supporting libraries.
The macro `BOOST_ENDIAN_INTRINSIC_MSG` is defined as either
`"no byte swap intrinsics"` or a string describing the particular set of
intrinsics being used. This is useful for eliminating missing intrinsics as a
source of performance issues.
## Performance
Consider this problem:
### Example 1
Add 100 to a big endian value in a file, then write the result to a file
[%header,cols=2*]
|===
|Endian arithmetic type approach |Endian conversion function approach
a|
----
big_int32_at x;
... read into x from a file ...
x += 100;
... write x to a file ...
----
a|
----
int32_t x;
... read into x from a file ...
big_to_native_inplace(x);
x += 100;
native_to_big_inplace(x);
... write x to a file ...
----
|===
*There will be no performance difference between the two approaches in optimized
builds, regardless of the native endianness of the machine.* That's because
optimizing compilers will generate exactly the same code for each. That
conclusion was confirmed by studying the generated assembly code for GCC and
Visual {cpp}. Furthermore, time spent doing I/O will determine the speed of this
application.
Now consider a slightly different problem:
### Example 2
Add a million values to a big endian value in a file, then write the result to a
file
[%header,cols=2*]
|===
|Endian arithmetic type approach |Endian conversion function approach
a|
----
big_int32_at x;
... read into x from a file ...
for (int32_t i = 0; i < 1000000; ++i)
x += i;
... write x to a file ...
----
a|
----
int32_t x;
... read into x from a file ...
big_to_native_inplace(x);
for (int32_t i = 0; i < 1000000; ++i)
x += i;
native_to_big_inplace(x);
... write x to a file ...
----
|===
With the Endian arithmetic approach, on little endian platforms an implicit
conversion from and then back to big endian is done inside the loop. With the
Endian conversion function approach, the user has ensured the conversions are
done outside the loop, so the code may run more quickly on little endian
platforms.
### Timings
These tests were run against release builds on a circa 2012 4-core little endian
X64 Intel Core i5-3570K CPU @ 3.40GHz under Windows 7.
CAUTION: The Windows CPU timer has very high granularity. Repeated runs of the
same tests often yield considerably different results.
See `test/loop_time_test.cpp` for the actual code and `benchmark/Jamfile.v2` for
the build setup.
#### GNU C++ version 4.8.2 on Linux virtual machine
Iterations: 10'000'000'000, Intrinsics: `__builtin_bswap16`, etc.
[%header,cols=3*]
|===
|Test Case |Endian arithmetic type |Endian conversion function
|16-bit aligned big endian |8.46 s |5.28 s
|16-bit aligned little endian |5.28 s |5.22 s
|32-bit aligned big endian |8.40 s |2.11 s
|32-bit aligned little endian |2.11 s |2.10 s
|64-bit aligned big endian |14.02 s |3.10 s
|64-bit aligned little endian |3.00 s |3.03 s
|===
#### Microsoft Visual C++ version 14.0
Iterations: 10'000'000'000, Intrinsics: `<cstdlib>` `_byteswap_ushort`, etc.
[%header,cols=3*]
|===
|Test Case |Endian arithmetic type |Endian conversion function
|16-bit aligned big endian |8.27 s |5.26 s
|16-bit aligned little endian |5.29 s |5.32 s
|32-bit aligned big endian |8.36 s |5.24 s
|32-bit aligned little endian |5.24 s |5.24 s
|64-bit aligned big endian |13.65 s |3.34 s
|64-bit aligned little endian |3.35 s |2.73 s
|===
[#overview_cpp03_support]
## {cpp}03 support for {cpp}11 features
[%header,cols=2*]
|===
|{cpp}11 Feature
|Action with {cpp}03 Compilers
|Scoped enums
|Uses header
http://www.boost.org/libs/core/doc/html/core/scoped_enum.html[boost/core/scoped_enum.hpp]
to emulate {cpp}11 scoped enums.
|`noexcept`
|Uses `BOOST_NOEXCEPT` macro, which is defined as null for compilers not
supporting this {cpp}11 feature.
|{cpp}11 PODs
(http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2007/n2342.htm[N2342])
|Takes advantage of {cpp}03 compilers that relax {cpp}03 POD rules, but see
Limitations <<buffers_limitations,here>> and <<arithmetic_limitations,here>>.
Also see macros for explicit POD control <<buffers_compilation,here>> and
<<arithmetic_compilation,here>>
|===
[#overview_faq]
## Overall FAQ
Is the implementation header only?::
Yes.
Are {cpp}03 compilers supported?::
Yes.
Does the implementation use compiler intrinsic built-in byte swapping?::
Yes, if available. See <<overview_intrinsics,Intrinsic built-in support>>.
Why bother with endianness?::
Binary data portability is the primary use case.
Does endianness have any uses outside of portable binary file or network I/O formats?::
Using the unaligned integer types with a size tailored to the application's
needs is a minor secondary use that saves internal or external memory space. For
example, using `big_int40_buf_t` or `big_int40_t` in a large array saves a lot
of space compared to one of the 64-bit types.
Why bother with binary I/O? Why not just use {cpp} Standard Library stream inserters and extractors?::
* Data interchange formats often specify binary integer data. Binary integer
data is smaller and therefore I/O is faster and file sizes are smaller. Transfer
between systems is less expensive.
* Furthermore, binary integer data is of fixed size, and so fixed-size disk
records are possible without padding, easing sorting and allowing random access.
* Disadvantages, such as the inability to use text utilities on the resulting
files, limit usefulness to applications where the binary I/O advantages are
paramount.
Which is better, big-endian or little-endian?::
Big-endian tends to be preferred in a networking environment and is a bit more
of an industry standard, but little-endian may be preferred for applications
that run primarily on x86, x86-64, and other little-endian CPU's. The
http://en.wikipedia.org/wiki/Endian[Wikipedia] article gives more pros and cons.
Why are only big and little native endianness supported?::
These are the only endian schemes that have any practical value today. PDP-11
and the other middle endian approaches are interesting curiosities but have no
relevance for today's {cpp} developers. The same is true for architectures that
allow runtime endianness switching. The
<<conversion_native_order_specification,specification for native ordering>> has
been carefully crafted to allow support for such orderings in the future, should
the need arise. Thanks to Howard Hinnant for suggesting this.
Why do both the buffer and arithmetic types exist?::
Conversions in the buffer types are explicit. Conversions in the arithmetic
types are implicit. This fundamental difference is a deliberate design feature
that would be lost if the inheritance hierarchy were collapsed.
The original design provided only arithmetic types. Buffer types were requested
during formal review by those wishing total control over when conversion occurs.
They also felt that buffer types would be less likely to be misused by
maintenance programmers not familiar with the implications of performing a lot
of integer operations on the endian arithmetic integer types.
What is gained by using the buffer types rather than always just using the arithmetic types?::
Assurance that hidden conversions are not performed. This is of overriding
importance to users concerned about achieving the ultimate in terms of speed.
"Always just using the arithmetic types" is fine for other users. When the
ultimate in speed needs to be ensured, the arithmetic types can be used in the
same design patterns or idioms that would be used for buffer types, resulting in
the same code being generated for either types.
What are the limitations of integer support?::
Tests have only been performed on machines that use two's complement
arithmetic. The Endian conversion functions only support 8, 16, 32, and 64-bit
aligned integers. The endian types only support 8, 16, 24, 32, 40, 48, 56, and
64-bit unaligned integers, and 8, 16, 32, and 64-bit aligned integers.
Is there floating point support?::
An attempt was made to support four-byte ``float``s and eight-byte
``double``s, limited to
http://en.wikipedia.org/wiki/IEEE_floating_point[IEEE 754] (also known as
ISO/IEC/IEEE 60559) floating point and further limited to systems where floating
point endianness does not differ from integer endianness. Even with those
limitations, support for floating point types was not reliable and was removed.
For example, simply reversing the endianness of a floating point number can
result in a signaling-NAN.
+
Support for `float` and `double` has since been reinstated for `endian_buffer`,
`endian_arithmetic` and the conversion functions that reverse endianness in place.
The conversion functions that take and return by value still do not support floating
point due to the above issues; reversing the bytes of a floating point number
does not necessarily produce another valid floating point number.

View File

@@ -0,0 +1,51 @@
// endian/example/conversion_use_case.cpp
// Copyright Beman Dawes 2014
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// This program reads a binary file of fixed length records, with a format defined
// in a header file supplied by a third-party. The records inserted into a vector,
// and the vector is sorted. The sorted records are then written to an output file.
// Full I/O error testing omitted for brevity, So don't try this at home.
#include "third_party_format.hpp"
#include <boost/endian/conversion.hpp>
#include <vector>
#include <fstream>
#include <algorithm>
#include <iostream>
using third_party::record;
int main()
{
std::ifstream in("data.bin", std::ios::binary);
if (!in) { std::cout << "Could not open data.bin\n"; return 1; }
std::ofstream out("sorted-data.bin", std::ios::binary);
if (!out) { std::cout << "Could not open sorted-data.bin\n"; return 1; }
record rec;
std::vector<record> recs;
while (!in.eof()) // read each record
{
in.read((char*)&rec, sizeof(rec));
rec.balance = boost::endian::big_to_native(rec.balance); // reverse if needed
recs.push_back(rec);
}
std::sort(recs.begin(), recs.end(), // decending sort by balance
[](const record& lhs, const record& rhs) -> bool
{ return lhs.balance > rhs.balance; });
for (auto &out_rec : recs) // write each record
{
out_rec.balance = boost::endian::native_to_big(out_rec.balance); // reverse if needed
out.write((const char*)&out_rec, sizeof(out_rec));
}
}

View File

@@ -0,0 +1,75 @@
// endian_example.cpp -------------------------------------------------------//
// Copyright Beman Dawes, 2006
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/endian
//----------------------------------------------------------------------------//
#include <boost/endian/detail/disable_warnings.hpp>
#include <iostream>
#include <cstdio>
#include <boost/endian/buffers.hpp>
#include <boost/static_assert.hpp>
using namespace boost::endian;
namespace
{
// This is an extract from a very widely used GIS file format. Why the designer
// decided to mix big and little endians in the same file is not known. But
// this is a real-world format and users wishing to write low level code
// manipulating these files have to deal with the mixed endianness.
struct header
{
big_int32_buf_at file_code;
big_int32_buf_at file_length;
little_int32_buf_at version;
little_int32_buf_at shape_type;
};
const char* filename = "test.dat";
}
int main(int, char* [])
{
header h;
BOOST_STATIC_ASSERT(sizeof(h) == 16U); // reality check
h.file_code = 0x01020304;
h.file_length = sizeof(header);
h.version = 1;
h.shape_type = 0x01020304;
// Low-level I/O such as POSIX read/write or <cstdio> fread/fwrite is sometimes
// used for binary file operations when ultimate efficiency is important.
// Such I/O is often performed in some C++ wrapper class, but to drive home the
// point that endian integers are often used in fairly low-level code that
// does bulk I/O operations, <cstdio> fopen/fwrite is used for I/O in this example.
std::FILE* fi = std::fopen(filename, "wb"); // MUST BE BINARY
if (!fi)
{
std::cout << "could not open " << filename << '\n';
return 1;
}
if (std::fwrite(&h, sizeof(header), 1, fi)!= 1)
{
std::cout << "write failure for " << filename << '\n';
return 1;
}
std::fclose(fi);
std::cout << "created file " << filename << '\n';
return 0;
}

View File

@@ -0,0 +1,19 @@
// endian/example/third_party_format.hpp
// Copyright Beman Dawes 2014
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
#include <cstdint>
namespace third_party
{
struct record
{
uint32_t id; // big endian
int32_t balance; // big endian
// ... data members whose endianness is not a concern
};
}

View File

@@ -0,0 +1,79 @@
// udt_conversion_example.cpp --------------------------------------------------------//
// Copyright Beman Dawes 2013
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
//--------------------------------------------------------------------------------------//
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/conversion.hpp>
#include <iostream>
#include <cstring>
using namespace boost::endian;
using std::cout;
using std::endl;
using boost::int32_t;
using boost::int64_t;
namespace user
{
class UDT
{
public:
UDT() : id_(0), value_(0) {desc_[0] = '\0';}
UDT(int32_t id, int64_t value, const char* desc) : id_(id), value_(value)
{
std::strncpy(desc_, desc, sizeof(desc_)-1);
desc_[sizeof(desc_)-1] = '\0';
}
int32_t id() const {return id_;}
int64_t value() const {return value_;}
const char* desc() const {return desc_;}
void id(int32_t x) {id_ = x;}
void value(int64_t v) {value_ = v;}
void desc(const char* s)
{
std::strncpy(desc_, s, sizeof(desc_)-1);
desc_[sizeof(desc_-1)] = '\0';
}
friend void endian_reverse_inplace(UDT&);
private:
int32_t id_;
int64_t value_;
char desc_[56]; // '/0'
};
void endian_reverse_inplace(UDT& x)
{
boost::endian::endian_reverse_inplace(x.id_);
boost::endian::endian_reverse_inplace(x.value_);
}
}
int main(int, char* [])
{
user::UDT x(1, 123456789012345LL, "Bingo!");
//cout << std::hex;
cout << "(1) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
user::endian_reverse_inplace(x);
cout << "(2) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
endian_reverse_inplace(x);
cout << "(3) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
conditional_reverse_inplace<order::little, order::big>(x);
cout << "(4) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
conditional_reverse_inplace(x, order::big, order::little);
cout << "(5) " << x.id() << ' ' << x.value() << ' ' << x.desc() << endl;
}
#include <boost/endian/detail/disable_warnings_pop.hpp>

View File

@@ -0,0 +1,152 @@
// endian/example/uses_cases.cpp -----------------------------------------------------//
// Copyright Beman Dawes 2014
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
//--------------------------------------------------------------------------------------//
#ifndef _SCL_SECURE_NO_WARNINGS
# define _SCL_SECURE_NO_WARNINGS
#endif
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#include <boost/endian/conversion.hpp>
#include <boost/endian/buffers.hpp>
#include <boost/endian/arithmetic.hpp>
#include <iostream>
using namespace boost::endian;
using std::cout;
using std::endl;
{ // Use case 2 - Endian buffer types
struct Record
{
big_ubuf32_t count; // big endian
big_buf32_t value; // big endian
};
Record rec;
read(&rec, sizeof(Record));
uint32_t count = rec.count.value();
int32_t value = rec.value.value();
++count;
value += fee;
rec.count = count;
rec.value = value;
write(&rec, sizeof(Record));
}
{ // Use case 3a - Endian arithmetic types
struct Record
{
big_uint32_t count; // big endian
big_int32_t value; // big endian
};
Record rec;
read(&rec, sizeof(Record));
++rec.count;
rec.value += fee;
write(&rec, sizeof(Record));
}
{ // Use case 3b - Endian arithmetic types
struct Record
{
big_uint32_t count; // big endian
big_int32_t value; // big endian
};
Record rec;
read(&rec, sizeof(Record));
uint32_t count = rec.count;
int32_t value = rec.value;
++count;
value += fee;
rec.count = count;
rec.value = value;
write(&rec, sizeof(Record));
}
// Recommended approach when conversion time is not a concern
//
// Conversion time is not a concert with this application because the minimum
// possible number of conversions is performed and because I/O time will be
// much greater than conversion time.
{
struct Record
{
big_uint32_t count; // big endian
big_int32_t value; // big endian
};
Record rec;
read(&rec, sizeof(Record));
++rec.count;
rec.value += fee;
write(&rec, sizeof(Record));
}
// Recommended approach when conversion time is a concern
//
// Conversion time is a concert with this application because (1) any conversions
// performed in the loop will consume a great deal of time and because (2)
// computation time will be much greater than I/O time.
{
struct Record
{
big_uint32_t count; // big endian
big_int32_t value; // big endian
};
Record rec;
read(&rec, sizeof(Record));
uint32_t count = rec.count;
int32_t value = rec.value;
for (long long i = 0; i < several_gazillion; ++i) // (1)
{
... immensely complex computation using rec variables many times // (2)
}
rec.count = count;
rec.value = value;
write(&rec, sizeof(Record));
}
}

View File

@@ -0,0 +1,13 @@
#ifndef BOOST_ENDIAN_HPP_INCLUDED
#define BOOST_ENDIAN_HPP_INCLUDED
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/conversion.hpp>
#include <boost/endian/buffers.hpp>
#include <boost/endian/arithmetic.hpp>
#endif // #ifndef BOOST_ENDIAN_HPP_INCLUDED

View File

@@ -0,0 +1,370 @@
// boost/endian/arithmetic.hpp -------------------------------------------------------//
// (C) Copyright Darin Adler 2000
// (C) Copyright Beman Dawes 2006, 2009, 2014
// (C) Copyright Peter Dimov 2019
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/endian
//--------------------------------------------------------------------------------------//
// Original design developed by Darin Adler based on classes developed by Mark
// Borgerding. Four original class templates were combined into a single endian
// class template by Beman Dawes, who also added the unrolled_byte_loops sign
// partial specialization to correctly extend the sign when cover integer size
// differs from endian representation size.
// TODO: When a compiler supporting constexpr becomes available, try possible uses.
#ifndef BOOST_ENDIAN_ARITHMETIC_HPP
#define BOOST_ENDIAN_ARITHMETIC_HPP
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable:4365) // conversion ... signed/unsigned mismatch
#endif
#include <boost/endian/buffers.hpp>
#include <boost/core/scoped_enum.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <iosfwd>
#include <climits>
#if defined(BOOST_BORLANDC) || defined(BOOST_CODEGEARC)
# pragma pack(push, 1)
#endif
# if CHAR_BIT != 8
# error Platforms with CHAR_BIT != 8 are not supported
# endif
# ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT {} // C++03
# else
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT = default; // C++0x
# endif
// g++ pre-4.6 does not support unrestricted unions, but we have no Config macro for that
# if (defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || BOOST_WORKAROUND(BOOST_GCC, < 40600)) && defined(BOOST_ENDIAN_FORCE_PODNESS)
# define BOOST_ENDIAN_NO_CTORS
# endif
# ifndef BOOST_ENDIAN_EXPLICIT_CTORS
# define BOOST_ENDIAN_EXPLICIT_OPT
# else
# define BOOST_ENDIAN_EXPLICIT_OPT explicit
# endif
//---------------------------------- synopsis ----------------------------------------//
namespace boost
{
namespace endian
{
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
BOOST_SCOPED_ENUM(align) Align = align::no>
class endian_arithmetic;
// big endian signed integer aligned types
typedef endian_arithmetic<order::big, int8_t, 8, align::yes> big_int8_at;
typedef endian_arithmetic<order::big, int16_t, 16, align::yes> big_int16_at;
typedef endian_arithmetic<order::big, int32_t, 32, align::yes> big_int32_at;
typedef endian_arithmetic<order::big, int64_t, 64, align::yes> big_int64_at;
// big endian unsigned integer aligned types
typedef endian_arithmetic<order::big, uint8_t, 8, align::yes> big_uint8_at;
typedef endian_arithmetic<order::big, uint16_t, 16, align::yes> big_uint16_at;
typedef endian_arithmetic<order::big, uint32_t, 32, align::yes> big_uint32_at;
typedef endian_arithmetic<order::big, uint64_t, 64, align::yes> big_uint64_at;
// little endian signed integer aligned types
typedef endian_arithmetic<order::little, int8_t, 8, align::yes> little_int8_at;
typedef endian_arithmetic<order::little, int16_t, 16, align::yes> little_int16_at;
typedef endian_arithmetic<order::little, int32_t, 32, align::yes> little_int32_at;
typedef endian_arithmetic<order::little, int64_t, 64, align::yes> little_int64_at;
// little endian unsigned integer aligned types
typedef endian_arithmetic<order::little, uint8_t, 8, align::yes> little_uint8_at;
typedef endian_arithmetic<order::little, uint16_t, 16, align::yes> little_uint16_at;
typedef endian_arithmetic<order::little, uint32_t, 32, align::yes> little_uint32_at;
typedef endian_arithmetic<order::little, uint64_t, 64, align::yes> little_uint64_at;
// aligned floating point types
typedef endian_arithmetic<order::big, float, 32, align::yes> big_float32_at;
typedef endian_arithmetic<order::big, double, 64, align::yes> big_float64_at;
typedef endian_arithmetic<order::little, float, 32, align::yes> little_float32_at;
typedef endian_arithmetic<order::little, double, 64, align::yes> little_float64_at;
// aligned native endian typedefs are not provided because
// <cstdint> types are superior for this use case
// big endian signed integer unaligned types
typedef endian_arithmetic<order::big, int_least8_t, 8> big_int8_t;
typedef endian_arithmetic<order::big, int_least16_t, 16> big_int16_t;
typedef endian_arithmetic<order::big, int_least32_t, 24> big_int24_t;
typedef endian_arithmetic<order::big, int_least32_t, 32> big_int32_t;
typedef endian_arithmetic<order::big, int_least64_t, 40> big_int40_t;
typedef endian_arithmetic<order::big, int_least64_t, 48> big_int48_t;
typedef endian_arithmetic<order::big, int_least64_t, 56> big_int56_t;
typedef endian_arithmetic<order::big, int_least64_t, 64> big_int64_t;
// big endian unsigned integer unaligned types
typedef endian_arithmetic<order::big, uint_least8_t, 8> big_uint8_t;
typedef endian_arithmetic<order::big, uint_least16_t, 16> big_uint16_t;
typedef endian_arithmetic<order::big, uint_least32_t, 24> big_uint24_t;
typedef endian_arithmetic<order::big, uint_least32_t, 32> big_uint32_t;
typedef endian_arithmetic<order::big, uint_least64_t, 40> big_uint40_t;
typedef endian_arithmetic<order::big, uint_least64_t, 48> big_uint48_t;
typedef endian_arithmetic<order::big, uint_least64_t, 56> big_uint56_t;
typedef endian_arithmetic<order::big, uint_least64_t, 64> big_uint64_t;
// little endian signed integer unaligned types
typedef endian_arithmetic<order::little, int_least8_t, 8> little_int8_t;
typedef endian_arithmetic<order::little, int_least16_t, 16> little_int16_t;
typedef endian_arithmetic<order::little, int_least32_t, 24> little_int24_t;
typedef endian_arithmetic<order::little, int_least32_t, 32> little_int32_t;
typedef endian_arithmetic<order::little, int_least64_t, 40> little_int40_t;
typedef endian_arithmetic<order::little, int_least64_t, 48> little_int48_t;
typedef endian_arithmetic<order::little, int_least64_t, 56> little_int56_t;
typedef endian_arithmetic<order::little, int_least64_t, 64> little_int64_t;
// little endian unsigned integer unaligned types
typedef endian_arithmetic<order::little, uint_least8_t, 8> little_uint8_t;
typedef endian_arithmetic<order::little, uint_least16_t, 16> little_uint16_t;
typedef endian_arithmetic<order::little, uint_least32_t, 24> little_uint24_t;
typedef endian_arithmetic<order::little, uint_least32_t, 32> little_uint32_t;
typedef endian_arithmetic<order::little, uint_least64_t, 40> little_uint40_t;
typedef endian_arithmetic<order::little, uint_least64_t, 48> little_uint48_t;
typedef endian_arithmetic<order::little, uint_least64_t, 56> little_uint56_t;
typedef endian_arithmetic<order::little, uint_least64_t, 64> little_uint64_t;
// native endian signed integer unaligned types
typedef endian_arithmetic<order::native, int_least8_t, 8> native_int8_t;
typedef endian_arithmetic<order::native, int_least16_t, 16> native_int16_t;
typedef endian_arithmetic<order::native, int_least32_t, 24> native_int24_t;
typedef endian_arithmetic<order::native, int_least32_t, 32> native_int32_t;
typedef endian_arithmetic<order::native, int_least64_t, 40> native_int40_t;
typedef endian_arithmetic<order::native, int_least64_t, 48> native_int48_t;
typedef endian_arithmetic<order::native, int_least64_t, 56> native_int56_t;
typedef endian_arithmetic<order::native, int_least64_t, 64> native_int64_t;
// native endian unsigned integer unaligned types
typedef endian_arithmetic<order::native, uint_least8_t, 8> native_uint8_t;
typedef endian_arithmetic<order::native, uint_least16_t, 16> native_uint16_t;
typedef endian_arithmetic<order::native, uint_least32_t, 24> native_uint24_t;
typedef endian_arithmetic<order::native, uint_least32_t, 32> native_uint32_t;
typedef endian_arithmetic<order::native, uint_least64_t, 40> native_uint40_t;
typedef endian_arithmetic<order::native, uint_least64_t, 48> native_uint48_t;
typedef endian_arithmetic<order::native, uint_least64_t, 56> native_uint56_t;
typedef endian_arithmetic<order::native, uint_least64_t, 64> native_uint64_t;
// unaligned floating point types
typedef endian_arithmetic<order::big, float, 32, align::no> big_float32_t;
typedef endian_arithmetic<order::big, double, 64, align::no> big_float64_t;
typedef endian_arithmetic<order::little, float, 32, align::no> little_float32_t;
typedef endian_arithmetic<order::little, double, 64, align::no> little_float64_t;
typedef endian_arithmetic<order::native, float, 32, align::no> native_float32_t;
typedef endian_arithmetic<order::native, double, 64, align::no> native_float64_t;
//---------------------------------- end synopsis ------------------------------------//
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
BOOST_SCOPED_ENUM(align) Align>
class endian_arithmetic
{
private:
typedef endian_buffer<Order, T, n_bits, Align> buffer_type;
#ifdef BOOST_ENDIAN_NO_CTORS
public:
#else
private:
#endif
buffer_type buf_;
public:
typedef T value_type;
#ifndef BOOST_ENDIAN_NO_CTORS
endian_arithmetic() BOOST_ENDIAN_DEFAULT_CONSTRUCT
BOOST_ENDIAN_EXPLICIT_OPT endian_arithmetic( T val ) BOOST_NOEXCEPT: buf_( val )
{
}
#endif
endian_arithmetic& operator=( T val ) BOOST_NOEXCEPT
{
buf_ = val;
return *this;
}
value_type value() const BOOST_NOEXCEPT
{
return buf_.value();
}
unsigned char const * data() const BOOST_NOEXCEPT
{
return buf_.data();
}
unsigned char * data() BOOST_NOEXCEPT
{
return buf_.data();
}
operator value_type() const BOOST_NOEXCEPT
{
return this->value();
}
operator buffer_type& () BOOST_NOEXCEPT
{
return buf_;
}
operator buffer_type const& () BOOST_NOEXCEPT
{
return buf_;
}
// operators
T operator+() const BOOST_NOEXCEPT
{
return this->value();
}
endian_arithmetic& operator+=( T y ) BOOST_NOEXCEPT
{
*this = static_cast<T>( this->value() + y );
return *this;
}
endian_arithmetic& operator-=( T y ) BOOST_NOEXCEPT
{
*this = static_cast<T>( this->value() - y );
return *this;
}
endian_arithmetic& operator*=( T y ) BOOST_NOEXCEPT
{
*this = static_cast<T>( this->value() * y );
return *this;
}
endian_arithmetic& operator/=( T y ) BOOST_NOEXCEPT
{
*this = static_cast<T>( this->value() / y );
return *this;
}
endian_arithmetic& operator%=( T y ) BOOST_NOEXCEPT
{
*this = static_cast<T>( this->value() % y );
return *this;
}
endian_arithmetic& operator&=( T y ) BOOST_NOEXCEPT
{
*this = static_cast<T>( this->value() & y );
return *this;
}
endian_arithmetic& operator|=( T y ) BOOST_NOEXCEPT
{
*this = static_cast<T>( this->value() | y );
return *this;
}
endian_arithmetic& operator^=( T y ) BOOST_NOEXCEPT
{
*this = static_cast<T>( this->value() ^ y );
return *this;
}
endian_arithmetic& operator<<=( T y ) BOOST_NOEXCEPT
{
*this = static_cast<T>( this->value() << y );
return *this;
}
endian_arithmetic& operator>>=( T y ) BOOST_NOEXCEPT
{
*this = static_cast<T>( this->value() >> y );
return *this;
}
endian_arithmetic& operator++() BOOST_NOEXCEPT
{
*this += 1;
return *this;
}
endian_arithmetic& operator--() BOOST_NOEXCEPT
{
*this -= 1;
return *this;
}
endian_arithmetic operator++(int) BOOST_NOEXCEPT
{
endian_arithmetic tmp( *this );
*this += 1;
return tmp;
}
endian_arithmetic operator--(int) BOOST_NOEXCEPT
{
endian_arithmetic tmp( *this );
*this -= 1;
return tmp;
}
template<class Ch, class Tr>
friend std::basic_ostream<Ch, Tr>&
operator<<( std::basic_ostream<Ch, Tr>& os, endian_arithmetic const& x )
{
return os << x.value();
}
template<class Ch, class Tr>
friend std::basic_istream<Ch, Tr>&
operator>>( std::basic_istream<Ch, Tr>& is, endian_arithmetic& x )
{
T i;
if( is >> i )
{
x = i;
}
return is;
}
};
} // namespace endian
} // namespace boost
#if defined(BOOST_BORLANDC) || defined(BOOST_CODEGEARC)
# pragma pack(pop)
#endif
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // BOOST_ENDIAN_ARITHMETIC_HPP

View File

@@ -0,0 +1,380 @@
// boost/endian/buffers.hpp ----------------------------------------------------------//
// (C) Copyright Darin Adler 2000
// (C) Copyright Beman Dawes 2006, 2009, 2014
// (C) Copyright Peter Dimov 2019
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/endian
//--------------------------------------------------------------------------------------//
// Original design developed by Darin Adler based on classes developed by Mark
// Borgerding. Four original class templates were combined into a single endian
// class template by Beman Dawes, who also added the unrolled_byte_loops sign
// partial specialization to correctly extend the sign when cover integer size
// differs from endian representation size.
// TODO: When a compiler supporting constexpr becomes available, try possible uses.
#ifndef BOOST_ENDIAN_BUFFERS_HPP
#define BOOST_ENDIAN_BUFFERS_HPP
#if defined(_MSC_VER)
# pragma warning(push)
# pragma warning(disable: 4127) // conditional expression is constant
#endif
#include <boost/endian/detail/endian_store.hpp>
#include <boost/endian/detail/endian_load.hpp>
#include <boost/core/scoped_enum.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/config.hpp>
#include <boost/config/workaround.hpp>
#include <iosfwd>
#include <climits>
#include <cstring>
#if defined(BOOST_BORLANDC) || defined(BOOST_CODEGEARC)
# pragma pack(push, 1)
#endif
# if CHAR_BIT != 8
# error Platforms with CHAR_BIT != 8 are not supported
# endif
# ifdef BOOST_NO_CXX11_DEFAULTED_FUNCTIONS
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT {} // C++03
# else
# define BOOST_ENDIAN_DEFAULT_CONSTRUCT = default; // C++0x
# endif
// g++ pre-4.6 does not support unrestricted unions, but we have no Config macro for that
# if (defined(BOOST_NO_CXX11_DEFAULTED_FUNCTIONS) || BOOST_WORKAROUND(BOOST_GCC, < 40600)) && defined(BOOST_ENDIAN_FORCE_PODNESS)
# define BOOST_ENDIAN_NO_CTORS
# endif
//---------------------------------- synopsis ----------------------------------------//
namespace boost
{
namespace endian
{
BOOST_SCOPED_ENUM_START(align)
{no, yes
# ifdef BOOST_ENDIAN_DEPRECATED_NAMES
, unaligned = no, aligned = yes
# endif
}; BOOST_SCOPED_ENUM_END
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
BOOST_SCOPED_ENUM(align) A = align::no>
class endian_buffer;
// aligned big endian signed integer buffers
typedef endian_buffer<order::big, int8_t, 8, align::yes> big_int8_buf_at;
typedef endian_buffer<order::big, int16_t, 16, align::yes> big_int16_buf_at;
typedef endian_buffer<order::big, int32_t, 32, align::yes> big_int32_buf_at;
typedef endian_buffer<order::big, int64_t, 64, align::yes> big_int64_buf_at;
// aligned big endian unsigned integer buffers
typedef endian_buffer<order::big, uint8_t, 8, align::yes> big_uint8_buf_at;
typedef endian_buffer<order::big, uint16_t, 16, align::yes> big_uint16_buf_at;
typedef endian_buffer<order::big, uint32_t, 32, align::yes> big_uint32_buf_at;
typedef endian_buffer<order::big, uint64_t, 64, align::yes> big_uint64_buf_at;
// aligned little endian signed integer buffers
typedef endian_buffer<order::little, int8_t, 8, align::yes> little_int8_buf_at;
typedef endian_buffer<order::little, int16_t, 16, align::yes> little_int16_buf_at;
typedef endian_buffer<order::little, int32_t, 32, align::yes> little_int32_buf_at;
typedef endian_buffer<order::little, int64_t, 64, align::yes> little_int64_buf_at;
// aligned little endian unsigned integer buffers
typedef endian_buffer<order::little, uint8_t, 8, align::yes> little_uint8_buf_at;
typedef endian_buffer<order::little, uint16_t, 16, align::yes> little_uint16_buf_at;
typedef endian_buffer<order::little, uint32_t, 32, align::yes> little_uint32_buf_at;
typedef endian_buffer<order::little, uint64_t, 64, align::yes> little_uint64_buf_at;
// aligned floating point buffers
typedef endian_buffer<order::big, float, 32, align::yes> big_float32_buf_at;
typedef endian_buffer<order::big, double, 64, align::yes> big_float64_buf_at;
typedef endian_buffer<order::little, float, 32, align::yes> little_float32_buf_at;
typedef endian_buffer<order::little, double, 64, align::yes> little_float64_buf_at;
// aligned native endian typedefs are not provided because
// <cstdint> types are superior for this use case
// unaligned big endian signed integer buffers
typedef endian_buffer<order::big, int_least8_t, 8> big_int8_buf_t;
typedef endian_buffer<order::big, int_least16_t, 16> big_int16_buf_t;
typedef endian_buffer<order::big, int_least32_t, 24> big_int24_buf_t;
typedef endian_buffer<order::big, int_least32_t, 32> big_int32_buf_t;
typedef endian_buffer<order::big, int_least64_t, 40> big_int40_buf_t;
typedef endian_buffer<order::big, int_least64_t, 48> big_int48_buf_t;
typedef endian_buffer<order::big, int_least64_t, 56> big_int56_buf_t;
typedef endian_buffer<order::big, int_least64_t, 64> big_int64_buf_t;
// unaligned big endian unsigned integer buffers
typedef endian_buffer<order::big, uint_least8_t, 8> big_uint8_buf_t;
typedef endian_buffer<order::big, uint_least16_t, 16> big_uint16_buf_t;
typedef endian_buffer<order::big, uint_least32_t, 24> big_uint24_buf_t;
typedef endian_buffer<order::big, uint_least32_t, 32> big_uint32_buf_t;
typedef endian_buffer<order::big, uint_least64_t, 40> big_uint40_buf_t;
typedef endian_buffer<order::big, uint_least64_t, 48> big_uint48_buf_t;
typedef endian_buffer<order::big, uint_least64_t, 56> big_uint56_buf_t;
typedef endian_buffer<order::big, uint_least64_t, 64> big_uint64_buf_t;
// unaligned little endian signed integer buffers
typedef endian_buffer<order::little, int_least8_t, 8> little_int8_buf_t;
typedef endian_buffer<order::little, int_least16_t, 16> little_int16_buf_t;
typedef endian_buffer<order::little, int_least32_t, 24> little_int24_buf_t;
typedef endian_buffer<order::little, int_least32_t, 32> little_int32_buf_t;
typedef endian_buffer<order::little, int_least64_t, 40> little_int40_buf_t;
typedef endian_buffer<order::little, int_least64_t, 48> little_int48_buf_t;
typedef endian_buffer<order::little, int_least64_t, 56> little_int56_buf_t;
typedef endian_buffer<order::little, int_least64_t, 64> little_int64_buf_t;
// unaligned little endian unsigned integer buffers
typedef endian_buffer<order::little, uint_least8_t, 8> little_uint8_buf_t;
typedef endian_buffer<order::little, uint_least16_t, 16> little_uint16_buf_t;
typedef endian_buffer<order::little, uint_least32_t, 24> little_uint24_buf_t;
typedef endian_buffer<order::little, uint_least32_t, 32> little_uint32_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 40> little_uint40_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 48> little_uint48_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 56> little_uint56_buf_t;
typedef endian_buffer<order::little, uint_least64_t, 64> little_uint64_buf_t;
// unaligned native endian signed integer buffers
typedef endian_buffer<order::native, int_least8_t, 8> native_int8_buf_t;
typedef endian_buffer<order::native, int_least16_t, 16> native_int16_buf_t;
typedef endian_buffer<order::native, int_least32_t, 24> native_int24_buf_t;
typedef endian_buffer<order::native, int_least32_t, 32> native_int32_buf_t;
typedef endian_buffer<order::native, int_least64_t, 40> native_int40_buf_t;
typedef endian_buffer<order::native, int_least64_t, 48> native_int48_buf_t;
typedef endian_buffer<order::native, int_least64_t, 56> native_int56_buf_t;
typedef endian_buffer<order::native, int_least64_t, 64> native_int64_buf_t;
// unaligned native endian unsigned integer buffers
typedef endian_buffer<order::native, uint_least8_t, 8> native_uint8_buf_t;
typedef endian_buffer<order::native, uint_least16_t, 16> native_uint16_buf_t;
typedef endian_buffer<order::native, uint_least32_t, 24> native_uint24_buf_t;
typedef endian_buffer<order::native, uint_least32_t, 32> native_uint32_buf_t;
typedef endian_buffer<order::native, uint_least64_t, 40> native_uint40_buf_t;
typedef endian_buffer<order::native, uint_least64_t, 48> native_uint48_buf_t;
typedef endian_buffer<order::native, uint_least64_t, 56> native_uint56_buf_t;
typedef endian_buffer<order::native, uint_least64_t, 64> native_uint64_buf_t;
// unaligned floating point buffers
typedef endian_buffer<order::big, float, 32, align::no> big_float32_buf_t;
typedef endian_buffer<order::big, double, 64, align::no> big_float64_buf_t;
typedef endian_buffer<order::little, float, 32, align::no> little_float32_buf_t;
typedef endian_buffer<order::little, double, 64, align::no> little_float64_buf_t;
typedef endian_buffer<order::native, float, 32, align::no> native_float32_buf_t;
typedef endian_buffer<order::native, double, 64, align::no> native_float64_buf_t;
// Stream inserter
template <class charT, class traits, BOOST_SCOPED_ENUM(order) Order, class T,
std::size_t n_bits, BOOST_SCOPED_ENUM(align) A>
std::basic_ostream<charT, traits>&
operator<<(std::basic_ostream<charT, traits>& os,
const endian_buffer<Order, T, n_bits, A>& x)
{
return os << x.value();
}
// Stream extractor
template <class charT, class traits, BOOST_SCOPED_ENUM(order) Order, class T,
std::size_t n_bits, BOOST_SCOPED_ENUM(align) A>
std::basic_istream<charT, traits>&
operator>>(std::basic_istream<charT, traits>& is,
endian_buffer<Order, T, n_bits, A>& x)
{
T i;
if (is >> i)
x = i;
return is;
}
//---------------------------------- end synopsis ------------------------------------//
// endian_buffer class template specializations --------------------------------------//
// Specializations that represent unaligned bytes.
// Taking an integer type as a parameter provides a nice way to pass both
// the size and signedness of the desired integer and get the appropriate
// corresponding integer type for the interface.
// Q: Should endian_buffer supply "value_type operator value_type() const noexcept"?
// A: No. The rationale for endian_buffers is to prevent high-cost hidden
// conversions. If an implicit conversion operator is supplied, hidden conversions
// can occur.
// unaligned endian_buffer specialization
template< BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits >
class endian_buffer<Order, T, n_bits, align::no>
{
#ifdef BOOST_ENDIAN_NO_CTORS
public:
#endif
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
unsigned char value_[ n_bits / 8 ];
public:
typedef T value_type;
#ifndef BOOST_ENDIAN_NO_CTORS
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
explicit endian_buffer( T val ) BOOST_NOEXCEPT
{
boost::endian::endian_store<T, n_bits / 8, Order>( value_, val );
}
#endif
endian_buffer& operator=( T val ) BOOST_NOEXCEPT
{
boost::endian::endian_store<T, n_bits / 8, Order>( value_, val );
return *this;
}
value_type value() const BOOST_NOEXCEPT
{
return boost::endian::endian_load<T, n_bits / 8, Order>( value_ );
}
unsigned char const * data() const BOOST_NOEXCEPT
{
return value_;
}
unsigned char * data() BOOST_NOEXCEPT
{
return value_;
}
};
// aligned specializations; only n_bits == 16/32/64 supported
// aligned endian_buffer specialization
template< BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits >
class endian_buffer<Order, T, n_bits, align::yes>
{
private:
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
union
{
unsigned char value_[ n_bits / 8 ];
T align_;
};
public:
typedef T value_type;
#ifndef BOOST_ENDIAN_NO_CTORS
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
explicit endian_buffer( T val ) BOOST_NOEXCEPT
{
boost::endian::endian_store<T, n_bits / 8, Order>( value_, val );
}
#endif
endian_buffer& operator=( T val ) BOOST_NOEXCEPT
{
boost::endian::endian_store<T, n_bits / 8, Order>( value_, val );
return *this;
}
value_type value() const BOOST_NOEXCEPT
{
return boost::endian::endian_load<T, n_bits / 8, Order>( value_ );
}
unsigned char const * data() const BOOST_NOEXCEPT
{
return value_;
}
unsigned char * data() BOOST_NOEXCEPT
{
return value_;
}
};
// aligned native endian_buffer specialization
template< class T, std::size_t n_bits >
class endian_buffer<order::native, T, n_bits, align::yes>
{
private:
BOOST_STATIC_ASSERT( (n_bits/8)*8 == n_bits );
BOOST_STATIC_ASSERT( sizeof(T) == n_bits/8 );
T value_;
public:
typedef T value_type;
#ifndef BOOST_ENDIAN_NO_CTORS
endian_buffer() BOOST_ENDIAN_DEFAULT_CONSTRUCT
explicit endian_buffer( T val ) BOOST_NOEXCEPT: value_( val )
{
}
#endif
endian_buffer& operator=( T val ) BOOST_NOEXCEPT
{
value_ = val;
return *this;
}
value_type value() const BOOST_NOEXCEPT
{
return value_;
}
unsigned char const * data() const BOOST_NOEXCEPT
{
return reinterpret_cast< unsigned char const* >( &value_ );
}
unsigned char * data() BOOST_NOEXCEPT
{
return reinterpret_cast< unsigned char* >( &value_ );
}
};
} // namespace endian
} // namespace boost
#if defined(BOOST_BORLANDC) || defined(BOOST_CODEGEARC)
# pragma pack(pop)
#endif
#if defined(_MSC_VER)
# pragma warning(pop)
#endif
#endif // BOOST_ENDIAN_BUFFERS_HPP

View File

@@ -0,0 +1,590 @@
// boost/endian/conversion.hpp -------------------------------------------------------//
// Copyright Beman Dawes 2010, 2011, 2014
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#ifndef BOOST_ENDIAN_CONVERSION_HPP
#define BOOST_ENDIAN_CONVERSION_HPP
#include <boost/endian/detail/endian_reverse.hpp>
#include <boost/endian/detail/endian_load.hpp>
#include <boost/endian/detail/endian_store.hpp>
#include <boost/endian/detail/order.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/is_array.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/config.hpp>
//------------------------------------- synopsis ---------------------------------------//
namespace boost
{
namespace endian
{
//--------------------------------------------------------------------------------------//
// //
// return-by-value interfaces //
// suggested by Phil Endecott //
// //
// user-defined types (UDTs) //
// //
// All return-by-value conversion function templates are required to be implemented in //
// terms of an unqualified call to "endian_reverse(x)", a function returning the //
// value of x with endianness reversed. This provides a customization point for any //
// UDT that provides a "endian_reverse" free-function meeting the requirements. //
// It must be defined in the same namespace as the UDT itself so that it will be found //
// by argument dependent lookup (ADL). //
// //
//--------------------------------------------------------------------------------------//
// reverse byte order
// requires T to be a non-bool integral type
// in detail/endian_reverse.hpp
//
// template<class T> inline BOOST_CONSTEXPR T endian_reverse( T x ) BOOST_NOEXCEPT;
// reverse byte order unless native endianness is big
template <class EndianReversible >
inline BOOST_CONSTEXPR EndianReversible big_to_native(EndianReversible x) BOOST_NOEXCEPT;
// Returns: x if native endian order is big, otherwise endian_reverse(x)
template <class EndianReversible >
inline BOOST_CONSTEXPR EndianReversible native_to_big(EndianReversible x) BOOST_NOEXCEPT;
// Returns: x if native endian order is big, otherwise endian_reverse(x)
// reverse byte order unless native endianness is little
template <class EndianReversible >
inline BOOST_CONSTEXPR EndianReversible little_to_native(EndianReversible x) BOOST_NOEXCEPT;
// Returns: x if native endian order is little, otherwise endian_reverse(x)
template <class EndianReversible >
inline BOOST_CONSTEXPR EndianReversible native_to_little(EndianReversible x) BOOST_NOEXCEPT;
// Returns: x if native endian order is little, otherwise endian_reverse(x)
// generic conditional reverse byte order
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from) BOOST_NOEXCEPT;
// Returns: If From == To have different values, from.
// Otherwise endian_reverse(from).
// Remarks: The From == To test, and as a consequence which form the return takes, is
// is determined at compile time.
// runtime conditional reverse byte order
template <class EndianReversible >
inline BOOST_CONSTEXPR EndianReversible conditional_reverse(EndianReversible from,
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order)
BOOST_NOEXCEPT;
// Returns: from_order == to_order ? from : endian_reverse(from).
//------------------------------------------------------------------------------------//
// Q: What happened to bswap, htobe, and the other synonym functions based on names
// popularized by BSD, OS X, and Linux?
// A: Turned out these may be implemented as macros on some systems. Ditto POSIX names
// for such functionality. Since macros would cause endless problems with functions
// of the same names, and these functions are just synonyms anyhow, they have been
// removed.
//------------------------------------------------------------------------------------//
// //
// reverse in place interfaces //
// //
// user-defined types (UDTs) //
// //
// All reverse in place function templates are required to be implemented in terms //
// of an unqualified call to "endian_reverse_inplace(x)", a function reversing //
// the endianness of x, which is a non-const reference. This provides a //
// customization point for any UDT that provides a "reverse_inplace" free-function //
// meeting the requirements. The free-function must be declared in the same //
// namespace as the UDT itself so that it will be found by argument-dependent //
// lookup (ADL). //
// //
//------------------------------------------------------------------------------------//
// reverse in place
// in detail/endian_reverse.hpp
//
// template <class EndianReversible>
// inline void endian_reverse_inplace(EndianReversible& x) BOOST_NOEXCEPT;
//
// Effects: x = endian_reverse(x)
// reverse in place unless native endianness is big
template <class EndianReversibleInplace>
inline void big_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
// Effects: none if native byte-order is big, otherwise endian_reverse_inplace(x)
template <class EndianReversibleInplace>
inline void native_to_big_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
// Effects: none if native byte-order is big, otherwise endian_reverse_inplace(x)
// reverse in place unless native endianness is little
template <class EndianReversibleInplace>
inline void little_to_native_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
// Effects: none if native byte-order is little, otherwise endian_reverse_inplace(x);
template <class EndianReversibleInplace>
inline void native_to_little_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
// Effects: none if native byte-order is little, otherwise endian_reverse_inplace(x);
// generic conditional reverse in place
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To,
class EndianReversibleInplace>
inline void conditional_reverse_inplace(EndianReversibleInplace& x) BOOST_NOEXCEPT;
// runtime reverse in place
template <class EndianReversibleInplace>
inline void conditional_reverse_inplace(EndianReversibleInplace& x,
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order)
BOOST_NOEXCEPT;
//----------------------------------- end synopsis -------------------------------------//
template <class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible big_to_native( EndianReversible x ) BOOST_NOEXCEPT
{
return boost::endian::conditional_reverse<order::big, order::native>( x );
}
template <class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible native_to_big( EndianReversible x ) BOOST_NOEXCEPT
{
return boost::endian::conditional_reverse<order::native, order::big>( x );
}
template <class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible little_to_native( EndianReversible x ) BOOST_NOEXCEPT
{
return boost::endian::conditional_reverse<order::little, order::native>( x );
}
template <class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible native_to_little( EndianReversible x ) BOOST_NOEXCEPT
{
return boost::endian::conditional_reverse<order::native, order::little>( x );
}
namespace detail
{
template<class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::true_type ) BOOST_NOEXCEPT
{
return x;
}
template<class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible conditional_reverse_impl( EndianReversible x, boost::false_type ) BOOST_NOEXCEPT
{
return endian_reverse( x );
}
} // namespace detail
// generic conditional reverse
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( boost::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value );
return detail::conditional_reverse_impl( x, boost::integral_constant<bool, From == To>() );
}
// runtime conditional reverse
template <class EndianReversible>
inline BOOST_CONSTEXPR EndianReversible conditional_reverse( EndianReversible x,
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( boost::is_class<EndianReversible>::value || detail::is_endian_reversible<EndianReversible>::value );
return from_order == to_order? x: endian_reverse( x );
}
//--------------------------------------------------------------------------------------//
// reverse-in-place implementation //
//--------------------------------------------------------------------------------------//
template <class EndianReversibleInplace>
inline void big_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
{
boost::endian::conditional_reverse_inplace<order::big, order::native>( x );
}
template <class EndianReversibleInplace>
inline void native_to_big_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
{
boost::endian::conditional_reverse_inplace<order::native, order::big>( x );
}
template <class EndianReversibleInplace>
inline void little_to_native_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
{
boost::endian::conditional_reverse_inplace<order::little, order::native>( x );
}
template <class EndianReversibleInplace>
inline void native_to_little_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
{
boost::endian::conditional_reverse_inplace<order::native, order::little>( x );
}
namespace detail
{
template<class EndianReversibleInplace>
inline void conditional_reverse_inplace_impl( EndianReversibleInplace&, boost::true_type ) BOOST_NOEXCEPT
{
}
template<class EndianReversibleInplace>
inline void conditional_reverse_inplace_impl( EndianReversibleInplace& x, boost::false_type ) BOOST_NOEXCEPT
{
endian_reverse_inplace( x );
}
} // namespace detail
// generic conditional reverse in place
template <BOOST_SCOPED_ENUM(order) From, BOOST_SCOPED_ENUM(order) To, class EndianReversibleInplace>
inline void conditional_reverse_inplace( EndianReversibleInplace& x ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT(
boost::is_class<EndianReversibleInplace>::value ||
boost::is_array<EndianReversibleInplace>::value ||
detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
detail::conditional_reverse_inplace_impl( x, boost::integral_constant<bool, From == To>() );
}
// runtime reverse in place
template <class EndianReversibleInplace>
inline void conditional_reverse_inplace( EndianReversibleInplace& x,
BOOST_SCOPED_ENUM(order) from_order, BOOST_SCOPED_ENUM(order) to_order ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT(
boost::is_class<EndianReversibleInplace>::value ||
boost::is_array<EndianReversibleInplace>::value ||
detail::is_endian_reversible_inplace<EndianReversibleInplace>::value );
if( from_order != to_order )
{
endian_reverse_inplace( x );
}
}
// load/store convenience functions
// load 16
inline boost::int16_t load_little_s16( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int16_t, 2, order::little>( p );
}
inline boost::uint16_t load_little_u16( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint16_t, 2, order::little>( p );
}
inline boost::int16_t load_big_s16( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int16_t, 2, order::big>( p );
}
inline boost::uint16_t load_big_u16( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint16_t, 2, order::big>( p );
}
// load 24
inline boost::int32_t load_little_s24( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int32_t, 3, order::little>( p );
}
inline boost::uint32_t load_little_u24( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint32_t, 3, order::little>( p );
}
inline boost::int32_t load_big_s24( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int32_t, 3, order::big>( p );
}
inline boost::uint32_t load_big_u24( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint32_t, 3, order::big>( p );
}
// load 32
inline boost::int32_t load_little_s32( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int32_t, 4, order::little>( p );
}
inline boost::uint32_t load_little_u32( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint32_t, 4, order::little>( p );
}
inline boost::int32_t load_big_s32( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int32_t, 4, order::big>( p );
}
inline boost::uint32_t load_big_u32( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint32_t, 4, order::big>( p );
}
// load 40
inline boost::int64_t load_little_s40( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 5, order::little>( p );
}
inline boost::uint64_t load_little_u40( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 5, order::little>( p );
}
inline boost::int64_t load_big_s40( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 5, order::big>( p );
}
inline boost::uint64_t load_big_u40( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 5, order::big>( p );
}
// load 48
inline boost::int64_t load_little_s48( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 6, order::little>( p );
}
inline boost::uint64_t load_little_u48( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 6, order::little>( p );
}
inline boost::int64_t load_big_s48( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 6, order::big>( p );
}
inline boost::uint64_t load_big_u48( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 6, order::big>( p );
}
// load 56
inline boost::int64_t load_little_s56( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 7, order::little>( p );
}
inline boost::uint64_t load_little_u56( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 7, order::little>( p );
}
inline boost::int64_t load_big_s56( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 7, order::big>( p );
}
inline boost::uint64_t load_big_u56( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 7, order::big>( p );
}
// load 64
inline boost::int64_t load_little_s64( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 8, order::little>( p );
}
inline boost::uint64_t load_little_u64( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 8, order::little>( p );
}
inline boost::int64_t load_big_s64( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::int64_t, 8, order::big>( p );
}
inline boost::uint64_t load_big_u64( unsigned char const * p ) BOOST_NOEXCEPT
{
return boost::endian::endian_load<boost::uint64_t, 8, order::big>( p );
}
// store 16
inline void store_little_s16( unsigned char * p, boost::int16_t v )
{
boost::endian::endian_store<boost::int16_t, 2, order::little>( p, v );
}
inline void store_little_u16( unsigned char * p, boost::uint16_t v )
{
boost::endian::endian_store<boost::uint16_t, 2, order::little>( p, v );
}
inline void store_big_s16( unsigned char * p, boost::int16_t v )
{
boost::endian::endian_store<boost::int16_t, 2, order::big>( p, v );
}
inline void store_big_u16( unsigned char * p, boost::uint16_t v )
{
boost::endian::endian_store<boost::uint16_t, 2, order::big>( p, v );
}
// store 24
inline void store_little_s24( unsigned char * p, boost::int32_t v )
{
boost::endian::endian_store<boost::int32_t, 3, order::little>( p, v );
}
inline void store_little_u24( unsigned char * p, boost::uint32_t v )
{
boost::endian::endian_store<boost::uint32_t, 3, order::little>( p, v );
}
inline void store_big_s24( unsigned char * p, boost::int32_t v )
{
boost::endian::endian_store<boost::int32_t, 3, order::big>( p, v );
}
inline void store_big_u24( unsigned char * p, boost::uint32_t v )
{
boost::endian::endian_store<boost::uint32_t, 3, order::big>( p, v );
}
// store 32
inline void store_little_s32( unsigned char * p, boost::int32_t v )
{
boost::endian::endian_store<boost::int32_t, 4, order::little>( p, v );
}
inline void store_little_u32( unsigned char * p, boost::uint32_t v )
{
boost::endian::endian_store<boost::uint32_t, 4, order::little>( p, v );
}
inline void store_big_s32( unsigned char * p, boost::int32_t v )
{
boost::endian::endian_store<boost::int32_t, 4, order::big>( p, v );
}
inline void store_big_u32( unsigned char * p, boost::uint32_t v )
{
boost::endian::endian_store<boost::uint32_t, 4, order::big>( p, v );
}
// store 40
inline void store_little_s40( unsigned char * p, boost::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 5, order::little>( p, v );
}
inline void store_little_u40( unsigned char * p, boost::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 5, order::little>( p, v );
}
inline void store_big_s40( unsigned char * p, boost::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 5, order::big>( p, v );
}
inline void store_big_u40( unsigned char * p, boost::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 5, order::big>( p, v );
}
// store 48
inline void store_little_s48( unsigned char * p, boost::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 6, order::little>( p, v );
}
inline void store_little_u48( unsigned char * p, boost::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 6, order::little>( p, v );
}
inline void store_big_s48( unsigned char * p, boost::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 6, order::big>( p, v );
}
inline void store_big_u48( unsigned char * p, boost::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 6, order::big>( p, v );
}
// store 56
inline void store_little_s56( unsigned char * p, boost::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 7, order::little>( p, v );
}
inline void store_little_u56( unsigned char * p, boost::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 7, order::little>( p, v );
}
inline void store_big_s56( unsigned char * p, boost::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 7, order::big>( p, v );
}
inline void store_big_u56( unsigned char * p, boost::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 7, order::big>( p, v );
}
// store 64
inline void store_little_s64( unsigned char * p, boost::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 8, order::little>( p, v );
}
inline void store_little_u64( unsigned char * p, boost::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 8, order::little>( p, v );
}
inline void store_big_s64( unsigned char * p, boost::int64_t v )
{
boost::endian::endian_store<boost::int64_t, 8, order::big>( p, v );
}
inline void store_big_u64( unsigned char * p, boost::uint64_t v )
{
boost::endian::endian_store<boost::uint64_t, 8, order::big>( p, v );
}
} // namespace endian
} // namespace boost
#endif // BOOST_ENDIAN_CONVERSION_HPP

View File

@@ -0,0 +1,33 @@
// disable_warnings.hpp --------------------------------------------------------------//
// Copyright Beman Dawes 2011
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
//--------------------------------------------------------------------------------------//
#ifdef _MSC_VER
#ifndef _SCL_SECURE_NO_WARNINGS
# define _SCL_SECURE_NO_WARNINGS
#endif
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
# pragma warning(push)
// triggered by boost/detail/lightweight_test.hpp
# pragma warning( disable : 4640 ) // ... construction of local static object is not thread-safe
// triggered by Microsoft's own headers, so disable
# pragma warning( disable : 4820 ) // padding added after data member
# pragma warning( disable : 4548 ) // expression before comma has no effect
# pragma warning( disable : 4668 ) // ... is not defined as a preprocessor macro
# pragma warning( disable : 4514 ) // ... unreferenced inline function has been removed
# pragma warning( disable : 4710 ) // ... function not inlined
# pragma warning( disable : 4986 ) // ... exception specification does not match previous declaration
# pragma warning( disable : 4711 ) // ... selected for automatic inline expansion
#endif

View File

@@ -0,0 +1,12 @@
// disable_warnings_pop.hpp ----------------------------------------------------------//
// Copyright Beman Dawes 2011
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
//--------------------------------------------------------------------------------------//
#ifdef _MSC_VER
# pragma warning(pop)
#endif

View File

@@ -0,0 +1,589 @@
#ifndef BOOST_ENDIAN_DETAIL_ENDIAN_LOAD_HPP_INCLUDED
#define BOOST_ENDIAN_DETAIL_ENDIAN_LOAD_HPP_INCLUDED
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/detail/endian_reverse.hpp>
#include <boost/endian/detail/order.hpp>
#include <boost/endian/detail/integral_by_size.hpp>
#include <boost/endian/detail/is_trivially_copyable.hpp>
#include <boost/type_traits/is_signed.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/static_assert.hpp>
#include <cstddef>
#include <cstring>
namespace boost
{
namespace endian
{
namespace detail
{
template<class T, std::size_t N1, BOOST_SCOPED_ENUM(order) O1, std::size_t N2, BOOST_SCOPED_ENUM(order) O2> struct endian_load_impl
{
};
} // namespace detail
// Requires:
//
// sizeof(T) must be 1, 2, 4, or 8
// 1 <= N <= sizeof(T)
// T is TriviallyCopyable
// if N < sizeof(T), T is integral or enum
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) Order>
inline T endian_load( unsigned char const * p ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 );
BOOST_STATIC_ASSERT( N >= 1 && N <= sizeof(T) );
return detail::endian_load_impl<T, sizeof(T), order::native, N, Order>()( p );
}
namespace detail
{
// same endianness, same size
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O> struct endian_load_impl<T, N, O, N, O>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
T t;
std::memcpy( &t, p, N );
return t;
}
};
// same size, reverse endianness
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O1, BOOST_SCOPED_ENUM(order) O2> struct endian_load_impl<T, N, O1, N, O2>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
typename integral_by_size<N>::type tmp;
std::memcpy( &tmp, p, N );
endian_reverse_inplace( tmp );
T t;
std::memcpy( &t, &tmp, N );
return t;
}
};
// expanding load 1 -> 2
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 2, Order, 1, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 2 ];
tmp[0] = p[0];
tmp[1] = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
return boost::endian::endian_load<T, 2, order::little>( tmp );
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 2, Order, 1, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 2 ];
tmp[0] = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[1] = p[0];
return boost::endian::endian_load<T, 2, order::big>( tmp );
}
};
// expanding load 1 -> 4
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 1, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 4 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = fill;
tmp[2] = fill;
tmp[3] = fill;
return boost::endian::endian_load<T, 4, order::little>( tmp );
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 1, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 4 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
tmp[2] = fill;
tmp[3] = p[0];
return boost::endian::endian_load<T, 4, order::big>( tmp );
}
};
// expanding load 2 -> 4
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 2, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 4 ];
unsigned char fill = boost::is_signed<T>::value && ( p[1] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
tmp[2] = fill;
tmp[3] = fill;
return boost::endian::endian_load<T, 4, order::little>( tmp );
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 2, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 4 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
tmp[2] = p[0];
tmp[3] = p[1];
return boost::endian::endian_load<T, 4, order::big>( tmp );
}
};
// expanding load 3 -> 4
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 3, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 4 ];
tmp[0] = p[0];
tmp[1] = p[1];
tmp[2] = p[2];
tmp[3] = boost::is_signed<T>::value && ( p[2] & 0x80 )? 0xFF: 0x00;
return boost::endian::endian_load<T, 4, order::little>( tmp );
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 4, Order, 3, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 4 ];
tmp[0] = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[1] = p[0];
tmp[2] = p[1];
tmp[3] = p[2];
return boost::endian::endian_load<T, 4, order::big>( tmp );
}
};
// expanding load 1 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 1, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = fill;
tmp[2] = fill;
tmp[3] = fill;
tmp[4] = fill;
tmp[5] = fill;
tmp[6] = fill;
tmp[7] = fill;
return boost::endian::endian_load<T, 8, order::little>( tmp );
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 1, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
tmp[2] = fill;
tmp[3] = fill;
tmp[4] = fill;
tmp[5] = fill;
tmp[6] = fill;
tmp[7] = p[0];
return boost::endian::endian_load<T, 8, order::big>( tmp );
}
};
// expanding load 2 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 2, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[1] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
tmp[2] = fill;
tmp[3] = fill;
tmp[4] = fill;
tmp[5] = fill;
tmp[6] = fill;
tmp[7] = fill;
return boost::endian::endian_load<T, 8, order::little>( tmp );
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 2, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
tmp[2] = fill;
tmp[3] = fill;
tmp[4] = fill;
tmp[5] = fill;
tmp[6] = p[0];
tmp[7] = p[1];
return boost::endian::endian_load<T, 8, order::big>( tmp );
}
};
// expanding load 3 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 3, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[2] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
tmp[2] = p[2];
tmp[3] = fill;
tmp[4] = fill;
tmp[5] = fill;
tmp[6] = fill;
tmp[7] = fill;
return boost::endian::endian_load<T, 8, order::little>( tmp );
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 3, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
tmp[2] = fill;
tmp[3] = fill;
tmp[4] = fill;
tmp[5] = p[0];
tmp[6] = p[1];
tmp[7] = p[2];
return boost::endian::endian_load<T, 8, order::big>( tmp );
}
};
// expanding load 4 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 4, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[3] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
tmp[2] = p[2];
tmp[3] = p[3];
tmp[4] = fill;
tmp[5] = fill;
tmp[6] = fill;
tmp[7] = fill;
return boost::endian::endian_load<T, 8, order::little>( tmp );
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 4, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
tmp[2] = fill;
tmp[3] = fill;
tmp[4] = p[0];
tmp[5] = p[1];
tmp[6] = p[2];
tmp[7] = p[3];
return boost::endian::endian_load<T, 8, order::big>( tmp );
}
};
// expanding load 5 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 5, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[4] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
tmp[2] = p[2];
tmp[3] = p[3];
tmp[4] = p[4];
tmp[5] = fill;
tmp[6] = fill;
tmp[7] = fill;
return boost::endian::endian_load<T, 8, order::little>( tmp );
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 5, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
tmp[2] = fill;
tmp[3] = p[0];
tmp[4] = p[1];
tmp[5] = p[2];
tmp[6] = p[3];
tmp[7] = p[4];
return boost::endian::endian_load<T, 8, order::big>( tmp );
}
};
// expanding load 6 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 6, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[5] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
tmp[2] = p[2];
tmp[3] = p[3];
tmp[4] = p[4];
tmp[5] = p[5];
tmp[6] = fill;
tmp[7] = fill;
return boost::endian::endian_load<T, 8, order::little>( tmp );
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 6, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = fill;
tmp[2] = p[0];
tmp[3] = p[1];
tmp[4] = p[2];
tmp[5] = p[3];
tmp[6] = p[4];
tmp[7] = p[5];
return boost::endian::endian_load<T, 8, order::big>( tmp );
}
};
// expanding load 7 -> 8
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 7, order::little>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[6] & 0x80 )? 0xFF: 0x00;
tmp[0] = p[0];
tmp[1] = p[1];
tmp[2] = p[2];
tmp[3] = p[3];
tmp[4] = p[4];
tmp[5] = p[5];
tmp[6] = p[6];
tmp[7] = fill;
return boost::endian::endian_load<T, 8, order::little>( tmp );
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_load_impl<T, 8, Order, 7, order::big>
{
inline T operator()( unsigned char const * p ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
unsigned char fill = boost::is_signed<T>::value && ( p[0] & 0x80 )? 0xFF: 0x00;
tmp[0] = fill;
tmp[1] = p[0];
tmp[2] = p[1];
tmp[3] = p[2];
tmp[4] = p[3];
tmp[5] = p[4];
tmp[6] = p[5];
tmp[7] = p[6];
return boost::endian::endian_load<T, 8, order::big>( tmp );
}
};
} // namespace detail
} // namespace endian
} // namespace boost
#endif // BOOST_ENDIAN_DETAIL_ENDIAN_LOAD_HPP_INCLUDED

View File

@@ -0,0 +1,178 @@
#ifndef BOOST_ENDIAN_DETAIL_ENDIAN_REVERSE_HPP_INCLUDED
#define BOOST_ENDIAN_DETAIL_ENDIAN_REVERSE_HPP_INCLUDED
// Copyright 2019, 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/detail/integral_by_size.hpp>
#include <boost/endian/detail/intrinsic.hpp>
#include <boost/endian/detail/is_scoped_enum.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/type_traits/enable_if.hpp>
#include <boost/type_traits/is_class.hpp>
#include <boost/type_traits/integral_constant.hpp>
#include <boost/static_assert.hpp>
#include <boost/cstdint.hpp>
#include <boost/config.hpp>
#include <cstddef>
#include <cstring>
#if defined(BOOST_ENDIAN_NO_INTRINSICS)
# if defined(BOOST_NO_CXX14_CONSTEXPR)
# define BOOST_ENDIAN_CONSTEXPR
# else
# define BOOST_ENDIAN_CONSTEXPR constexpr
# endif
#else
# if defined(BOOST_ENDIAN_CONSTEXPR_INTRINSICS)
# define BOOST_ENDIAN_CONSTEXPR BOOST_CONSTEXPR
# else
# define BOOST_ENDIAN_CONSTEXPR
# endif
#endif
namespace boost
{
namespace endian
{
namespace detail
{
// -- portable approach suggested by tymofey, with avoidance of undefined behavior
// as suggested by Giovanni Piero Deretta, with a further refinement suggested
// by Pyry Jahkola.
// -- intrinsic approach suggested by reviewers, and by David Stone, who provided
// his Boost licensed macro implementation (detail/intrinsic.hpp)
inline uint8_t BOOST_CONSTEXPR endian_reverse_impl( uint8_t x ) BOOST_NOEXCEPT
{
return x;
}
inline uint16_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint16_t x ) BOOST_NOEXCEPT
{
#ifdef BOOST_ENDIAN_NO_INTRINSICS
return (x << 8) | (x >> 8);
#else
return BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x);
#endif
}
inline uint32_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint32_t x ) BOOST_NOEXCEPT
{
#ifdef BOOST_ENDIAN_NO_INTRINSICS
uint32_t step16 = x << 16 | x >> 16;
return ((step16 << 8) & 0xff00ff00) | ((step16 >> 8) & 0x00ff00ff);
#else
return BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x);
#endif
}
inline uint64_t BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint64_t x ) BOOST_NOEXCEPT
{
#ifdef BOOST_ENDIAN_NO_INTRINSICS
uint64_t step32 = x << 32 | x >> 32;
uint64_t step16 = (step32 & 0x0000FFFF0000FFFFULL) << 16 | (step32 & 0xFFFF0000FFFF0000ULL) >> 16;
return (step16 & 0x00FF00FF00FF00FFULL) << 8 | (step16 & 0xFF00FF00FF00FF00ULL) >> 8;
#else
return BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x);
# endif
}
#if defined(BOOST_HAS_INT128)
inline uint128_type BOOST_ENDIAN_CONSTEXPR endian_reverse_impl( uint128_type x ) BOOST_NOEXCEPT
{
return endian_reverse_impl( static_cast<uint64_t>( x >> 64 ) ) |
static_cast<uint128_type>( endian_reverse_impl( static_cast<uint64_t>( x ) ) ) << 64;
}
#endif
// is_endian_reversible
template<class T> struct is_endian_reversible: boost::integral_constant<bool,
(boost::is_integral<T>::value && !boost::is_same<T, bool>::value) || is_scoped_enum<T>::value>
{
};
// is_endian_reversible_inplace
template<class T> struct is_endian_reversible_inplace: boost::integral_constant<bool,
boost::is_integral<T>::value || boost::is_enum<T>::value || boost::is_same<T, float>::value || boost::is_same<T, double>::value>
{
};
} // namespace detail
// Requires:
// T is non-bool integral or scoped enumeration type
template<class T> inline BOOST_CONSTEXPR
typename enable_if_< !is_class<T>::value, T >::type
endian_reverse( T x ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( detail::is_endian_reversible<T>::value );
typedef typename detail::integral_by_size< sizeof(T) >::type uintN_t;
return static_cast<T>( detail::endian_reverse_impl( static_cast<uintN_t>( x ) ) );
}
// Requires:
// T is integral, enumeration, float or double
template<class T> inline
typename enable_if_< !is_class<T>::value >::type
endian_reverse_inplace( T & x ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( detail::is_endian_reversible_inplace<T>::value );
typename detail::integral_by_size< sizeof(T) >::type x2;
std::memcpy( &x2, &x, sizeof(T) );
x2 = detail::endian_reverse_impl( x2 );
std::memcpy( &x, &x2, sizeof(T) );
}
// Default implementation for user-defined types
template<class T> inline
typename enable_if_< is_class<T>::value >::type
endian_reverse_inplace( T & x ) BOOST_NOEXCEPT
{
x = endian_reverse( x );
}
// endian_reverse_inplace for arrays
template<class T, std::size_t N>
inline void endian_reverse_inplace( T (&x)[ N ] ) BOOST_NOEXCEPT
{
for( std::size_t i = 0; i < N; ++i )
{
endian_reverse_inplace( x[i] );
}
}
} // namespace endian
} // namespace boost
#endif // BOOST_ENDIAN_DETAIL_ENDIAN_REVERSE_HPP_INCLUDED

View File

@@ -0,0 +1,442 @@
#ifndef BOOST_ENDIAN_DETAIL_ENDIAN_STORE_HPP_INCLUDED
#define BOOST_ENDIAN_DETAIL_ENDIAN_STORE_HPP_INCLUDED
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/detail/endian_reverse.hpp>
#include <boost/endian/detail/order.hpp>
#include <boost/endian/detail/integral_by_size.hpp>
#include <boost/endian/detail/is_trivially_copyable.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/static_assert.hpp>
#include <cstddef>
#include <cstring>
namespace boost
{
namespace endian
{
namespace detail
{
template<class T, std::size_t N1, BOOST_SCOPED_ENUM(order) O1, std::size_t N2, BOOST_SCOPED_ENUM(order) O2> struct endian_store_impl
{
};
} // namespace detail
// Requires:
//
// sizeof(T) must be 1, 2, 4, or 8
// 1 <= N <= sizeof(T)
// T is TriviallyCopyable
// if N < sizeof(T), T is integral or enum
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) Order>
inline void endian_store( unsigned char * p, T const & v ) BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( sizeof(T) == 1 || sizeof(T) == 2 || sizeof(T) == 4 || sizeof(T) == 8 );
BOOST_STATIC_ASSERT( N >= 1 && N <= sizeof(T) );
return detail::endian_store_impl<T, sizeof(T), order::native, N, Order>()( p, v );
}
namespace detail
{
// same endianness, same size
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O> struct endian_store_impl<T, N, O, N, O>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
std::memcpy( p, &v, N );
}
};
// same size, reverse endianness
template<class T, std::size_t N, BOOST_SCOPED_ENUM(order) O1, BOOST_SCOPED_ENUM(order) O2> struct endian_store_impl<T, N, O1, N, O2>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_trivially_copyable<T>::value );
typename integral_by_size<N>::type tmp;
std::memcpy( &tmp, &v, N );
endian_reverse_inplace( tmp );
std::memcpy( p, &tmp, N );
}
};
// truncating store 2 -> 1
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 2, Order, 1, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 2 ];
boost::endian::endian_store<T, 2, order::little>( tmp, v );
p[0] = tmp[0];
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 2, Order, 1, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 2 ];
boost::endian::endian_store<T, 2, order::big>( tmp, v );
p[0] = tmp[1];
}
};
// truncating store 4 -> 1
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 1, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 4 ];
boost::endian::endian_store<T, 4, order::little>( tmp, v );
p[0] = tmp[0];
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 1, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 4 ];
boost::endian::endian_store<T, 4, order::big>( tmp, v );
p[0] = tmp[3];
}
};
// truncating store 4 -> 2
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 2, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 4 ];
boost::endian::endian_store<T, 4, order::little>( tmp, v );
p[0] = tmp[0];
p[1] = tmp[1];
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 2, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 4 ];
boost::endian::endian_store<T, 4, order::big>( tmp, v );
p[0] = tmp[2];
p[1] = tmp[3];
}
};
// truncating store 4 -> 3
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 3, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 4 ];
boost::endian::endian_store<T, 4, order::little>( tmp, v );
p[0] = tmp[0];
p[1] = tmp[1];
p[2] = tmp[2];
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 4, Order, 3, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 4 ];
boost::endian::endian_store<T, 4, order::big>( tmp, v );
p[0] = tmp[1];
p[1] = tmp[2];
p[2] = tmp[3];
}
};
// truncating store 8 -> 1
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 1, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
p[0] = tmp[0];
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 1, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );
p[0] = tmp[7];
}
};
// truncating store 8 -> 2
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 2, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
p[0] = tmp[0];
p[1] = tmp[1];
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 2, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );
p[0] = tmp[6];
p[1] = tmp[7];
}
};
// truncating store 8 -> 3
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 3, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
p[0] = tmp[0];
p[1] = tmp[1];
p[2] = tmp[2];
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 3, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );
p[0] = tmp[5];
p[1] = tmp[6];
p[2] = tmp[7];
}
};
// truncating store 8 -> 4
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 4, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
p[0] = tmp[0];
p[1] = tmp[1];
p[2] = tmp[2];
p[3] = tmp[3];
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 4, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );
p[0] = tmp[4];
p[1] = tmp[5];
p[2] = tmp[6];
p[3] = tmp[7];
}
};
// truncating store 8 -> 5
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 5, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
p[0] = tmp[0];
p[1] = tmp[1];
p[2] = tmp[2];
p[3] = tmp[3];
p[4] = tmp[4];
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 5, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );
p[0] = tmp[3];
p[1] = tmp[4];
p[2] = tmp[5];
p[3] = tmp[6];
p[4] = tmp[7];
}
};
// truncating store 8 -> 6
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 6, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
p[0] = tmp[0];
p[1] = tmp[1];
p[2] = tmp[2];
p[3] = tmp[3];
p[4] = tmp[4];
p[5] = tmp[5];
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 6, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );
p[0] = tmp[2];
p[1] = tmp[3];
p[2] = tmp[4];
p[3] = tmp[5];
p[4] = tmp[6];
p[5] = tmp[7];
}
};
// truncating store 8 -> 7
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 7, order::little>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::little>( tmp, v );
p[0] = tmp[0];
p[1] = tmp[1];
p[2] = tmp[2];
p[3] = tmp[3];
p[4] = tmp[4];
p[5] = tmp[5];
p[6] = tmp[6];
}
};
template<class T, BOOST_SCOPED_ENUM(order) Order> struct endian_store_impl<T, 8, Order, 7, order::big>
{
inline void operator()( unsigned char * p, T const & v ) const BOOST_NOEXCEPT
{
BOOST_STATIC_ASSERT( is_integral<T>::value || is_enum<T>::value );
unsigned char tmp[ 8 ];
boost::endian::endian_store<T, 8, order::big>( tmp, v );
p[0] = tmp[1];
p[1] = tmp[2];
p[2] = tmp[3];
p[3] = tmp[4];
p[4] = tmp[5];
p[5] = tmp[6];
p[6] = tmp[7];
}
};
} // namespace detail
} // namespace endian
} // namespace boost
#endif // BOOST_ENDIAN_DETAIL_ENDIAN_STORE_HPP_INCLUDED

View File

@@ -0,0 +1,57 @@
#ifndef BOOST_ENDIAN_DETAIL_INTEGRAL_BY_SIZE_HPP_INCLUDED
#define BOOST_ENDIAN_DETAIL_INTEGRAL_BY_SIZE_HPP_INCLUDED
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/cstdint.hpp>
#include <boost/config.hpp>
#include <cstddef>
namespace boost
{
namespace endian
{
namespace detail
{
template<std::size_t N> struct integral_by_size
{
};
template<> struct integral_by_size<1>
{
typedef uint8_t type;
};
template<> struct integral_by_size<2>
{
typedef uint16_t type;
};
template<> struct integral_by_size<4>
{
typedef uint32_t type;
};
template<> struct integral_by_size<8>
{
typedef uint64_t type;
};
#if defined(BOOST_HAS_INT128)
template<> struct integral_by_size<16>
{
typedef uint128_type type;
};
#endif
} // namespace detail
} // namespace endian
} // namespace boost
#endif // BOOST_ENDIAN_DETAIL_INTEGRAL_BY_SIZE_HPP_INCLUDED

View File

@@ -0,0 +1,69 @@
// endian/detail/intrinsic.hpp -------------------------------------------------------//
// Copyright (C) 2012 David Stone
// Copyright Beman Dawes 2013
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#ifndef BOOST_ENDIAN_INTRINSIC_HPP
#define BOOST_ENDIAN_INTRINSIC_HPP
// Allow user to force BOOST_ENDIAN_NO_INTRINSICS in case they aren't available for a
// particular platform/compiler combination. Please report such platform/compiler
// combinations to the Boost mailing list.
#ifndef BOOST_ENDIAN_NO_INTRINSICS
#ifndef __has_builtin // Optional of course
#define __has_builtin(x) 0 // Compatibility with non-clang compilers
#endif
#if defined(_MSC_VER) && ( !defined(__clang__) || defined(__c2__) )
// Microsoft documents these as being compatible since Windows 95 and specifically
// lists runtime library support since Visual Studio 2003 (aka 7.1).
// Clang/c2 uses the Microsoft rather than GCC intrinsics, so we check for
// defined(_MSC_VER) before defined(__clang__)
# define BOOST_ENDIAN_INTRINSIC_MSG "cstdlib _byteswap_ushort, etc."
# include <cstdlib>
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) _byteswap_ushort(x)
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) _byteswap_ulong(x)
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) _byteswap_uint64(x)
// GCC and Clang recent versions provide intrinsic byte swaps via builtins
#elif (defined(__clang__) && __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)) \
|| (defined(__GNUC__ ) && \
(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3)))
# define BOOST_ENDIAN_INTRINSIC_MSG "__builtin_bswap16, etc."
// prior to 4.8, gcc did not provide __builtin_bswap16 on some platforms so we emulate it
// see http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52624
// Clang has a similar problem, but their feature test macros make it easier to detect
# if (defined(__clang__) && __has_builtin(__builtin_bswap16)) \
|| (defined(__GNUC__) &&(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 8)))
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) __builtin_bswap16(x)
# else
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) __builtin_bswap32((x) << 16)
# endif
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) __builtin_bswap32(x)
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) __builtin_bswap64(x)
# define BOOST_ENDIAN_CONSTEXPR_INTRINSICS
// Linux systems provide the byteswap.h header, with
#elif defined(__linux__)
// don't check for obsolete forms defined(linux) and defined(__linux) on the theory that
// compilers that predefine only these are so old that byteswap.h probably isn't present.
# define BOOST_ENDIAN_INTRINSIC_MSG "byteswap.h bswap_16, etc."
# include <byteswap.h>
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x) bswap_16(x)
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x) bswap_32(x)
# define BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x) bswap_64(x)
#else
# define BOOST_ENDIAN_NO_INTRINSICS
# define BOOST_ENDIAN_INTRINSIC_MSG "no byte swap intrinsics"
#endif
#elif !defined(BOOST_ENDIAN_INTRINSIC_MSG)
# define BOOST_ENDIAN_INTRINSIC_MSG "no byte swap intrinsics"
#endif // BOOST_ENDIAN_NO_INTRINSICS
#endif // BOOST_ENDIAN_INTRINSIC_HPP

View File

@@ -0,0 +1,35 @@
#ifndef BOOST_ENDIAN_DETAIL_IS_SCOPED_ENUM_HPP_INCLUDED
#define BOOST_ENDIAN_DETAIL_IS_SCOPED_ENUM_HPP_INCLUDED
// Copyright 2020 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/type_traits/conditional.hpp>
#include <boost/type_traits/is_enum.hpp>
#include <boost/type_traits/is_convertible.hpp>
namespace boost
{
namespace endian
{
namespace detail
{
template<class T> struct negation: boost::integral_constant<bool, !T::value> {};
template<class T> struct is_scoped_enum:
boost::conditional<
boost::is_enum<T>::value,
negation< boost::is_convertible<T, int> >,
boost::false_type
>::type
{
};
} // namespace detail
} // namespace endian
} // namespace boost
#endif // BOOST_ENDIAN_DETAIL_IS_SCOPED_ENUM_HPP_INCLUDED

View File

@@ -0,0 +1,40 @@
#ifndef BOOST_ENDIAN_DETAIL_IS_TRIVIALLY_COPYABLE_HPP_INCLUDED
#define BOOST_ENDIAN_DETAIL_IS_TRIVIALLY_COPYABLE_HPP_INCLUDED
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/config.hpp>
#include <boost/type_traits/has_trivial_copy.hpp>
#include <boost/type_traits/has_trivial_assign.hpp>
#include <boost/type_traits/has_trivial_destructor.hpp>
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
# include <type_traits>
#endif
namespace boost
{
namespace endian
{
namespace detail
{
#if !defined(BOOST_NO_CXX11_HDR_TYPE_TRAITS)
using std::is_trivially_copyable;
#else
template<class T> struct is_trivially_copyable: boost::integral_constant<bool,
boost::has_trivial_copy<T>::value && boost::has_trivial_assign<T>::value && boost::has_trivial_destructor<T>::value> {};
#endif
} // namespace detail
} // namespace endian
} // namespace boost
#endif // BOOST_ENDIAN_DETAIL_IS_TRIVIALLY_COPYABLE_HPP_INCLUDED

View File

@@ -0,0 +1,59 @@
#ifndef BOOST_ENDIAN_DETAIL_ORDER_HPP_INCLUDED
#define BOOST_ENDIAN_DETAIL_ORDER_HPP_INCLUDED
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/core/scoped_enum.hpp>
#if defined(__BYTE_ORDER__) && defined(__ORDER_LITTLE_ENDIAN__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
# define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER little
#elif defined(__BYTE_ORDER__) && defined(__ORDER_BIG_ENDIAN__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
# define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER big
#elif defined(__BYTE_ORDER__) && defined(__ORDER_PDP_ENDIAN__) && __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__
# error The Boost.Endian library does not support platforms with PDP endianness.
#elif defined(__LITTLE_ENDIAN__)
# define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER little
#elif defined(__BIG_ENDIAN__)
# define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER big
#elif defined(_MSC_VER) || defined(__i386__) || defined(__x86_64__)
# define BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER little
#else
# error The Boost.Endian library could not determine the endianness of this platform.
#endif
namespace boost
{
namespace endian
{
BOOST_SCOPED_ENUM_START(order)
{
big,
little,
native = BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER
}; BOOST_SCOPED_ENUM_END
} // namespace endian
} // namespace boost
#undef BOOST_ENDIAN_NATIVE_ORDER_INITIALIZER
#endif // BOOST_ENDIAN_DETAIL_ORDER_HPP_INCLUDED

View File

@@ -0,0 +1,118 @@
// boost/endian/endian.hpp -----------------------------------------------------------//
// Copyright Beman Dawes 2015
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/endian
#ifndef BOOST_ENDIAN_ENDIAN_HPP
#define BOOST_ENDIAN_ENDIAN_HPP
#ifndef BOOST_ENDIAN_DEPRECATED_NAMES
# error "<boost/endian/endian.hpp> is deprecated. Define BOOST_ENDIAN_DEPRECATED_NAMES to use."
#endif
#include <boost/config/header_deprecated.hpp>
BOOST_HEADER_DEPRECATED( "<boost/endian/arithmetic.hpp>" )
#include <boost/endian/arithmetic.hpp>
#include <boost/config.hpp>
namespace boost
{
namespace endian
{
typedef order endianness;
typedef align alignment;
# ifndef BOOST_NO_CXX11_TEMPLATE_ALIASES
template <BOOST_SCOPED_ENUM(order) Order, class T, std::size_t n_bits,
BOOST_SCOPED_ENUM(align) Align = align::no>
using endian = endian_arithmetic<Order, T, n_bits, Align>;
# endif
// unaligned big endian signed integer types
typedef endian_arithmetic< order::big, int_least8_t, 8 > big8_t;
typedef endian_arithmetic< order::big, int_least16_t, 16 > big16_t;
typedef endian_arithmetic< order::big, int_least32_t, 24 > big24_t;
typedef endian_arithmetic< order::big, int_least32_t, 32 > big32_t;
typedef endian_arithmetic< order::big, int_least64_t, 40 > big40_t;
typedef endian_arithmetic< order::big, int_least64_t, 48 > big48_t;
typedef endian_arithmetic< order::big, int_least64_t, 56 > big56_t;
typedef endian_arithmetic< order::big, int_least64_t, 64 > big64_t;
// unaligned big endian_arithmetic unsigned integer types
typedef endian_arithmetic< order::big, uint_least8_t, 8 > ubig8_t;
typedef endian_arithmetic< order::big, uint_least16_t, 16 > ubig16_t;
typedef endian_arithmetic< order::big, uint_least32_t, 24 > ubig24_t;
typedef endian_arithmetic< order::big, uint_least32_t, 32 > ubig32_t;
typedef endian_arithmetic< order::big, uint_least64_t, 40 > ubig40_t;
typedef endian_arithmetic< order::big, uint_least64_t, 48 > ubig48_t;
typedef endian_arithmetic< order::big, uint_least64_t, 56 > ubig56_t;
typedef endian_arithmetic< order::big, uint_least64_t, 64 > ubig64_t;
// unaligned little endian_arithmetic signed integer types
typedef endian_arithmetic< order::little, int_least8_t, 8 > little8_t;
typedef endian_arithmetic< order::little, int_least16_t, 16 > little16_t;
typedef endian_arithmetic< order::little, int_least32_t, 24 > little24_t;
typedef endian_arithmetic< order::little, int_least32_t, 32 > little32_t;
typedef endian_arithmetic< order::little, int_least64_t, 40 > little40_t;
typedef endian_arithmetic< order::little, int_least64_t, 48 > little48_t;
typedef endian_arithmetic< order::little, int_least64_t, 56 > little56_t;
typedef endian_arithmetic< order::little, int_least64_t, 64 > little64_t;
// unaligned little endian_arithmetic unsigned integer types
typedef endian_arithmetic< order::little, uint_least8_t, 8 > ulittle8_t;
typedef endian_arithmetic< order::little, uint_least16_t, 16 > ulittle16_t;
typedef endian_arithmetic< order::little, uint_least32_t, 24 > ulittle24_t;
typedef endian_arithmetic< order::little, uint_least32_t, 32 > ulittle32_t;
typedef endian_arithmetic< order::little, uint_least64_t, 40 > ulittle40_t;
typedef endian_arithmetic< order::little, uint_least64_t, 48 > ulittle48_t;
typedef endian_arithmetic< order::little, uint_least64_t, 56 > ulittle56_t;
typedef endian_arithmetic< order::little, uint_least64_t, 64 > ulittle64_t;
// unaligned native endian_arithmetic signed integer types
typedef endian_arithmetic< order::native, int_least8_t, 8 > native8_t;
typedef endian_arithmetic< order::native, int_least16_t, 16 > native16_t;
typedef endian_arithmetic< order::native, int_least32_t, 24 > native24_t;
typedef endian_arithmetic< order::native, int_least32_t, 32 > native32_t;
typedef endian_arithmetic< order::native, int_least64_t, 40 > native40_t;
typedef endian_arithmetic< order::native, int_least64_t, 48 > native48_t;
typedef endian_arithmetic< order::native, int_least64_t, 56 > native56_t;
typedef endian_arithmetic< order::native, int_least64_t, 64 > native64_t;
// unaligned native endian_arithmetic unsigned integer types
typedef endian_arithmetic< order::native, uint_least8_t, 8 > unative8_t;
typedef endian_arithmetic< order::native, uint_least16_t, 16 > unative16_t;
typedef endian_arithmetic< order::native, uint_least32_t, 24 > unative24_t;
typedef endian_arithmetic< order::native, uint_least32_t, 32 > unative32_t;
typedef endian_arithmetic< order::native, uint_least64_t, 40 > unative40_t;
typedef endian_arithmetic< order::native, uint_least64_t, 48 > unative48_t;
typedef endian_arithmetic< order::native, uint_least64_t, 56 > unative56_t;
typedef endian_arithmetic< order::native, uint_least64_t, 64 > unative64_t;
// aligned native endian_arithmetic typedefs are not provided because
// <cstdint> types are superior for this use case
typedef endian_arithmetic< order::big, int16_t, 16, align::yes > aligned_big16_t;
typedef endian_arithmetic< order::big, uint16_t, 16, align::yes > aligned_ubig16_t;
typedef endian_arithmetic< order::little, int16_t, 16, align::yes > aligned_little16_t;
typedef endian_arithmetic< order::little, uint16_t, 16, align::yes > aligned_ulittle16_t;
typedef endian_arithmetic< order::big, int32_t, 32, align::yes > aligned_big32_t;
typedef endian_arithmetic< order::big, uint32_t, 32, align::yes > aligned_ubig32_t;
typedef endian_arithmetic< order::little, int32_t, 32, align::yes > aligned_little32_t;
typedef endian_arithmetic< order::little, uint32_t, 32, align::yes > aligned_ulittle32_t;
typedef endian_arithmetic< order::big, int64_t, 64, align::yes > aligned_big64_t;
typedef endian_arithmetic< order::big, uint64_t, 64, align::yes > aligned_ubig64_t;
typedef endian_arithmetic< order::little, int64_t, 64, align::yes > aligned_little64_t;
typedef endian_arithmetic< order::little, uint64_t, 64, align::yes > aligned_ulittle64_t;
} // namespace endian
} // namespace boost
#endif //BOOST_ENDIAN_ENDIAN_HPP

View File

@@ -0,0 +1,18 @@
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; URL=doc/html/endian.html">
</head>
<body>
<p>
Automatic redirection failed, please go to
<a href="doc/html/endian.html">doc/html/endian.html</a>.
</p>
</body>
</html>
<!--
Copyright 2001 Beman Dawes
Distributed under the Boost Software License, Version 1.0.
(http://www.boost.org/LICENSE_1_0.txt)
-->

View File

@@ -0,0 +1,17 @@
{
"key": "endian",
"name": "Endian",
"authors": [
"Beman Dawes"
],
"maintainers": [
"Peter Dimov <pdimov -at- gmail.com>"
],
"description": "Types and conversion functions for correct byte ordering and more regardless of processor endianness.",
"category": [
"IO",
"Math",
"Miscellaneous"
],
"cxxstd": "03"
}

View File

@@ -0,0 +1,11 @@
# Copyright 2018, 2019 Peter Dimov
# Distributed under 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
include(BoostTestJamfile OPTIONAL RESULT_VARIABLE HAVE_BOOST_TEST)
if(HAVE_BOOST_TEST)
boost_test_jamfile(FILE Jamfile.v2 LINK_LIBRARIES Boost::endian Boost::core)
endif()

View File

@@ -0,0 +1,116 @@
# Boost Endian Library test Jamfile
# Copyright Beman Dawes 2006, 2013
# Copyright 2018, 2019 Peter Dimov
# Distributed under the Boost Software License, Version 1.0.
# See http://www.boost.org/LICENSE_1_0.txt
# See library home page at http://www.boost.org/libs/endian
import testing ;
project
: default-build
<warnings>all
: requirements
<toolset>msvc:<warnings-as-errors>on
<toolset>gcc:<cxxflags>-Wno-long-long
<toolset>gcc-4.4.7:<cxxflags>-Wno-strict-aliasing
<toolset>gcc-4.4.7:<cxxflags>-Wno-sign-compare
<toolset>gcc:<warnings-as-errors>on
<toolset>clang:<cxxflags>-Wno-long-long
<toolset>clang:<warnings-as-errors>on
;
local rule run-ni ( sources + )
{
return [ run $(sources) : : : <define>BOOST_ENDIAN_NO_INTRINSICS : $(sources[1]:B)_ni ] ;
}
run buffer_test.cpp ;
run-ni buffer_test.cpp ;
run endian_test.cpp ;
run-ni endian_test.cpp ;
run endian_operations_test.cpp ;
run-ni endian_operations_test.cpp ;
run endian_in_union_test.cpp ;
run conversion_test.cpp ;
run-ni conversion_test.cpp ;
run intrinsic_test.cpp ;
run quick.cpp ;
local allow-warnings =
"-<toolset>msvc:<warnings-as-errors>on"
"-<toolset>gcc:<warnings-as-errors>on"
"-<toolset>clang:<warnings-as-errors>on" ;
compile spirit_conflict_test.cpp : $(allow-warnings) ;
run endian_reverse_test.cpp ;
run-ni endian_reverse_test.cpp ;
run endian_load_test.cpp ;
run-ni endian_load_test.cpp ;
run endian_store_test.cpp ;
run-ni endian_store_test.cpp ;
run endian_ld_st_roundtrip_test.cpp ;
run-ni endian_ld_st_roundtrip_test.cpp ;
run endian_arithmetic_test.cpp
: : : "<toolset>gcc,<address-model>32:<cxxflags>-ffloat-store" ;
run endian_arithmetic_test.cpp : : :
"<toolset>gcc,<address-model>32:<cxxflags>-ffloat-store" <define>BOOST_ENDIAN_NO_INTRINSICS : endian_arithmetic_test_ni ;
run deprecated_test.cpp ;
compile endian_reverse_cx_test.cpp ;
compile endian_reverse_cx_test.cpp : <define>BOOST_ENDIAN_NO_INTRINSICS : endian_reverse_cx_test_ni ;
run load_convenience_test.cpp ;
run-ni load_convenience_test.cpp ;
run store_convenience_test.cpp ;
run-ni store_convenience_test.cpp ;
run float_typedef_test.cpp ;
run-ni float_typedef_test.cpp ;
run data_test.cpp ;
run-ni data_test.cpp ;
run endian_hpp_test.cpp ;
run-ni endian_hpp_test.cpp ;
run order_test.cpp ;
run endian_reverse_test2.cpp ;
run-ni endian_reverse_test2.cpp ;
run is_scoped_enum_test.cpp ;
run endian_reverse_test3.cpp ;
run-ni endian_reverse_test3.cpp ;
run endian_reverse_test4.cpp ;
run-ni endian_reverse_test4.cpp ;
run endian_reverse_test5.cpp ;
run-ni endian_reverse_test5.cpp ;
run packed_buffer_test.cpp ;
run arithmetic_buffer_test.cpp ;
run packed_arithmetic_test.cpp ;

View File

@@ -0,0 +1,45 @@
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/arithmetic.hpp>
#include <boost/endian/buffers.hpp>
#include <boost/core/lightweight_test.hpp>
template<class A, class B> void test()
{
A a( 5 );
BOOST_TEST_EQ( a.value(), 5 );
B& b = a;
BOOST_TEST_EQ( b.value(), 5 );
b = 14;
BOOST_TEST_EQ( b.value(), 14 );
BOOST_TEST_EQ( a.value(), 14 );
A const& ca = a;
BOOST_TEST_EQ( ca.value(), 14 );
B const& cb = b;
BOOST_TEST_EQ( cb.value(), 14 );
a = 31;
BOOST_TEST_EQ( a.value(), 31 );
BOOST_TEST_EQ( b.value(), 31 );
BOOST_TEST_EQ( ca.value(), 31 );
BOOST_TEST_EQ( cb.value(), 31 );
}
int main()
{
using namespace boost::endian;
test<big_int16_t, big_int16_buf_t>();
test<little_int32_t, little_int32_buf_t>();
return boost::report_errors();
}

View File

@@ -0,0 +1,233 @@
// benchmark.cpp ---------------------------------------------------------------------//
// Copyright Beman Dawes 2011
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#ifndef _SCL_SECURE_NO_WARNINGS
# define _SCL_SECURE_NO_WARNINGS
#endif
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#include <cstdlib>
#include <boost/endian/conversion.hpp>
#include <boost/random.hpp>
#include <boost/cstdint.hpp>
#include <boost/timer/timer.hpp>
#include <iostream>
#include <string>
using namespace boost;
using std::cout;
using std::cerr;
using std::endl;
using std::vector;
namespace
{
std::string command_args;
long long n_cases;
int places = 2;
bool verbose (false);
#ifndef BOOST_TWO_ARG
typedef int32_t (*timee_func)(int32_t);
#else
typedef void (*timee_func)(int32_t, int32_t&);
#endif
typedef boost::timer::nanosecond_type nanosecond_t;
//--------------------------------------------------------------------------------------//
nanosecond_t benchmark(timee_func timee, const char* msg,
nanosecond_t overhead = 0)
// Returns: total cpu time (i.e. system time + user time)
{
if (verbose)
cout << "\nRunning benchmark..." << endl;
int64_t sum = 0;
boost::timer::cpu_times times;
nanosecond_t cpu_time;
boost::timer::auto_cpu_timer t(places);
for (long long i = n_cases; i; --i)
{
# ifndef BOOST_TWO_ARG
sum += timee(static_cast<int32_t>(i)) ;
# else
int32_t y;
timee(static_cast<int32_t>(i), y);
sum += y;
# endif
}
t.stop();
times = t.elapsed();
cpu_time = (times.system + times.user) - overhead;
const long double sec = 1000000000.0L;
cout.setf(std::ios_base::fixed, std::ios_base::floatfield);
cout.precision(places);
cout << msg << " " << cpu_time / sec << endl;
if (verbose)
{
t.report();
cout << " Benchmark complete\n"
" sum is " << sum << endl;
}
return cpu_time;
}
void process_command_line(int argc, char * argv[])
{
for (int a = 0; a < argc; ++a)
{
command_args += argv[a];
if (a != argc-1)
command_args += ' ';
}
cout << command_args << '\n';;
if (argc >=2)
#ifndef _MSC_VER
n_cases = std::atoll(argv[1]);
#else
n_cases = _atoi64(argv[1]);
#endif
for (; argc > 2; ++argv, --argc)
{
if ( *(argv[2]+1) == 'p' )
places = atoi( argv[2]+2 );
else if ( *(argv[2]+1) == 'v' )
verbose = true;
else
{
cout << "Error - unknown option: " << argv[2] << "\n\n";
argc = -1;
break;
}
}
if (argc < 2)
{
cout << "Usage: benchmark n [Options]\n"
" The argument n specifies the number of test cases to run\n"
" Options:\n"
" -v Verbose messages\n"
" -p# Decimal places for times; default -p" << places << "\n";
return std::exit(1);
}
}
inline void inplace(int32_t& x)
{
x = (static_cast<uint32_t>(x) << 24)
| ((static_cast<uint32_t>(x) << 8) & 0x00ff0000)
| ((static_cast<uint32_t>(x) >> 8) & 0x0000ff00)
| (static_cast<uint32_t>(x) >> 24);
}
inline int32_t by_return(int32_t x)
{
return (static_cast<uint32_t>(x) << 24)
| ((static_cast<uint32_t>(x) << 8) & 0x00ff0000)
| ((static_cast<uint32_t>(x) >> 8) & 0x0000ff00)
| (static_cast<uint32_t>(x) >> 24);
}
inline int32_t by_return_intrinsic(int32_t x)
{
return BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(static_cast<uint32_t>(x));
}
inline int32_t by_return_pyry(int32_t x)
{
uint32_t step16;
step16 = static_cast<uint32_t>(x) << 16 | static_cast<uint32_t>(x) >> 16;
return
((static_cast<uint32_t>(step16) << 8) & 0xff00ff00)
| ((static_cast<uint32_t>(step16) >> 8) & 0x00ff00ff);
}
inline int32_t two_operand(int32_t x, int32_t& y)
{
return y = ((x << 24) & 0xff000000) | ((x << 8) & 0x00ff0000) | ((x >> 24) & 0x000000ff)
| ((x >> 8) & 0x0000ff00);
}
inline int32_t modify_noop(int32_t x)
{
int32_t v(x);
return v;
}
inline int32_t modify_inplace(int32_t x)
{
int32_t v(x);
inplace(v);
return v;
}
inline int32_t modify_by_return(int32_t x)
{
int32_t v(x);
return by_return(v);
}
inline int32_t modify_by_return_pyry(int32_t x)
{
int32_t v(x);
return by_return_pyry(v);
}
inline int32_t modify_by_return_intrinsic(int32_t x)
{
int32_t v(x);
return by_return_intrinsic(v);
}
inline void non_modify_assign(int32_t x, int32_t& y)
{
y = x;
}
inline void non_modify_two_operand(int32_t x, int32_t& y)
{
two_operand(x, y);
}
inline void non_modify_by_return(int32_t x, int32_t& y)
{
y = by_return(x);
}
} // unnamed namespace
//-------------------------------------- main() ---------------------------------------//
int main(int argc, char * argv[])
{
process_command_line(argc, argv);
nanosecond_t overhead;
#ifndef BOOST_TWO_ARG
overhead = benchmark(modify_noop, "modify no-op");
benchmark(modify_inplace, "modify in place"/*, overhead*/);
benchmark(modify_by_return, "modify by return"/*, overhead*/);
benchmark(modify_by_return_pyry, "modify by return_pyry"/*, overhead*/);
benchmark(modify_by_return_intrinsic, "modify by return_intrinsic"/*, overhead*/);
#else
overhead = benchmark(non_modify_assign, "non_modify_assign ");
benchmark(non_modify_two_operand, "non_modify_two_operand", overhead);
benchmark(non_modify_by_return, "non_modify_by_return ", overhead);
#endif
return 0;
}

View File

@@ -0,0 +1,337 @@
// buffer_test.cpp -------------------------------------------------------------------//
// Copyright Beman Dawes 2014
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/endian
//--------------------------------------------------------------------------------------//
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/buffers.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/cstdint.hpp>
#include <iostream>
#include <sstream>
#include <limits>
using namespace boost::endian;
using std::cout;
using std::endl;
namespace
{
// check_size ------------------------------------------------------------//
void check_size()
{
BOOST_TEST_EQ(sizeof(big_int8_buf_t), 1u);
BOOST_TEST_EQ(sizeof(big_int16_buf_t), 2u);
BOOST_TEST_EQ(sizeof(big_int24_buf_t), 3u);
BOOST_TEST_EQ(sizeof(big_int32_buf_t), 4u);
BOOST_TEST_EQ(sizeof(big_int40_buf_t), 5u);
BOOST_TEST_EQ(sizeof(big_int48_buf_t), 6u);
BOOST_TEST_EQ(sizeof(big_int56_buf_t), 7u);
BOOST_TEST_EQ(sizeof(big_int64_buf_t), 8u);
BOOST_TEST_EQ(sizeof(big_uint8_buf_t), 1u);
BOOST_TEST_EQ(sizeof(big_uint16_buf_t), 2u);
BOOST_TEST_EQ(sizeof(big_uint24_buf_t), 3u);
BOOST_TEST_EQ(sizeof(big_uint32_buf_t), 4u);
BOOST_TEST_EQ(sizeof(big_uint40_buf_t), 5u);
BOOST_TEST_EQ(sizeof(big_uint48_buf_t), 6u);
BOOST_TEST_EQ(sizeof(big_uint56_buf_t), 7u);
BOOST_TEST_EQ(sizeof(big_uint64_buf_t), 8u);
BOOST_TEST_EQ(sizeof(big_float32_buf_t), 4u);
BOOST_TEST_EQ(sizeof(big_float64_buf_t), 8u);
BOOST_TEST_EQ(sizeof(little_int8_buf_t), 1u);
BOOST_TEST_EQ(sizeof(little_int16_buf_t), 2u);
BOOST_TEST_EQ(sizeof(little_int24_buf_t), 3u);
BOOST_TEST_EQ(sizeof(little_int32_buf_t), 4u);
BOOST_TEST_EQ(sizeof(little_int40_buf_t), 5u);
BOOST_TEST_EQ(sizeof(little_int48_buf_t), 6u);
BOOST_TEST_EQ(sizeof(little_int56_buf_t), 7u);
BOOST_TEST_EQ(sizeof(little_int64_buf_t), 8u);
BOOST_TEST_EQ(sizeof(little_uint8_buf_t), 1u);
BOOST_TEST_EQ(sizeof(little_uint16_buf_t), 2u);
BOOST_TEST_EQ(sizeof(little_uint24_buf_t), 3u);
BOOST_TEST_EQ(sizeof(little_uint32_buf_t), 4u);
BOOST_TEST_EQ(sizeof(little_uint40_buf_t), 5u);
BOOST_TEST_EQ(sizeof(little_uint48_buf_t), 6u);
BOOST_TEST_EQ(sizeof(little_uint56_buf_t), 7u);
BOOST_TEST_EQ(sizeof(little_uint64_buf_t), 8u);
BOOST_TEST_EQ(sizeof(little_float32_buf_t), 4u);
BOOST_TEST_EQ(sizeof(little_float64_buf_t), 8u);
BOOST_TEST_EQ(sizeof(native_int8_buf_t), 1u);
BOOST_TEST_EQ(sizeof(native_int16_buf_t), 2u);
BOOST_TEST_EQ(sizeof(native_int24_buf_t), 3u);
BOOST_TEST_EQ(sizeof(native_int32_buf_t), 4u);
BOOST_TEST_EQ(sizeof(native_int40_buf_t), 5u);
BOOST_TEST_EQ(sizeof(native_int48_buf_t), 6u);
BOOST_TEST_EQ(sizeof(native_int56_buf_t), 7u);
BOOST_TEST_EQ(sizeof(native_int64_buf_t), 8u);
BOOST_TEST_EQ(sizeof(native_uint8_buf_t), 1u);
BOOST_TEST_EQ(sizeof(native_uint16_buf_t), 2u);
BOOST_TEST_EQ(sizeof(native_uint24_buf_t), 3u);
BOOST_TEST_EQ(sizeof(native_uint32_buf_t), 4u);
BOOST_TEST_EQ(sizeof(native_uint40_buf_t), 5u);
BOOST_TEST_EQ(sizeof(native_uint48_buf_t), 6u);
BOOST_TEST_EQ(sizeof(native_uint56_buf_t), 7u);
BOOST_TEST_EQ(sizeof(native_uint64_buf_t), 8u);
BOOST_TEST_EQ(sizeof(native_float32_buf_t), 4u);
BOOST_TEST_EQ(sizeof(native_float64_buf_t), 8u);
BOOST_TEST_EQ(sizeof(big_int8_buf_at), 1u);
BOOST_TEST_EQ(sizeof(big_int16_buf_at), 2u);
BOOST_TEST_EQ(sizeof(big_int32_buf_at), 4u);
BOOST_TEST_EQ(sizeof(big_int64_buf_at), 8u);
BOOST_TEST_EQ(sizeof(big_uint8_buf_at), 1u);
BOOST_TEST_EQ(sizeof(big_uint16_buf_at), 2u);
BOOST_TEST_EQ(sizeof(big_uint32_buf_at), 4u);
BOOST_TEST_EQ(sizeof(big_uint64_buf_at), 8u);
BOOST_TEST_EQ(sizeof(big_float32_buf_at), 4u);
BOOST_TEST_EQ(sizeof(big_float64_buf_at), 8u);
BOOST_TEST_EQ(sizeof(little_int8_buf_at), 1u);
BOOST_TEST_EQ(sizeof(little_int16_buf_at), 2u);
BOOST_TEST_EQ(sizeof(little_int32_buf_at), 4u);
BOOST_TEST_EQ(sizeof(little_int64_buf_at), 8u);
BOOST_TEST_EQ(sizeof(little_uint8_buf_at), 1u);
BOOST_TEST_EQ(sizeof(little_uint16_buf_at), 2u);
BOOST_TEST_EQ(sizeof(little_uint32_buf_at), 4u);
BOOST_TEST_EQ(sizeof(little_uint64_buf_at), 8u);
BOOST_TEST_EQ(sizeof(little_float32_buf_at), 4u);
BOOST_TEST_EQ(sizeof(little_float64_buf_at), 8u);
} // check_size
// test_inserter_and_extractor -----------------------------------------------------//
void test_inserter_and_extractor()
{
std::cout << "test inserter and extractor..." << std::endl;
big_uint64_buf_t bu64(0x010203040506070ULL);
little_uint64_buf_t lu64(0x010203040506070ULL);
boost::uint64_t x;
std::stringstream ss;
ss << bu64;
ss >> x;
BOOST_TEST_EQ(x, 0x010203040506070ULL);
ss.clear();
ss << lu64;
ss >> x;
BOOST_TEST_EQ(x, 0x010203040506070ULL);
ss.clear();
ss << 0x010203040506070ULL;
big_uint64_buf_t bu64z(0);
ss >> bu64z;
BOOST_TEST_EQ(bu64z.value(), bu64.value());
ss.clear();
ss << 0x010203040506070ULL;
little_uint64_buf_t lu64z(0);
ss >> lu64z;
BOOST_TEST_EQ(lu64z.value(), lu64.value());
std::cout << "test inserter and extractor complete" << std::endl;
}
template<class T> struct unaligned
{
char x;
T y;
};
template<class T> void test_buffer_type( typename T::value_type v1, typename T::value_type v2 )
{
T buffer( v1 );
BOOST_TEST_EQ( buffer.value(), v1 );
buffer = v2;
BOOST_TEST_EQ( buffer.value(), v2 );
unaligned<T> buffer2 = { 0, T( v1 ) };
BOOST_TEST_EQ( buffer2.y.value(), v1 );
buffer2.y = v2;
BOOST_TEST_EQ( buffer2.y.value(), v2 );
}
void test_construction_and_assignment()
{
std::cout << "test construction and assignment..." << std::endl;
test_buffer_type< big_int8_buf_at>( 0x01, -0x01 );
test_buffer_type<big_int16_buf_at>( 0x0102, -0x0102 );
test_buffer_type<big_int32_buf_at>( 0x01020304, -0x01020304 );
test_buffer_type<big_int64_buf_at>( 0x0102030405060708LL, -0x0102030405060708LL );
test_buffer_type< big_uint8_buf_at>( 0x01, 0xFE );
test_buffer_type<big_uint16_buf_at>( 0x0102, 0xFE02 );
test_buffer_type<big_uint32_buf_at>( 0x01020304, 0xFE020304 );
test_buffer_type<big_uint64_buf_at>( 0x0102030405060708ULL, 0xFE02030405060708ULL );
test_buffer_type<big_float32_buf_at>( +1.5f, -3.14f );
test_buffer_type<big_float64_buf_at>( +1.5, -3.14 );
test_buffer_type< little_int8_buf_at>( 0x01, -0x01 );
test_buffer_type<little_int16_buf_at>( 0x0102, -0x0102 );
test_buffer_type<little_int32_buf_at>( 0x01020304, -0x01020304 );
test_buffer_type<little_int64_buf_at>( 0x0102030405060708LL, -0x0102030405060708LL );
test_buffer_type< little_uint8_buf_at>( 0x01, 0xFE );
test_buffer_type<little_uint16_buf_at>( 0x0102, 0xFE02 );
test_buffer_type<little_uint32_buf_at>( 0x01020304, 0xFE020304 );
test_buffer_type<little_uint64_buf_at>( 0x0102030405060708ULL, 0xFE02030405060708ULL );
test_buffer_type<little_float32_buf_at>( +1.5f, -3.14f );
test_buffer_type<little_float64_buf_at>( +1.5, -3.14 );
test_buffer_type< big_int8_buf_t>( 0x01, -0x01 );
test_buffer_type<big_int16_buf_t>( 0x0102, -0x0102 );
test_buffer_type<big_int24_buf_t>( 0x010203, -0x010203 );
test_buffer_type<big_int32_buf_t>( 0x01020304, -0x01020304 );
test_buffer_type<big_int40_buf_t>( 0x0102030405LL, -0x0102030405LL );
test_buffer_type<big_int48_buf_t>( 0x010203040506LL, -0x010203040506LL );
test_buffer_type<big_int56_buf_t>( 0x01020304050607LL, -0x01020304050607LL );
test_buffer_type<big_int64_buf_t>( 0x0102030405060708LL, -0x0102030405060708LL );
test_buffer_type<big_float32_buf_t>( +1.5f, -3.14f );
test_buffer_type<big_float64_buf_t>( +1.5, -3.14 );
test_buffer_type< little_uint8_buf_t>( 0x01, 0xFE );
test_buffer_type<little_uint16_buf_t>( 0x0102, 0xFE02 );
test_buffer_type<little_uint24_buf_t>( 0x010203, 0xFE0203 );
test_buffer_type<little_uint32_buf_t>( 0x01020304, 0xFE020304 );
test_buffer_type<little_uint40_buf_t>( 0x0102030405ULL, 0xFE02030405ULL );
test_buffer_type<little_uint48_buf_t>( 0x010203040506ULL, 0xFE0203040506ULL );
test_buffer_type<little_uint56_buf_t>( 0x01020304050607ULL, 0xFE020304050607ULL );
test_buffer_type<little_uint64_buf_t>( 0x0102030405060708ULL, 0xFE02030405060708ULL );
test_buffer_type<little_float32_buf_t>( +1.5f, -3.14f );
test_buffer_type<little_float64_buf_t>( +1.5, -3.14 );
std::cout << "test construction and assignment complete" << std::endl;
}
template <typename T>
void test_boundary_values_()
{
test_buffer_type< endian_buffer<order::big, T, sizeof(T) * CHAR_BIT, align::no > >( std::numeric_limits<T>::min(), std::numeric_limits<T>::max() );
test_buffer_type< endian_buffer<order::little, T, sizeof(T) * CHAR_BIT, align::no > >( std::numeric_limits<T>::min(), std::numeric_limits<T>::max() );
test_buffer_type< endian_buffer<order::big, T, sizeof(T) * CHAR_BIT, align::yes> >( std::numeric_limits<T>::min(), std::numeric_limits<T>::max() );
test_buffer_type< endian_buffer<order::little, T, sizeof(T) * CHAR_BIT, align::yes> >( std::numeric_limits<T>::min(), std::numeric_limits<T>::max() );
}
void test_boundary_values()
{
std::cout << "test boundary values..." << std::endl;
// integer types
test_boundary_values_<signed char>();
test_boundary_values_<unsigned char>();
test_boundary_values_<signed short>();
test_boundary_values_<unsigned short>();
test_boundary_values_<signed int>();
test_boundary_values_<unsigned int>();
test_boundary_values_<signed long>();
test_boundary_values_<unsigned long>();
test_boundary_values_<signed long long>();
test_boundary_values_<unsigned long long>();
// character types
test_boundary_values_<char>();
#if !defined(BOOST_NO_CXX11_CHAR16_T)
test_boundary_values_<char16_t>();
#endif
#if !defined(BOOST_NO_CXX11_CHAR32_T)
test_boundary_values_<char32_t>();
#endif
// floating-point types
test_boundary_values_<float>();
test_boundary_values_<double>();
std::cout << "test boundary values complete" << std::endl;
}
} // unnamed namespace
//--------------------------------------------------------------------------------------//
int cpp_main(int, char *[])
{
cout << "byte swap intrinsics: " BOOST_ENDIAN_INTRINSIC_MSG << endl;
cout << " construct big endian aligned" << endl;
big_int32_buf_at x(1122334455);
cout << " assign to buffer from built-in integer" << endl;
x = 1234567890;
cout << " operator==(buffer.value(), built-in)" << endl;
bool b1(x.value() == 1234567890);
BOOST_TEST(b1);
cout << " construct little endian unaligned" << endl;
little_int32_buf_t x2(1122334455);
cout << " assign to buffer from built-in integer" << endl;
x2 = 1234567890;
cout << " operator==(buffer.value(), built-in)" << endl;
bool b2(x2.value() == 1234567890);
BOOST_TEST(b2);
check_size();
test_inserter_and_extractor();
test_construction_and_assignment();
test_boundary_values();
cout << " done" << endl;
return ::boost::report_errors();
}
int main( int argc, char* argv[] )
{
try
{
return cpp_main( argc, argv );
}
catch( std::exception const & x )
{
BOOST_ERROR( x.what() );
return boost::report_errors();
}
}
#include <boost/endian/detail/disable_warnings_pop.hpp>

View File

@@ -0,0 +1,18 @@
# Copyright 2018, 2019 Peter Dimov
# Distributed under 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
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_install_test LANGUAGES CXX)
find_package(boost_endian REQUIRED)
find_package(boost_core REQUIRED)
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::endian Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@@ -0,0 +1,39 @@
# Copyright 2018, 2019 Peter Dimov
# Distributed under 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
cmake_minimum_required(VERSION 3.5...3.16)
project(cmake_subdir_test LANGUAGES CXX)
add_subdirectory(../.. boostorg/endian)
# boost_add_subdir
function(boost_add_subdir name)
add_subdirectory(../../../${name} boostorg/${name})
endfunction()
# primary dependencies
boost_add_subdir(config)
boost_add_subdir(core)
boost_add_subdir(static_assert)
boost_add_subdir(type_traits)
# secondary dependencies
boost_add_subdir(assert)
boost_add_subdir(throw_exception)
# --target check
add_executable(quick ../quick.cpp)
target_link_libraries(quick Boost::endian Boost::core)
enable_testing()
add_test(quick quick)
add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --output-on-failure -C $<CONFIG>)

View File

@@ -0,0 +1,398 @@
// conversion_test.cpp ---------------------------------------------------------------//
// Copyright Beman Dawes 2010
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
//--------------------------------------------------------------------------------------//
#if defined(_MSC_VER)
# pragma warning( disable: 4127 ) // conditional expression is constant
# if _MSC_VER < 1500
# pragma warning( disable: 4267 ) // '+=': possible loss of data
# endif
#endif
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/conversion.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/type_traits/is_integral.hpp>
#include <boost/type_traits/make_unsigned.hpp>
#include <boost/static_assert.hpp>
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cstddef>
namespace be = boost::endian;
using std::cout;
using std::endl;
using boost::int8_t;
using boost::uint8_t;
using boost::int16_t;
using boost::uint16_t;
using boost::int32_t;
using boost::uint32_t;
using boost::int64_t;
using boost::uint64_t;
template <class T> inline T std_endian_reverse(T x) BOOST_NOEXCEPT
{
T tmp(x);
std::reverse( reinterpret_cast<unsigned char*>(&tmp), reinterpret_cast<unsigned char*>(&tmp) + sizeof(T) );
return tmp;
}
namespace
{
// values for tests
static unsigned char const test_value_bytes[] = { 0xF1, 0x02, 0xE3, 0x04, 0xD5, 0x06, 0xC7, 0x08 };
template<class T> void native_value( T& x )
{
BOOST_STATIC_ASSERT( boost::is_integral<T>::value && sizeof( T ) <= 8 );
std::memcpy( &x, test_value_bytes, sizeof( x ) );
}
template<class T> void little_value( T& x )
{
BOOST_STATIC_ASSERT( boost::is_integral<T>::value && sizeof( T ) <= 8 );
typedef typename boost::make_unsigned<T>::type U;
x = 0;
for( std::size_t i = 0; i < sizeof( x ); ++i )
{
x += static_cast<U>( test_value_bytes[ i ] ) << ( 8 * i );
}
}
template<class T> void big_value( T& x )
{
BOOST_STATIC_ASSERT( boost::is_integral<T>::value && sizeof( T ) <= 8 );
typedef typename boost::make_unsigned<T>::type U;
x = 0;
for( std::size_t i = 0; i < sizeof( x ); ++i )
{
x += static_cast<U>( test_value_bytes[ i ] ) << ( 8 * ( sizeof( x ) - i - 1 ) );
}
}
template <class T>
void test()
{
T native;
T big;
T little;
native_value(native);
big_value(big);
little_value(little);
// validate the values used by the tests below
if( be::order::native == be::order::big )
{
BOOST_TEST_EQ(native, big);
BOOST_TEST_EQ(::std_endian_reverse(native), little);
}
else
{
BOOST_TEST_EQ(::std_endian_reverse(native), big);
BOOST_TEST_EQ(native, little);
}
// value-by-value tests
// unconditional reverse
BOOST_TEST_EQ(be::endian_reverse(big), little);
BOOST_TEST_EQ(be::endian_reverse(little), big);
// conditional reverse
BOOST_TEST_EQ(be::native_to_big(native), big);
BOOST_TEST_EQ(be::native_to_little(native), little);
BOOST_TEST_EQ(be::big_to_native(big), native);
BOOST_TEST_EQ(be::little_to_native(little), native);
// generic conditional reverse
BOOST_TEST_EQ((be::conditional_reverse<be::order::big, be::order::big>(big)), big);
BOOST_TEST_EQ((be::conditional_reverse<be::order::little,
be::order::little>(little)), little);
BOOST_TEST_EQ((be::conditional_reverse<be::order::native,
be::order::native>(native)), native);
BOOST_TEST_EQ((be::conditional_reverse<be::order::big,
be::order::little>(big)), little);
BOOST_TEST_EQ((be::conditional_reverse<be::order::big,
be::order::native>(big)), native);
BOOST_TEST_EQ((be::conditional_reverse<be::order::little,
be::order::big>(little)), big);
BOOST_TEST_EQ((be::conditional_reverse<be::order::little,
be::order::native>(little)), native);
BOOST_TEST_EQ((be::conditional_reverse<be::order::native,
be::order::big>(native)), big);
BOOST_TEST_EQ((be::conditional_reverse<be::order::native,
be::order::little>(native)), little);
// runtime conditional reverse
BOOST_TEST_EQ((be::conditional_reverse(big, be::order::big, be::order::big)),
big);
BOOST_TEST_EQ((be::conditional_reverse(little, be::order::little,
be::order::little)), little);
BOOST_TEST_EQ((be::conditional_reverse(native, be::order::native,
be::order::native)), native);
BOOST_TEST_EQ((be::conditional_reverse(big, be::order::big,
be::order::little)), little);
BOOST_TEST_EQ((be::conditional_reverse(big, be::order::big,
be::order::native)), native);
BOOST_TEST_EQ((be::conditional_reverse(little, be::order::little,
be::order::big)), big);
BOOST_TEST_EQ((be::conditional_reverse(little, be::order::little,
be::order::native)), native);
BOOST_TEST_EQ((be::conditional_reverse(native, be::order::native,
be::order::big)), big);
BOOST_TEST_EQ((be::conditional_reverse(native, be::order::native,
be::order::little)), little);
// modify-in-place tests
T x;
// unconditional reverse
x = big; be::endian_reverse_inplace(x); BOOST_TEST_EQ(x, little);
x = little; be::endian_reverse_inplace(x); BOOST_TEST_EQ(x, big);
// conditional reverse
x = native; be::native_to_big_inplace(x); BOOST_TEST_EQ(x, big);
x = native; be::native_to_little_inplace(x); BOOST_TEST_EQ(x, little);
x = big; be::big_to_native_inplace(x); BOOST_TEST_EQ(x, native);
x = little; be::little_to_native_inplace(x); BOOST_TEST_EQ(x, native);
// generic conditional reverse
x = big; be::conditional_reverse_inplace<be::order::big, be::order::big>(x);
BOOST_TEST_EQ(x, big);
x = little; be::conditional_reverse_inplace<be::order::little, be::order::little>(x);
BOOST_TEST_EQ(x, little);
x = native; be::conditional_reverse_inplace<be::order::native, be::order::native>(x);
BOOST_TEST_EQ(x, native);
x = big; be::conditional_reverse_inplace<be::order::big, be::order::little>(x);
BOOST_TEST_EQ(x, little);
x = big; be::conditional_reverse_inplace<be::order::big, be::order::native>(x);
BOOST_TEST_EQ(x, native);
x = little; be::conditional_reverse_inplace<be::order::little, be::order::big>(x);
BOOST_TEST_EQ(x, big);
x = little; be::conditional_reverse_inplace<be::order::little, be::order::native>(x);
BOOST_TEST_EQ(x, native);
x = native; be::conditional_reverse_inplace<be::order::native, be::order::big>(x);
BOOST_TEST_EQ(x, big);
x = native; be::conditional_reverse_inplace<be::order::native, be::order::little>(x);
BOOST_TEST_EQ(x, little);
// runtime conditional reverse
x = big;
be::conditional_reverse_inplace(x, be::order::big, be::order::big);
BOOST_TEST_EQ(x, big);
x = little;
be::conditional_reverse_inplace(x, be::order::little, be::order::little);
BOOST_TEST_EQ(x, little);
x = native;
be::conditional_reverse_inplace(x, be::order::native, be::order::native);
BOOST_TEST_EQ(x, native);
x = big;
be::conditional_reverse_inplace(x, be::order::big, be::order::little);
BOOST_TEST_EQ(x, little);
x = big;
be::conditional_reverse_inplace(x, be::order::big, be::order::native);
BOOST_TEST_EQ(x, native);
x = little;
be::conditional_reverse_inplace(x, be::order::little, be::order::big);
BOOST_TEST_EQ(x, big);
x = little;
be::conditional_reverse_inplace(x, be::order::little, be::order::native);
BOOST_TEST_EQ(x, native);
x = native;
be::conditional_reverse_inplace(x, be::order::native, be::order::big);
BOOST_TEST_EQ(x, big);
x = native;
be::conditional_reverse_inplace(x, be::order::native, be::order::little);
BOOST_TEST_EQ(x, little);
}
//--------------------------------------------------------------------------------------//
template <class UDT>
void udt_test()
{
UDT udt, tmp;
int64_t big;
int64_t little;
int64_t native;
big_value(big);
little_value(little);
native_value(native);
udt.member1 = big;
udt.member2 = little;
udt.member3 = native;
tmp = be::conditional_reverse<be::order::big, be::order::little>(udt);
BOOST_TEST_EQ(tmp.member1, be::endian_reverse(big));
BOOST_TEST_EQ(tmp.member2, be::endian_reverse(little));
BOOST_TEST_EQ(tmp.member3, be::endian_reverse(native));
be::conditional_reverse_inplace<be::order::big, be::order::little>(udt);
BOOST_TEST_EQ(udt.member1, be::endian_reverse(big));
BOOST_TEST_EQ(udt.member2, be::endian_reverse(little));
BOOST_TEST_EQ(udt.member3, be::endian_reverse(native));
udt.member1 = big;
udt.member2 = little;
udt.member3 = native;
tmp.member1 = tmp.member2 = tmp.member3 = 0;
tmp = be::conditional_reverse<be::order::big, be::order::big>(udt);
BOOST_TEST_EQ(tmp.member1, big);
BOOST_TEST_EQ(tmp.member2, little);
BOOST_TEST_EQ(tmp.member3, native);
be::conditional_reverse_inplace<be::order::big, be::order::big>(udt);
BOOST_TEST_EQ(udt.member1, big);
BOOST_TEST_EQ(udt.member2, little);
BOOST_TEST_EQ(udt.member3, native);
}
} // unnamed namespace
//--------------------------------------------------------------------------------------//
// User-defined types
namespace user
{
// UDT1 supplies both endian_reverse and endian_reverse_inplace
struct UDT1
{
int64_t member1;
int64_t member2;
int64_t member3;
};
UDT1 endian_reverse(const UDT1& udt) BOOST_NOEXCEPT
{
UDT1 tmp;
tmp.member1 = boost::endian::endian_reverse(udt.member1);
tmp.member2 = boost::endian::endian_reverse(udt.member2);
tmp.member3 = boost::endian::endian_reverse(udt.member3);
return tmp;
}
void endian_reverse_inplace(UDT1& udt) BOOST_NOEXCEPT
{
boost::endian::endian_reverse_inplace(udt.member1);
boost::endian::endian_reverse_inplace(udt.member2);
boost::endian::endian_reverse_inplace(udt.member3);
}
// UDT2 supplies only endian_reverse
struct UDT2
{
int64_t member1;
int64_t member2;
int64_t member3;
};
UDT2 endian_reverse(const UDT2& udt) BOOST_NOEXCEPT
{
UDT2 tmp;
tmp.member1 = boost::endian::endian_reverse(udt.member1);
tmp.member2 = boost::endian::endian_reverse(udt.member2);
tmp.member3 = boost::endian::endian_reverse(udt.member3);
return tmp;
}
// UDT3 supplies neither endian_reverse nor endian_reverse_inplace,
// so udt_test<UDT3>() should fail to compile
struct UDT3
{
int64_t member1;
int64_t member2;
int64_t member3;
};
} // namespace user
//--------------------------------------------------------------------------------------//
int cpp_main(int, char * [])
{
if( be::order::native == be::order::little )
{
cout << "Little endian" << endl;
}
else if( be::order::native == be::order::big )
{
cout << "Big endian" << endl;
}
else
{
cout << "Unknown endian" << endl;
}
cout << "byte swap intrinsics: " BOOST_ENDIAN_INTRINSIC_MSG << endl;
//std::cerr << std::hex;
cout << "int8_t" << endl;
test<int8_t>();
cout << "uint8_t" << endl;
test<uint8_t>();
cout << "int16_t" << endl;
test<int16_t>();
cout << "uint16_t" << endl;
test<uint16_t>();
cout << "int32_t" << endl;
test<int32_t>();
cout << "uint32_t" << endl;
test<uint32_t>();
cout << "int64_t" << endl;
test<int64_t>();
cout << "uint64_t" << endl;
test<uint64_t>();
cout << "UDT 1" << endl;
udt_test<user::UDT1>();
cout << "UDT 2" << endl;
udt_test<user::UDT2>();
#ifdef BOOST_ENDIAN_COMPILE_FAIL
cout << "UDT 3" << endl;
udt_test<user::UDT3>(); // should fail to compile since has not endian_reverse()
#endif
return ::boost::report_errors();
}
int main( int argc, char* argv[] )
{
try
{
return cpp_main( argc, argv );
}
catch( std::exception const & x )
{
BOOST_ERROR( x.what() );
return boost::report_errors();
}
}
#include <boost/endian/detail/disable_warnings_pop.hpp>

View File

@@ -0,0 +1,95 @@
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/arithmetic.hpp>
#include <boost/endian/buffers.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <cstddef>
template<class U> void test()
{
{
U u( 0 );
unsigned char * p1 = u.data();
void * p2 = &u;
BOOST_TEST_EQ( p1, p2 );
}
{
U const u( 0 );
unsigned char const * p1 = u.data();
void const * p2 = &u;
BOOST_TEST_EQ( p1, p2 );
}
}
template<class T, std::size_t Bits> void test_unaligned()
{
using namespace boost::endian;
test< endian_buffer<order::big, T, Bits, align::no> >();
test< endian_buffer<order::little, T, Bits, align::no> >();
test< endian_buffer<order::native, T, Bits, align::no> >();
test< endian_arithmetic<order::big, T, Bits, align::no> >();
test< endian_arithmetic<order::little, T, Bits, align::no> >();
test< endian_arithmetic<order::native, T, Bits, align::no> >();
}
template<class T, std::size_t Bits> void test_aligned()
{
using namespace boost::endian;
test< endian_buffer<order::big, T, Bits, align::yes> >();
test< endian_buffer<order::little, T, Bits, align::yes> >();
test< endian_arithmetic<order::big, T, Bits, align::yes> >();
test< endian_arithmetic<order::little, T, Bits, align::yes> >();
}
int main()
{
test_unaligned<boost::int_least8_t, 8>();
test_unaligned<boost::int_least16_t, 16>();
test_unaligned<boost::int_least32_t, 24>();
test_unaligned<boost::int_least32_t, 32>();
test_unaligned<boost::int_least64_t, 40>();
test_unaligned<boost::int_least64_t, 48>();
test_unaligned<boost::int_least64_t, 56>();
test_unaligned<boost::int_least64_t, 64>();
test_unaligned<boost::uint_least8_t, 8>();
test_unaligned<boost::uint_least16_t, 16>();
test_unaligned<boost::uint_least32_t, 24>();
test_unaligned<boost::uint_least32_t, 32>();
test_unaligned<boost::uint_least64_t, 40>();
test_unaligned<boost::uint_least64_t, 48>();
test_unaligned<boost::uint_least64_t, 56>();
test_unaligned<boost::uint_least64_t, 64>();
test_unaligned<float, 32>();
test_unaligned<double, 64>();
test_aligned<boost::int8_t, 8>();
test_aligned<boost::int16_t, 16>();
test_aligned<boost::int32_t, 32>();
test_aligned<boost::int64_t, 64>();
test_aligned<boost::uint8_t, 8>();
test_aligned<boost::uint16_t, 16>();
test_aligned<boost::uint32_t, 32>();
test_aligned<boost::uint64_t, 64>();
test_aligned<float, 32>();
test_aligned<double, 64>();
return boost::report_errors();
}

View File

@@ -0,0 +1,196 @@
// deprecated_test.cpp ---------------------------------------------------------------//
// Copyright Beman Dawes 2014, 2015
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/endian
//--------------------------------------------------------------------------------------//
#include <boost/endian/detail/disable_warnings.hpp>
#define BOOST_ENDIAN_DEPRECATED_NAMES
#include <boost/endian/endian.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/cstdint.hpp>
#include <iostream>
#include <sstream>
using namespace boost::endian;
using std::cout;
using std::endl;
namespace
{
// check_size ----------------------------------------------------------------------//
void check_size()
{
BOOST_TEST_EQ(sizeof(big8_t), 1);
BOOST_TEST_EQ(sizeof(big16_t), 2);
BOOST_TEST_EQ(sizeof(big24_t), 3);
BOOST_TEST_EQ(sizeof(big32_t), 4);
BOOST_TEST_EQ(sizeof(big40_t), 5);
BOOST_TEST_EQ(sizeof(big48_t), 6);
BOOST_TEST_EQ(sizeof(big56_t), 7);
BOOST_TEST_EQ(sizeof(big64_t), 8);
BOOST_TEST_EQ(sizeof(ubig8_t), 1);
BOOST_TEST_EQ(sizeof(ubig16_t), 2);
BOOST_TEST_EQ(sizeof(ubig24_t), 3);
BOOST_TEST_EQ(sizeof(ubig32_t), 4);
BOOST_TEST_EQ(sizeof(ubig40_t), 5);
BOOST_TEST_EQ(sizeof(ubig48_t), 6);
BOOST_TEST_EQ(sizeof(ubig56_t), 7);
BOOST_TEST_EQ(sizeof(ubig64_t), 8);
BOOST_TEST_EQ(sizeof(little8_t), 1);
BOOST_TEST_EQ(sizeof(little16_t), 2);
BOOST_TEST_EQ(sizeof(little24_t), 3);
BOOST_TEST_EQ(sizeof(little32_t), 4);
BOOST_TEST_EQ(sizeof(little40_t), 5);
BOOST_TEST_EQ(sizeof(little48_t), 6);
BOOST_TEST_EQ(sizeof(little56_t), 7);
BOOST_TEST_EQ(sizeof(little64_t), 8);
BOOST_TEST_EQ(sizeof(ulittle8_t), 1);
BOOST_TEST_EQ(sizeof(ulittle16_t), 2);
BOOST_TEST_EQ(sizeof(ulittle24_t), 3);
BOOST_TEST_EQ(sizeof(ulittle32_t), 4);
BOOST_TEST_EQ(sizeof(ulittle40_t), 5);
BOOST_TEST_EQ(sizeof(ulittle48_t), 6);
BOOST_TEST_EQ(sizeof(ulittle56_t), 7);
BOOST_TEST_EQ(sizeof(ulittle64_t), 8);
BOOST_TEST_EQ(sizeof(native8_t), 1);
BOOST_TEST_EQ(sizeof(native16_t), 2);
BOOST_TEST_EQ(sizeof(native24_t), 3);
BOOST_TEST_EQ(sizeof(native32_t), 4);
BOOST_TEST_EQ(sizeof(native40_t), 5);
BOOST_TEST_EQ(sizeof(native48_t), 6);
BOOST_TEST_EQ(sizeof(native56_t), 7);
BOOST_TEST_EQ(sizeof(native64_t), 8);
BOOST_TEST_EQ(sizeof(unative8_t), 1);
BOOST_TEST_EQ(sizeof(unative16_t), 2);
BOOST_TEST_EQ(sizeof(unative24_t), 3);
BOOST_TEST_EQ(sizeof(unative32_t), 4);
BOOST_TEST_EQ(sizeof(unative40_t), 5);
BOOST_TEST_EQ(sizeof(unative48_t), 6);
BOOST_TEST_EQ(sizeof(unative56_t), 7);
BOOST_TEST_EQ(sizeof(unative64_t), 8);
BOOST_TEST_EQ(sizeof(aligned_big16_t), 2);
BOOST_TEST_EQ(sizeof(aligned_big32_t), 4);
BOOST_TEST_EQ(sizeof(aligned_big64_t), 8);
BOOST_TEST_EQ(sizeof(aligned_ubig16_t), 2);
BOOST_TEST_EQ(sizeof(aligned_ubig32_t), 4);
BOOST_TEST_EQ(sizeof(aligned_ubig64_t), 8);
BOOST_TEST_EQ(sizeof(aligned_little16_t), 2);
BOOST_TEST_EQ(sizeof(aligned_little32_t), 4);
BOOST_TEST_EQ(sizeof(aligned_little64_t), 8);
BOOST_TEST_EQ(sizeof(aligned_ulittle16_t), 2);
BOOST_TEST_EQ(sizeof(aligned_ulittle32_t), 4);
BOOST_TEST_EQ(sizeof(aligned_ulittle64_t), 8);
# ifndef BOOST_NO_CXX11_TEMPLATE_ALIASES
BOOST_TEST_EQ(sizeof(endian<endianness::big, int_least16_t, 16>), 2);
BOOST_TEST_EQ(sizeof(endian<endianness::big,
int_least16_t, 16, alignment::unaligned>), 2);
# endif
} // check_size
// test_inserter_and_extractor -----------------------------------------------------//
void test_inserter_and_extractor()
{
std::cout << "test inserter and extractor..." << std::endl;
ubig64_t bu64(0x010203040506070ULL);
ulittle64_t lu64(0x010203040506070ULL);
boost::uint64_t x;
std::stringstream ss;
ss << bu64;
ss >> x;
BOOST_TEST_EQ(x, 0x010203040506070ULL);
ss.clear();
ss << lu64;
ss >> x;
BOOST_TEST_EQ(x, 0x010203040506070ULL);
ss.clear();
ss << 0x010203040506070ULL;
ubig64_t bu64z(0);
ss >> bu64z;
BOOST_TEST_EQ(bu64z, bu64);
ss.clear();
ss << 0x010203040506070ULL;
ulittle64_t lu64z(0);
ss >> lu64z;
BOOST_TEST_EQ(lu64z, lu64);
std::cout << "test inserter and extractor complete" << std::endl;
}
} // unnamed namespace
//--------------------------------------------------------------------------------------//
int cpp_main(int, char *[])
{
cout << "byte swap intrinsics: " BOOST_ENDIAN_INTRINSIC_MSG << endl;
cout << " construct big endian aligned" << endl;
big32_t x(1122334455);
cout << " assign to buffer from built-in integer" << endl;
x = 1234567890;
cout << " operator==(buffer.value(), built-in)" << endl;
bool b1(x == 1234567890);
BOOST_TEST(b1);
cout << " construct little endian unaligned" << endl;
little32_t x2(1122334455);
cout << " assign to buffer from built-in integer" << endl;
x2 = 1234567890;
cout << " operator==(buffer.value(), built-in)" << endl;
bool b2(x2 == 1234567890);
BOOST_TEST(b2);
check_size();
test_inserter_and_extractor();
cout << " done" << endl;
return ::boost::report_errors();
}
int main( int argc, char* argv[] )
{
try
{
return cpp_main( argc, argv );
}
catch( std::exception const & x )
{
BOOST_ERROR( x.what() );
return boost::report_errors();
}
}
#include <boost/endian/detail/disable_warnings_pop.hpp>

View File

@@ -0,0 +1,164 @@
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/arithmetic.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <cstddef>
template<BOOST_SCOPED_ENUM(boost::endian::order) Order, BOOST_SCOPED_ENUM(boost::endian::align) Align, class T> void test_arithmetic_( T const& x )
{
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y( x );
BOOST_TEST_EQ( +x, +y );
BOOST_TEST_EQ( x + x, y + y );
BOOST_TEST_EQ( x - x, y - y );
BOOST_TEST_EQ( x * x, y * y );
BOOST_TEST_EQ( x / x, y / y );
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( x2 += x, y2 += y );
}
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( x2 -= x, y2 -= y );
}
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( x2 *= x, y2 *= y );
}
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( x2 /= x, y2 /= y );
}
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( ++x2, ++y2 );
}
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( --x2, --y2 );
}
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( x2++, y2++ );
}
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( x2--, y2-- );
}
}
template<BOOST_SCOPED_ENUM(boost::endian::order) Order, BOOST_SCOPED_ENUM(boost::endian::align) Align, class T> void test_integral_( T const& x )
{
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y( x );
BOOST_TEST_EQ( x % x, y % y );
BOOST_TEST_EQ( x & x, y & y );
BOOST_TEST_EQ( x | x, y | y );
BOOST_TEST_EQ( x ^ x, y ^ y );
BOOST_TEST_EQ( x << 1, y << 1 );
BOOST_TEST_EQ( x >> 1, y >> 1 );
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( x2 %= x, y2 %= y );
}
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( x2 &= x, y2 &= y );
}
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( x2 |= x, y2 |= y );
}
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( x2 ^= x, y2 ^= y );
}
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( x2 <<= 1, y2 <<= 1 );
}
{
T x2( x );
boost::endian::endian_arithmetic<Order, T, sizeof(T) * 8, Align> y2( y );
BOOST_TEST_EQ( x2 >>= 1, y2 >>= 1 );
}
}
template<class T> void test_arithmetic( T const& x )
{
test_arithmetic_<boost::endian::order::little, boost::endian::align::no>( x );
test_arithmetic_<boost::endian::order::little, boost::endian::align::yes>( x );
test_arithmetic_<boost::endian::order::big, boost::endian::align::no>( x );
test_arithmetic_<boost::endian::order::big, boost::endian::align::yes>( x );
}
template<class T> void test_integral( T const& x )
{
test_arithmetic( x );
test_integral_<boost::endian::order::little, boost::endian::align::no>( x );
test_integral_<boost::endian::order::little, boost::endian::align::yes>( x );
test_integral_<boost::endian::order::big, boost::endian::align::no>( x );
test_integral_<boost::endian::order::big, boost::endian::align::yes>( x );
}
int main()
{
test_integral( 0x7EF2 );
test_integral( 0x01020304u );
test_arithmetic( 3.1416f );
test_arithmetic( 3.14159 );
return boost::report_errors();
}

View File

@@ -0,0 +1,59 @@
// Copyright 2019 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
using namespace boost::endian;
// conversion
{
BOOST_TEST_EQ( endian_reverse( 0x01020304 ), 0x04030201 );
}
// buffers
{
little_uint32_buf_t v( 0x01020304 );
BOOST_TEST_EQ( v.data()[ 0 ], 0x04 );
BOOST_TEST_EQ( v.data()[ 1 ], 0x03 );
BOOST_TEST_EQ( v.data()[ 2 ], 0x02 );
BOOST_TEST_EQ( v.data()[ 3 ], 0x01 );
}
{
big_uint32_buf_t v( 0x01020304 );
BOOST_TEST_EQ( v.data()[ 0 ], 0x01 );
BOOST_TEST_EQ( v.data()[ 1 ], 0x02 );
BOOST_TEST_EQ( v.data()[ 2 ], 0x03 );
BOOST_TEST_EQ( v.data()[ 3 ], 0x04 );
}
// arithmetic
{
little_uint32_t v( 0x01020304 );
BOOST_TEST_EQ( v.data()[ 0 ], 0x04 );
BOOST_TEST_EQ( v.data()[ 1 ], 0x03 );
BOOST_TEST_EQ( v.data()[ 2 ], 0x02 );
BOOST_TEST_EQ( v.data()[ 3 ], 0x01 );
}
{
big_uint32_t v( 0x01020304 );
BOOST_TEST_EQ( v.data()[ 0 ], 0x01 );
BOOST_TEST_EQ( v.data()[ 1 ], 0x02 );
BOOST_TEST_EQ( v.data()[ 2 ], 0x03 );
BOOST_TEST_EQ( v.data()[ 3 ], 0x04 );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,81 @@
// endian_in_union_test.cpp -------------------------------------------------//
// Copyright Beman Dawes 2008
// Distributed under 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)
// See library home page at http://www.boost.org/libs/endian
//----------------------------------------------------------------------------//
#define BOOST_ENDIAN_FORCE_PODNESS
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/arithmetic.hpp>
using namespace boost::endian;
union U
{
big_int8_t big_8;
big_int16_t big_16;
big_int24_t big_24;
big_int32_t big_32;
big_int40_t big_40;
big_int48_t big_48;
big_int56_t big_56;
big_int64_t big_64;
big_uint8_t big_u8;
big_uint16_t big_u16;
big_uint24_t big_u24;
big_uint32_t big_u32;
big_uint40_t big_u40;
big_uint48_t big_u48;
big_uint56_t big_u56;
big_uint64_t big_u64;
little_int8_t little_8;
little_int16_t little_16;
little_int24_t little_24;
little_int32_t little_32;
little_int40_t little_40;
little_int48_t little_48;
little_int56_t little_56;
little_int64_t little_64;
little_uint8_t little_u8;
little_uint16_t little_u16;
little_uint24_t little_u24;
little_uint32_t little_u32;
little_uint40_t little_u40;
little_uint48_t little_u48;
little_uint56_t little_u56;
little_uint64_t little_u64;
native_int8_t native_8;
native_int16_t native_16;
native_int24_t native_24;
native_int32_t native_32;
native_int40_t native_40;
native_int48_t native_48;
native_int56_t native_56;
native_int64_t native_64;
native_uint8_t native_u8;
native_uint16_t native_u16;
native_uint24_t native_u24;
native_uint32_t native_u32;
native_uint40_t native_u40;
native_uint48_t native_u48;
native_uint56_t native_u56;
native_uint64_t native_u64;
};
U foo;
int main()
{
}

View File

@@ -0,0 +1,45 @@
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/conversion.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <cstddef>
template<class T> void test( T const& x )
{
{
unsigned char buffer[ sizeof(T) ];
boost::endian::endian_store<T, sizeof(T), boost::endian::order::little>( buffer, x );
T x2 = boost::endian::endian_load<T, sizeof(T), boost::endian::order::little>( buffer );
BOOST_TEST_EQ( x, x2 );
}
{
unsigned char buffer[ sizeof(T) ];
boost::endian::endian_store<T, sizeof(T), boost::endian::order::big>( buffer, x );
T x2 = boost::endian::endian_load<T, sizeof(T), boost::endian::order::big>( buffer );
BOOST_TEST_EQ( x, x2 );
}
}
enum E
{
e = 0xF1F2F3
};
int main()
{
test( 1.2e+34f );
test( -1.234e+56 );
test( e );
return boost::report_errors();
}

View File

@@ -0,0 +1,263 @@
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/conversion.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <cstddef>
int main()
{
{
unsigned char v[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 };
// 1 -> 1
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int8_t, 1, boost::endian::order::little>( v )), 0x01 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint8_t, 1, boost::endian::order::little>( v )), 0x01 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int8_t, 1, boost::endian::order::big>( v )), 0x01 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint8_t, 1, boost::endian::order::big>( v )), 0x01 );
// 1 -> 2
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int16_t, 1, boost::endian::order::little>( v )), 0x01 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint16_t, 1, boost::endian::order::little>( v )), 0x01 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int16_t, 1, boost::endian::order::big>( v )), 0x01 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint16_t, 1, boost::endian::order::big>( v )), 0x01 );
// 2 -> 2
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int16_t, 2, boost::endian::order::little>( v )), 0x0201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint16_t, 2, boost::endian::order::little>( v )), 0x0201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int16_t, 2, boost::endian::order::big>( v )), 0x0102 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint16_t, 2, boost::endian::order::big>( v )), 0x0102 );
// 1 -> 4
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 1, boost::endian::order::little>( v )), 0x01 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 1, boost::endian::order::little>( v )), 0x01 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 1, boost::endian::order::big>( v )), 0x01 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 1, boost::endian::order::big>( v )), 0x01 );
// 2 -> 4
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 2, boost::endian::order::little>( v )), 0x0201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 2, boost::endian::order::little>( v )), 0x0201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 2, boost::endian::order::big>( v )), 0x0102 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 2, boost::endian::order::big>( v )), 0x0102 );
// 3 -> 4
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 3, boost::endian::order::little>( v )), 0x030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 3, boost::endian::order::little>( v )), 0x030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 3, boost::endian::order::big>( v )), 0x010203 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 3, boost::endian::order::big>( v )), 0x010203 );
// 4 -> 4
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 4, boost::endian::order::little>( v )), 0x04030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 4, boost::endian::order::little>( v )), 0x04030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 4, boost::endian::order::big>( v )), 0x01020304 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 4, boost::endian::order::big>( v )), 0x01020304 );
// 1 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 1, boost::endian::order::little>( v )), 0x01 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 1, boost::endian::order::little>( v )), 0x01 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 1, boost::endian::order::big>( v )), 0x01 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 1, boost::endian::order::big>( v )), 0x01 );
// 2 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 2, boost::endian::order::little>( v )), 0x0201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 2, boost::endian::order::little>( v )), 0x0201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 2, boost::endian::order::big>( v )), 0x0102 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 2, boost::endian::order::big>( v )), 0x0102 );
// 3 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 3, boost::endian::order::little>( v )), 0x030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 3, boost::endian::order::little>( v )), 0x030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 3, boost::endian::order::big>( v )), 0x010203 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 3, boost::endian::order::big>( v )), 0x010203 );
// 4 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 4, boost::endian::order::little>( v )), 0x04030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 4, boost::endian::order::little>( v )), 0x04030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 4, boost::endian::order::big>( v )), 0x01020304 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 4, boost::endian::order::big>( v )), 0x01020304 );
// 5 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 5, boost::endian::order::little>( v )), 0x0504030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 5, boost::endian::order::little>( v )), 0x0504030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 5, boost::endian::order::big>( v )), 0x0102030405 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 5, boost::endian::order::big>( v )), 0x0102030405 );
// 6 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 6, boost::endian::order::little>( v )), 0x060504030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 6, boost::endian::order::little>( v )), 0x060504030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 6, boost::endian::order::big>( v )), 0x010203040506 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 6, boost::endian::order::big>( v )), 0x010203040506 );
// 7 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 7, boost::endian::order::little>( v )), 0x07060504030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 7, boost::endian::order::little>( v )), 0x07060504030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 7, boost::endian::order::big>( v )), 0x01020304050607 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 7, boost::endian::order::big>( v )), 0x01020304050607 );
// 8 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 8, boost::endian::order::little>( v )), 0x0807060504030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 8, boost::endian::order::little>( v )), 0x0807060504030201 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 8, boost::endian::order::big>( v )), 0x0102030405060708 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 8, boost::endian::order::big>( v )), 0x0102030405060708 );
}
{
unsigned char v[] = { 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8 };
// 1 -> 1
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int8_t, 1, boost::endian::order::little>( v )), -15 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint8_t, 1, boost::endian::order::little>( v )), 0xF1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int8_t, 1, boost::endian::order::big>( v )), -15 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint8_t, 1, boost::endian::order::big>( v )), 0xF1 );
// 1 -> 2
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int16_t, 1, boost::endian::order::little>( v )), -15 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint16_t, 1, boost::endian::order::little>( v )), 0xF1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int16_t, 1, boost::endian::order::big>( v )), -15 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint16_t, 1, boost::endian::order::big>( v )), 0xF1 );
// 2 -> 2
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int16_t, 2, boost::endian::order::little>( v )), -3343 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint16_t, 2, boost::endian::order::little>( v )), 0xF2F1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int16_t, 2, boost::endian::order::big>( v )), -3598 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint16_t, 2, boost::endian::order::big>( v )), 0xF1F2 );
// 1 -> 4
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 1, boost::endian::order::little>( v )), -15 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 1, boost::endian::order::little>( v )), 0xF1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 1, boost::endian::order::big>( v )), -15 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 1, boost::endian::order::big>( v )), 0xF1 );
// 2 -> 4
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 2, boost::endian::order::little>( v )), -3343 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 2, boost::endian::order::little>( v )), 0xF2F1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 2, boost::endian::order::big>( v )), -3598 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 2, boost::endian::order::big>( v )), 0xF1F2 );
// 3 -> 4
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 3, boost::endian::order::little>( v )), -789775 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 3, boost::endian::order::little>( v )), 0xF3F2F1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 3, boost::endian::order::big>( v )), -920845 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 3, boost::endian::order::big>( v )), 0xF1F2F3 );
// 4 -> 4
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 4, boost::endian::order::little>( v )), 0xF4F3F2F1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 4, boost::endian::order::little>( v )), 0xF4F3F2F1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int32_t, 4, boost::endian::order::big>( v )), 0xF1F2F3F4 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint32_t, 4, boost::endian::order::big>( v )), 0xF1F2F3F4 );
// 1 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 1, boost::endian::order::little>( v )), -15 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 1, boost::endian::order::little>( v )), 0xF1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 1, boost::endian::order::big>( v )), -15 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 1, boost::endian::order::big>( v )), 0xF1 );
// 2 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 2, boost::endian::order::little>( v )), -3343 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 2, boost::endian::order::little>( v )), 0xF2F1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 2, boost::endian::order::big>( v )), -3598 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 2, boost::endian::order::big>( v )), 0xF1F2 );
// 3 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 3, boost::endian::order::little>( v )), -789775 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 3, boost::endian::order::little>( v )), 0xF3F2F1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 3, boost::endian::order::big>( v )), -920845 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 3, boost::endian::order::big>( v )), 0xF1F2F3 );
// 4 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 4, boost::endian::order::little>( v )), -185339151 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 4, boost::endian::order::little>( v )), 0xF4F3F2F1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 4, boost::endian::order::big>( v )), -235736076 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 4, boost::endian::order::big>( v )), 0xF1F2F3F4 );
// 5 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 5, boost::endian::order::little>( v )), -43135012111 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 5, boost::endian::order::little>( v )), 0xF5F4F3F2F1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 5, boost::endian::order::big>( v )), -60348435211 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 5, boost::endian::order::big>( v )), 0xF1F2F3F4F5 );
// 6 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 6, boost::endian::order::little>( v )), -9938739662095 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 6, boost::endian::order::little>( v )), 0xF6F5F4F3F2F1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 6, boost::endian::order::big>( v )), -15449199413770 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 6, boost::endian::order::big>( v )), 0xF1F2F3F4F5F6 );
// 7 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 7, boost::endian::order::little>( v )), -2261738553347343 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 7, boost::endian::order::little>( v )), 0xF7F6F5F4F3F2F1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 7, boost::endian::order::big>( v )), -3954995049924873 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 7, boost::endian::order::big>( v )), 0xF1F2F3F4F5F6F7 );
// 8 -> 8
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 8, boost::endian::order::little>( v )), 0xF8F7F6F5F4F3F2F1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 8, boost::endian::order::little>( v )), 0xF8F7F6F5F4F3F2F1 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::int64_t, 8, boost::endian::order::big>( v )), 0xF1F2F3F4F5F6F7F8 );
BOOST_TEST_EQ( (boost::endian::endian_load<boost::uint64_t, 8, boost::endian::order::big>( v )), 0xF1F2F3F4F5F6F7F8 );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,503 @@
// endian_operations_test.cpp --------------------------------------------------------//
// Copyright Beman Dawes 2008
// Distributed under 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)
// See library home page at http://www.boost.org/libs/endian
//--------------------------------------------------------------------------------------//
// This test probes operator overloading, including interaction between
// operand types.
// See endian_test for tests of endianness correctness, size, and value.
#include <boost/endian/detail/disable_warnings.hpp>
#ifdef _MSC_VER
# pragma warning( disable : 4242 ) // conversion ..., possible loss of data
# pragma warning( disable : 4244 ) // conversion ..., possible loss of data
# pragma warning( disable : 4018 ) // signed/unsigned mismatch
# pragma warning( disable : 4365 ) // signed/unsigned mismatch
# pragma warning( disable : 4389 ) // signed/unsigned mismatch
#elif defined(__GNUC__)
# pragma GCC diagnostic ignored "-Wconversion"
#endif
#include <boost/endian/arithmetic.hpp>
#include <boost/type_traits/is_signed.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/cstdint.hpp>
#include <cassert>
#include <iostream>
#include <sstream>
namespace be = boost::endian;
template <class T>
struct value_type
{
typedef typename T::value_type type;
};
template<> struct value_type<char> { typedef char type; };
template<> struct value_type<unsigned char> { typedef unsigned char type; };
template<> struct value_type<signed char> { typedef signed char type; };
template<> struct value_type<short> { typedef short type; };
template<> struct value_type<unsigned short> { typedef unsigned short type; };
template<> struct value_type<int> { typedef int type; };
template<> struct value_type<unsigned int> { typedef unsigned int type; };
template<> struct value_type<long> { typedef long type; };
template<> struct value_type<unsigned long> { typedef unsigned long type; };
template<> struct value_type<long long> { typedef long long type; };
template<> struct value_type<unsigned long long> { typedef unsigned long long type; };
template <class T1, class T2>
struct default_construct
{
static void test()
{
T1 o1;
o1 = 1; // quiet warnings
if (o1) return; // quiet warnings
}
};
template <class T1, class T2>
struct construct
{
static void test()
{
T2 o2(1);
T1 o1(static_cast<T1>(o2));
++o1; // quiet gcc unused variable warning
}
};
template <class T1, class T2>
struct initialize
{
static void test()
{
T1 o2(2);
T1 o1 = o2;
++o1; // quiet gcc unused variable warning
}
};
template <class T1, class T2>
struct assign
{
static void test()
{
T2 o2;
o2 = 1;
T1 o1;
o1 = o2;
if (o1) return; // quiet warnings
}
};
template <class T1, class T2, bool SameSignedness>
struct do_relational
{
static void test()
{
T1 o1(1);
T2 o2(2);
BOOST_TEST( !(o1 == o2) );
BOOST_TEST( o1 != o2 );
BOOST_TEST( o1 < o2 );
BOOST_TEST( o1 <= o2 );
BOOST_TEST( !(o1 > o2) );
BOOST_TEST( !(o1 >= o2 ) );
}
};
template <class T1, class T2>
struct do_relational<T1, T2, false>
{
static void test()
{
}
};
template <class T1, class T2>
struct relational
{
static void test()
{
do_relational<T1, T2,
boost::is_signed<typename value_type<T1>::type>::value
== boost::is_signed<typename value_type<T2>::type>::value
>::test();
// do_relational<T1, T2, true>::test();
}
};
template <class T1, class T2>
struct op_plus
{
static void test()
{
T1 o1(1);
T2 o2(2);
T1 o3;
o3 = +o1;
o3 = o1 + o2;
o1 += o2;
if (o3) return; // quiet warnings
}
};
template <class T1, class T2>
struct op_star
{
static void test()
{
T1 o1(1);
T2 o2(2);
T1 o3;
o3 = o1 * o2;
o1 *= o2;
if (o3) return; // quiet warnings
}
};
template <template<class, class> class Test, class T1>
void op_test_aux()
{
Test<T1, char>::test();
Test<T1, unsigned char>::test();
Test<T1, signed char>::test();
Test<T1, short>::test();
Test<T1, unsigned short>::test();
Test<T1, int>::test();
Test<T1, unsigned int>::test();
Test<T1, long>::test();
Test<T1, unsigned long>::test();
Test<T1, long long>::test();
Test<T1, unsigned long long>::test();
Test<T1, be::big_int16_at>::test();
Test<T1, be::big_int32_at>::test();
Test<T1, be::big_int64_at>::test();
Test<T1, be::big_uint16_at>::test();
Test<T1, be::big_uint32_at>::test();
Test<T1, be::big_uint64_at>::test();
Test<T1, be::little_int16_at>::test();
Test<T1, be::little_int32_at>::test();
Test<T1, be::little_int64_at>::test();
Test<T1, be::little_uint16_at>::test();
Test<T1, be::little_uint32_at>::test();
Test<T1, be::little_uint64_at>::test();
Test<T1, be::big_int8_t>::test();
Test<T1, be::big_int16_t>::test();
Test<T1, be::big_int24_t>::test();
Test<T1, be::big_int32_t>::test();
Test<T1, be::big_int40_t>::test();
Test<T1, be::big_int48_t>::test();
Test<T1, be::big_int56_t>::test();
Test<T1, be::big_int64_t>::test();
Test<T1, be::big_uint8_t>::test();
Test<T1, be::big_uint16_t>::test();
Test<T1, be::big_uint24_t>::test();
Test<T1, be::big_uint32_t>::test();
Test<T1, be::big_uint40_t>::test();
Test<T1, be::big_uint64_t>::test();
Test<T1, be::little_int16_t>::test();
Test<T1, be::little_int24_t>::test();
Test<T1, be::little_int32_t>::test();
Test<T1, be::little_int64_t>::test();
Test<T1, be::little_uint16_t>::test();
Test<T1, be::little_uint32_t>::test();
Test<T1, be::little_uint56_t>::test();
Test<T1, be::little_uint64_t>::test();
Test<T1, be::native_int16_t>::test();
Test<T1, be::native_int24_t>::test();
Test<T1, be::native_int32_t>::test();
Test<T1, be::native_int64_t>::test();
#ifdef BOOST_LONG_ENDIAN_TEST
Test<T1, be::native_uint16_t>::test();
Test<T1, be::native_uint24_t>::test();
Test<T1, be::native_uint32_t>::test();
Test<T1, be::native_uint48_t>::test();
Test<T1, be::native_uint64_t>::test();
Test<T1, be::big_uint48_t>::test();
Test<T1, be::big_uint56_t>::test();
Test<T1, be::little_int8_t>::test();
Test<T1, be::little_int56_t>::test();
Test<T1, be::little_int40_t>::test();
Test<T1, be::little_int48_t>::test();
Test<T1, be::little_uint8_t>::test();
Test<T1, be::little_uint24_t>::test();
Test<T1, be::little_uint40_t>::test();
Test<T1, be::little_uint48_t>::test();
Test<T1, be::native_int8_t>::test();
Test<T1, be::native_int40_t>::test();
Test<T1, be::native_int48_t>::test();
Test<T1, be::native_int56_t>::test();
Test<T1, be::native_uint8_t>::test();
Test<T1, be::native_uint40_t>::test();
Test<T1, be::native_uint56_t>::test();
#endif
}
template <template<class, class> class Test>
void op_test()
{
op_test_aux<Test, char>();
op_test_aux<Test, unsigned char>();
op_test_aux<Test, signed char>();
op_test_aux<Test, short>();
op_test_aux<Test, unsigned short>();
op_test_aux<Test, int>();
op_test_aux<Test, unsigned int>();
op_test_aux<Test, long>();
op_test_aux<Test, unsigned long>();
op_test_aux<Test, long long>();
op_test_aux<Test, unsigned long long>();
op_test_aux<Test, be::big_int16_at>();
op_test_aux<Test, be::big_int32_at>();
op_test_aux<Test, be::big_int64_at>();
op_test_aux<Test, be::little_int16_at>();
op_test_aux<Test, be::little_int32_at>();
op_test_aux<Test, be::little_int64_at>();
#ifdef BOOST_LONG_ENDIAN_TEST
op_test_aux<Test, be::big_int8_t>();
op_test_aux<Test, be::big_int16_t>();
op_test_aux<Test, be::big_int24_t>();
op_test_aux<Test, be::big_int32_t>();
op_test_aux<Test, be::big_int40_t>();
op_test_aux<Test, be::big_int48_t>();
op_test_aux<Test, be::big_int56_t>();
op_test_aux<Test, be::big_int64_t>();
op_test_aux<Test, be::big_uint8_t>();
op_test_aux<Test, be::big_uint16_t>();
op_test_aux<Test, be::big_uint24_t>();
op_test_aux<Test, be::big_uint32_t>();
op_test_aux<Test, be::big_uint40_t>();
op_test_aux<Test, be::big_uint48_t>();
op_test_aux<Test, be::big_uint56_t>();
op_test_aux<Test, be::big_uint64_t>();
op_test_aux<Test, be::little_int8_t>();
op_test_aux<Test, be::little_int16_t>();
op_test_aux<Test, be::little_int24_t>();
op_test_aux<Test, be::little_int32_t>();
op_test_aux<Test, be::little_int40_t>();
op_test_aux<Test, be::little_int48_t>();
op_test_aux<Test, be::little_int56_t>();
op_test_aux<Test, be::little_int64_t>();
op_test_aux<Test, be::little_uint8_t>();
op_test_aux<Test, be::little_uint16_t>();
op_test_aux<Test, be::little_uint24_t>();
op_test_aux<Test, be::little_uint32_t>();
op_test_aux<Test, be::little_uint40_t>();
op_test_aux<Test, be::little_uint48_t>();
op_test_aux<Test, be::little_uint56_t>();
op_test_aux<Test, be::little_uint64_t>();
op_test_aux<Test, be::native_int8_t>();
op_test_aux<Test, be::native_int16_t>();
op_test_aux<Test, be::native_int24_t>();
op_test_aux<Test, be::native_int32_t>();
op_test_aux<Test, be::native_int40_t>();
op_test_aux<Test, be::native_int48_t>();
op_test_aux<Test, be::native_int56_t>();
op_test_aux<Test, be::native_int64_t>();
op_test_aux<Test, be::native_uint8_t>();
op_test_aux<Test, be::native_uint16_t>();
op_test_aux<Test, be::native_uint24_t>();
op_test_aux<Test, be::native_uint32_t>();
op_test_aux<Test, be::native_uint40_t>();
op_test_aux<Test, be::native_uint48_t>();
op_test_aux<Test, be::native_uint56_t>();
op_test_aux<Test, be::native_uint64_t>();
#endif
}
// test_inserter_and_extractor -----------------------------------------------------//
void test_inserter_and_extractor()
{
std::cout << "test inserter and extractor..." << std::endl;
be::big_uint64_t bu64(0x010203040506070ULL);
be::little_uint64_t lu64(0x010203040506070ULL);
boost::uint64_t x;
std::stringstream ss;
ss << bu64;
ss >> x;
BOOST_TEST_EQ(x, 0x010203040506070ULL);
ss.clear();
ss << lu64;
ss >> x;
BOOST_TEST_EQ(x, 0x010203040506070ULL);
ss.clear();
ss << 0x010203040506070ULL;
be::big_uint64_t bu64z(0);
ss >> bu64z;
BOOST_TEST_EQ(bu64z, bu64);
ss.clear();
ss << 0x010203040506070ULL;
be::little_uint64_t lu64z(0);
ss >> lu64z;
BOOST_TEST_EQ(lu64z, lu64);
std::cout << "test inserter and extractor complete" << std::endl;
}
void f_big_int32_ut(be::big_int32_t) {}
// main ------------------------------------------------------------------------------//
int cpp_main(int, char * [])
{
// make sure some simple things work
be::big_int32_t o1(1);
be::big_int32_t o2(2L);
be::big_int32_t o3(3LL);
be::big_int64_t o4(1);
std::clog << "set up test values\n";
be::big_int32_t big(12345);
be::little_uint16_t little_u(10);
be::big_int64_t result;
// this is the use case that is so irritating that it caused the endian
// constructors to be made non-explicit
std::clog << "\nf(1234) where f(big_int32_t)\n";
f_big_int32_ut(1234);
std::clog << "\nresult = big\n";
result = big;
std::clog << "\nresult = +big\n";
result = +big;
std::clog << "\nresult = -big\n";
result = -big;
std::clog << "\n++big\n";
++big;
std::clog << "\nresult = big++\n";
result = big++;
std::clog << "\n--big\n";
--big;
std::clog << "\nbig--\n";
big--;
std::clog << "\nresult = big * big\n";
result = big * big;
std::clog << "\nresult = big * big\n";
result = big * big;
std::clog << "\nresult = big * little_u\n";
result = big * little_u;
std::clog << "\nbig *= little_u\n";
big *= little_u;
std::clog << "\nresult = little_u * big\n";
result = little_u * big;
std::clog << "\nresult = big * 5\n";
result = big * 5;
std::clog << "\nbig *= 5\n";
big *= 5;
std::clog << "\nresult = 5 * big\n";
result = 5 * big;
std::clog << "\nresult = little_u * 5\n";
result = little_u * 5;
std::clog << "\nresult = 5 * little_u\n";
result = 5 * little_u;
std::clog << "\nresult = 5 * 10\n";
result = 5 * 10;
std::clog << "\n";
// test from Roland Schwarz that detected ambiguities; these ambiguities
// were eliminated by BOOST_ENDIAN_MINIMAL_COVER_OPERATORS
unsigned u;
be::little_uint32_t u1;
be::little_uint32_t u2;
u = 9;
u1 = 1;
std::clog << "\nu2 = u1 + u\n";
u2 = u1 + u;
std::clog << "\n";
// variations to detect ambiguities
be::little_uint32_t u3 = u1 + 5;
u3 = u1 + 5u;
if (u1 == 5)
{}
if (u1 == 5u)
{}
u1 += 5;
u1 += 5u;
u2 = u1 + 5;
u2 = u1 + 5u;
// one more wrinkle
be::little_uint16_t u4(3);
u4 = 3;
std::clog << "\nu2 = u1 + u4\n";
u2 = u1 + u4;
std::clog << "\n";
test_inserter_and_extractor();
// perform the indicated test on ~60*60 operand types
op_test<default_construct>();
op_test<construct>(); // includes copy construction
op_test<initialize>();
op_test<assign>();
op_test<relational>();
op_test<op_plus>();
op_test<op_star>();
return boost::report_errors();
}
int main( int argc, char* argv[] )
{
try
{
return cpp_main( argc, argv );
}
catch( std::exception const & x )
{
BOOST_ERROR( x.what() );
return boost::report_errors();
}
}

View File

@@ -0,0 +1,40 @@
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/conversion.hpp>
#include <boost/config/pragma_message.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#if defined(BOOST_NO_CXX11_CONSTEXPR)
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_NO_CXX11_CONSTEXPR is defined")
#elif defined(BOOST_ENDIAN_NO_INTRINSICS) && defined(BOOST_NO_CXX14_CONSTEXPR)
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_ENDIAN_NO_INTRINSICS and BOOST_NO_CXX14_CONSTEXPR are defined")
#elif !defined(BOOST_ENDIAN_NO_INTRINSICS) && !defined(BOOST_ENDIAN_CONSTEXPR_INTRINSICS)
BOOST_PRAGMA_MESSAGE("Test skipped because BOOST_ENDIAN_NO_INTRINSICS and BOOST_ENDIAN_CONSTEXPR_INTRINSICS are not defined")
#else
using namespace boost::endian;
#define STATIC_ASSERT(expr) static_assert(expr, #expr)
STATIC_ASSERT( endian_reverse( static_cast<boost::uint8_t>( 0x01 ) ) == 0x01 );
STATIC_ASSERT( endian_reverse( static_cast<boost::uint16_t>( 0x0102 ) ) == 0x0201 );
STATIC_ASSERT( endian_reverse( static_cast<boost::uint32_t>( 0x01020304 ) ) == 0x04030201 );
STATIC_ASSERT( endian_reverse( static_cast<boost::uint64_t>( 0x0102030405060708 ) ) == 0x0807060504030201 );
STATIC_ASSERT( big_to_native( native_to_big( 0x01020304 ) ) == 0x01020304 );
STATIC_ASSERT( little_to_native( native_to_little( 0x01020304 ) ) == 0x01020304 );
STATIC_ASSERT( native_to_big( 0x01020304 ) == (conditional_reverse<order::native, order::big>( 0x01020304 )) );
STATIC_ASSERT( native_to_big( 0x01020304 ) == conditional_reverse( 0x01020304, order::native, order::big ) );
#endif

View File

@@ -0,0 +1,223 @@
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#if defined(_MSC_VER)
# pragma warning( disable: 4309 ) // static_cast: truncation of constant value
#endif
#include <boost/endian/conversion.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <cstddef>
template<class T, std::size_t N = sizeof(T)> struct test_value
{
};
template<class T> struct test_value<T, 1>
{
static const T v1 = static_cast<T>( 0x1F );
static const T w1 = static_cast<T>( 0x1F );
static const T v2 = static_cast<T>( 0xF1 );
static const T w2 = static_cast<T>( 0xF1 );
};
template<class T> T const test_value<T, 1>::v1;
template<class T> T const test_value<T, 1>::w1;
template<class T> T const test_value<T, 1>::v2;
template<class T> T const test_value<T, 1>::w2;
template<class T> struct test_value<T, 2>
{
static const T v1 = static_cast<T>( 0x1F2E );
static const T w1 = static_cast<T>( 0x2E1F );
static const T v2 = static_cast<T>( 0xF1E2 );
static const T w2 = static_cast<T>( 0xE2F1 );
};
template<class T> T const test_value<T, 2>::v1;
template<class T> T const test_value<T, 2>::w1;
template<class T> T const test_value<T, 2>::v2;
template<class T> T const test_value<T, 2>::w2;
template<class T> struct test_value<T, 4>
{
static const T v1 = static_cast<T>( 0x1F2E3D4C );
static const T w1 = static_cast<T>( 0x4C3D2E1F );
static const T v2 = static_cast<T>( 0xF1E2D3C4 );
static const T w2 = static_cast<T>( 0xC4D3E2F1 );
};
template<class T> T const test_value<T, 4>::v1;
template<class T> T const test_value<T, 4>::w1;
template<class T> T const test_value<T, 4>::v2;
template<class T> T const test_value<T, 4>::w2;
template<class T> struct test_value<T, 8>
{
static const T v1 = static_cast<T>( 0x1F2E3D4C5B6A7988ull );
static const T w1 = static_cast<T>( 0x88796A5B4C3D2E1Full );
static const T v2 = static_cast<T>( 0xF1E2D3C4B5A69788ull );
static const T w2 = static_cast<T>( 0x8897A6B5C4D3E2F1ull );
};
template<class T> T const test_value<T, 8>::v1;
template<class T> T const test_value<T, 8>::w1;
template<class T> T const test_value<T, 8>::v2;
template<class T> T const test_value<T, 8>::w2;
#if defined(BOOST_HAS_INT128)
template<class T> struct test_value<T, 16>
{
static const T v1 = static_cast<T>( 0x1F2E3D4C5B6A7988ull ) << 64 | static_cast<T>( 0xF1E2D3C4B5A69780ull );
static const T w1 = static_cast<T>( 0x8097A6B5C4D3E2F1ull ) << 64 | static_cast<T>( 0x88796A5B4C3D2E1Full );
static const T v2 = static_cast<T>( 0xF1E2D3C4B5A69788ull ) << 64 | static_cast<T>( 0x1F2E3D4C5B6A7980ull );
static const T w2 = static_cast<T>( 0x80796A5B4C3D2E1Full ) << 64 | static_cast<T>( 0x8897A6B5C4D3E2F1ull );
};
template<class T> T const test_value<T, 16>::v1;
template<class T> T const test_value<T, 16>::w1;
template<class T> T const test_value<T, 16>::v2;
template<class T> T const test_value<T, 16>::w2;
#endif // #if defined(BOOST_HAS_INT128)
template<class T> void test()
{
using boost::endian::endian_reverse;
using boost::endian::endian_reverse_inplace;
{
T t1 = test_value<T>::v1;
T t2 = endian_reverse( t1 );
BOOST_TEST_EQ( t2, test_value<T>::w1 );
T t3 = endian_reverse( t2 );
BOOST_TEST_EQ( t3, t1 );
T t4 = t1;
endian_reverse_inplace( t4 );
BOOST_TEST_EQ( t4, test_value<T>::w1 );
endian_reverse_inplace( t4 );
BOOST_TEST_EQ( t4, t1 );
}
{
T t1 = test_value<T>::v2;
T t2 = endian_reverse( t1 );
BOOST_TEST_EQ( t2, test_value<T>::w2 );
T t3 = endian_reverse( t2 );
BOOST_TEST_EQ( t3, t1 );
T t4 = t1;
endian_reverse_inplace( t4 );
BOOST_TEST_EQ( t4, test_value<T>::w2 );
endian_reverse_inplace( t4 );
BOOST_TEST_EQ( t4, t1 );
}
}
template<class T> void test_np()
{
using boost::endian::endian_reverse;
using boost::endian::endian_reverse_inplace;
{
T t1 = test_value<T>::v1;
T t2 = endian_reverse( t1 );
BOOST_TEST( t2 == test_value<T>::w1 );
T t3 = endian_reverse( t2 );
BOOST_TEST( t3 == t1 );
T t4 = t1;
endian_reverse_inplace( t4 );
BOOST_TEST( t4 == test_value<T>::w1 );
endian_reverse_inplace( t4 );
BOOST_TEST( t4 == t1 );
}
{
T t1 = test_value<T>::v2;
T t2 = endian_reverse( t1 );
BOOST_TEST( t2 == test_value<T>::w2 );
T t3 = endian_reverse( t2 );
BOOST_TEST( t3 == t1 );
T t4 = t1;
endian_reverse_inplace( t4 );
BOOST_TEST( t4 == test_value<T>::w2 );
endian_reverse_inplace( t4 );
BOOST_TEST( t4 == t1 );
}
}
int main()
{
test<boost::int8_t>();
test<boost::uint8_t>();
test<boost::int16_t>();
test<boost::uint16_t>();
test<boost::int32_t>();
test<boost::uint32_t>();
test<boost::int64_t>();
test<boost::uint64_t>();
test<char>();
test<unsigned char>();
test<signed char>();
test<short>();
test<unsigned short>();
test<int>();
test<unsigned int>();
test<long>();
test<unsigned long>();
test<long long>();
test<unsigned long long>();
#if !defined(BOOST_NO_CXX11_CHAR16_T)
test<char16_t>();
#endif
#if !defined(BOOST_NO_CXX11_CHAR32_T)
test<char32_t>();
#endif
#if defined(BOOST_HAS_INT128)
test_np<boost::int128_type>();
test_np<boost::uint128_type>();
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,39 @@
// Copyright 2019, 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/conversion.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/type_traits/enable_if.hpp>
#include <boost/type_traits/is_same.hpp>
#include <boost/cstdint.hpp>
namespace N
{
struct X
{
boost::uint32_t m;
};
template<class T> typename boost::enable_if_<boost::is_same<T, X>::value, T>::type endian_reverse( T x )
{
using boost::endian::endian_reverse;
X r = { endian_reverse( x.m ) };
return r;
}
} // namespace N
int main()
{
using namespace boost::endian;
N::X x1 = { 0x01020304 };
N::X x2 = endian_reverse( x1 );
BOOST_TEST_EQ( x2.m, 0x04030201 );
return boost::report_errors();
}

View File

@@ -0,0 +1,83 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/conversion.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <cstddef>
template<class T> void test_reverse( T x )
{
using boost::endian::endian_reverse;
T x2( x );
x2 = endian_reverse( endian_reverse( x2 ) );
BOOST_TEST( x == x2 );
x2 = boost::endian::native_to_little( boost::endian::little_to_native( x2 ) );
BOOST_TEST( x == x2 );
x2 = boost::endian::native_to_big( boost::endian::big_to_native( x2 ) );
BOOST_TEST( x == x2 );
}
template<class T> void test_reverse_inplace( T x )
{
using boost::endian::endian_reverse_inplace;
T x2( x );
endian_reverse_inplace( x2 );
endian_reverse_inplace( x2 );
BOOST_TEST( x == x2 );
boost::endian::native_to_little_inplace( x2 );
boost::endian::little_to_native_inplace( x2 );
BOOST_TEST( x == x2 );
boost::endian::native_to_big_inplace( x2 );
boost::endian::big_to_native_inplace( x2 );
BOOST_TEST( x == x2 );
}
enum E1 { e1 };
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
enum E2: long { e2 };
enum class E3 { e3 };
enum class E4: long { e4 };
#endif
int main()
{
test_reverse( 1 );
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
test_reverse( E3::e3 );
test_reverse( E4::e4 );
#endif
test_reverse_inplace( 1 );
test_reverse_inplace( true );
test_reverse_inplace( 1.0f );
test_reverse_inplace( 1.0 );
test_reverse_inplace( e1 );
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
test_reverse_inplace( e2 );
test_reverse_inplace( E3::e3 );
test_reverse_inplace( E4::e4 );
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,74 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/conversion.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <cstddef>
template<class T> void test_reverse_inplace( T x )
{
using boost::endian::endian_reverse_inplace;
T x2( x );
endian_reverse_inplace( x2 );
endian_reverse_inplace( x2 );
BOOST_TEST( x == x2 );
boost::endian::native_to_little_inplace( x2 );
boost::endian::little_to_native_inplace( x2 );
BOOST_TEST( x == x2 );
boost::endian::native_to_big_inplace( x2 );
boost::endian::big_to_native_inplace( x2 );
BOOST_TEST( x == x2 );
}
struct X
{
int v1_;
int v2_;
};
inline bool operator==( X const& x1, X const& x2 )
{
return x1.v1_ == x2.v1_ && x1.v2_ == x2.v2_;
}
inline void endian_reverse_inplace( X & x )
{
using boost::endian::endian_reverse_inplace;
endian_reverse_inplace( x.v1_ );
endian_reverse_inplace( x.v2_ );
}
struct Y
{
X x1_;
X x2_[ 2 ];
};
inline bool operator==( Y const& y1, Y const& y2 )
{
return y1.x1_ == y2.x1_ && y1.x2_[0] == y2.x2_[0] && y1.x2_[1] == y2.x2_[1];
}
inline void endian_reverse_inplace( Y & y )
{
using boost::endian::endian_reverse_inplace;
endian_reverse_inplace( y.x1_ );
endian_reverse_inplace( y.x2_ );
}
int main()
{
Y y = { { 1, 2 }, { { 3, 4 }, { 5, 6 } } };
test_reverse_inplace( y );
return boost::report_errors();
}

View File

@@ -0,0 +1,30 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/conversion.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <cstddef>
int main()
{
int v[] = { 1, 2 };
boost::endian::endian_reverse_inplace( v );
boost::endian::endian_reverse_inplace( v );
BOOST_TEST_EQ( v[0], 1 );
BOOST_TEST_EQ( v[1], 2 );
boost::endian::native_to_little_inplace( v );
boost::endian::little_to_native_inplace( v );
BOOST_TEST_EQ( v[0], 1 );
BOOST_TEST_EQ( v[1], 2 );
boost::endian::native_to_big_inplace( v );
boost::endian::big_to_native_inplace( v );
BOOST_TEST_EQ( v[0], 1 );
BOOST_TEST_EQ( v[1], 2 );
return boost::report_errors();
}

View File

@@ -0,0 +1,310 @@
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/conversion.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <cstddef>
#include <ostream>
#include <iomanip>
class byte_span
{
private:
unsigned char const * p_;
std::size_t n_;
public:
byte_span( unsigned char const * p, std::size_t n ): p_( p ), n_( n )
{
}
template<std::size_t N> explicit byte_span( unsigned char const (&a)[ N ] ): p_( a ), n_( N )
{
}
bool operator==( byte_span const& r ) const
{
if( n_ != r.n_ ) return false;
for( std::size_t i = 0; i < n_; ++i )
{
if( p_[ i ] != r.p_[ i ] ) return false;
}
return true;
}
friend std::ostream& operator<<( std::ostream& os, byte_span s )
{
if( s.n_ == 0 ) return os;
os << std::hex << std::setfill( '0' ) << std::uppercase;
os << std::setw( 2 ) << +s.p_[ 0 ];
for( std::size_t i = 1; i < s.n_; ++i )
{
os << ':' << std::setw( 2 ) << +s.p_[ i ];
}
os << std::dec << std::setfill( ' ' ) << std::nouppercase;;
return os;
}
};
template<class T> void test_1()
{
{
unsigned char v[] = { 0xAA, 0xAA };
boost::endian::endian_store<T, 1, boost::endian::order::little>( v, 0x01 );
unsigned char w[] = { 0x01, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
{
unsigned char v[] = { 0xAA, 0xAA };
boost::endian::endian_store<T, 1, boost::endian::order::big>( v, 0x01 );
unsigned char w[] = { 0x01, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
}
template<class T> void test_2()
{
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 2, boost::endian::order::little>( v, 0x0102 );
unsigned char w[] = { 0x02, 0x01, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 2, boost::endian::order::big>( v, 0x0102 );
unsigned char w[] = { 0x01, 0x02, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
}
template<class T> void test_3()
{
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 3, boost::endian::order::little>( v, 0x010203 );
unsigned char w[] = { 0x03, 0x02, 0x01, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 3, boost::endian::order::big>( v, 0x010203 );
unsigned char w[] = { 0x01, 0x02, 0x03, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
}
template<class T> void test_4()
{
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 4, boost::endian::order::little>( v, 0x01020304 );
unsigned char w[] = { 0x04, 0x03, 0x02, 0x01, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 4, boost::endian::order::big>( v, 0x01020304 );
unsigned char w[] = { 0x01, 0x02, 0x03, 0x04, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
}
template<class T> void test_5()
{
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 5, boost::endian::order::little>( v, 0x0102030405 );
unsigned char w[] = { 0x05, 0x04, 0x03, 0x02, 0x01, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 5, boost::endian::order::big>( v, 0x0102030405 );
unsigned char w[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
}
template<class T> void test_6()
{
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 6, boost::endian::order::little>( v, 0x010203040506 );
unsigned char w[] = { 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 6, boost::endian::order::big>( v, 0x010203040506 );
unsigned char w[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
}
template<class T> void test_7()
{
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 7, boost::endian::order::little>( v, 0x01020304050607 );
unsigned char w[] = { 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 7, boost::endian::order::big>( v, 0x01020304050607 );
unsigned char w[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
}
template<class T> void test_8()
{
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 8, boost::endian::order::little>( v, 0x0102030405060708 );
unsigned char w[] = { 0x08, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
{
unsigned char v[] = { 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA, 0xAA };
boost::endian::endian_store<T, 8, boost::endian::order::big>( v, 0x0102030405060708 );
unsigned char w[] = { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0xAA };
BOOST_TEST_EQ( byte_span( v ), byte_span( w ) );
}
}
int main()
{
// 1
test_1<boost::int8_t>();
test_1<boost::uint8_t>();
test_1<boost::int16_t>();
test_1<boost::uint16_t>();
test_1<boost::int32_t>();
test_1<boost::uint32_t>();
test_1<boost::int64_t>();
test_1<boost::uint64_t>();
// 2
test_2<boost::int16_t>();
test_2<boost::uint16_t>();
test_2<boost::int32_t>();
test_2<boost::uint32_t>();
test_2<boost::int64_t>();
test_2<boost::uint64_t>();
// 3
test_3<boost::int32_t>();
test_3<boost::uint32_t>();
test_3<boost::int64_t>();
test_3<boost::uint64_t>();
// 4
test_4<boost::int32_t>();
test_4<boost::uint32_t>();
test_4<boost::int64_t>();
test_4<boost::uint64_t>();
// 5
test_5<boost::int64_t>();
test_5<boost::uint64_t>();
// 6
test_6<boost::int64_t>();
test_6<boost::uint64_t>();
// 7
test_7<boost::int64_t>();
test_7<boost::uint64_t>();
// 8
test_8<boost::int64_t>();
test_8<boost::uint64_t>();
return boost::report_errors();
}

View File

@@ -0,0 +1,852 @@
// endian_test.cpp ---------------------------------------------------------//
// Copyright Beman Dawes 1999-2008
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See library home page at http://www.boost.org/libs/endian
//----------------------------------------------------------------------------//
// This test probes for correct endianness, size, and value.
// See endian_operations_test for tests of operator correctness and interaction
// between operand types.
//----------------------------------------------------------------------------//
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/arithmetic.hpp>
#include <boost/cstdint.hpp>
#include <iostream>
#include <limits>
#include <climits>
#include <cstdlib> // for atoi(), exit()
#include <cstring> // for memcmp()
#if defined(_MSC_VER)
# pragma warning(disable: 4127) // conditional expression is constant
#endif
using namespace std; // Not the best programming practice, but I
using namespace boost; // want to verify this combination of using
using namespace boost::endian; // namespaces works. See endian_operations_test
// // for tests that don't do "using namespace".
#define VERIFY(predicate) verify( predicate, __LINE__ )
#define VERIFY_SIZE(actual, expected) verify_size( actual, expected, __LINE__ )
#define VERIFY_VALUE_AND_OPS(endian_t,expected_t,expected) verify_value_and_ops<endian_t, expected_t>( expected, __LINE__ )
#define VERIFY_BIG_REPRESENTATION(t) verify_representation<t>( true, __LINE__ )
#define VERIFY_LITTLE_REPRESENTATION(t) verify_representation<t>( false, __LINE__ )
#define VERIFY_NATIVE_REPRESENTATION(t) verify_native_representation<t>( __LINE__ )
namespace
{
int err_count;
void verify( bool x, int line )
{
if ( x ) return;
++err_count;
cout << "Error: verify failed on line " << line << endl;
}
void verify_size( size_t actual, size_t expected, int line )
{
if ( actual == expected ) return;
++err_count;
cout << "Error: verify size failed on line " << line << endl;
cout << " A structure with an expected sizeof() " << expected
<< " had an actual sizeof() " << actual
<< "\n This will cause uses of endian types to fail\n";
}
template <class Endian, class Base>
void verify_value_and_ops( const Base & expected, int line )
{
Endian v( expected );
verify( v == expected, line );
Endian v2;
v2.operator=( expected );
verify( v2 == expected, line );
++v; // verify integer_cover_operators being applied to this type -
// will fail to compile if no endian<> specialization is present
Endian v3( static_cast<Base>( 1 ) );
Endian x(static_cast<typename Endian::value_type>(v2+v3));
if ( x == x ) // silence warning
return;
}
const char * big_rep = "\x12\x34\x56\x78\x9A\xBC\xDE\xF0";
const char * little_rep = "\xF0\xDE\xBC\x9A\x78\x56\x34\x12";
template <class Endian>
void verify_representation( bool is_big, int line )
{
int silence = 0;
Endian x ( static_cast<typename Endian::value_type>
(0x123456789abcdef0LL + silence) ); // will truncate
if ( is_big )
verify( memcmp( &x,
reinterpret_cast<const char*>(big_rep)+8-sizeof(Endian),
sizeof(Endian) ) == 0, line );
else
verify( memcmp( &x, little_rep, sizeof(Endian) ) == 0, line );
}
template <class Endian>
inline void verify_native_representation( int line )
{
verify_representation<Endian>( order::native == order::big, line );
}
// detect_order -----------------------------------------------------//
void detect_order()
{
union View
{
long long i;
unsigned char c[8];
};
View v = { 0x0102030405060708LL }; // initialize v.i
if ( memcmp( v.c, "\x8\7\6\5\4\3\2\1", 8) == 0 )
{
cout << "This machine is little-endian.\n";
if( order::native != order::little )
{
cout << "yet boost::endian::order::native does not equal boost::endian::order::little.\n"
"The Boost Endian library must be revised to work correctly on this system.\n"
"Please report this problem to the Boost mailing list.\n";
exit(1);
}
}
else if ( memcmp( v.c, "\1\2\3\4\5\6\7\x8", 8) == 0 )
{
cout << "This machine is big-endian.\n";
if( order::native != order::big )
{
cout << "yet boost::endian::order::native does not equal boost::endian::order::big.\n"
"The Boost Endian library must be revised to work correctly on this system.\n"
"Please report this problem to the Boost mailing list.\n";
exit(1);
}
}
else
{
cout << "This machine is neither strict big-endian nor strict little-endian\n"
"The Boost Endian library must be revised to work correctly on this system.\n"
"Please report this problem to the Boost mailing list.\n";
exit(1);
}
cout << "That should not matter and is presented for your information only.\n";
} // detect_order
// check_data ------------------------------------------------------------//
void check_data()
{
big_int8_t big_8;
big_int16_t big_16;
big_int24_t big_24;
big_int32_t big_32;
big_int40_t big_40;
big_int48_t big_48;
big_int56_t big_56;
big_int64_t big_64;
big_uint8_t big_u8;
big_uint16_t big_u16;
big_uint24_t big_u24;
big_uint32_t big_u32;
big_uint40_t big_u40;
big_uint48_t big_u48;
big_uint56_t big_u56;
big_uint64_t big_u64;
little_int8_t little_8;
little_int16_t little_16;
little_int24_t little_24;
little_int32_t little_32;
little_int40_t little_40;
little_int48_t little_48;
little_int56_t little_56;
little_int64_t little_64;
little_uint8_t little_u8;
little_uint16_t little_u16;
little_uint24_t little_u24;
little_uint32_t little_u32;
little_uint40_t little_u40;
little_uint48_t little_u48;
little_uint56_t little_u56;
little_uint64_t little_u64;
native_int8_t native_8;
native_int16_t native_16;
native_int24_t native_24;
native_int32_t native_32;
native_int40_t native_40;
native_int48_t native_48;
native_int56_t native_56;
native_int64_t native_64;
native_uint8_t native_u8;
native_uint16_t native_u16;
native_uint24_t native_u24;
native_uint32_t native_u32;
native_uint40_t native_u40;
native_uint48_t native_u48;
native_uint56_t native_u56;
native_uint64_t native_u64;
big_int16_at big_align_int16;
big_int32_at big_align_int32;
big_int64_at big_align_int64;
big_uint16_at big_align_uint16;
big_uint32_at big_align_uint32;
big_uint64_at big_align_uint64;
little_int16_at little_align_int16;
little_int32_at little_align_int32;
little_int64_at little_align_int64;
little_uint16_at little_align_uint16;
little_uint32_at little_align_uint32;
little_uint64_at little_align_uint64;
VERIFY(big_8.data() == reinterpret_cast<const unsigned char *>(&big_8));
VERIFY(big_16.data() == reinterpret_cast<const unsigned char *>(&big_16));
VERIFY(big_24.data() == reinterpret_cast<const unsigned char *>(&big_24));
VERIFY(big_32.data() == reinterpret_cast<const unsigned char *>(&big_32));
VERIFY(big_40.data() == reinterpret_cast<const unsigned char *>(&big_40));
VERIFY(big_48.data() == reinterpret_cast<const unsigned char *>(&big_48));
VERIFY(big_56.data() == reinterpret_cast<const unsigned char *>(&big_56));
VERIFY(big_64.data() == reinterpret_cast<const unsigned char *>(&big_64));
VERIFY(big_u8.data() == reinterpret_cast<const unsigned char *>(&big_u8));
VERIFY(big_u16.data() == reinterpret_cast<const unsigned char *>(&big_u16));
VERIFY(big_u24.data() == reinterpret_cast<const unsigned char *>(&big_u24));
VERIFY(big_u32.data() == reinterpret_cast<const unsigned char *>(&big_u32));
VERIFY(big_u40.data() == reinterpret_cast<const unsigned char *>(&big_u40));
VERIFY(big_u48.data() == reinterpret_cast<const unsigned char *>(&big_u48));
VERIFY(big_u56.data() == reinterpret_cast<const unsigned char *>(&big_u56));
VERIFY(big_u64.data() == reinterpret_cast<const unsigned char *>(&big_u64));
VERIFY(little_8.data() == reinterpret_cast<const unsigned char *>(&little_8));
VERIFY(little_16.data() == reinterpret_cast<const unsigned char *>(&little_16));
VERIFY(little_24.data() == reinterpret_cast<const unsigned char *>(&little_24));
VERIFY(little_32.data() == reinterpret_cast<const unsigned char *>(&little_32));
VERIFY(little_40.data() == reinterpret_cast<const unsigned char *>(&little_40));
VERIFY(little_48.data() == reinterpret_cast<const unsigned char *>(&little_48));
VERIFY(little_56.data() == reinterpret_cast<const unsigned char *>(&little_56));
VERIFY(little_64.data() == reinterpret_cast<const unsigned char *>(&little_64));
VERIFY(little_u8.data() == reinterpret_cast<const unsigned char *>(&little_u8));
VERIFY(little_u16.data() == reinterpret_cast<const unsigned char *>(&little_u16));
VERIFY(little_u24.data() == reinterpret_cast<const unsigned char *>(&little_u24));
VERIFY(little_u32.data() == reinterpret_cast<const unsigned char *>(&little_u32));
VERIFY(little_u40.data() == reinterpret_cast<const unsigned char *>(&little_u40));
VERIFY(little_u48.data() == reinterpret_cast<const unsigned char *>(&little_u48));
VERIFY(little_u56.data() == reinterpret_cast<const unsigned char *>(&little_u56));
VERIFY(little_u64.data() == reinterpret_cast<const unsigned char *>(&little_u64));
VERIFY(native_8.data() == reinterpret_cast<const unsigned char *>(&native_8));
VERIFY(native_16.data() == reinterpret_cast<const unsigned char *>(&native_16));
VERIFY(native_24.data() == reinterpret_cast<const unsigned char *>(&native_24));
VERIFY(native_32.data() == reinterpret_cast<const unsigned char *>(&native_32));
VERIFY(native_40.data() == reinterpret_cast<const unsigned char *>(&native_40));
VERIFY(native_48.data() == reinterpret_cast<const unsigned char *>(&native_48));
VERIFY(native_56.data() == reinterpret_cast<const unsigned char *>(&native_56));
VERIFY(native_64.data() == reinterpret_cast<const unsigned char *>(&native_64));
VERIFY(native_u8.data() == reinterpret_cast<const unsigned char *>(&native_u8));
VERIFY(native_u16.data() == reinterpret_cast<const unsigned char *>(&native_u16));
VERIFY(native_u24.data() == reinterpret_cast<const unsigned char *>(&native_u24));
VERIFY(native_u32.data() == reinterpret_cast<const unsigned char *>(&native_u32));
VERIFY(native_u40.data() == reinterpret_cast<const unsigned char *>(&native_u40));
VERIFY(native_u48.data() == reinterpret_cast<const unsigned char *>(&native_u48));
VERIFY(native_u56.data() == reinterpret_cast<const unsigned char *>(&native_u56));
VERIFY(native_u64.data() == reinterpret_cast<const unsigned char *>(&native_u64));
VERIFY(big_align_int16.data() == reinterpret_cast<const unsigned char *>(&big_align_int16));
VERIFY(big_align_int32.data() == reinterpret_cast<const unsigned char *>(&big_align_int32));
VERIFY(big_align_int64.data() == reinterpret_cast<const unsigned char *>(&big_align_int64));
VERIFY(big_align_uint16.data() == reinterpret_cast<const unsigned char *>(&big_align_uint16));
VERIFY(big_align_uint32.data() == reinterpret_cast<const unsigned char *>(&big_align_uint32));
VERIFY(big_align_uint64.data() == reinterpret_cast<const unsigned char *>(&big_align_uint64));
VERIFY(little_align_int16.data() == reinterpret_cast<const unsigned char *>(&little_align_int16));
VERIFY(little_align_int32.data() == reinterpret_cast<const unsigned char *>(&little_align_int32));
VERIFY(little_align_int64.data() == reinterpret_cast<const unsigned char *>(&little_align_int64));
VERIFY(little_align_uint16.data() == reinterpret_cast<const unsigned char *>(&little_align_uint16));
VERIFY(little_align_uint32.data() == reinterpret_cast<const unsigned char *>(&little_align_uint32));
VERIFY(little_align_uint64.data() == reinterpret_cast<const unsigned char *>(&little_align_uint64));
}
// check_size ------------------------------------------------------------//
void check_size()
{
VERIFY( numeric_limits<signed char>::digits == 7 );
VERIFY( numeric_limits<unsigned char>::digits == 8 );
VERIFY_SIZE( sizeof( big_int8_t ), 1 );
VERIFY_SIZE( sizeof( big_int16_t ), 2 );
VERIFY_SIZE( sizeof( big_int24_t ), 3 );
VERIFY_SIZE( sizeof( big_int32_t ), 4 );
VERIFY_SIZE( sizeof( big_int40_t ), 5 );
VERIFY_SIZE( sizeof( big_int48_t ), 6 );
VERIFY_SIZE( sizeof( big_int56_t ), 7 );
VERIFY_SIZE( sizeof( big_int64_t ), 8 );
VERIFY_SIZE( sizeof( big_uint8_t ), 1 );
VERIFY_SIZE( sizeof( big_uint16_t ), 2 );
VERIFY_SIZE( sizeof( big_uint24_t ), 3 );
VERIFY_SIZE( sizeof( big_uint32_t ), 4 );
VERIFY_SIZE( sizeof( big_uint40_t ), 5 );
VERIFY_SIZE( sizeof( big_uint48_t ), 6 );
VERIFY_SIZE( sizeof( big_uint56_t ), 7 );
VERIFY_SIZE( sizeof( big_uint64_t ), 8 );
VERIFY_SIZE( sizeof( little_int8_t ), 1 );
VERIFY_SIZE( sizeof( little_int16_t ), 2 );
VERIFY_SIZE( sizeof( little_int24_t ), 3 );
VERIFY_SIZE( sizeof( little_int32_t ), 4 );
VERIFY_SIZE( sizeof( little_int40_t ), 5 );
VERIFY_SIZE( sizeof( little_int48_t ), 6 );
VERIFY_SIZE( sizeof( little_int56_t ), 7 );
VERIFY_SIZE( sizeof( little_int64_t ), 8 );
VERIFY_SIZE( sizeof( little_uint8_t ), 1 );
VERIFY_SIZE( sizeof( little_uint16_t ), 2 );
VERIFY_SIZE( sizeof( little_uint24_t ), 3 );
VERIFY_SIZE( sizeof( little_uint32_t ), 4 );
VERIFY_SIZE( sizeof( little_uint40_t ), 5 );
VERIFY_SIZE( sizeof( little_uint48_t ), 6 );
VERIFY_SIZE( sizeof( little_uint56_t ), 7 );
VERIFY_SIZE( sizeof( little_uint64_t ), 8 );
VERIFY_SIZE( sizeof( native_int8_t ), 1 );
VERIFY_SIZE( sizeof( native_int16_t ), 2 );
VERIFY_SIZE( sizeof( native_int24_t ), 3 );
VERIFY_SIZE( sizeof( native_int32_t ), 4 );
VERIFY_SIZE( sizeof( native_int40_t ), 5 );
VERIFY_SIZE( sizeof( native_int48_t ), 6 );
VERIFY_SIZE( sizeof( native_int56_t ), 7 );
VERIFY_SIZE( sizeof( native_int64_t ), 8 );
VERIFY_SIZE( sizeof( native_uint8_t ), 1 );
VERIFY_SIZE( sizeof( native_uint16_t ), 2 );
VERIFY_SIZE( sizeof( native_uint24_t ), 3 );
VERIFY_SIZE( sizeof( native_uint32_t ), 4 );
VERIFY_SIZE( sizeof( native_uint40_t ), 5 );
VERIFY_SIZE( sizeof( native_uint48_t ), 6 );
VERIFY_SIZE( sizeof( native_uint56_t ), 7 );
VERIFY_SIZE( sizeof( native_uint64_t ), 8 );
VERIFY_SIZE(sizeof(big_int8_at), 1);
VERIFY_SIZE(sizeof(big_int16_at), 2);
VERIFY_SIZE( sizeof( big_int32_at ), 4 );
VERIFY_SIZE( sizeof( big_int64_at ), 8 );
VERIFY_SIZE(sizeof(big_uint8_at), 1);
VERIFY_SIZE(sizeof(big_uint16_at), 2);
VERIFY_SIZE( sizeof( big_uint32_at ), 4 );
VERIFY_SIZE( sizeof( big_uint64_at ), 8 );
VERIFY_SIZE(sizeof(little_int8_at), 1);
VERIFY_SIZE(sizeof(little_int16_at), 2);
VERIFY_SIZE( sizeof( little_int32_at ), 4 );
VERIFY_SIZE( sizeof( little_int64_at ), 8 );
VERIFY_SIZE(sizeof(little_uint8_at), 1);
VERIFY_SIZE(sizeof(little_uint16_at), 2);
VERIFY_SIZE( sizeof( little_uint32_at ), 4 );
VERIFY_SIZE( sizeof( little_uint64_at ), 8 );
} // check_size
// check_alignment -------------------------------------------------------//
void check_alignment()
{
// structs with offsets % 2 == 1 for type of size > 1 to ensure no alignment
// bytes added for any size > 1
struct big_struct
{
big_int8_t v0;
big_int16_t v1;
big_int24_t v3;
char v6;
big_int32_t v7;
big_int40_t v11;
char v16;
big_int48_t v17;
big_int56_t v23;
char v30;
big_int64_t v31;
};
struct big_u_struct
{
big_uint8_t v0;
big_uint16_t v1;
big_uint24_t v3;
char v6;
big_uint32_t v7;
big_uint40_t v11;
char v16;
big_uint48_t v17;
big_uint56_t v23;
char v30;
big_uint64_t v31;
};
struct little_struct
{
little_int8_t v0;
little_int16_t v1;
little_int24_t v3;
char v6;
little_int32_t v7;
little_int40_t v11;
char v16;
little_int48_t v17;
little_int56_t v23;
char v30;
little_int64_t v31;
};
struct little_u_struct
{
little_uint8_t v0;
little_uint16_t v1;
little_uint24_t v3;
char v6;
little_uint32_t v7;
little_uint40_t v11;
char v16;
little_uint48_t v17;
little_uint56_t v23;
char v30;
little_uint64_t v31;
};
struct native_struct
{
native_int8_t v0;
native_int16_t v1;
native_int24_t v3;
char v6;
native_int32_t v7;
native_int40_t v11;
char v16;
native_int48_t v17;
native_int56_t v23;
char v30;
native_int64_t v31;
};
struct native_u_struct
{
native_uint8_t v0;
native_uint16_t v1;
native_uint24_t v3;
char v6;
native_uint32_t v7;
native_uint40_t v11;
char v16;
native_uint48_t v17;
native_uint56_t v23;
char v30;
native_uint64_t v31;
};
// aligned test cases
struct big_aligned_struct
{
big_int16_at v0;
big_int32_at v1;
char v3;
// on a 32-bit system, the padding here may be 3 rather than 7 bytes
big_int64_at v4;
};
struct little_aligned_struct
{
little_int16_at v0;
little_int32_at v1;
char v3;
// on a 32-bit system, the padding here may be 3 rather than 7 bytes
little_int64_at v4;
};
int saved_err_count = err_count;
VERIFY_SIZE( sizeof(big_struct), 39 );
VERIFY_SIZE( sizeof(big_u_struct), 39 );
VERIFY_SIZE( sizeof(little_struct), 39 );
VERIFY_SIZE( sizeof(little_u_struct), 39 );
VERIFY_SIZE( sizeof(native_struct), 39 );
VERIFY_SIZE( sizeof(native_u_struct), 39 );
VERIFY( sizeof(big_aligned_struct) <= 24 );
VERIFY( sizeof(little_aligned_struct) <= 24 );
if ( saved_err_count == err_count )
{
cout <<
"Size and alignment for structures of endian types are as expected.\n";
}
} // check_alignment
// check_representation_and_range_and_ops --------------------------------//
void check_representation_and_range_and_ops()
{
// unaligned integer types
VERIFY_BIG_REPRESENTATION( big_int8_t );
VERIFY_VALUE_AND_OPS( big_int8_t, int_least8_t, 0x7e );
VERIFY_VALUE_AND_OPS( big_int8_t, int_least8_t, -0x80 );
VERIFY_BIG_REPRESENTATION( big_int16_t );
VERIFY_VALUE_AND_OPS( big_int16_t, int_least16_t, 0x7ffe );
VERIFY_VALUE_AND_OPS( big_int16_t, int_least16_t, -0x8000 );
VERIFY_BIG_REPRESENTATION( big_int24_t );
VERIFY_VALUE_AND_OPS( big_int24_t, int_least32_t, 0x7ffffe );
VERIFY_VALUE_AND_OPS( big_int24_t, int_least32_t, -0x800000 );
VERIFY_BIG_REPRESENTATION( big_int32_t );
VERIFY_VALUE_AND_OPS( big_int32_t, int_least32_t, 0x7ffffffe );
VERIFY_VALUE_AND_OPS( big_int32_t, int_least32_t, -0x7fffffff-1 );
VERIFY_BIG_REPRESENTATION( big_int40_t );
VERIFY_VALUE_AND_OPS( big_int40_t, int_least64_t, 0x7ffffffffeLL );
VERIFY_VALUE_AND_OPS( big_int40_t, int_least64_t, -0x8000000000LL );
VERIFY_BIG_REPRESENTATION( big_int48_t );
VERIFY_VALUE_AND_OPS( big_int48_t, int_least64_t, 0x7ffffffffffeLL );
VERIFY_VALUE_AND_OPS( big_int48_t, int_least64_t, -0x800000000000LL );
VERIFY_BIG_REPRESENTATION( big_int56_t );
VERIFY_VALUE_AND_OPS( big_int56_t, int_least64_t, 0x7ffffffffffffeLL );
VERIFY_VALUE_AND_OPS( big_int56_t, int_least64_t, -0x80000000000000LL );
VERIFY_BIG_REPRESENTATION( big_int64_t );
VERIFY_VALUE_AND_OPS( big_int64_t, int_least64_t, 0x7ffffffffffffffeLL );
VERIFY_VALUE_AND_OPS( big_int64_t, int_least64_t, -0x7fffffffffffffffLL-1 );
VERIFY_BIG_REPRESENTATION( big_uint8_t );
VERIFY_VALUE_AND_OPS( big_uint8_t, uint_least8_t, 0xff );
VERIFY_BIG_REPRESENTATION( big_uint16_t );
VERIFY_VALUE_AND_OPS( big_uint16_t, uint_least16_t, 0xffff );
VERIFY_BIG_REPRESENTATION( big_uint24_t );
VERIFY_VALUE_AND_OPS( big_uint24_t, uint_least32_t, 0xffffff );
VERIFY_BIG_REPRESENTATION( big_uint32_t );
VERIFY_VALUE_AND_OPS( big_uint32_t, uint_least32_t, 0xffffffff );
VERIFY_BIG_REPRESENTATION( big_uint40_t );
VERIFY_VALUE_AND_OPS( big_uint40_t, uint_least64_t, 0xffffffffffLL );
VERIFY_BIG_REPRESENTATION( big_uint48_t );
VERIFY_VALUE_AND_OPS( big_uint48_t, uint_least64_t, 0xffffffffffffLL );
VERIFY_BIG_REPRESENTATION( big_uint56_t );
VERIFY_VALUE_AND_OPS( big_uint56_t, uint_least64_t, 0xffffffffffffffLL );
VERIFY_BIG_REPRESENTATION( big_uint64_t );
VERIFY_VALUE_AND_OPS( big_uint64_t, uint_least64_t, 0xffffffffffffffffULL );
VERIFY_LITTLE_REPRESENTATION( little_int8_t );
VERIFY_VALUE_AND_OPS( little_int8_t, int_least8_t, 0x7e );
VERIFY_VALUE_AND_OPS( little_int8_t, int_least8_t, -0x80 );
VERIFY_LITTLE_REPRESENTATION( little_int16_t );
VERIFY_VALUE_AND_OPS( little_int16_t, int_least16_t, 0x7ffe );
VERIFY_VALUE_AND_OPS( little_int16_t, int_least16_t, -0x8000 );
VERIFY_LITTLE_REPRESENTATION( little_int24_t );
VERIFY_VALUE_AND_OPS( little_int24_t, int_least32_t, 0x7ffffe );
VERIFY_VALUE_AND_OPS( little_int24_t, int_least32_t, -0x800000 );
VERIFY_LITTLE_REPRESENTATION( little_int32_t );
VERIFY_VALUE_AND_OPS( little_int32_t, int_least32_t, 0x7ffffffe );
VERIFY_VALUE_AND_OPS( little_int32_t, int_least32_t, -0x7fffffff-1 );
VERIFY_LITTLE_REPRESENTATION( little_int40_t );
VERIFY_VALUE_AND_OPS( little_int40_t, int_least64_t, 0x7ffffffffeLL );
VERIFY_VALUE_AND_OPS( little_int40_t, int_least64_t, -0x8000000000LL );
VERIFY_LITTLE_REPRESENTATION( little_int48_t );
VERIFY_VALUE_AND_OPS( little_int48_t, int_least64_t, 0x7ffffffffffeLL );
VERIFY_VALUE_AND_OPS( little_int48_t, int_least64_t, -0x800000000000LL );
VERIFY_LITTLE_REPRESENTATION( little_int56_t );
VERIFY_VALUE_AND_OPS( little_int56_t, int_least64_t, 0x7ffffffffffffeLL );
VERIFY_VALUE_AND_OPS( little_int56_t, int_least64_t, -0x80000000000000LL );
VERIFY_LITTLE_REPRESENTATION( little_int64_t );
VERIFY_VALUE_AND_OPS( little_int64_t, int_least64_t, 0x7ffffffffffffffeLL );
VERIFY_VALUE_AND_OPS( little_int64_t, int_least64_t, -0x7fffffffffffffffLL-1 );
VERIFY_LITTLE_REPRESENTATION( little_uint8_t );
VERIFY_VALUE_AND_OPS( little_uint8_t, uint_least8_t, 0xff );
VERIFY_LITTLE_REPRESENTATION( little_uint16_t );
VERIFY_VALUE_AND_OPS( little_uint16_t, uint_least16_t, 0xffff );
VERIFY_LITTLE_REPRESENTATION( little_uint24_t );
VERIFY_VALUE_AND_OPS( little_uint24_t, uint_least32_t, 0xffffff );
VERIFY_LITTLE_REPRESENTATION( little_uint32_t );
VERIFY_VALUE_AND_OPS( little_uint32_t, uint_least32_t, 0xffffffff );
VERIFY_LITTLE_REPRESENTATION( little_uint40_t );
VERIFY_VALUE_AND_OPS( little_uint40_t, uint_least64_t, 0xffffffffffLL );
VERIFY_LITTLE_REPRESENTATION( little_uint48_t );
VERIFY_VALUE_AND_OPS( little_uint48_t, uint_least64_t, 0xffffffffffffLL );
VERIFY_LITTLE_REPRESENTATION( little_uint56_t );
VERIFY_VALUE_AND_OPS( little_uint56_t, uint_least64_t, 0xffffffffffffffLL );
VERIFY_LITTLE_REPRESENTATION( little_uint64_t );
VERIFY_VALUE_AND_OPS( little_uint64_t, uint_least64_t, 0xffffffffffffffffULL );
VERIFY_NATIVE_REPRESENTATION( native_int8_t );
VERIFY_VALUE_AND_OPS( native_int8_t, int_least8_t, 0x7e );
VERIFY_VALUE_AND_OPS( native_int8_t, int_least8_t, -0x80 );
VERIFY_NATIVE_REPRESENTATION( native_int16_t );
VERIFY_VALUE_AND_OPS( native_int16_t, int_least16_t, 0x7ffe );
VERIFY_VALUE_AND_OPS( native_int16_t, int_least16_t, -0x8000 );
VERIFY_NATIVE_REPRESENTATION( native_int24_t );
VERIFY_VALUE_AND_OPS( native_int24_t, int_least32_t, 0x7ffffe );
VERIFY_VALUE_AND_OPS( native_int24_t, int_least32_t, -0x800000 );
VERIFY_NATIVE_REPRESENTATION( native_int32_t );
VERIFY_VALUE_AND_OPS( native_int32_t, int_least32_t, 0x7ffffffe );
VERIFY_VALUE_AND_OPS( native_int32_t, int_least32_t, -0x7fffffff-1 );
VERIFY_NATIVE_REPRESENTATION( native_int40_t );
VERIFY_VALUE_AND_OPS( native_int40_t, int_least64_t, 0x7ffffffffeLL );
VERIFY_VALUE_AND_OPS( native_int40_t, int_least64_t, -0x8000000000LL );
VERIFY_NATIVE_REPRESENTATION( native_int48_t );
VERIFY_VALUE_AND_OPS( native_int48_t, int_least64_t, 0x7ffffffffffeLL );
VERIFY_VALUE_AND_OPS( native_int48_t, int_least64_t, -0x800000000000LL );
VERIFY_NATIVE_REPRESENTATION( native_int56_t );
VERIFY_VALUE_AND_OPS( native_int56_t, int_least64_t, 0x7ffffffffffffeLL );
VERIFY_VALUE_AND_OPS( native_int56_t, int_least64_t, -0x80000000000000LL );
VERIFY_NATIVE_REPRESENTATION( native_int64_t );
VERIFY_VALUE_AND_OPS( native_int64_t, int_least64_t, 0x7ffffffffffffffeLL );
VERIFY_VALUE_AND_OPS( native_int64_t, int_least64_t, -0x7fffffffffffffffLL-1 );
VERIFY_NATIVE_REPRESENTATION( native_uint8_t );
VERIFY_VALUE_AND_OPS( native_uint8_t, uint_least8_t, 0xff );
VERIFY_NATIVE_REPRESENTATION( native_uint16_t );
VERIFY_VALUE_AND_OPS( native_uint16_t, uint_least16_t, 0xffff );
VERIFY_NATIVE_REPRESENTATION( native_uint24_t );
VERIFY_VALUE_AND_OPS( native_uint24_t, uint_least32_t, 0xffffff );
VERIFY_NATIVE_REPRESENTATION( native_uint32_t );
VERIFY_VALUE_AND_OPS( native_uint32_t, uint_least32_t, 0xffffffff );
VERIFY_NATIVE_REPRESENTATION( native_uint40_t );
VERIFY_VALUE_AND_OPS( native_uint40_t, uint_least64_t, 0xffffffffffLL );
VERIFY_NATIVE_REPRESENTATION( native_uint48_t );
VERIFY_VALUE_AND_OPS( native_uint48_t, uint_least64_t, 0xffffffffffffLL );
VERIFY_NATIVE_REPRESENTATION( native_uint56_t );
VERIFY_VALUE_AND_OPS( native_uint56_t, uint_least64_t, 0xffffffffffffffLL );
VERIFY_NATIVE_REPRESENTATION( native_uint64_t );
VERIFY_VALUE_AND_OPS( native_uint64_t, uint_least64_t, 0xffffffffffffffffULL );
// aligned integer types
VERIFY_BIG_REPRESENTATION( big_int16_at );
VERIFY_VALUE_AND_OPS( big_int16_at, int_least16_t, 0x7ffe );
VERIFY_VALUE_AND_OPS( big_int16_at, int_least16_t, -0x8000 );
VERIFY_BIG_REPRESENTATION( big_int32_at );
VERIFY_VALUE_AND_OPS( big_int32_at, int_least32_t, 0x7ffffffe );
VERIFY_VALUE_AND_OPS( big_int32_at, int_least32_t, -0x7fffffff-1 );
VERIFY_BIG_REPRESENTATION( big_int64_at );
VERIFY_VALUE_AND_OPS( big_int64_at, int_least64_t, 0x7ffffffffffffffeLL );
VERIFY_VALUE_AND_OPS( big_int64_at, int_least64_t, -0x7fffffffffffffffLL-1 );
VERIFY_BIG_REPRESENTATION( big_uint16_at );
VERIFY_VALUE_AND_OPS( big_uint16_at, uint_least16_t, 0xffff );
VERIFY_BIG_REPRESENTATION( big_uint32_at );
VERIFY_VALUE_AND_OPS( big_uint32_at, uint_least32_t, 0xffffffff );
VERIFY_BIG_REPRESENTATION( big_uint64_at );
VERIFY_VALUE_AND_OPS( big_uint64_at, uint_least64_t, 0xffffffffffffffffULL );
VERIFY_LITTLE_REPRESENTATION( little_int16_at );
VERIFY_VALUE_AND_OPS( little_int16_at, int_least16_t, 0x7ffe );
VERIFY_VALUE_AND_OPS( little_int16_at, int_least16_t, -0x8000 );
VERIFY_LITTLE_REPRESENTATION( little_int32_at );
VERIFY_VALUE_AND_OPS( little_int32_at, int_least32_t, 0x7ffffffe );
VERIFY_VALUE_AND_OPS( little_int32_at, int_least32_t, -0x7fffffff-1 );
VERIFY_LITTLE_REPRESENTATION( little_int64_at );
VERIFY_VALUE_AND_OPS( little_int64_at, int_least64_t, 0x7ffffffffffffffeLL );
VERIFY_VALUE_AND_OPS( little_int64_at, int_least64_t, -0x7fffffffffffffffLL-1 );
VERIFY_LITTLE_REPRESENTATION( little_uint16_at );
VERIFY_VALUE_AND_OPS( little_uint16_at, uint_least16_t, 0xffff );
VERIFY_LITTLE_REPRESENTATION( little_uint32_at );
VERIFY_VALUE_AND_OPS( little_uint32_at, uint_least32_t, 0xffffffff );
VERIFY_LITTLE_REPRESENTATION( little_uint64_at );
VERIFY_VALUE_AND_OPS( little_uint64_at, uint_least64_t, 0xffffffffffffffffULL );
} // check_representation_and_range
/*
class MyInt
{
int32_t mx;
public:
MyInt(int32_t x = 0) : mx(x) {}
operator int32_t() const {return mx;}
//friend int32_t operator+(const MyInt& x) {return x;}
};
void check_udt()
{
typedef boost::endian::endian_arithmetic< order::big, MyInt, 32 > mybig_int32_ut;
mybig_int32_ut v(10);
cout << "+v is " << +v << endl;
v += 1;
cout << "v is " << +v << endl;
v -= 2;
cout << "v is " << +v << endl;
v *= 2;
cout << "v is " << +v << endl;
++v;
cout << "v is " << +v << endl;
--v;
cout << "v is " << +v << endl;
// cout << "v+v is " << +(v+v) << endl;
}
void check_udt_le()
{
typedef boost::endian::endian_arithmetic< order::little, MyInt, 32 > mylittle_int32_ut;
mylittle_int32_ut v(10);
cout << "+v is " << +v << endl;
v += 1;
cout << "v is " << +v << endl;
v -= 2;
cout << "v is " << +v << endl;
v *= 2;
cout << "v is " << +v << endl;
++v;
cout << "v is " << +v << endl;
--v;
cout << "v is " << +v << endl;
// cout << "v+v is " << +(v+v) << endl;
}
*/
long iterations = 10000;
template< class Endian >
Endian timing_test( const char * s)
{
cout << s << " timing test, " << iterations << " iterations: ";
// progress_timer t;
Endian v = 1;
for ( long i = 0; i < iterations; ++i )
{
v += 1;
v *= 3;
++v;
v *= i;
if ( i == 0 ) VERIFY_VALUE_AND_OPS( Endian, typename Endian::value_type, 21 );
}
return v;
}
} // unnamed namespace
// main ------------------------------------------------------------------------------//
int cpp_main( int argc, char * argv[] )
{
cout << "Usage: "
<< argv[0] << " [#],\n where # specifies iteration count\n"
" default iteration count is " << iterations << endl;
if ( argc > 1 )
iterations = atol( argv[1] );
if ( iterations < 1 ) iterations = 1;
detect_order();
check_size();
check_alignment();
check_representation_and_range_and_ops();
check_data();
//check_udt();
//check_udt_le();
//timing_test<big_int32_t> ( "big_int32_t" );
//timing_test<big_int32_at>( "big_int32_at" );
//timing_test<little_int32_t> ( "little_int32_t" );
//timing_test<little_int32_at>( "little_int32_at" );
cout << "\n" << err_count << " errors detected\nTest "
<< (err_count==0 ? "passed\n\n" : "failed\n\n");
return err_count ? 1 : 0;
} // main
int main( int argc, char* argv[] )
{
try
{
return cpp_main( argc, argv );
}
catch( std::exception const & x )
{
std::cout << "Exception: " << x.what() << std::endl;
return 1;
}
}

View File

@@ -0,0 +1,83 @@
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/arithmetic.hpp>
#include <boost/endian/buffers.hpp>
#include <boost/core/lightweight_test.hpp>
template<class T> struct align
{
char _;
T v;
explicit align( typename T::value_type y ): _(), v( y )
{
}
};
template<class T> struct align2
{
char _;
T v;
};
template<class T, class U> void test_buffer( U const & y, bool aligned )
{
align<T> x( y );
BOOST_TEST_EQ( sizeof(x), aligned? sizeof( align2<U> ): 1 + sizeof(U) );
BOOST_TEST_EQ( x.v.value(), y );
}
template<class T, class U> void test_arithmetic( U const & y, bool aligned )
{
test_buffer<T>( y, aligned );
align<T> x( y );
BOOST_TEST_EQ( x.v + 7, y + 7 );
}
int main()
{
using namespace boost::endian;
// buffers
test_buffer<big_float32_buf_t>( 3.1416f, false );
test_buffer<big_float64_buf_t>( 3.14159, false );
test_buffer<little_float32_buf_t>( 3.1416f, false );
test_buffer<little_float64_buf_t>( 3.14159, false );
test_buffer<native_float32_buf_t>( 3.1416f, false );
test_buffer<native_float64_buf_t>( 3.14159, false );
test_buffer<big_float32_buf_at>( 3.1416f, true );
test_buffer<big_float64_buf_at>( 3.14159, true );
test_buffer<little_float32_buf_at>( 3.1416f, true );
test_buffer<little_float64_buf_at>( 3.14159, true );
// arithmetic
test_arithmetic<big_float32_t>( 3.1416f, false );
test_arithmetic<big_float64_t>( 3.14159, false );
test_arithmetic<little_float32_t>( 3.1416f, false );
test_arithmetic<little_float64_t>( 3.14159, false );
test_arithmetic<native_float32_t>( 3.1416f, false );
test_arithmetic<native_float64_t>( 3.14159, false );
test_arithmetic<big_float32_at>( 3.1416f, true );
test_arithmetic<big_float64_at>( 3.14159, true );
test_arithmetic<little_float32_at>( 3.1416f, true );
test_arithmetic<little_float64_at>( 3.14159, true );
return boost::report_errors();
}

View File

@@ -0,0 +1,35 @@
// Copyright Beman Dawes 2013
// Copyright 2018 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/detail/intrinsic.hpp>
#include <boost/core/lightweight_test.hpp>
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
int main()
{
std::cout << "BOOST_ENDIAN_INTRINSIC_MSG: " BOOST_ENDIAN_INTRINSIC_MSG << std::endl;
#ifndef BOOST_ENDIAN_NO_INTRINSICS
uint16 x2 = 0x1122U;
uint16 y2 = BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_2(x2);
BOOST_TEST_EQ( y2, 0x2211U );
uint32 x4 = 0x11223344UL;
uint32 y4 = BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_4(x4);
BOOST_TEST_EQ( y4, 0x44332211UL );
uint64 x8 = 0x1122334455667788U;
uint64 y8 = BOOST_ENDIAN_INTRINSIC_BYTE_SWAP_8(x8);
BOOST_TEST_EQ( y8, 0x8877665544332211ULL );
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,78 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/detail/is_scoped_enum.hpp>
#include <boost/core/lightweight_test_trait.hpp>
#include <boost/config.hpp>
enum E1 {};
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
enum E2: long {};
enum class E3 {};
enum class E4: long {};
#endif
struct X
{
operator int() const { return 0; }
};
struct Y;
template<class T> void test_true()
{
using boost::endian::detail::is_scoped_enum;
BOOST_TEST_TRAIT_TRUE((is_scoped_enum<T>));
BOOST_TEST_TRAIT_TRUE((is_scoped_enum<T const>));
BOOST_TEST_TRAIT_TRUE((is_scoped_enum<T volatile>));
BOOST_TEST_TRAIT_TRUE((is_scoped_enum<T const volatile>));
}
template<class T> void test_false()
{
using boost::endian::detail::is_scoped_enum;
BOOST_TEST_TRAIT_FALSE((is_scoped_enum<T>));
BOOST_TEST_TRAIT_FALSE((is_scoped_enum<T const>));
BOOST_TEST_TRAIT_FALSE((is_scoped_enum<T volatile>));
BOOST_TEST_TRAIT_FALSE((is_scoped_enum<T const volatile>));
}
template<class T> void test_false_()
{
using boost::endian::detail::is_scoped_enum;
BOOST_TEST_NOT((is_scoped_enum<T>::value));
BOOST_TEST_NOT((is_scoped_enum<T const>::value));
BOOST_TEST_NOT((is_scoped_enum<T volatile>::value));
BOOST_TEST_NOT((is_scoped_enum<T const volatile>::value));
}
int main()
{
test_false<int>();
test_false<bool>();
test_false<X>();
test_false_<Y>();
test_false<void>();
test_false<int[]>();
test_false<int[1]>();
test_false<E1>();
#if !defined(BOOST_NO_CXX11_SCOPED_ENUMS)
test_false<E2>();
test_true<E3>();
test_true<E4>();
#endif
return boost::report_errors();
}

View File

@@ -0,0 +1,75 @@
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/conversion.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <cstddef>
int main()
{
using namespace boost::endian;
unsigned char v[] = { 0xF1, 0xF2, 0xF3, 0xF4, 0xF5, 0xF6, 0xF7, 0xF8 };
// 16
BOOST_TEST_EQ( load_little_s16( v ), -3343 );
BOOST_TEST_EQ( load_little_u16( v ), 0xF2F1 );
BOOST_TEST_EQ( load_big_s16( v ), -3598 );
BOOST_TEST_EQ( load_big_u16( v ), 0xF1F2 );
// 24
BOOST_TEST_EQ( load_little_s24( v ), -789775 );
BOOST_TEST_EQ( load_little_u24( v ), 0xF3F2F1 );
BOOST_TEST_EQ( load_big_s24( v ), -920845 );
BOOST_TEST_EQ( load_big_u24( v ), 0xF1F2F3 );
// 32
BOOST_TEST_EQ( load_little_s32( v ), 0xF4F3F2F1 );
BOOST_TEST_EQ( load_little_u32( v ), 0xF4F3F2F1 );
BOOST_TEST_EQ( load_big_s32( v ), 0xF1F2F3F4 );
BOOST_TEST_EQ( load_big_u32( v ), 0xF1F2F3F4 );
// 40
BOOST_TEST_EQ( load_little_s40( v ), -43135012111 );
BOOST_TEST_EQ( load_little_u40( v ), 0xF5F4F3F2F1 );
BOOST_TEST_EQ( load_big_s40( v ), -60348435211 );
BOOST_TEST_EQ( load_big_u40( v ), 0xF1F2F3F4F5 );
// 48
BOOST_TEST_EQ( load_little_s48( v ), -9938739662095 );
BOOST_TEST_EQ( load_little_u48( v ), 0xF6F5F4F3F2F1 );
BOOST_TEST_EQ( load_big_s48( v ), -15449199413770 );
BOOST_TEST_EQ( load_big_u48( v ), 0xF1F2F3F4F5F6 );
// 56
BOOST_TEST_EQ( load_little_s56( v ), -2261738553347343 );
BOOST_TEST_EQ( load_little_u56( v ), 0xF7F6F5F4F3F2F1 );
BOOST_TEST_EQ( load_big_s56( v ), -3954995049924873 );
BOOST_TEST_EQ( load_big_u56( v ), 0xF1F2F3F4F5F6F7 );
// 64
BOOST_TEST_EQ( load_little_s64( v ), 0xF8F7F6F5F4F3F2F1 );
BOOST_TEST_EQ( load_little_u64( v ), 0xF8F7F6F5F4F3F2F1 );
BOOST_TEST_EQ( load_big_s64( v ), 0xF1F2F3F4F5F6F7F8 );
BOOST_TEST_EQ( load_big_u64( v ), 0xF1F2F3F4F5F6F7F8 );
return boost::report_errors();
}

View File

@@ -0,0 +1,315 @@
// loop_time_test.cpp ----------------------------------------------------------------//
// Copyright Beman Dawes 2013
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
//--------------------------------------------------------------------------------------//
//#define BOOST_ENDIAN_NO_INTRINSICS
#include <boost/endian/detail/disable_warnings.hpp>
#include <boost/endian/conversion.hpp>
#include <boost/endian/arithmetic.hpp>
#include <boost/cstdint.hpp>
#include <boost/timer/timer.hpp>
#include <iostream>
#include <cstdlib>
#include <string>
#include <boost/detail/lightweight_main.hpp>
#ifdef _MSC_VER
# pragma warning (push)
# pragma warning (disable : 4459)
#endif
#include <boost/lexical_cast.hpp>
#ifdef _MSC_VER
# pragma warning (pop)
#endif
using namespace boost;
using namespace boost::endian;
using std::cout;
using std::endl;
namespace
{
typedef boost::timer::nanosecond_type nanosecond_t;
std::string command_args;
uint64_t n; // number of test cases to run
int places = 2; // decimal places for times
bool verbose (false);
bool time_aligned (true);
bool time_unaligned (true);
bool time_16(true);
bool time_32(true);
bool time_64(true);
void process_command_line(int argc, char * argv[])
{
for (int a = 0; a < argc; ++a)
{
command_args += argv[a];
if (a != argc-1)
command_args += ' ';
}
// cout << command_args << '\n';;
if (argc >=2)
#ifndef _MSC_VER
n = atoll(argv[1]);
#else
n = _atoi64(argv[1]);
#endif
for (; argc > 2; ++argv, --argc)
{
if ( *(argv[2]+1) == 'p' )
places = atoi( argv[2]+2 );
else if (*(argv[2] + 1) == 'v')
verbose = true;
else if (*(argv[2] + 1) == 'a')
time_unaligned = false;
else if (*(argv[2] + 1) == 'u')
time_aligned = false;
else if (*(argv[2] + 1) == '1')
time_32 = time_64 = false;
else if (*(argv[2] + 1) == '3')
time_16 = time_64 = false;
else if (*(argv[2] + 1) == '6')
time_16 = time_32 = false;
else
{
cout << "Error - unknown option: " << argv[2] << "\n\n";
argc = -1;
break;
}
}
if (argc < 2)
{
cout << "Usage: loop_time_test n [Options]\n"
" The argument n specifies the number of test cases to run\n"
" Options:\n"
" -v Verbose messages\n"
" -p# Decimal places for times; default -p" << places << "\n"
" -a Aligned tests only\n"
" -u Unaligned tests only\n"
" -16 16-bit tests only\n"
" -32 32-bit tests only\n"
" -64 64-bit tests only\n"
;
return std::exit(1);
}
}
std::string with_digit_separator(int64_t x)
{
std::string s = boost::lexical_cast<std::string>(x);
std::string s2;
for (std::string::size_type i = 0; i < s.size(); ++i)
{
if (i && ((s.size()-i) % 3) == 0)
s2 += '\'';
s2 += s[i];
}
return s2;
}
//--------------------------------------------------------------------------------------//
template <class T, class EndianT>
void time()
{
T total = 0;
{
// cout << "*************Endian integer approach...\n";
EndianT x(0);
boost::timer::cpu_timer t;
for (uint64_t i = 0; i < n; ++i)
{
x += static_cast<T>(i);
}
t.stop();
total += x;
cout << "<td align=\"right\">" << t.format(places, "%t") << " s</td>";
}
{
// cout << "***************Endian conversion approach...\n";
T x(0);
boost::timer::cpu_timer t;
native_to_big_inplace(x);
for (uint64_t i = 0; i < n; ++i)
{
x += static_cast<T>(i);
}
big_to_native_inplace(x);
t.stop();
native_to_big_inplace(x);
if (x != total)
throw std::logic_error("integer approach total != conversion approach total");
cout << "<td align=\"right\">" << t.format(places, "%t") << " s</td>";
}
}
void test_big_align_int16()
{
cout << "<tr><td>16-bit aligned big endian</td>";
time<int16_t, big_int16_at>();
cout << "</tr>\n";
}
void test_little_align_int16()
{
cout << "<tr><td>16-bit aligned little endian</td>";
time<int16_t, little_int16_at>();
cout << "</tr>\n";
}
void test_big_int16()
{
cout << "<tr><td>16-bit unaligned big endian</td>";
time<int16_t, big_int16_t>();
cout << "</tr>\n";
}
void test_little_int16()
{
cout << "<tr><td>16-bit unaligned little endian</td>";
time<int16_t, little_int16_t>();
cout << "</tr>\n";
}
void test_big_align_int32()
{
cout << "<tr><td>32-bit aligned big endian</td>";
time<int32_t, big_int32_at>();
cout << "</tr>\n";
}
void test_little_align_int32()
{
cout << "<tr><td>32-bit aligned little endian</td>";
time<int32_t, little_int32_at>();
cout << "</tr>\n";
}
void test_big_int32()
{
cout << "<tr><td>32-bit unaligned big endian</td>";
time<int32_t, big_int32_t>();
cout << "</tr>\n";
}
void test_little_int32()
{
cout << "<tr><td>32-bit unaligned little endian</td>";
time<int32_t, little_int32_t>();
cout << "</tr>\n";
}
void test_big_align_int64()
{
cout << "<tr><td>64-bit aligned big endian</td>";
time<int64_t, big_int64_at>();
cout << "</tr>\n";
}
void test_little_align_int64()
{
cout << "<tr><td>64-bit aligned little endian</td>";
time<int64_t, little_int64_at>();
cout << "</tr>\n";
}
void test_big_int64()
{
cout << "<tr><td>64-bit unaligned big endian</td>";
time<int64_t, big_int64_t>();
cout << "</tr>\n";
}
void test_little_int64()
{
cout << "<tr><td>64-bit unaligned little endian</td>";
time<int64_t, little_int64_t>();
cout << "</tr>\n";
}
} // unnamed namespace
//--------------------------------------------------------------------------------------//
int cpp_main(int argc, char* argv[])
{
process_command_line(argc, argv);
cout
<< "<html>\n<head>\n<title>Endian Loop Time Test</title>\n</head>\n<body>\n"
<< "<!-- boost-no-inspect -->\n"
<< "<div align=\"center\"> <center>\n"
<< "<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\""
<< "style=\"border-collapse: collapse\" bordercolor=\"#111111\">\n"
<< "<tr><td colspan=\"6\" align=\"center\"><b>"
<< BOOST_COMPILER << "</b></td></tr>\n"
<< "<tr><td colspan=\"6\" align=\"center\"><b>"
<< " Iterations: " << with_digit_separator(n)
<< ", Intrinsics: " BOOST_ENDIAN_INTRINSIC_MSG
<< "</b></td></tr>\n"
<< "<tr><td><b>Test Case</b></td>\n"
"<td align=\"center\"><b>Endian<br>arithmetic<br>type</b></td>\n"
"<td align=\"center\"><b>Endian<br>conversion<br>function</b></td>\n"
"</tr>\n"
;
if (time_aligned)
{
if (time_16)
{
test_big_align_int16();
test_little_align_int16();
}
if (time_32)
{
test_big_align_int32();
test_little_align_int32();
}
if (time_64)
{
test_big_align_int64();
test_little_align_int64();
}
}
if (time_unaligned)
{
if (time_16)
{
test_big_int16();
test_little_int16();
}
if (time_32)
{
test_big_int32();
test_little_int32();
}
if (time_64)
{
test_big_int64();
test_little_int64();
}
}
cout << "\n</div> </center>\n"
<< "\n</table>\n</body>\n</html>\n";
return 0;
}
#include <boost/endian/detail/disable_warnings_pop.hpp>

View File

@@ -0,0 +1,138 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{D9C80FE0-20A6-4711-A3F4-676019BD5A06}</ProjectGuid>
<RootNamespace>associatedfiles</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>MultiByte</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup />
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClInclude Include="..\..\..\include\boost\endian\arithmetic.hpp" />
<ClInclude Include="..\..\..\include\boost\endian\buffers.hpp" />
<ClInclude Include="..\..\..\include\boost\endian\conversion.hpp" />
<ClInclude Include="..\..\..\include\boost\endian\detail\config.hpp" />
<ClInclude Include="..\..\..\include\boost\endian\detail\cover_operators.hpp" />
<ClInclude Include="..\..\..\include\boost\endian\detail\disable_warnings.hpp" />
<ClInclude Include="..\..\..\include\boost\endian\detail\disable_warnings_pop.hpp" />
<ClInclude Include="..\..\..\include\boost\endian\detail\intrinsic.hpp" />
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\doc\arithmetic.html" />
<None Include="..\..\..\doc\buffers.html" />
<None Include="..\..\..\doc\conversion.html" />
<None Include="..\..\..\doc\index.html" />
<None Include="..\..\..\doc\mini_review_topics.html" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,63 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<Filter Include="Source Files">
<UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
</Filter>
<Filter Include="Header Files">
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
<Extensions>h;hh;hpp;hxx;hm;inl;inc;xsd</Extensions>
</Filter>
<Filter Include="Resource Files">
<UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>
<Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>
</Filter>
<Filter Include="HTML Files">
<UniqueIdentifier>{f0ee044b-7428-42ef-a455-a9b440bd64d3}</UniqueIdentifier>
</Filter>
</ItemGroup>
<ItemGroup>
<ClInclude Include="..\..\..\include\boost\endian\arithmetic.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\boost\endian\buffers.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\boost\endian\conversion.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\boost\endian\detail\config.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\boost\endian\detail\cover_operators.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\boost\endian\detail\disable_warnings.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\boost\endian\detail\disable_warnings_pop.hpp">
<Filter>Header Files</Filter>
</ClInclude>
<ClInclude Include="..\..\..\include\boost\endian\detail\intrinsic.hpp">
<Filter>Header Files</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<None Include="..\..\..\doc\conversion.html">
<Filter>HTML Files</Filter>
</None>
<None Include="..\..\..\doc\buffers.html">
<Filter>HTML Files</Filter>
</None>
<None Include="..\..\..\doc\index.html">
<Filter>HTML Files</Filter>
</None>
<None Include="..\..\..\doc\mini_review_topics.html">
<Filter>HTML Files</Filter>
</None>
<None Include="..\..\..\doc\arithmetic.html">
<Filter>HTML Files</Filter>
</None>
</ItemGroup>
</Project>

View File

@@ -0,0 +1,178 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{C9FEAE75-4DD9-44F5-B302-9910559A91BE}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>benchmark</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BOOST_ALL_DYN_LINK;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 10 -v</Command>
<Message>Executing test...</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>BOOST_ALL_DYN_LINK;WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 10 -v</Command>
<Message>Executing test...</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>BOOST_ALL_DYN_LINK;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 10000 -v</Command>
<Message>Executing test...</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>BOOST_ALL_DYN_LINK;WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
<AssemblerListingLocation>$(IntDir)</AssemblerListingLocation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 10000 -v</Command>
<Message>Executing test...</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\benchmark.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,161 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{BFB68CF4-EB92-4E5C-9694-A939496C5CDE}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>buffer_test</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\buffer_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,24 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir>$(SolutionName)\$(Configuration)\</OutDir>
<IntDir>$(SolutionName)\$(ProjectName)\$(Configuration)\</IntDir>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x86);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup>
<ClCompile>
<AdditionalIncludeDirectories>..\..\..\..\..;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<WarningLevel>EnableAllWarnings</WarningLevel>
<PreprocessorDefinitions>BOOST_LIGHTWEIGHT_TEST_OSTREAM=std::cout;BOOST_ALL_DYN_LINK;_UNICODE;UNICODE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
</ClCompile>
<PostBuildEvent>
<Message>Executing test $(TargetName).exe...</Message>
<Command>"$(TargetDir)\$(TargetName).exe"</Command>
</PostBuildEvent>
<Link>
<AdditionalLibraryDirectories>../../../../..\stage\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
</Link>
</ItemDefinitionGroup>
</Project>

View File

@@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{0DA4B909-1E3D-43A2-A248-3FE73E499726}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>conversion_test_clang</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_clang_3_7</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140_Clang_3_7</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="Shared">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<WarningLevel>EnableAllWarnings</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
<ExceptionHandling>Enabled</ExceptionHandling>
<AdditionalIncludeDirectories>../../../../../</AdditionalIncludeDirectories>
<RuntimeTypeInfo>true</RuntimeTypeInfo>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>NotUsing</PrecompiledHeader>
<Optimization>Disabled</Optimization>
<SDLCheck>true</SDLCheck>
<ExceptionHandling>Enabled</ExceptionHandling>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\conversion_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,158 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{1139E765-DE0F-497A-A7D9-EB2683521DF1}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>conversion_use_case</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\example\conversion_use_case.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<ItemGroup>
<ClCompile Include="..\..\conversion_test.cpp" />
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>converter_test</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Message>Executing test...</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Message>Executing test...</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Message>Executing test...</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Message>Executing test...</Message>
</PostBuildEvent>
</ItemDefinitionGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,89 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{DA4BC67F-9284-4D2C-81D5-407312C31BD7}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>deprecated_test</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\deprecated_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,28 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.24720.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "conversion_test_clang", "conversion_test_clang\conversion_test_clang.vcxproj", "{0DA4B909-1E3D-43A2-A248-3FE73E499726}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|x64 = Debug|x64
Debug|x86 = Debug|x86
Release|x64 = Release|x64
Release|x86 = Release|x86
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{0DA4B909-1E3D-43A2-A248-3FE73E499726}.Debug|x64.ActiveCfg = Debug|x64
{0DA4B909-1E3D-43A2-A248-3FE73E499726}.Debug|x64.Build.0 = Debug|x64
{0DA4B909-1E3D-43A2-A248-3FE73E499726}.Debug|x86.ActiveCfg = Debug|Win32
{0DA4B909-1E3D-43A2-A248-3FE73E499726}.Debug|x86.Build.0 = Debug|Win32
{0DA4B909-1E3D-43A2-A248-3FE73E499726}.Release|x64.ActiveCfg = Release|x64
{0DA4B909-1E3D-43A2-A248-3FE73E499726}.Release|x64.Build.0 = Release|x64
{0DA4B909-1E3D-43A2-A248-3FE73E499726}.Release|x86.ActiveCfg = Release|Win32
{0DA4B909-1E3D-43A2-A248-3FE73E499726}.Release|x86.Build.0 = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,160 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 14
VisualStudioVersion = 14.0.22609.0
MinimumVisualStudioVersion = 10.0.40219.1
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_test", "endian_test\endian_test.vcxproj", "{74C201F3-8308-40BE-BC0F-24974DEAF405}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_in_union_test", "endian_in_union_test\endian_in_union_test.vcxproj", "{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_operations_test", "endian_operations_test\endian_operations_test.vcxproj", "{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "scoped_enum_emulation_test", "scoped_enum_emulation_test\scoped_enum_emulation_test.vcxproj", "{8420E151-B23B-4651-B526-6AB11EF1E278}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "endian_example", "endian_example\endian_example.vcxproj", "{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "benchmark", "benchmark\benchmark.vcxproj", "{C9FEAE75-4DD9-44F5-B302-9910559A91BE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "converter_test", "converter_test\converter_test.vcxproj", "{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "udt_conversion_example", "udt_conversion_example\udt_conversion_example.vcxproj", "{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "speed_test", "speed_test\speed_test.vcxproj", "{5407AF29-59E9-4DE2-9939-F067576F7868}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "loop_time_test", "loop_time_test\loop_time_test.vcxproj", "{541A2D06-B34E-4592-BE47-F87DF47E73D8}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "buffer_test", "buffer_test\buffer_test.vcxproj", "{BFB68CF4-EB92-4E5C-9694-A939496C5CDE}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "conversion_use_case", "conversion_use_case\conversion_use_case.vcxproj", "{1139E765-DE0F-497A-A7D9-EB2683521DF1}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "associated-files", "associated-files\associated-files.vcxproj", "{D9C80FE0-20A6-4711-A3F4-676019BD5A06}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "experiment", "experiment\experiment.vcxproj", "{CE9D8719-6E86-41D0-97CA-5BE5272594E9}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "deprecated_test", "deprecated_test\deprecated_test.vcxproj", "{DA4BC67F-9284-4D2C-81D5-407312C31BD7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Win32 = Debug|Win32
Debug|x64 = Debug|x64
Release|Win32 = Release|Win32
Release|x64 = Release|x64
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{74C201F3-8308-40BE-BC0F-24974DEAF405}.Debug|Win32.ActiveCfg = Debug|Win32
{74C201F3-8308-40BE-BC0F-24974DEAF405}.Debug|Win32.Build.0 = Debug|Win32
{74C201F3-8308-40BE-BC0F-24974DEAF405}.Debug|x64.ActiveCfg = Debug|x64
{74C201F3-8308-40BE-BC0F-24974DEAF405}.Debug|x64.Build.0 = Debug|x64
{74C201F3-8308-40BE-BC0F-24974DEAF405}.Release|Win32.ActiveCfg = Release|Win32
{74C201F3-8308-40BE-BC0F-24974DEAF405}.Release|Win32.Build.0 = Release|Win32
{74C201F3-8308-40BE-BC0F-24974DEAF405}.Release|x64.ActiveCfg = Release|x64
{74C201F3-8308-40BE-BC0F-24974DEAF405}.Release|x64.Build.0 = Release|x64
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Debug|Win32.ActiveCfg = Debug|Win32
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Debug|Win32.Build.0 = Debug|Win32
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Debug|x64.ActiveCfg = Debug|x64
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Debug|x64.Build.0 = Debug|x64
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Release|Win32.ActiveCfg = Release|Win32
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Release|Win32.Build.0 = Release|Win32
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Release|x64.ActiveCfg = Release|x64
{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}.Release|x64.Build.0 = Release|x64
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Debug|Win32.ActiveCfg = Debug|Win32
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Debug|Win32.Build.0 = Debug|Win32
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Debug|x64.ActiveCfg = Debug|x64
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Debug|x64.Build.0 = Debug|x64
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Release|Win32.ActiveCfg = Release|Win32
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Release|Win32.Build.0 = Release|Win32
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Release|x64.ActiveCfg = Release|x64
{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}.Release|x64.Build.0 = Release|x64
{8420E151-B23B-4651-B526-6AB11EF1E278}.Debug|Win32.ActiveCfg = Debug|Win32
{8420E151-B23B-4651-B526-6AB11EF1E278}.Debug|x64.ActiveCfg = Debug|x64
{8420E151-B23B-4651-B526-6AB11EF1E278}.Release|Win32.ActiveCfg = Release|Win32
{8420E151-B23B-4651-B526-6AB11EF1E278}.Release|x64.ActiveCfg = Release|x64
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Debug|Win32.ActiveCfg = Debug|Win32
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Debug|Win32.Build.0 = Debug|Win32
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Debug|x64.ActiveCfg = Debug|x64
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Debug|x64.Build.0 = Debug|x64
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Release|Win32.ActiveCfg = Release|Win32
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Release|Win32.Build.0 = Release|Win32
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Release|x64.ActiveCfg = Release|x64
{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}.Release|x64.Build.0 = Release|x64
{C9FEAE75-4DD9-44F5-B302-9910559A91BE}.Debug|Win32.ActiveCfg = Debug|Win32
{C9FEAE75-4DD9-44F5-B302-9910559A91BE}.Debug|Win32.Build.0 = Debug|Win32
{C9FEAE75-4DD9-44F5-B302-9910559A91BE}.Debug|x64.ActiveCfg = Debug|x64
{C9FEAE75-4DD9-44F5-B302-9910559A91BE}.Debug|x64.Build.0 = Debug|x64
{C9FEAE75-4DD9-44F5-B302-9910559A91BE}.Release|Win32.ActiveCfg = Release|Win32
{C9FEAE75-4DD9-44F5-B302-9910559A91BE}.Release|Win32.Build.0 = Release|Win32
{C9FEAE75-4DD9-44F5-B302-9910559A91BE}.Release|x64.ActiveCfg = Release|x64
{C9FEAE75-4DD9-44F5-B302-9910559A91BE}.Release|x64.Build.0 = Release|x64
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Debug|Win32.ActiveCfg = Debug|Win32
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Debug|Win32.Build.0 = Debug|Win32
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Debug|x64.ActiveCfg = Debug|x64
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Debug|x64.Build.0 = Debug|x64
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Release|Win32.ActiveCfg = Release|Win32
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Release|Win32.Build.0 = Release|Win32
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Release|x64.ActiveCfg = Release|x64
{EAE18F4D-AAF2-4C19-86FB-1144B5BD5993}.Release|x64.Build.0 = Release|x64
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Debug|Win32.ActiveCfg = Debug|Win32
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Debug|Win32.Build.0 = Debug|Win32
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Debug|x64.ActiveCfg = Debug|x64
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Debug|x64.Build.0 = Debug|x64
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Release|Win32.ActiveCfg = Release|Win32
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Release|Win32.Build.0 = Release|Win32
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Release|x64.ActiveCfg = Release|x64
{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}.Release|x64.Build.0 = Release|x64
{5407AF29-59E9-4DE2-9939-F067576F7868}.Debug|Win32.ActiveCfg = Debug|Win32
{5407AF29-59E9-4DE2-9939-F067576F7868}.Debug|Win32.Build.0 = Debug|Win32
{5407AF29-59E9-4DE2-9939-F067576F7868}.Debug|x64.ActiveCfg = Debug|x64
{5407AF29-59E9-4DE2-9939-F067576F7868}.Debug|x64.Build.0 = Debug|x64
{5407AF29-59E9-4DE2-9939-F067576F7868}.Release|Win32.ActiveCfg = Release|Win32
{5407AF29-59E9-4DE2-9939-F067576F7868}.Release|Win32.Build.0 = Release|Win32
{5407AF29-59E9-4DE2-9939-F067576F7868}.Release|x64.ActiveCfg = Release|x64
{5407AF29-59E9-4DE2-9939-F067576F7868}.Release|x64.Build.0 = Release|x64
{541A2D06-B34E-4592-BE47-F87DF47E73D8}.Debug|Win32.ActiveCfg = Debug|Win32
{541A2D06-B34E-4592-BE47-F87DF47E73D8}.Debug|Win32.Build.0 = Debug|Win32
{541A2D06-B34E-4592-BE47-F87DF47E73D8}.Debug|x64.ActiveCfg = Debug|x64
{541A2D06-B34E-4592-BE47-F87DF47E73D8}.Debug|x64.Build.0 = Debug|x64
{541A2D06-B34E-4592-BE47-F87DF47E73D8}.Release|Win32.ActiveCfg = Release|Win32
{541A2D06-B34E-4592-BE47-F87DF47E73D8}.Release|Win32.Build.0 = Release|Win32
{541A2D06-B34E-4592-BE47-F87DF47E73D8}.Release|x64.ActiveCfg = Release|x64
{541A2D06-B34E-4592-BE47-F87DF47E73D8}.Release|x64.Build.0 = Release|x64
{BFB68CF4-EB92-4E5C-9694-A939496C5CDE}.Debug|Win32.ActiveCfg = Debug|Win32
{BFB68CF4-EB92-4E5C-9694-A939496C5CDE}.Debug|Win32.Build.0 = Debug|Win32
{BFB68CF4-EB92-4E5C-9694-A939496C5CDE}.Debug|x64.ActiveCfg = Debug|x64
{BFB68CF4-EB92-4E5C-9694-A939496C5CDE}.Debug|x64.Build.0 = Debug|x64
{BFB68CF4-EB92-4E5C-9694-A939496C5CDE}.Release|Win32.ActiveCfg = Release|Win32
{BFB68CF4-EB92-4E5C-9694-A939496C5CDE}.Release|Win32.Build.0 = Release|Win32
{BFB68CF4-EB92-4E5C-9694-A939496C5CDE}.Release|x64.ActiveCfg = Release|x64
{BFB68CF4-EB92-4E5C-9694-A939496C5CDE}.Release|x64.Build.0 = Release|x64
{1139E765-DE0F-497A-A7D9-EB2683521DF1}.Debug|Win32.ActiveCfg = Debug|Win32
{1139E765-DE0F-497A-A7D9-EB2683521DF1}.Debug|Win32.Build.0 = Debug|Win32
{1139E765-DE0F-497A-A7D9-EB2683521DF1}.Debug|x64.ActiveCfg = Debug|x64
{1139E765-DE0F-497A-A7D9-EB2683521DF1}.Debug|x64.Build.0 = Debug|x64
{1139E765-DE0F-497A-A7D9-EB2683521DF1}.Release|Win32.ActiveCfg = Release|Win32
{1139E765-DE0F-497A-A7D9-EB2683521DF1}.Release|Win32.Build.0 = Release|Win32
{1139E765-DE0F-497A-A7D9-EB2683521DF1}.Release|x64.ActiveCfg = Release|x64
{1139E765-DE0F-497A-A7D9-EB2683521DF1}.Release|x64.Build.0 = Release|x64
{D9C80FE0-20A6-4711-A3F4-676019BD5A06}.Debug|Win32.ActiveCfg = Debug|Win32
{D9C80FE0-20A6-4711-A3F4-676019BD5A06}.Debug|Win32.Build.0 = Debug|Win32
{D9C80FE0-20A6-4711-A3F4-676019BD5A06}.Debug|x64.ActiveCfg = Debug|x64
{D9C80FE0-20A6-4711-A3F4-676019BD5A06}.Debug|x64.Build.0 = Debug|x64
{D9C80FE0-20A6-4711-A3F4-676019BD5A06}.Release|Win32.ActiveCfg = Release|Win32
{D9C80FE0-20A6-4711-A3F4-676019BD5A06}.Release|Win32.Build.0 = Release|Win32
{D9C80FE0-20A6-4711-A3F4-676019BD5A06}.Release|x64.ActiveCfg = Release|x64
{D9C80FE0-20A6-4711-A3F4-676019BD5A06}.Release|x64.Build.0 = Release|x64
{CE9D8719-6E86-41D0-97CA-5BE5272594E9}.Debug|Win32.ActiveCfg = Debug|Win32
{CE9D8719-6E86-41D0-97CA-5BE5272594E9}.Debug|Win32.Build.0 = Debug|Win32
{CE9D8719-6E86-41D0-97CA-5BE5272594E9}.Debug|x64.ActiveCfg = Debug|Win32
{CE9D8719-6E86-41D0-97CA-5BE5272594E9}.Release|Win32.ActiveCfg = Release|Win32
{CE9D8719-6E86-41D0-97CA-5BE5272594E9}.Release|Win32.Build.0 = Release|Win32
{CE9D8719-6E86-41D0-97CA-5BE5272594E9}.Release|x64.ActiveCfg = Release|Win32
{DA4BC67F-9284-4D2C-81D5-407312C31BD7}.Debug|Win32.ActiveCfg = Debug|Win32
{DA4BC67F-9284-4D2C-81D5-407312C31BD7}.Debug|Win32.Build.0 = Debug|Win32
{DA4BC67F-9284-4D2C-81D5-407312C31BD7}.Debug|x64.ActiveCfg = Debug|Win32
{DA4BC67F-9284-4D2C-81D5-407312C31BD7}.Release|Win32.ActiveCfg = Release|Win32
{DA4BC67F-9284-4D2C-81D5-407312C31BD7}.Release|Win32.Build.0 = Release|Win32
{DA4BC67F-9284-4D2C-81D5-407312C31BD7}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
EndGlobal

View File

@@ -0,0 +1,166 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8638A3D8-D121-40BF-82E5-127F1B1B2CB2}</ProjectGuid>
<RootNamespace>endian_example</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\example\endian_example.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,170 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{3926C6DC-9D1E-4227-BEF5-81F5EC621A75}</ProjectGuid>
<RootNamespace>endian_in_union_test</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\endian_in_union_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,180 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{A0060A5B-673C-4AD8-BD08-A5C643B1A1CB}</ProjectGuid>
<RootNamespace>endian_operations_test</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<DisableSpecificWarnings>4552;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<PreprocessToFile>false</PreprocessToFile>
<PreprocessSuppressLineNumbers>false</PreprocessSuppressLineNumbers>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<DisableSpecificWarnings>4552;%(DisableSpecificWarnings)</DisableSpecificWarnings>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\endian_operations_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,172 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{74C201F3-8308-40BE-BC0F-24974DEAF405}</ProjectGuid>
<RootNamespace>endian_test</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<OutDir>$(SolutionDir)$(Configuration)\</OutDir>
<IntDir>$(Configuration)\</IntDir>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<AdditionalIncludeDirectories>%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\endian_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,168 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{541A2D06-B34E-4592-BE47-F87DF47E73D8}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>loop_time_test</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 1234</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 1</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 100000000</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<AssemblerOutput>AssemblyAndSourceCode</AssemblerOutput>
<AssemblerListingLocation>c:/temp/</AssemblerListingLocation>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 1000000000</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\loop_time_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,166 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{8420E151-B23B-4651-B526-6AB11EF1E278}</ProjectGuid>
<RootNamespace>scoped_enum_emulation_test</RootNamespace>
<Keyword>Win32Proj</Keyword>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<WholeProgramOptimization>true</WholeProgramOptimization>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<CharacterSet>Unicode</CharacterSet>
<PlatformToolset>v141</PlatformToolset>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup>
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</LinkIncremental>
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</LinkIncremental>
<LinkIncremental Condition="'$(Configuration)|$(Platform)'=='Release|x64'">false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<MinimalRebuild>true</MinimalRebuild>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>EditAndContinue</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
<RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<TargetMachine>MachineX86</TargetMachine>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<Optimization>MaxSpeed</Optimization>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
<FunctionLevelLinking>true</FunctionLevelLinking>
<PrecompiledHeader>
</PrecompiledHeader>
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
<WarningLevel>Level3</WarningLevel>
</ClCompile>
<Link>
<GenerateDebugInformation>true</GenerateDebugInformation>
<SubSystem>Console</SubSystem>
<OptimizeReferences>true</OptimizeReferences>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\scoped_enum_emulation_test.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,167 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{5407AF29-59E9-4DE2-9939-F067576F7868}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>speed_test</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 1000000</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 1000000</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 100000000</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
<PostBuildEvent>
<Command>"$(TargetDir)\$(TargetName).exe" 100000000</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\speed_test.cpp" />
<ClCompile Include="..\..\speed_test_functions.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,154 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{27A53564-D32B-4A32-8A6E-2F3BD252EEBA}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>udt_conversion_example</RootNamespace>
<WindowsTargetPlatformVersion>10.0.15063.0</WindowsTargetPlatformVersion>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v141</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\example\udt_conversion_example.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,157 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup Label="ProjectConfigurations">
<ProjectConfiguration Include="Debug|Win32">
<Configuration>Debug</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Debug|x64">
<Configuration>Debug</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|Win32">
<Configuration>Release</Configuration>
<Platform>Win32</Platform>
</ProjectConfiguration>
<ProjectConfiguration Include="Release|x64">
<Configuration>Release</Configuration>
<Platform>x64</Platform>
</ProjectConfiguration>
</ItemGroup>
<PropertyGroup Label="Globals">
<ProjectGuid>{36BF451A-EAEF-4140-92E4-6EA461A26107}</ProjectGuid>
<Keyword>Win32Proj</Keyword>
<RootNamespace>uses_cases</RootNamespace>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>true</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
<ConfigurationType>Application</ConfigurationType>
<UseDebugLibraries>false</UseDebugLibraries>
<PlatformToolset>v140</PlatformToolset>
<WholeProgramOptimization>true</WholeProgramOptimization>
<CharacterSet>Unicode</CharacterSet>
</PropertyGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
<ImportGroup Label="ExtensionSettings">
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
<Import Project="..\common.props" />
</ImportGroup>
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LinkIncremental>true</LinkIncremental>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<ExecutablePath>..\..\..\..\..\stage\lib;$(VC_ExecutablePath_x64);$(WindowsSDK_ExecutablePath);$(VS_ExecutablePath);$(MSBuild_ExecutablePath);$(SystemRoot)\SysWow64;$(FxCopDir);$(PATH);</ExecutablePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LinkIncremental>false</LinkIncremental>
</PropertyGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<ClCompile>
<PrecompiledHeader>
</PrecompiledHeader>
<WarningLevel>Level3</WarningLevel>
<Optimization>Disabled</Optimization>
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<ClCompile>
<WarningLevel>Level3</WarningLevel>
<PrecompiledHeader>
</PrecompiledHeader>
<Optimization>MaxSpeed</Optimization>
<FunctionLevelLinking>true</FunctionLevelLinking>
<IntrinsicFunctions>true</IntrinsicFunctions>
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
<SDLCheck>true</SDLCheck>
</ClCompile>
<Link>
<SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
<OptimizeReferences>true</OptimizeReferences>
</Link>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="..\..\..\example\use_cases.cpp" />
</ItemGroup>
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>

View File

@@ -0,0 +1,87 @@
// Copyright 2019 Peter Dimov
//
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/detail/order.hpp>
#include <boost/core/lightweight_test.hpp>
#include <boost/config.hpp>
#include <boost/cstdint.hpp>
#include <cstddef>
#include <ostream>
#include <iomanip>
#if defined(_MSC_VER)
# pragma warning(disable: 4127) // conditional expression is constant
#endif
class byte_span
{
private:
unsigned char const * p_;
std::size_t n_;
public:
byte_span( unsigned char const * p, std::size_t n ): p_( p ), n_( n )
{
}
template<std::size_t N> explicit byte_span( unsigned char const (&a)[ N ] ): p_( a ), n_( N )
{
}
bool operator==( byte_span const& r ) const
{
if( n_ != r.n_ ) return false;
for( std::size_t i = 0; i < n_; ++i )
{
if( p_[ i ] != r.p_[ i ] ) return false;
}
return true;
}
friend std::ostream& operator<<( std::ostream& os, byte_span s )
{
if( s.n_ == 0 ) return os;
os << std::hex << std::setfill( '0' ) << std::uppercase;
os << std::setw( 2 ) << +s.p_[ 0 ];
for( std::size_t i = 1; i < s.n_; ++i )
{
os << ':' << std::setw( 2 ) << +s.p_[ i ];
}
os << std::dec << std::setfill( ' ' ) << std::nouppercase;
return os;
}
};
int main()
{
boost::uint64_t v = static_cast<boost::uint64_t>( 0x0102030405060708ull );
byte_span v2( reinterpret_cast<unsigned char const*>( &v ), sizeof(v) );
if( boost::endian::order::native == boost::endian::order::little )
{
unsigned char w[] = { 8, 7, 6, 5, 4, 3, 2, 1 };
BOOST_TEST_EQ( v2, byte_span( w ) );
}
else if( boost::endian::order::native == boost::endian::order::big )
{
unsigned char w[] = { 1, 2, 3, 4, 5, 6, 7, 8 };
BOOST_TEST_EQ( v2, byte_span( w ) );
}
else
{
BOOST_ERROR( "boost::endian::order::native is neither big nor little" );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,38 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if !defined(__GNUC__)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE( "Skipping test because __GNUC__ is not defined" )
int main() {}
#else
#define BOOST_ENDIAN_FORCE_PODNESS
#define BOOST_ENDIAN_NO_CTORS
#include <boost/endian/arithmetic.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost::endian;
struct X
{
big_uint16_t a;
native_float64_t b;
little_uint16_t c;
} __attribute__((packed));
int main()
{
BOOST_TEST_EQ( sizeof(big_uint16_t), 2 );
BOOST_TEST_EQ( sizeof(native_float64_t), 8 );
BOOST_TEST_EQ( sizeof(little_uint16_t), 2 );
BOOST_TEST_EQ( sizeof(X), 12 );
return boost::report_errors();
}
#endif

View File

@@ -0,0 +1,38 @@
// Copyright 2020 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// https://www.boost.org/LICENSE_1_0.txt
#if !defined(__GNUC__)
#include <boost/config/pragma_message.hpp>
BOOST_PRAGMA_MESSAGE( "Skipping test because __GNUC__ is not defined" )
int main() {}
#else
#define BOOST_ENDIAN_FORCE_PODNESS
#define BOOST_ENDIAN_NO_CTORS
#include <boost/endian/buffers.hpp>
#include <boost/core/lightweight_test.hpp>
using namespace boost::endian;
struct X
{
big_uint16_buf_t a;
native_float64_buf_t b;
little_uint16_buf_t c;
} __attribute__((packed));
int main()
{
BOOST_TEST_EQ( sizeof(big_uint16_buf_t), 2 );
BOOST_TEST_EQ( sizeof(native_float64_buf_t), 8 );
BOOST_TEST_EQ( sizeof(little_uint16_buf_t), 2 );
BOOST_TEST_EQ( sizeof(X), 12 );
return boost::report_errors();
}
#endif

View File

@@ -0,0 +1,31 @@
// Copyright 2019 Peter Dimov
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
#include <boost/endian/arithmetic.hpp>
#include <boost/core/lightweight_test.hpp>
int main()
{
using namespace boost::endian;
{
little_uint32_t v( 0x01020304 );
BOOST_TEST_EQ( v.data()[ 0 ], 0x04 );
BOOST_TEST_EQ( v.data()[ 1 ], 0x03 );
BOOST_TEST_EQ( v.data()[ 2 ], 0x02 );
BOOST_TEST_EQ( v.data()[ 3 ], 0x01 );
}
{
big_uint32_t v( 0x01020304 );
BOOST_TEST_EQ( v.data()[ 0 ], 0x01 );
BOOST_TEST_EQ( v.data()[ 1 ], 0x02 );
BOOST_TEST_EQ( v.data()[ 2 ], 0x03 );
BOOST_TEST_EQ( v.data()[ 3 ], 0x04 );
}
return boost::report_errors();
}

View File

@@ -0,0 +1,48 @@
// scoped_enum_emulation_test.cpp ----------------------------------------------------//
// Copyright Beman Dawes, 2009
// Distributed under the Boost Software License, Version 1.0.
// See http://www.boost.org/LICENSE_1_0.txt
// See documentation at http://www.boost.org/libs/utility/scoped_enum_emulation.html
// #include <boost/detail/disable_warnings.hpp>
// #include <boost/config/warning_disable.hpp>
#include <boost/detail/scoped_enum_emulation.hpp>
#include <boost/assert.hpp>
BOOST_SCOPED_ENUM_START(traffic_light) { red=0, yellow, green }; BOOST_SCOPED_ENUM_END
BOOST_SCOPED_ENUM_START(algae) { green=0, red, cyan }; BOOST_SCOPED_ENUM_END
struct color
{
BOOST_SCOPED_ENUM_START(value_t) { red, green, blue }; BOOST_SCOPED_ENUM_END
BOOST_SCOPED_ENUM(value_t) value;
};
void foo( BOOST_SCOPED_ENUM(algae) arg )
{
BOOST_ASSERT( arg == algae::cyan );
}
int main()
{
BOOST_SCOPED_ENUM(traffic_light) signal( traffic_light::red );
BOOST_SCOPED_ENUM(algae) sample( algae::red );
BOOST_ASSERT( signal == traffic_light::red );
BOOST_ASSERT( sample == algae::red );
foo( algae::cyan );
color tracker;
tracker.value = color::value_t::blue;
if (tracker.value == color::value_t::blue) return 0; // quiet warnings
return 0;
}

View File

@@ -0,0 +1,194 @@
// speed_test.cpp --------------------------------------------------------------------//
// Copyright Beman Dawes 2013
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
//--------------------------------------------------------------------------------------//
//#define BOOST_ENDIAN_NO_INTRINSICS
#include <boost/endian/detail/disable_warnings.hpp>
#include "speed_test_functions.hpp"
#include <boost/endian/conversion.hpp>
#include <boost/endian/arithmetic.hpp>
#include <boost/cstdint.hpp>
#include <boost/timer/timer.hpp>
#include <iostream>
#include <cstdlib>
#include <boost/detail/lightweight_main.hpp>
using namespace boost;
using namespace boost::endian;
using std::cout;
using std::endl;
namespace
{
typedef boost::timer::nanosecond_type nanosecond_t;
std::string command_args;
uint64_t n; // number of test cases to run
int places = 2; // decimal places for times
bool verbose (false);
void process_command_line(int argc, char * argv[])
{
for (int a = 0; a < argc; ++a)
{
command_args += argv[a];
if (a != argc-1)
command_args += ' ';
}
// cout << command_args << '\n';;
if (argc >=2)
#ifndef _MSC_VER
n = atoll(argv[1]);
#else
n = _atoi64(argv[1]);
#endif
for (; argc > 2; ++argv, --argc)
{
if ( *(argv[2]+1) == 'p' )
places = atoi( argv[2]+2 );
else if ( *(argv[2]+1) == 'v' )
verbose = true;
else
{
cout << "Error - unknown option: " << argv[2] << "\n\n";
argc = -1;
break;
}
}
if (argc < 2)
{
cout << "Usage: speed_test n [Options]\n"
" The argument n specifies the number of test cases to run\n"
" Options:\n"
" -v Verbose messages\n"
" -p# Decimal places for times; default -p" << places << "\n";
return std::exit(1);
}
}
//--------------------------------------------------------------------------------------//
template <class T, class EndianT, class Function>
void time(Function f)
{
T x(0);
EndianT y(0);
boost::timer::cpu_timer t;
for (uint64_t i = 0; i < n; ++i)
{
f(x, y);
}
t.stop();
cout << "<td align=\"right\">" << t.format(places, "%t") << " s</td>";
}
void test_big_int16()
{
cout << "<tr><td>16-bit aligned big endian</td>";
time<int16_t, big_int16_t>(user::return_x_big_int16);
time<int16_t, big_int16_t>(user::return_x_value_big_int16);
time<int16_t, big_int16_t>(user::return_x_inplace_big_int16);
time<int16_t, big_int16_t>(user::return_y_big_int16);
cout << "</tr>\n";
}
void test_little_int16()
{
cout << "<tr><td>16-bit aligned little endian</td>";
time<int16_t, little_int16_t>(user::return_x_little_int16);
time<int16_t, little_int16_t>(user::return_x_value_little_int16);
time<int16_t, little_int16_t>(user::return_x_inplace_little_int16);
time<int16_t, little_int16_t>(user::return_y_little_int16);
cout << "</tr>\n";
}
void test_big_int32()
{
cout << "<tr><td>32-bit aligned big endian</td>";
time<int32_t, big_int32_t>(user::return_x_big_int32);
time<int32_t, big_int32_t>(user::return_x_value_big_int32);
time<int32_t, big_int32_t>(user::return_x_inplace_big_int32);
time<int32_t, big_int32_t>(user::return_y_big_int32);
cout << "</tr>\n";
}
void test_little_int32()
{
cout << "<tr><td>32-bit aligned little endian</td>";
time<int32_t, little_int32_t>(user::return_x_little_int32);
time<int32_t, little_int32_t>(user::return_x_value_little_int32);
time<int32_t, little_int32_t>(user::return_x_inplace_little_int32);
time<int32_t, little_int32_t>(user::return_y_little_int32);
cout << "</tr>\n";
}
void test_big_int64()
{
cout << "<tr><td>64-bit aligned big endian</td>";
time<int64_t, big_int64_t>(user::return_x_big_int64);
time<int64_t, big_int64_t>(user::return_x_value_big_int64);
time<int64_t, big_int64_t>(user::return_x_inplace_big_int64);
time<int64_t, big_int64_t>(user::return_y_big_int64);
cout << "</tr>\n";
}
void test_little_int64()
{
cout << "<tr><td>64-bit aligned little endian</td>";
time<int64_t, little_int64_t>(user::return_x_little_int64);
time<int64_t, little_int64_t>(user::return_x_value_little_int64);
time<int64_t, little_int64_t>(user::return_x_inplace_little_int64);
time<int64_t, little_int64_t>(user::return_y_little_int64);
cout << "</tr>\n";
}
} // unnamed namespace
//--------------------------------------------------------------------------------------//
int cpp_main(int argc, char* argv[])
{
process_command_line(argc, argv);
cout
<< "<html>\n<head>\n<title>Endian Speed Test</title>\n</head>\n<body>\n"
<< "<table border=\"1\" cellpadding=\"5\" cellspacing=\"0\""
<< "style=\"border-collapse: collapse\" bordercolor=\"#111111\">\n"
<< "<tr><td colspan=\"6\" align=\"center\"><b>"
<< BOOST_COMPILER << "</b></td></tr>\n"
<< "<tr><td colspan=\"6\" align=\"center\"><b>"
<< " Iterations: " << n
<< ", Intrinsics: " BOOST_ENDIAN_INTRINSIC_MSG
<< "</b></td></tr>\n"
<< "<tr><td><b>Test Case</b></td>\n"
"<td align=\"center\"><b>int<br>arg</b></td>\n"
"<td align=\"center\"><b>int<br>value(arg)</b></td>\n"
"<td align=\"center\"><b>int<br>in place(arg)</b></td>\n"
"<td align=\"center\"><b>Endian<br>arg</b></td>\n"
"</tr>\n"
;
test_big_int16();
test_little_int16();
test_big_int32();
test_little_int32();
test_big_int64();
test_little_int64();
cout << "\n</table>\n</body>\n</html>\n";
return 0;
}
#include <boost/endian/detail/disable_warnings_pop.hpp>

View File

@@ -0,0 +1,96 @@
// speed_test_functions.cpp ----------------------------------------------------------//
// Copyright Beman Dawes 2013
// Distributed under the Boost Software License, Version 1.0.
// http://www.boost.org/LICENSE_1_0.txt
//--------------------------------------------------------------------------------------//
// These functions are in a separate compilation unit partially to defeat optimizers
// and partially to create a worst case scenario. They are in a user namespace for
// realism.
//--------------------------------------------------------------------------------------//
#ifndef _SCL_SECURE_NO_WARNINGS
# define _SCL_SECURE_NO_WARNINGS
#endif
#ifndef _CRT_SECURE_NO_WARNINGS
# define _CRT_SECURE_NO_WARNINGS
#endif
#include "speed_test_functions.hpp"
namespace user
{
int16_t return_x_big_int16(int16_t x, big_int16_t) BOOST_NOEXCEPT { return x; }
int16_t return_x_little_int16(int16_t x, little_int16_t) BOOST_NOEXCEPT { return x; }
int16_t return_x_value_big_int16(int16_t x, big_int16_t) BOOST_NOEXCEPT
{
return conditional_reverse<order::native, order::big>(x);
}
int16_t return_x_value_little_int16(int16_t x, little_int16_t) BOOST_NOEXCEPT
{
return conditional_reverse<order::native, order::little>(x);
}
int16_t return_x_inplace_big_int16(int16_t x, big_int16_t) BOOST_NOEXCEPT
{
conditional_reverse_inplace<order::native, order::big>(x); return x;
}
int16_t return_x_inplace_little_int16(int16_t x, little_int16_t) BOOST_NOEXCEPT
{
conditional_reverse_inplace<order::native, order::little>(x); return x;
}
int16_t return_y_big_int16(int16_t x, big_int16_t y) BOOST_NOEXCEPT { return y; }
int16_t return_y_little_int16(int16_t x, little_int16_t y) BOOST_NOEXCEPT { return y; }
//------------------------------------------------------------------------------------//
int32_t return_x_big_int32(int32_t x, big_int32_t) BOOST_NOEXCEPT { return x; }
int32_t return_x_little_int32(int32_t x, little_int32_t) BOOST_NOEXCEPT { return x; }
int32_t return_x_value_big_int32(int32_t x, big_int32_t) BOOST_NOEXCEPT
{
return conditional_reverse<order::native, order::big>(x);
}
int32_t return_x_value_little_int32(int32_t x, little_int32_t) BOOST_NOEXCEPT
{
return conditional_reverse<order::native, order::little>(x);
}
int32_t return_x_inplace_big_int32(int32_t x, big_int32_t) BOOST_NOEXCEPT
{
conditional_reverse_inplace<order::native, order::big>(x); return x;
}
int32_t return_x_inplace_little_int32(int32_t x, little_int32_t) BOOST_NOEXCEPT
{
conditional_reverse_inplace<order::native, order::little>(x); return x;
}
int32_t return_y_big_int32(int32_t x, big_int32_t y) BOOST_NOEXCEPT { return y; }
int32_t return_y_little_int32(int32_t x, little_int32_t y) BOOST_NOEXCEPT { return y; }
//------------------------------------------------------------------------------------//
int64_t return_x_big_int64(int64_t x, big_int64_t) BOOST_NOEXCEPT { return x; }
int64_t return_x_little_int64(int64_t x, little_int64_t) BOOST_NOEXCEPT { return x; }
int64_t return_x_value_big_int64(int64_t x, big_int64_t) BOOST_NOEXCEPT
{
return conditional_reverse<order::native, order::big>(x);
}
int64_t return_x_value_little_int64(int64_t x, little_int64_t) BOOST_NOEXCEPT
{
return conditional_reverse<order::native, order::little>(x);
}
int64_t return_x_inplace_big_int64(int64_t x, big_int64_t) BOOST_NOEXCEPT
{
conditional_reverse_inplace<order::native, order::big>(x); return x;
}
int64_t return_x_inplace_little_int64(int64_t x, little_int64_t) BOOST_NOEXCEPT
{
conditional_reverse_inplace<order::native, order::little>(x); return x;
}
int64_t return_y_big_int64(int64_t x, big_int64_t y) BOOST_NOEXCEPT { return y; }
int64_t return_y_little_int64(int64_t x, little_int64_t y) BOOST_NOEXCEPT { return y; }
}

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