diff --git a/.cargo/config.toml b/.cargo/config.toml
new file mode 100644
index 0000000000000000000000000000000000000000..fcd33554f29e89318604763e7c0226d346e77b99
--- /dev/null
+++ b/.cargo/config.toml
@@ -0,0 +1,2 @@
+[build]
+target-dir = "build"
diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile
new file mode 100644
index 0000000000000000000000000000000000000000..fa4afe350d63cad98259a1a44515918cbbddb383
--- /dev/null
+++ b/.devcontainer/Dockerfile
@@ -0,0 +1,11 @@
+FROM library/node:lts-bookworm
+
+ARG DEBIAN_FRONTEND=noninteractive
+RUN apt update && \
+ apt-get install -y nodejs nasm gdb unzip p7zip-full openjdk-17-jre wget python3 qemu-system-x86 git-core build-essential libc6-dev-i386-cross libc6-dev-i386 clang curl time
+RUN npm install -g jshint
+RUN curl https://sh.rustup.rs -sSf | sh -s -- -y
+RUN /root/.cargo/bin/rustup toolchain install stable && \
+ /root/.cargo/bin/rustup target add wasm32-unknown-unknown && \
+ /root/.cargo/bin/rustup component add rustfmt-preview && \
+ /root/.cargo/bin/rustup update && /root/.cargo/bin/rustup update nightly
diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json
new file mode 100644
index 0000000000000000000000000000000000000000..ac453fa06b6aa75988c6dcd785981990a5c4b9f9
--- /dev/null
+++ b/.devcontainer/devcontainer.json
@@ -0,0 +1,28 @@
+{
+ "name": "v86 dev container",
+ "build": {
+ "dockerfile": "Dockerfile",
+ "args": {
+ "VARIANT": "ubuntu"
+ }
+ },
+ "features": {
+ "ghcr.io/devcontainers-contrib/features/curl-apt-get:1": {},
+ "ghcr.io/jungaretti/features/ripgrep:1": {}
+ },
+ "customizations": {
+ "vscode": {
+ "extensions": [
+ "ms-azuretools.vscode-docker",
+ "yzhang.markdown-all-in-one",
+ "DavidAnson.vscode-markdownlint",
+ "christian-kohler.npm-intellisense",
+ "dbaeumer.vscode-eslint",
+ "dustypomerleau.rust-syntax",
+ "serayuzgur.crates",
+ "ms-vscode.makefile-tools",
+ "rust-lang.rust-analyzer"
+ ]
+ }
+ }
+}
\ No newline at end of file
diff --git a/.editorconfig b/.editorconfig
new file mode 100644
index 0000000000000000000000000000000000000000..d9668d844f591ed7915d2a57b432441dcbe130ea
--- /dev/null
+++ b/.editorconfig
@@ -0,0 +1,6 @@
+root=true
+
+[*.js]
+charset = utf-8
+indent_style = space
+indent_size = 4
diff --git a/.gitattributes b/.gitattributes
index a6344aac8c09253b3b630fb776ae94478aa0275b..dd94dabd1d80574ab26d116fd77474aefa09cbc7 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,35 +1,4 @@
-*.7z filter=lfs diff=lfs merge=lfs -text
-*.arrow filter=lfs diff=lfs merge=lfs -text
-*.bin filter=lfs diff=lfs merge=lfs -text
-*.bz2 filter=lfs diff=lfs merge=lfs -text
-*.ckpt filter=lfs diff=lfs merge=lfs -text
-*.ftz filter=lfs diff=lfs merge=lfs -text
-*.gz filter=lfs diff=lfs merge=lfs -text
-*.h5 filter=lfs diff=lfs merge=lfs -text
-*.joblib filter=lfs diff=lfs merge=lfs -text
-*.lfs.* filter=lfs diff=lfs merge=lfs -text
-*.mlmodel filter=lfs diff=lfs merge=lfs -text
-*.model filter=lfs diff=lfs merge=lfs -text
-*.msgpack filter=lfs diff=lfs merge=lfs -text
-*.npy filter=lfs diff=lfs merge=lfs -text
-*.npz filter=lfs diff=lfs merge=lfs -text
-*.onnx filter=lfs diff=lfs merge=lfs -text
-*.ot filter=lfs diff=lfs merge=lfs -text
-*.parquet filter=lfs diff=lfs merge=lfs -text
-*.pb filter=lfs diff=lfs merge=lfs -text
-*.pickle filter=lfs diff=lfs merge=lfs -text
-*.pkl filter=lfs diff=lfs merge=lfs -text
-*.pt filter=lfs diff=lfs merge=lfs -text
-*.pth filter=lfs diff=lfs merge=lfs -text
-*.rar filter=lfs diff=lfs merge=lfs -text
-*.safetensors filter=lfs diff=lfs merge=lfs -text
-saved_model/**/* filter=lfs diff=lfs merge=lfs -text
-*.tar.* filter=lfs diff=lfs merge=lfs -text
-*.tar filter=lfs diff=lfs merge=lfs -text
-*.tflite filter=lfs diff=lfs merge=lfs -text
-*.tgz filter=lfs diff=lfs merge=lfs -text
-*.wasm filter=lfs diff=lfs merge=lfs -text
-*.xz filter=lfs diff=lfs merge=lfs -text
-*.zip filter=lfs diff=lfs merge=lfs -text
-*.zst filter=lfs diff=lfs merge=lfs -text
-*tfevents* filter=lfs diff=lfs merge=lfs -text
+lib/zstd/* linguist-vendored
+lib/softfloat/* linguist-vendored
+bios/seabios-debug.bin filter=lfs diff=lfs merge=lfs -text
+bios/seabios.bin filter=lfs diff=lfs merge=lfs -text
diff --git a/.github/ISSUE_TEMPLATE/issue.md b/.github/ISSUE_TEMPLATE/issue.md
new file mode 100644
index 0000000000000000000000000000000000000000..8ee7d34d1ff625a3ce644cf5f5c7104efba2e64d
--- /dev/null
+++ b/.github/ISSUE_TEMPLATE/issue.md
@@ -0,0 +1,24 @@
+---
+name: Issue
+about: Bug reports or feature requests
+title: ''
+labels: ''
+assignees: ''
+
+---
+
+
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
new file mode 100644
index 0000000000000000000000000000000000000000..24723c9ccfd32fa05f77402effb1095f990d4e11
--- /dev/null
+++ b/.github/workflows/ci.yml
@@ -0,0 +1,180 @@
+name: CI
+
+on:
+ push:
+ pull_request:
+
+jobs:
+ eslint:
+ name: eslint
+ runs-on: ubuntu-latest
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+
+ - name: Run eslint
+ run: sudo npm install -g eslint; make eslint
+
+ test:
+ runs-on: ubuntu-latest
+ name: Build and test
+ timeout-minutes: 60
+ steps:
+ - name: Checkout repository
+ uses: actions/checkout@v4
+ with:
+ fetch-depth: 0
+ filter: tree:0
+
+ - name: Setup Node.js version
+ uses: actions/setup-node@v4
+ with:
+ node-version: '20'
+ check-latest: true
+ registry-url: 'https://registry.npmjs.org'
+
+ - name: Setup toolchain
+ run: |
+ rustup toolchain install stable --profile minimal
+ rustup target add wasm32-unknown-unknown
+ rustup component add rustfmt
+
+ - name: Install APT packages
+ run: |
+ sudo apt-get update -y
+ sudo apt-get install nasm gdb qemu-system-x86 libc6-dev-i386 -y
+
+ - name: Build all-debug
+ run: make all-debug
+
+ - name: Build all
+ run: make all
+
+ - name: Build fallback
+ run: make build/v86-fallback.wasm
+
+ - name: rustfmt check
+ run: make rustfmt
+
+ - name: Fetch kvm-unit-test cache
+ uses: actions/cache@v4
+ id: cache-kvm-unit-test
+ with:
+ path: tests/kvm-unit-tests/
+ key: ${{ runner.os }}-kvm-unit-test
+
+ - name: Build kvm-unit-test
+ if: steps.cache-kvm-unit-test.outputs.cache-hit != 'true'
+ run: (cd tests/kvm-unit-tests && ./configure && make x86/realmode.flat)
+
+ - name: Run kvm-unit-test
+ run: tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/realmode.flat
+
+ - name: Fetch namsmtests cache
+ uses: actions/cache@v4
+ id: cache-nasmtests
+ with:
+ path: tests/nasm/build/
+ key: ${{ runner.os }}-nasmtests
+
+ - name: Run nasmtests
+ run: MAX_PARALLEL_TESTS=1 make nasmtests
+
+ - name: Run nasmtests-force-jit
+ run: MAX_PARALLEL_TESTS=1 make nasmtests-force-jit
+
+ - name: Run rust-test
+ run: make rust-test
+
+ - name: Fetch image cache
+ uses: actions/cache@v4
+ id: cache-images
+ with:
+ path: images/
+ key: ${{ runner.os }}-images-v2
+
+ - name: Download uncached images
+ if: steps.cache-images.outputs.cache-hit != 'true'
+ run: mkdir -p images && curl --compressed --output-dir images --remote-name-all https://i.copy.sh/{linux.iso,linux3.iso,linux4.iso,buildroot-bzimage68.bin,TinyCore-11.0.iso,oberon.img,msdos.img,openbsd-floppy.img,kolibri.img,windows101.img,os8.img,freedos722.img,mobius-fd-release5.img,msdos622.img}
+
+ - name: Run api-tests
+ run: make api-tests
+
+ - name: Run qemutests
+ run: make qemutests
+
+ - name: Run qemutests-release
+ run: make qemutests-release
+
+ - name: Run jitpagingtests
+ run: make jitpagingtests
+
+ - name: Run integration tests
+ run: MAX_PARALLEL_TESTS=1 make tests
+
+ - name: Run devices tests
+ run: make devices-test
+
+ - name: Run expect tests
+ run: make expect-tests
+
+ - name: Update package.json version
+ run: make update-package-json-version
+
+ - name: Upload the artifact
+ uses: actions/upload-artifact@v4
+ with:
+ name: v86
+ path: |
+ package.json
+ LICENSE
+ Readme.md
+ build/libv86*.js
+ build/libv86*.js.map
+ build/v86*.wasm
+ build/*.mjs
+
+ upload:
+ name: Upload release
+ runs-on: ubuntu-latest
+ needs: test
+ if: github.ref == 'refs/heads/master'
+
+ permissions:
+ id-token: write
+ contents: write
+
+ steps:
+ - name: Delete old release and tag
+ uses: dev-drprasad/delete-tag-and-release@v1.0.1
+ with:
+ delete_release: true
+ tag_name: latest
+ github_token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Get artifacts
+ uses: actions/download-artifact@v4
+ with:
+ name: v86
+
+ - name: Display structure of downloaded files
+ run: ls -R
+
+ - uses: actions/setup-node@v4
+ with:
+ node-version: '20.x'
+ registry-url: 'https://registry.npmjs.org'
+
+ - name: Release to GitHub
+ uses: ncipollo/release-action@v1
+ with:
+ name: Latest Release
+ tag: latest
+ commit: master
+ body: ${{ github.event.head_commit.message }}
+ artifacts: "build/libv86*.js,build/libv86*.js.map,build/*.mjs,build/v86*.wasm"
+ prerelease: true
+
+ - run: npm publish --provenance --access public
+ env:
+ NODE_AUTH_TOKEN: ${{ secrets.NODE_AUTH_TOKEN }}
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..aecb1925303b61e51ac60b5c40362b50528676f3
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,28 @@
+*.swp
+*.swo
+tests/qemu/test-i386
+tests/jit-paging/test-jit
+*.map
+build/
+closure-compiler/
+images/
+*.bak
+*.orig
+*.wasm
+*.o
+*.bin
+*.img
+*.fixture
+*.fuse_hidden*
+*.DS_Store
+node_modules/
+Cargo.lock
+build-head
+src/rust/gen/interpreter.rs
+src/rust/gen/interpreter0f.rs
+src/rust/gen/analyzer.rs
+src/rust/gen/analyzer0f.rs
+src/rust/gen/jit.rs
+src/rust/gen/jit0f.rs
+bios/seabios
+bench-results
diff --git a/.rustfmt.toml b/.rustfmt.toml
new file mode 100644
index 0000000000000000000000000000000000000000..17785c13bf6f721b83e9c271b3c42812bb27605c
--- /dev/null
+++ b/.rustfmt.toml
@@ -0,0 +1,6 @@
+use_field_init_shorthand = true
+match_block_trailing_comma = true
+fn_single_line = true
+imports_indent = "Block"
+control_brace_style = "ClosingNextLine"
+single_line_if_else_max_width = 92
diff --git a/.vscode/tasks.json b/.vscode/tasks.json
new file mode 100644
index 0000000000000000000000000000000000000000..a35aff80df8d92a72c24e57ef92dc865bfc1d541
--- /dev/null
+++ b/.vscode/tasks.json
@@ -0,0 +1,12 @@
+{
+ // See https://go.microsoft.com/fwlink/?LinkId=733558
+ // for the documentation about the tasks.json format
+ "version": "2.0.0",
+ "tasks": [
+ {
+ "label": "Fetch images",
+ "type": "shell",
+ "command": "wget -P images/ https://i.copy.sh/{linux3.iso,linux.iso,linux4.iso,buildroot-bzimage.bin,openbsd-floppy.img,kolibri.img,windows101.img,os8.img,freedos722.img}"
+ }
+ ]
+}
diff --git a/Cargo.toml b/Cargo.toml
new file mode 100644
index 0000000000000000000000000000000000000000..f7ad7aab2732ea6049f90e7c488a16b047cc4ddf
--- /dev/null
+++ b/Cargo.toml
@@ -0,0 +1,30 @@
+[package]
+name = "v86"
+version = "0.1.0"
+publish = false
+edition = "2021"
+
+[features]
+default = []
+profiler = []
+
+[lib]
+crate-type = ["cdylib"]
+path = "src/rust/lib.rs"
+
+[profile.test]
+lto = false
+opt-level = 2
+overflow-checks = false
+
+[profile.dev]
+lto = true
+opt-level = 2
+panic = "abort"
+overflow-checks = false
+
+[profile.release]
+lto = true
+opt-level = 3
+incremental = false
+panic = "abort"
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000000000000000000000000000000000..5033d6de0b4f0173aecb9abc5dc94d21b1387381
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,22 @@
+Copyright (c) 2012, The v86 contributors
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+1. Redistributions of source code must retain the above copyright notice, this
+ list of conditions and the following disclaimer.
+2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
+ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
+ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
diff --git a/LICENSE.MIT b/LICENSE.MIT
new file mode 100644
index 0000000000000000000000000000000000000000..738c67e5b74f1279fd6433663c7bb66aab9510fc
--- /dev/null
+++ b/LICENSE.MIT
@@ -0,0 +1,22 @@
+QEMU Floppy disk emulator (Intel 82078)
+
+Copyright (c) 2003, 2007 Jocelyn Mayer
+Copyright (c) 2008 Hervé Poussineau
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000000000000000000000000000000000000..3cf8e987a5a1463b8cf44ee31cb2faac83da8b2f
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,398 @@
+CLOSURE_DIR=closure-compiler
+CLOSURE=$(CLOSURE_DIR)/compiler.jar
+NASM_TEST_DIR=./tests/nasm
+
+INSTRUCTION_TABLES=src/rust/gen/jit.rs src/rust/gen/jit0f.rs \
+ src/rust/gen/interpreter.rs src/rust/gen/interpreter0f.rs \
+ src/rust/gen/analyzer.rs src/rust/gen/analyzer0f.rs \
+
+# Only the dependencies common to both generate_{jit,interpreter}.js
+GEN_DEPENDENCIES=$(filter-out gen/generate_interpreter.js gen/generate_jit.js gen/generate_analyzer.js, $(wildcard gen/*.js))
+JIT_DEPENDENCIES=$(GEN_DEPENDENCIES) gen/generate_jit.js
+INTERPRETER_DEPENDENCIES=$(GEN_DEPENDENCIES) gen/generate_interpreter.js
+ANALYZER_DEPENDENCIES=$(GEN_DEPENDENCIES) gen/generate_analyzer.js
+
+STRIP_DEBUG_FLAG=
+ifeq ($(STRIP_DEBUG),true)
+STRIP_DEBUG_FLAG=--v86-strip-debug
+endif
+
+WASM_OPT ?= false
+
+default: build/v86-debug.wasm
+all: build/v86_all.js build/libv86.js build/libv86.mjs build/v86.wasm
+all-debug: build/libv86-debug.js build/libv86-debug.mjs build/v86-debug.wasm
+browser: build/v86_all.js
+
+# Used for nodejs builds and in order to profile code.
+# `debug` gives identifiers a readable name, make sure it doesn't have any side effects.
+CLOSURE_READABLE=--formatting PRETTY_PRINT --debug
+
+CLOSURE_SOURCE_MAP=\
+ --source_map_format V3\
+ --create_source_map '%outname%.map'
+
+CLOSURE_FLAGS=\
+ --generate_exports\
+ --externs src/externs.js\
+ --warning_level VERBOSE\
+ --jscomp_error accessControls\
+ --jscomp_error checkRegExp\
+ --jscomp_error checkTypes\
+ --jscomp_error checkVars\
+ --jscomp_error conformanceViolations\
+ --jscomp_error const\
+ --jscomp_error constantProperty\
+ --jscomp_error deprecated\
+ --jscomp_error deprecatedAnnotations\
+ --jscomp_error duplicateMessage\
+ --jscomp_error es5Strict\
+ --jscomp_error externsValidation\
+ --jscomp_error globalThis\
+ --jscomp_error invalidCasts\
+ --jscomp_error misplacedTypeAnnotation\
+ --jscomp_error missingProperties\
+ --jscomp_error missingReturn\
+ --jscomp_error msgDescriptions\
+ --jscomp_error nonStandardJsDocs\
+ --jscomp_error suspiciousCode\
+ --jscomp_error strictModuleDepCheck\
+ --jscomp_error typeInvalidation\
+ --jscomp_error undefinedVars\
+ --jscomp_error unknownDefines\
+ --jscomp_error visibility\
+ --use_types_for_optimization\
+ --assume_function_wrapper\
+ --summary_detail_level 3\
+ --language_in ECMASCRIPT_2020\
+ --language_out ECMASCRIPT_2020
+
+CARGO_FLAGS_SAFE=\
+ --target wasm32-unknown-unknown \
+ -- \
+ -C linker=tools/rust-lld-wrapper \
+ -C link-args="--import-table --global-base=4096 $(STRIP_DEBUG_FLAG)" \
+ -C link-args="build/softfloat.o" \
+ -C link-args="build/zstddeclib.o" \
+ --verbose
+
+CARGO_FLAGS=$(CARGO_FLAGS_SAFE) -C target-feature=+bulk-memory -C target-feature=+multivalue -C target-feature=+simd128
+
+CORE_FILES=cjs.js const.js io.js main.js lib.js buffer.js ide.js pci.js floppy.js \
+ dma.js pit.js vga.js ps2.js rtc.js uart.js \
+ acpi.js iso9660.js \
+ state.js ne2k.js sb16.js virtio.js virtio_console.js virtio_net.js virtio_balloon.js \
+ bus.js log.js cpu.js \
+ elf.js kernel.js
+LIB_FILES=9p.js filesystem.js marshall.js
+BROWSER_FILES=screen.js keyboard.js mouse.js speaker.js serial.js \
+ network.js starter.js worker_bus.js dummy_screen.js \
+ inbrowser_network.js fake_network.js wisp_network.js fetch_network.js \
+ print_stats.js filestorage.js
+
+RUST_FILES=$(shell find src/rust/ -name '*.rs') \
+ src/rust/gen/interpreter.rs src/rust/gen/interpreter0f.rs \
+ src/rust/gen/jit.rs src/rust/gen/jit0f.rs \
+ src/rust/gen/analyzer.rs src/rust/gen/analyzer0f.rs
+
+CORE_FILES:=$(addprefix src/,$(CORE_FILES))
+LIB_FILES:=$(addprefix lib/,$(LIB_FILES))
+BROWSER_FILES:=$(addprefix src/browser/,$(BROWSER_FILES))
+
+build/v86_all.js: $(CLOSURE) src/*.js src/browser/*.js lib/*.js
+ mkdir -p build
+ -ls -lh build/v86_all.js
+ java -jar $(CLOSURE) \
+ --js_output_file build/v86_all.js\
+ --define=DEBUG=false\
+ $(CLOSURE_SOURCE_MAP)\
+ $(CLOSURE_FLAGS)\
+ --compilation_level ADVANCED\
+ --js $(CORE_FILES)\
+ --js $(LIB_FILES)\
+ --js $(BROWSER_FILES)\
+ --js src/browser/main.js
+ ls -lh build/v86_all.js
+
+build/v86_all_debug.js: $(CLOSURE) src/*.js src/browser/*.js lib/*.js
+ mkdir -p build
+ java -jar $(CLOSURE) \
+ --js_output_file build/v86_all_debug.js\
+ --define=DEBUG=true\
+ $(CLOSURE_SOURCE_MAP)\
+ $(CLOSURE_FLAGS)\
+ --compilation_level ADVANCED\
+ --js $(CORE_FILES)\
+ --js $(LIB_FILES)\
+ --js $(BROWSER_FILES)\
+ --js src/browser/main.js
+
+build/libv86.js: $(CLOSURE) src/*.js lib/*.js src/browser/*.js
+ mkdir -p build
+ -ls -lh build/libv86.js
+ java -jar $(CLOSURE) \
+ --js_output_file build/libv86.js\
+ --define=DEBUG=false\
+ $(CLOSURE_FLAGS)\
+ --compilation_level SIMPLE\
+ --jscomp_off=missingProperties\
+ --output_wrapper ';(function(){%output%}).call(this);'\
+ --js $(CORE_FILES)\
+ --js $(BROWSER_FILES)\
+ --js $(LIB_FILES)
+ ls -lh build/libv86.js
+
+build/libv86.mjs: $(CLOSURE) src/*.js lib/*.js src/browser/*.js
+ mkdir -p build
+ -ls -lh build/libv86.js
+ java -jar $(CLOSURE) \
+ --js_output_file build/libv86.mjs\
+ --define=DEBUG=false\
+ $(CLOSURE_FLAGS)\
+ --compilation_level SIMPLE\
+ --jscomp_off=missingProperties\
+ --output_wrapper ';let module = {exports:{}}; %output%; export default module.exports.V86; export let {V86, CPU} = module.exports;'\
+ --js $(CORE_FILES)\
+ --js $(BROWSER_FILES)\
+ --js $(LIB_FILES)\
+ --chunk_output_type=ES_MODULES\
+ --emit_use_strict=false
+ ls -lh build/libv86.mjs
+
+build/libv86-debug.js: $(CLOSURE) src/*.js lib/*.js src/browser/*.js
+ mkdir -p build
+ java -jar $(CLOSURE) \
+ --js_output_file build/libv86-debug.js\
+ --define=DEBUG=true\
+ $(CLOSURE_FLAGS)\
+ $(CLOSURE_READABLE)\
+ --compilation_level SIMPLE\
+ --jscomp_off=missingProperties\
+ --output_wrapper ';(function(){%output%}).call(this);'\
+ --js $(CORE_FILES)\
+ --js $(BROWSER_FILES)\
+ --js $(LIB_FILES)
+
+build/libv86-debug.mjs: $(CLOSURE) src/*.js lib/*.js src/browser/*.js
+ mkdir -p build
+ java -jar $(CLOSURE) \
+ --js_output_file build/libv86-debug.mjs\
+ --define=DEBUG=true\
+ $(CLOSURE_FLAGS)\
+ --compilation_level SIMPLE\
+ --jscomp_off=missingProperties\
+ --output_wrapper ';let module = {exports:{}}; %output%; export default module.exports.V86; export let {V86, CPU} = module.exports;'\
+ --js $(CORE_FILES)\
+ --js $(BROWSER_FILES)\
+ --js $(LIB_FILES)\
+ --chunk_output_type=ES_MODULES\
+ --emit_use_strict=false
+ ls -lh build/libv86-debug.mjs
+
+src/rust/gen/jit.rs: $(JIT_DEPENDENCIES)
+ ./gen/generate_jit.js --output-dir build/ --table jit
+src/rust/gen/jit0f.rs: $(JIT_DEPENDENCIES)
+ ./gen/generate_jit.js --output-dir build/ --table jit0f
+
+src/rust/gen/interpreter.rs: $(INTERPRETER_DEPENDENCIES)
+ ./gen/generate_interpreter.js --output-dir build/ --table interpreter
+src/rust/gen/interpreter0f.rs: $(INTERPRETER_DEPENDENCIES)
+ ./gen/generate_interpreter.js --output-dir build/ --table interpreter0f
+
+src/rust/gen/analyzer.rs: $(ANALYZER_DEPENDENCIES)
+ ./gen/generate_analyzer.js --output-dir build/ --table analyzer
+src/rust/gen/analyzer0f.rs: $(ANALYZER_DEPENDENCIES)
+ ./gen/generate_analyzer.js --output-dir build/ --table analyzer0f
+
+build/v86.wasm: $(RUST_FILES) build/softfloat.o build/zstddeclib.o Cargo.toml
+ mkdir -p build/
+ -BLOCK_SIZE=K ls -l build/v86.wasm
+ cargo rustc --release $(CARGO_FLAGS)
+ cp build/wasm32-unknown-unknown/release/v86.wasm build/v86.wasm
+ -$(WASM_OPT) && wasm-opt -O2 --strip-debug build/v86.wasm -o build/v86.wasm
+ BLOCK_SIZE=K ls -l build/v86.wasm
+
+build/v86-debug.wasm: $(RUST_FILES) build/softfloat.o build/zstddeclib.o Cargo.toml
+ mkdir -p build/
+ -BLOCK_SIZE=K ls -l build/v86-debug.wasm
+ cargo rustc $(CARGO_FLAGS)
+ cp build/wasm32-unknown-unknown/debug/v86.wasm build/v86-debug.wasm
+ BLOCK_SIZE=K ls -l build/v86-debug.wasm
+
+build/v86-fallback.wasm: $(RUST_FILES) build/softfloat.o build/zstddeclib.o Cargo.toml
+ mkdir -p build/
+ cargo rustc --release $(CARGO_FLAGS_SAFE)
+ cp build/wasm32-unknown-unknown/release/v86.wasm build/v86-fallback.wasm || true
+
+debug-with-profiler: $(RUST_FILES) build/softfloat.o build/zstddeclib.o Cargo.toml
+ mkdir -p build/
+ cargo rustc --features profiler $(CARGO_FLAGS)
+ cp build/wasm32-unknown-unknown/debug/v86.wasm build/v86-debug.wasm || true
+
+with-profiler: $(RUST_FILES) build/softfloat.o build/zstddeclib.o Cargo.toml
+ mkdir -p build/
+ cargo rustc --release --features profiler $(CARGO_FLAGS)
+ cp build/wasm32-unknown-unknown/release/v86.wasm build/v86.wasm || true
+
+watch:
+ cargo watch -x 'rustc $(CARGO_FLAGS)' -s 'cp build/wasm32-unknown-unknown/debug/v86.wasm build/v86-debug.wasm'
+
+build/softfloat.o: lib/softfloat/softfloat.c
+ mkdir -p build
+ clang -c -Wall \
+ --target=wasm32 -O3 -flto -nostdlib -fvisibility=hidden -ffunction-sections -fdata-sections \
+ -DSOFTFLOAT_FAST_INT64 -DINLINE_LEVEL=5 -DSOFTFLOAT_FAST_DIV32TO16 -DSOFTFLOAT_FAST_DIV64TO32 \
+ -o build/softfloat.o \
+ lib/softfloat/softfloat.c
+
+build/zstddeclib.o: lib/zstd/zstddeclib.c
+ mkdir -p build
+ clang -c -Wall \
+ --target=wasm32 -O3 -flto -nostdlib -fvisibility=hidden -ffunction-sections -fdata-sections \
+ -DZSTDLIB_VISIBILITY="" \
+ -o build/zstddeclib.o \
+ lib/zstd/zstddeclib.c
+
+clean:
+ -rm build/libv86.js
+ -rm build/libv86.mjs
+ -rm build/libv86-debug.js
+ -rm build/libv86-debug.mjs
+ -rm build/v86_all.js
+ -rm build/v86.wasm
+ -rm build/v86-debug.wasm
+ -rm $(INSTRUCTION_TABLES)
+ -rm build/*.map
+ -rm build/*.wast
+ -rm build/*.o
+ $(MAKE) -C $(NASM_TEST_DIR) clean
+
+run:
+ python3 -m http.server 2> /dev/null
+
+update_version:
+ set -e ;\
+ COMMIT=`git log --format="%h" -n 1` ;\
+ DATE=`git log --date="format:%b %e, %Y %H:%m" --format="%cd" -n 1` ;\
+ SEARCH='Version: [a-f0-9]\+ ([^(]\+)' ;\
+ REPLACE='Version: '$$COMMIT' ('$$DATE')' ;\
+ sed -i "s@$$SEARCH@$$REPLACE@g" index.html ;\
+ SEARCH='' ;\
+ REPLACE='' ;\
+ sed -i "s@$$SEARCH@$$REPLACE@g" index.html ;\
+ grep $$COMMIT index.html
+
+
+$(CLOSURE):
+ mkdir -p $(CLOSURE_DIR)
+ # don't upgrade until https://github.com/google/closure-compiler/issues/3972 is fixed
+ wget -nv -O $(CLOSURE) https://repo1.maven.org/maven2/com/google/javascript/closure-compiler/v20210601/closure-compiler-v20210601.jar
+
+build/integration-test-fs/fs.json: images/buildroot-bzimage68.bin
+ mkdir -p build/integration-test-fs/flat
+ cp images/buildroot-bzimage68.bin build/integration-test-fs/bzImage
+ touch build/integration-test-fs/initrd
+ cd build/integration-test-fs && tar cfv fs.tar bzImage initrd
+ ./tools/fs2json.py build/integration-test-fs/fs.tar --out build/integration-test-fs/fs.json
+ ./tools/copy-to-sha256.py build/integration-test-fs/fs.tar build/integration-test-fs/flat
+ rm build/integration-test-fs/fs.tar build/integration-test-fs/bzImage build/integration-test-fs/initrd
+
+tests: build/v86-debug.wasm build/integration-test-fs/fs.json
+ LOG_LEVEL=3 ./tests/full/run.js
+
+tests-release: build/libv86.js build/v86.wasm build/integration-test-fs/fs.json
+ TEST_RELEASE_BUILD=1 ./tests/full/run.js
+
+nasmtests: build/v86-debug.wasm
+ $(NASM_TEST_DIR)/create_tests.js
+ $(NASM_TEST_DIR)/gen_fixtures.js
+ $(NASM_TEST_DIR)/run.js
+
+nasmtests-force-jit: build/v86-debug.wasm
+ $(NASM_TEST_DIR)/create_tests.js
+ $(NASM_TEST_DIR)/gen_fixtures.js
+ $(NASM_TEST_DIR)/run.js --force-jit
+
+jitpagingtests: build/v86-debug.wasm
+ $(MAKE) -C tests/jit-paging test-jit
+ ./tests/jit-paging/run.js
+
+qemutests: build/v86-debug.wasm
+ $(MAKE) -C tests/qemu test-i386
+ LOG_LEVEL=3 ./tests/qemu/run.js build/qemu-test-result
+ ./tests/qemu/run-qemu.js > build/qemu-test-reference
+ diff build/qemu-test-result build/qemu-test-reference
+
+qemutests-release: build/libv86.mjs build/v86.wasm
+ $(MAKE) -C tests/qemu test-i386
+ TEST_RELEASE_BUILD=1 time ./tests/qemu/run.js build/qemu-test-result
+ ./tests/qemu/run-qemu.js > build/qemu-test-reference
+ diff build/qemu-test-result build/qemu-test-reference
+
+kvm-unit-test: build/v86-debug.wasm
+ (cd tests/kvm-unit-tests && ./configure && make x86/realmode.flat)
+ tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/realmode.flat
+
+kvm-unit-test-release: build/libv86.mjs build/v86.wasm
+ (cd tests/kvm-unit-tests && ./configure && make x86/realmode.flat)
+ TEST_RELEASE_BUILD=1 tests/kvm-unit-tests/run.mjs tests/kvm-unit-tests/x86/realmode.flat
+
+expect-tests: build/v86-debug.wasm build/libwabt.cjs
+ make -C tests/expect/tests
+ ./tests/expect/run.js
+
+devices-test: build/v86-debug.wasm
+ ./tests/devices/virtio_9p.js
+ ./tests/devices/virtio_console.js
+ ./tests/devices/fetch_network.js
+ USE_VIRTIO=1 ./tests/devices/fetch_network.js
+ ./tests/devices/wisp_network.js
+ ./tests/devices/virtio_balloon.js
+
+rust-test: $(RUST_FILES)
+ env RUSTFLAGS="-D warnings" RUST_BACKTRACE=full RUST_TEST_THREADS=1 cargo test -- --nocapture
+ ./tests/rust/verify-wasmgen-dummy-output.js
+
+rust-test-intensive:
+ QUICKCHECK_TESTS=100000000 make rust-test
+
+api-tests: build/v86-debug.wasm
+ ./tests/api/clean-shutdown.js
+ ./tests/api/state.js
+ ./tests/api/reset.js
+ ./tests/api/floppy.js
+ ./tests/api/cdrom-insert-eject.js
+ ./tests/api/serial.js
+ ./tests/api/reboot.js
+ ./tests/api/pic.js
+
+all-tests: eslint kvm-unit-test qemutests qemutests-release jitpagingtests api-tests nasmtests nasmtests-force-jit rust-test tests expect-tests
+ # Skipping:
+ # - devices-test (hangs)
+
+eslint:
+ eslint src tests gen lib examples tools
+
+rustfmt: $(RUST_FILES)
+ cargo fmt --all -- --check --config fn_single_line=true,control_brace_style=ClosingNextLine
+
+build/capstone-x86.min.js:
+ mkdir -p build
+ wget -nv -P build https://github.com/AlexAltea/capstone.js/releases/download/v3.0.5-rc1/capstone-x86.min.js
+
+build/libwabt.cjs:
+ mkdir -p build
+ wget -nv -P build https://github.com/WebAssembly/wabt/archive/1.0.6.zip
+ unzip -j -d build/ build/1.0.6.zip wabt-1.0.6/demo/libwabt.js
+ mv build/libwabt.js build/libwabt.cjs
+ rm build/1.0.6.zip
+
+build/xterm.js:
+ curl https://cdn.jsdelivr.net/npm/xterm@5.2.1/lib/xterm.min.js > build/xterm.js
+ curl https://cdn.jsdelivr.net/npm/xterm@5.2.1/lib/xterm.js.map > build/xterm.js.map
+ curl https://cdn.jsdelivr.net/npm/xterm@5.2.1/css/xterm.css > build/xterm.css
+
+update-package-json-version:
+ git describe --tags --exclude latest | sed 's/-/./' | tr - + | tee build/version
+ jq --arg version "$$(cat build/version)" '.version = $$version' package.json > package.json.tmp
+ mv package.json.tmp package.json
diff --git a/Readme.md b/Readme.md
new file mode 100644
index 0000000000000000000000000000000000000000..51454edb6fbac49027f23eeb5edd0324b91b7510
--- /dev/null
+++ b/Readme.md
@@ -0,0 +1,215 @@
+[](https://gitter.im/copy/v86) or #v86 on [irc.libera.chat](https://libera.chat/)
+
+v86 emulates an x86-compatible CPU and hardware. Machine code is translated to
+WebAssembly modules at runtime in order to achieve decent performance. Here's a
+list of emulated hardware:
+
+- An x86-compatible CPU. The instruction set is around Pentium 4 level,
+ including full SSE3 support. Some features are missing, in particular:
+ - Task gates, far calls in protected mode
+ - Some 16 bit protected mode features
+ - Single stepping (trap flag, debug registers)
+ - Some exceptions, especially floating point and SSE
+ - Multicore
+ - 64-bit extensions
+- A floating point unit (FPU). Calculations are done using the Berkeley
+ SoftFloat library and therefore should be precise (but slow). Trigonometric
+ and log functions are emulated using 64-bit floats and may be less precise.
+ Not all FPU exceptions are supported.
+- A floppy disk controller (8272A).
+- An 8042 Keyboard Controller, PS2. With mouse support.
+- An 8254 Programmable Interval Timer (PIT).
+- An 8259 Programmable Interrupt Controller (PIC).
+- Partial APIC support.
+- A CMOS Real Time Clock (RTC).
+- A generic VGA card with SVGA support and Bochs VBE Extensions.
+- A PCI bus. This one is partly incomplete and not used by every device.
+- An IDE disk controller.
+ - A built-in ISO 9660 CD-ROM generator.
+- An NE2000 (RTL8390) PCI network card.
+- Various virtio devices: Filesystem, network and balloon.
+- A SoundBlaster 16 sound card.
+
+## Demos
+
+[9front](https://copy.sh/v86/?profile=9front) —
+[Arch Linux](https://copy.sh/v86/?profile=archlinux) —
+[Android-x86 1.6-r2](https://copy.sh/v86?profile=android) —
+[Android-x86 4.4-r2](https://copy.sh/v86?profile=android4) —
+[BasicLinux](https://copy.sh/v86/?profile=basiclinux) —
+[Buildroot Linux](https://copy.sh/v86/?profile=buildroot) —
+[Damn Small Linux](https://copy.sh/v86/?profile=dsl) —
+[ELKS](https://copy.sh/v86/?profile=elks) —
+[FreeDOS](https://copy.sh/v86/?profile=freedos) —
+[FreeBSD](https://copy.sh/v86/?profile=freebsd) —
+[FiwixOS](https://copy.sh/v86/?profile=fiwix) —
+[Haiku](https://copy.sh/v86/?profile=haiku) —
+[SkiffOS](https://copy.sh/v86/?profile=copy/skiffos) —
+[ReactOS](https://copy.sh/v86/?profile=reactos) —
+[Windows 2000](https://copy.sh/v86/?profile=windows2000) —
+[Windows 98](https://copy.sh/v86/?profile=windows98) —
+[Windows 95](https://copy.sh/v86/?profile=windows95) —
+[Windows 1.01](https://copy.sh/v86/?profile=windows1) —
+[MS-DOS 6.22](https://copy.sh/v86/?profile=msdos) —
+[OpenBSD](https://copy.sh/v86/?profile=openbsd) —
+[Oberon](https://copy.sh/v86/?profile=oberon) —
+[KolibriOS](https://copy.sh/v86/?profile=kolibrios) —
+[SkiftOS](https://copy.sh/v86?profile=skift) —
+[QNX](https://copy.sh/v86/?profile=qnx)
+
+## Documentation
+
+[How it works](docs/how-it-works.md) —
+[Networking](docs/networking.md) —
+[Alpine Linux guest setup](tools/docker/alpine/) —
+[Arch Linux guest setup](docs/archlinux.md) —
+[Windows NT guest setup](docs/windows-nt.md) —
+[Windows 9x guest setup](docs/windows-9x.md) —
+[9p filesystem](docs/filesystem.md) —
+[Linux rootfs on 9p](docs/linux-9p-image.md) —
+[Profiling](docs/profiling.md) —
+[CPU Idling](docs/cpu-idling.md)
+
+## Compatibility
+
+Here's an overview of the operating systems supported in v86:
+
+- Linux works pretty well. 64-bit kernels are not supported.
+ - [Buildroot](https://buildroot.uclibc.org) can be used to build a minimal image.
+ [humphd/browser-vm](https://github.com/humphd/browser-vm) and
+ [darin755/browser-buildroot](https://github.com/Darin755/browser-buildroot) have some useful scripts for building one.
+ - [SkiffOS](https://github.com/skiffos/SkiffOS/tree/master/configs/browser/v86) (based on Buildroot) can cross-compile a custom image.
+ - Ubuntu and other Debian derivatives works up to the latest version that supported i386 (16.04 LTS or 18.04 LTS for some variants).
+ - Alpine Linux works. An image can be built from a Dockerfile, see [tools/docker/alpine/](tools/docker/alpine/).
+ - Arch Linux 32 works. See [archlinux.md](docs/archlinux.md) for building an image.
+- ReactOS works.
+- FreeDOS, Windows 1.01 and MS-DOS run very well.
+- KolibriOS works.
+- Haiku works.
+- Android-x86 has been tested up to 4.4-r2.
+- Windows 1, 3.x, 95, 98, ME, NT and 2000 work reasonably well.
+ - In Windows 2000 and higher the PC type has to be changed from ACPI PC to Standard PC
+ - There are some known boot issues ([#250](https://github.com/copy/v86/issues/250), [#433](https://github.com/copy/v86/issues/433), [#507](https://github.com/copy/v86/issues/507), [#555](https://github.com/copy/v86/issues/555), [#620](https://github.com/copy/v86/issues/620), [#645](https://github.com/copy/v86/issues/645))
+ - See [Windows 9x guest setup](docs/windows-9x.md)
+- Windows XP, Vista and 8 work under certain conditions (see [#86](https://github.com/copy/v86/issues/86), [#208](https://github.com/copy/v86/issues/208))
+ - See [Windows NT guest setup](docs/windows-nt.md)
+- Many hobby operating systems work.
+- 9front works.
+- Plan 9 doesn't work.
+- QNX works.
+- OS/2 doesn't work.
+- FreeBSD works.
+- OpenBSD works with a specific boot configuration. At the `boot>` prompt type
+ `boot -c`, then at the `UKC>` prompt `disable mpbios` and `exit`.
+- NetBSD works only with a custom kernel, see [#350](https://github.com/copy/v86/issues/350).
+- SerenityOS works (only 32-bit versions).
+- [SkiftOS](https://skiftos.org/) works.
+
+You can get some information on the disk images here: https://github.com/copy/images.
+
+## How to build, run and embed?
+
+You need:
+
+- make
+- Rust with the wasm32-unknown-unknown target
+- A version of clang compatible with Rust
+- java (for Closure Compiler, not necessary when using `debug.html`)
+- nodejs (a recent version is required, v16.11.1 is known to be working)
+- To run tests: nasm, gdb, qemu-system, gcc, libc-i386 and rustfmt
+
+See [tools/docker/test-image/Dockerfile](tools/docker/test-image/Dockerfile)
+for a full setup on Debian or
+[WSL](https://docs.microsoft.com/en-us/windows/wsl/install).
+
+- Run `make` to build the debug build (at `debug.html`).
+- Run `make all` to build the optimized build (at `index.html`).
+- ROM and disk images are loaded via XHR, so if you want to try out `index.html`
+ locally, make sure to serve it from a local webserver. You can use `make run`
+ to serve the files using Python's http module.
+- If you only want to embed v86 in a webpage you can use libv86.js. For usage,
+ check out the [examples](examples/). You can download it from the release section.
+
+### Alternatively, to build using Docker
+
+- If you have Docker installed, you can run the whole system inside a container.
+- See `tools/docker/exec` to find the Dockerfile required for this.
+- You can run `docker build -f tools/docker/exec/Dockerfile -t v86:alpine-3.19 .` from the root directory to generate docker image.
+- Then you can simply run `docker run -it -p 8000:8000 v86:alpine-3.19` to start the server.
+- Check `localhost:8000` for hosted server.
+
+### Running via Dev Container
+
+- If you are using an IDE that supports Dev Containers, such as GitHub Codespaces, the Visual Studio Code Remote Container extension, or possibly others such as Jetbrains' IntelliJ IDEA, you can setup the development environment in a Dev Container.
+- Follow the instructions from your development environment to setup the container.
+- Run the Task "Fetch images" in order to download images for testing.
+
+## Testing
+
+The disk images for testing are not included in this repository. You can
+download them directly from the website using:
+
+`curl --compressed --output-dir images/ --remote-name-all https://i.copy.sh/{linux.iso,linux3.iso,linux4.iso,buildroot-bzimage68.bin,TinyCore-11.0.iso,oberon.img,msdos.img,openbsd-floppy.img,kolibri.img,windows101.img,os8.img,freedos722.img,mobius-fd-release5.img,msdos622.img}`
+
+Run integration tests: `make tests`
+
+Run all tests: `make jshint rustfmt kvm-unit-test nasmtests nasmtests-force-jit expect-tests jitpagingtests qemutests rust-test tests`
+
+See [tests/Readme.md](tests/Readme.md) for more information.
+
+## API examples
+
+- [Basic](examples/basic.html)
+- [Programatically using the serial terminal](examples/serial.html)
+- [A Lua interpreter](examples/lua.html)
+- [Two instances in one window](examples/two_instances.html)
+- [Networking between browser windows/tabs using the Broadcast Channel API](examples/broadcast-network.html)
+- [TCP Terminal (fetch-based networking)](examples/tcp_terminal.html)
+- [Saving and restoring emulator state](examples/save_restore.html)
+
+Using v86 for your own purposes is as easy as:
+
+```javascript
+var emulator = new V86({
+ screen_container: document.getElementById("screen_container"),
+ bios: {
+ url: "../../bios/seabios.bin",
+ },
+ vga_bios: {
+ url: "../../bios/vgabios.bin",
+ },
+ cdrom: {
+ url: "../../images/linux.iso",
+ },
+ autostart: true,
+});
+```
+
+See [starter.js](src/browser/starter.js).
+
+## License
+
+v86 is distributed under the terms of the Simplified BSD License, see
+[LICENSE](LICENSE). The following third-party dependencies are included in the
+repository under their own licenses:
+
+- [`lib/softfloat/softfloat.c`](lib/softfloat/softfloat.c)
+- [`lib/zstd/zstddeclib.c`](lib/zstd/zstddeclib.c)
+- [`tests/kvm-unit-tests/`](tests/kvm-unit-tests)
+- [`tests/qemutests/`](tests/qemutests)
+- [`src/floppy.js/`](src/floppy.js) contains parts ported from qemu under the MIT license, see LICENSE.MIT.
+
+## Credits
+
+- CPU test cases via [QEMU](https://wiki.qemu.org/Main_Page)
+- More tests via [kvm-unit-tests](https://www.linux-kvm.org/page/KVM-unit-tests)
+- [zstd](https://github.com/facebook/zstd) support is included for better compression of state images
+- [Berkeley SoftFloat](http://www.jhauser.us/arithmetic/SoftFloat.html) is included to precisely emulate 80-bit floating point numbers
+- [The jor1k project](https://github.com/s-macke/jor1k) for 9p, filesystem and uart drivers
+- [WinWorld](https://winworldpc.com/) sources of some old operating systems
+- [OS/2 Museum](https://www.os2museum.com/) sources of some old operating systems
+- [ArchiveOS](https://archiveos.org/) sources of several operating systems
+
+## More questions?
+
+Shoot me an email to `copy@copy.sh`. Please report bugs on GitHub.
diff --git a/bios/.gitignore b/bios/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..10d00b5797e22ac9fe59a898bf5aff311f0f10ac
--- /dev/null
+++ b/bios/.gitignore
@@ -0,0 +1 @@
+*.gz
diff --git a/bios/COPYING.LESSER b/bios/COPYING.LESSER
new file mode 100644
index 0000000000000000000000000000000000000000..fc8a5de7edf437cdc98a216370faf7c757279bcb
--- /dev/null
+++ b/bios/COPYING.LESSER
@@ -0,0 +1,165 @@
+ GNU LESSER GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+
+ This version of the GNU Lesser General Public License incorporates
+the terms and conditions of version 3 of the GNU General Public
+License, supplemented by the additional permissions listed below.
+
+ 0. Additional Definitions.
+
+ As used herein, "this License" refers to version 3 of the GNU Lesser
+General Public License, and the "GNU GPL" refers to version 3 of the GNU
+General Public License.
+
+ "The Library" refers to a covered work governed by this License,
+other than an Application or a Combined Work as defined below.
+
+ An "Application" is any work that makes use of an interface provided
+by the Library, but which is not otherwise based on the Library.
+Defining a subclass of a class defined by the Library is deemed a mode
+of using an interface provided by the Library.
+
+ A "Combined Work" is a work produced by combining or linking an
+Application with the Library. The particular version of the Library
+with which the Combined Work was made is also called the "Linked
+Version".
+
+ The "Minimal Corresponding Source" for a Combined Work means the
+Corresponding Source for the Combined Work, excluding any source code
+for portions of the Combined Work that, considered in isolation, are
+based on the Application, and not on the Linked Version.
+
+ The "Corresponding Application Code" for a Combined Work means the
+object code and/or source code for the Application, including any data
+and utility programs needed for reproducing the Combined Work from the
+Application, but excluding the System Libraries of the Combined Work.
+
+ 1. Exception to Section 3 of the GNU GPL.
+
+ You may convey a covered work under sections 3 and 4 of this License
+without being bound by section 3 of the GNU GPL.
+
+ 2. Conveying Modified Versions.
+
+ If you modify a copy of the Library, and, in your modifications, a
+facility refers to a function or data to be supplied by an Application
+that uses the facility (other than as an argument passed when the
+facility is invoked), then you may convey a copy of the modified
+version:
+
+ a) under this License, provided that you make a good faith effort to
+ ensure that, in the event an Application does not supply the
+ function or data, the facility still operates, and performs
+ whatever part of its purpose remains meaningful, or
+
+ b) under the GNU GPL, with none of the additional permissions of
+ this License applicable to that copy.
+
+ 3. Object Code Incorporating Material from Library Header Files.
+
+ The object code form of an Application may incorporate material from
+a header file that is part of the Library. You may convey such object
+code under terms of your choice, provided that, if the incorporated
+material is not limited to numerical parameters, data structure
+layouts and accessors, or small macros, inline functions and templates
+(ten or fewer lines in length), you do both of the following:
+
+ a) Give prominent notice with each copy of the object code that the
+ Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the object code with a copy of the GNU GPL and this license
+ document.
+
+ 4. Combined Works.
+
+ You may convey a Combined Work under terms of your choice that,
+taken together, effectively do not restrict modification of the
+portions of the Library contained in the Combined Work and reverse
+engineering for debugging such modifications, if you also do each of
+the following:
+
+ a) Give prominent notice with each copy of the Combined Work that
+ the Library is used in it and that the Library and its use are
+ covered by this License.
+
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
+ document.
+
+ c) For a Combined Work that displays copyright notices during
+ execution, include the copyright notice for the Library among
+ these notices, as well as a reference directing the user to the
+ copies of the GNU GPL and this license document.
+
+ d) Do one of the following:
+
+ 0) Convey the Minimal Corresponding Source under the terms of this
+ License, and the Corresponding Application Code in a form
+ suitable for, and under terms that permit, the user to
+ recombine or relink the Application with a modified version of
+ the Linked Version to produce a modified Combined Work, in the
+ manner specified by section 6 of the GNU GPL for conveying
+ Corresponding Source.
+
+ 1) Use a suitable shared library mechanism for linking with the
+ Library. A suitable mechanism is one that (a) uses at run time
+ a copy of the Library already present on the user's computer
+ system, and (b) will operate properly with a modified version
+ of the Library that is interface-compatible with the Linked
+ Version.
+
+ e) Provide Installation Information, but only if you would otherwise
+ be required to provide such information under section 6 of the
+ GNU GPL, and only to the extent that such information is
+ necessary to install and execute a modified version of the
+ Combined Work produced by recombining or relinking the
+ Application with a modified version of the Linked Version. (If
+ you use option 4d0, the Installation Information must accompany
+ the Minimal Corresponding Source and Corresponding Application
+ Code. If you use option 4d1, you must provide the Installation
+ Information in the manner specified by section 6 of the GNU GPL
+ for conveying Corresponding Source.)
+
+ 5. Combined Libraries.
+
+ You may place library facilities that are a work based on the
+Library side by side in a single library together with other library
+facilities that are not Applications and are not covered by this
+License, and convey such a combined library under terms of your
+choice, if you do both of the following:
+
+ a) Accompany the combined library with a copy of the same work based
+ on the Library, uncombined with any other library facilities,
+ conveyed under the terms of this License.
+
+ b) Give prominent notice with the combined library that part of it
+ is a work based on the Library, and explaining where to find the
+ accompanying uncombined form of the same work.
+
+ 6. Revised Versions of the GNU Lesser General Public License.
+
+ The Free Software Foundation may publish revised and/or new versions
+of the GNU Lesser General Public License from time to time. Such new
+versions will be similar in spirit to the present version, but may
+differ in detail to address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Library as you received it specifies that a certain numbered version
+of the GNU Lesser General Public License "or any later version"
+applies to it, you have the option of following the terms and
+conditions either of that published version or of any later version
+published by the Free Software Foundation. If the Library as you
+received it does not specify a version number of the GNU Lesser
+General Public License, you may choose any version of the GNU Lesser
+General Public License ever published by the Free Software Foundation.
+
+ If the Library as you received it specifies that a proxy can decide
+whether future versions of the GNU Lesser General Public License shall
+apply, that proxy's public statement of acceptance of any version is
+permanent authorization for you to choose that version for the
+Library.
diff --git a/bios/bochs-bios.bin b/bios/bochs-bios.bin
new file mode 100644
index 0000000000000000000000000000000000000000..2a92970369644fe3e1c2f09c08fd49946782e491
Binary files /dev/null and b/bios/bochs-bios.bin differ
diff --git a/bios/bochs-vgabios.bin b/bios/bochs-vgabios.bin
new file mode 100644
index 0000000000000000000000000000000000000000..311168e5620eaeccb8c94e82485964b4ab46b84d
Binary files /dev/null and b/bios/bochs-vgabios.bin differ
diff --git a/bios/fetch-and-build-seabios.sh b/bios/fetch-and-build-seabios.sh
new file mode 100644
index 0000000000000000000000000000000000000000..e17ed8b5b64367988969e8475c99b58c7aa36818
--- /dev/null
+++ b/bios/fetch-and-build-seabios.sh
@@ -0,0 +1,13 @@
+set -e
+git clone https://git.seabios.org/seabios.git || true
+(cd seabios && git checkout rel-1.16.2)
+
+cp seabios.config seabios/.config
+make -C seabios
+cp seabios/out/bios.bin seabios.bin
+cp seabios/out/vgabios.bin vgabios.bin
+
+cp seabios-debug.config seabios/.config
+make -C seabios
+cp seabios/out/bios.bin seabios-debug.bin
+cp seabios/out/vgabios.bin vgabios-debug.bin
diff --git a/bios/seabios-debug.bin b/bios/seabios-debug.bin
new file mode 100644
index 0000000000000000000000000000000000000000..2dd30ee6a3830070660dedad9a40e34a7410d981
--- /dev/null
+++ b/bios/seabios-debug.bin
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:24174391d6612384bfaabe315d5b8405b16740a37bfd69367dc37fc321bcde1a
+size 262144
diff --git a/bios/seabios-debug.config b/bios/seabios-debug.config
new file mode 100644
index 0000000000000000000000000000000000000000..538500990887f7861ea4cc0adc4913efb5f3f9fd
--- /dev/null
+++ b/bios/seabios-debug.config
@@ -0,0 +1,119 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# SeaBIOS Configuration
+#
+
+#
+# General Features
+#
+# CONFIG_COREBOOT is not set
+CONFIG_QEMU=y
+# CONFIG_CSM is not set
+CONFIG_QEMU_HARDWARE=y
+CONFIG_XEN=y
+CONFIG_THREADS=y
+# CONFIG_RELOCATE_INIT is not set
+# CONFIG_BOOTMENU is not set
+CONFIG_BOOTORDER=y
+CONFIG_HOST_BIOS_GEOMETRY=y
+CONFIG_ENTRY_EXTRASTACK=y
+CONFIG_MALLOC_UPPERMEMORY=y
+CONFIG_ROM_SIZE=0
+
+#
+# Hardware support
+#
+CONFIG_ATA=y
+CONFIG_ATA_DMA=y
+CONFIG_ATA_PIO32=y
+CONFIG_AHCI=y
+CONFIG_SDCARD=y
+CONFIG_VIRTIO_BLK=y
+CONFIG_VIRTIO_SCSI=y
+CONFIG_PVSCSI=y
+CONFIG_ESP_SCSI=y
+CONFIG_LSI_SCSI=y
+CONFIG_MEGASAS=y
+CONFIG_MPT_SCSI=y
+CONFIG_FLOPPY=y
+CONFIG_FLASH_FLOPPY=y
+# CONFIG_NVME is not set
+CONFIG_PS2PORT=y
+# CONFIG_USB is not set
+CONFIG_SERIAL=y
+# CONFIG_SERCON is not set
+CONFIG_LPT=y
+CONFIG_RTC_TIMER=y
+CONFIG_HARDWARE_IRQ=y
+CONFIG_USE_SMM=y
+CONFIG_CALL32_SMM=y
+CONFIG_MTRR_INIT=y
+CONFIG_PMTIMER=y
+CONFIG_TSC_TIMER=y
+
+#
+# BIOS interfaces
+#
+CONFIG_DRIVES=y
+CONFIG_CDROM_BOOT=y
+CONFIG_CDROM_EMU=y
+CONFIG_PCIBIOS=y
+CONFIG_APMBIOS=y
+CONFIG_PNPBIOS=y
+CONFIG_OPTIONROMS=y
+CONFIG_PMM=y
+CONFIG_BOOT=y
+CONFIG_KEYBOARD=y
+CONFIG_KBD_CALL_INT15_4F=y
+CONFIG_MOUSE=y
+CONFIG_S3_RESUME=y
+CONFIG_VGAHOOKS=y
+# CONFIG_DISABLE_A20 is not set
+# CONFIG_WRITABLE_UPPERMEMORY is not set
+CONFIG_TCGBIOS=y
+
+#
+# BIOS Tables
+#
+CONFIG_PIRTABLE=y
+CONFIG_MPTABLE=y
+# CONFIG_SMBIOS is not set
+CONFIG_ACPI=y
+CONFIG_ACPI_DSDT=y
+CONFIG_FW_ROMFILE_LOAD=y
+CONFIG_ACPI_PARSE=y
+
+#
+# VGA ROM
+#
+# CONFIG_NO_VGABIOS is not set
+# CONFIG_VGA_STANDARD_VGA is not set
+# CONFIG_VGA_CIRRUS is not set
+# CONFIG_VGA_ATI is not set
+CONFIG_VGA_BOCHS=y
+# CONFIG_VGA_GEODEGX2 is not set
+# CONFIG_VGA_GEODELX is not set
+# CONFIG_DISPLAY_BOCHS is not set
+# CONFIG_VGA_RAMFB is not set
+CONFIG_VGA_BOCHS_STDVGA=y
+# CONFIG_VGA_BOCHS_VMWARE is not set
+# CONFIG_VGA_BOCHS_QXL is not set
+# CONFIG_VGA_BOCHS_VIRTIO is not set
+CONFIG_BUILD_VGABIOS=y
+CONFIG_VGA_STDVGA_PORTS=y
+CONFIG_VGA_FIXUP_ASM=y
+CONFIG_VGA_ALLOCATE_EXTRA_STACK=y
+CONFIG_VGA_EXTRA_STACK_SIZE=512
+CONFIG_VGA_VBE=y
+CONFIG_VGA_PCI=y
+CONFIG_OVERRIDE_PCI_ID=y
+CONFIG_VGA_VID=0x1234
+CONFIG_VGA_DID=0x1111
+
+#
+# Debugging
+#
+CONFIG_DEBUG_LEVEL=8
+# CONFIG_DEBUG_SERIAL is not set
+# CONFIG_DEBUG_SERIAL_MMIO is not set
+CONFIG_DEBUG_IO=y
diff --git a/bios/seabios.bin b/bios/seabios.bin
new file mode 100644
index 0000000000000000000000000000000000000000..7cf1a1775e4ffe0d748ebd95dc056cd5539657bb
--- /dev/null
+++ b/bios/seabios.bin
@@ -0,0 +1,3 @@
+version https://git-lfs.github.com/spec/v1
+oid sha256:73e3f359102e3a9982c35fce98eb7cd08f18303ac7f1ba6ebfbe6cdc1c244d98
+size 131072
diff --git a/bios/seabios.config b/bios/seabios.config
new file mode 100644
index 0000000000000000000000000000000000000000..6eb62b61de9c2392ab12c385001ff89f06fd8a66
--- /dev/null
+++ b/bios/seabios.config
@@ -0,0 +1,116 @@
+#
+# Automatically generated file; DO NOT EDIT.
+# SeaBIOS Configuration
+#
+
+#
+# General Features
+#
+# CONFIG_COREBOOT is not set
+CONFIG_QEMU=y
+# CONFIG_CSM is not set
+CONFIG_QEMU_HARDWARE=y
+CONFIG_XEN=y
+CONFIG_THREADS=y
+# CONFIG_RELOCATE_INIT is not set
+# CONFIG_BOOTMENU is not set
+CONFIG_BOOTORDER=y
+CONFIG_HOST_BIOS_GEOMETRY=y
+CONFIG_ENTRY_EXTRASTACK=y
+CONFIG_MALLOC_UPPERMEMORY=y
+CONFIG_ROM_SIZE=0
+
+#
+# Hardware support
+#
+CONFIG_ATA=y
+CONFIG_ATA_DMA=y
+CONFIG_ATA_PIO32=y
+CONFIG_AHCI=y
+CONFIG_SDCARD=y
+CONFIG_VIRTIO_BLK=y
+CONFIG_VIRTIO_SCSI=y
+CONFIG_PVSCSI=y
+CONFIG_ESP_SCSI=y
+CONFIG_LSI_SCSI=y
+CONFIG_MEGASAS=y
+CONFIG_MPT_SCSI=y
+CONFIG_FLOPPY=y
+CONFIG_FLASH_FLOPPY=y
+# CONFIG_NVME is not set
+CONFIG_PS2PORT=y
+# CONFIG_USB is not set
+CONFIG_SERIAL=y
+# CONFIG_SERCON is not set
+CONFIG_LPT=y
+CONFIG_RTC_TIMER=y
+CONFIG_HARDWARE_IRQ=y
+CONFIG_USE_SMM=y
+CONFIG_CALL32_SMM=y
+CONFIG_MTRR_INIT=y
+CONFIG_PMTIMER=y
+CONFIG_TSC_TIMER=y
+
+#
+# BIOS interfaces
+#
+CONFIG_DRIVES=y
+CONFIG_CDROM_BOOT=y
+CONFIG_CDROM_EMU=y
+CONFIG_PCIBIOS=y
+CONFIG_APMBIOS=y
+CONFIG_PNPBIOS=y
+CONFIG_OPTIONROMS=y
+CONFIG_PMM=y
+CONFIG_BOOT=y
+CONFIG_KEYBOARD=y
+CONFIG_KBD_CALL_INT15_4F=y
+CONFIG_MOUSE=y
+CONFIG_S3_RESUME=y
+CONFIG_VGAHOOKS=y
+# CONFIG_DISABLE_A20 is not set
+# CONFIG_WRITABLE_UPPERMEMORY is not set
+CONFIG_TCGBIOS=y
+
+#
+# BIOS Tables
+#
+CONFIG_PIRTABLE=y
+CONFIG_MPTABLE=y
+# CONFIG_SMBIOS is not set
+CONFIG_ACPI=y
+CONFIG_ACPI_DSDT=y
+CONFIG_FW_ROMFILE_LOAD=y
+CONFIG_ACPI_PARSE=y
+
+#
+# VGA ROM
+#
+# CONFIG_NO_VGABIOS is not set
+# CONFIG_VGA_STANDARD_VGA is not set
+# CONFIG_VGA_CIRRUS is not set
+# CONFIG_VGA_ATI is not set
+CONFIG_VGA_BOCHS=y
+# CONFIG_VGA_GEODEGX2 is not set
+# CONFIG_VGA_GEODELX is not set
+# CONFIG_DISPLAY_BOCHS is not set
+# CONFIG_VGA_RAMFB is not set
+CONFIG_VGA_BOCHS_STDVGA=y
+# CONFIG_VGA_BOCHS_VMWARE is not set
+# CONFIG_VGA_BOCHS_QXL is not set
+# CONFIG_VGA_BOCHS_VIRTIO is not set
+CONFIG_BUILD_VGABIOS=y
+CONFIG_VGA_STDVGA_PORTS=y
+CONFIG_VGA_FIXUP_ASM=y
+CONFIG_VGA_ALLOCATE_EXTRA_STACK=y
+CONFIG_VGA_EXTRA_STACK_SIZE=512
+CONFIG_VGA_VBE=y
+CONFIG_VGA_PCI=y
+CONFIG_OVERRIDE_PCI_ID=y
+CONFIG_VGA_VID=0x1234
+CONFIG_VGA_DID=0x1111
+
+#
+# Debugging
+#
+CONFIG_DEBUG_LEVEL=0
diff --git a/bios/vgabios-debug.bin b/bios/vgabios-debug.bin
new file mode 100644
index 0000000000000000000000000000000000000000..bd9c84ab98568ebae0dd4adcae241ef4411d4f19
Binary files /dev/null and b/bios/vgabios-debug.bin differ
diff --git a/bios/vgabios.bin b/bios/vgabios.bin
new file mode 100644
index 0000000000000000000000000000000000000000..bd393e2b5edb10c04a822fb9e7c02b7cb4ffa6f5
Binary files /dev/null and b/bios/vgabios.bin differ
diff --git a/debug.html b/debug.html
new file mode 100644
index 0000000000000000000000000000000000000000..7aac6d96693e338e7d44d69e27ec449b9093d32c
--- /dev/null
+++ b/debug.html
@@ -0,0 +1,313 @@
+
+
+
+
+
+
+
+
+
+
+
diff --git a/docs/.gitignore b/docs/.gitignore
new file mode 100644
index 0000000000000000000000000000000000000000..3c3629e647f5ddf82548912e337bea9826b434af
--- /dev/null
+++ b/docs/.gitignore
@@ -0,0 +1 @@
+node_modules
diff --git a/docs/archlinux.md b/docs/archlinux.md
new file mode 100644
index 0000000000000000000000000000000000000000..454c110352ebbe6fabba1d15cc66ee0bd31f2efc
--- /dev/null
+++ b/docs/archlinux.md
@@ -0,0 +1,491 @@
+See [Alpine setup](../tools/docker/alpine/Readme.md) for a more reliable and
+faster way to automatically build Linux images for v86.
+
+(This document partly also applies to other Linuxes)
+
+Choosing an installer ISO
+-------------------------
+
+Download Arch Linux 32 from https://archlinux32.org.
+
+Basic installation using QEMU
+-----------------------
+
+Installing Arch Linux with these instructions will result in a raw disk image that can be booted by v86.
+
+```sh
+# fetch archlinux32 installer
+wget https://mirror.archlinux32.org/archisos/archlinux32-2021.12.01-i686.iso
+
+# Create a 10 gigabyte disk image. If you intend to pacstrap only 'base' then 1.5G should be fine also.
+qemu-img create arch.img 10G
+
+# Follow the normal installation process (you can add accel=kvm if your system supports it to speed up the installation)
+qemu-system-x86_64 -m 256 -drive file=arch.img,format=raw -cdrom archlinux32-2021.12.01-i686.iso
+```
+
+For keyboard support, it is necessary to open /etc/mkinitcpio.conf and edit the following line:
+
+```sh
+MODULES="atkbd i8042"
+```
+
+For the changes to take effect, you need to regenerate the initial ramdisk with `mkinitcpio -p linux`
+
+The resulting `arch.img` file is a bootable disk image for v86.
+
+Scripting image creation for v86
+--------------------------------
+
+Installing the ISO by hand takes a long time if you intend to recreate the image many times. There are various reasons why you might want to do this more than once. For example: because the emulator is slow you might want to compile any new software release in QEMU which is much faster and then use the resulting image in v86 instead of making the emulator compile the software. Another reason is that the build progress potentially takes long and if you want to do automated builds in parallel to find out what configurations do and don't work you can just throw more computing power at the problem in order to solve it. This example requires that you have `packer`, `qemu` and `kpartx` installed.
+
+### Creating a packer template
+
+[Packer](https://www.packer.io/docs/builders/qemu.html) is a tool that lets you boot an ISO in any of multiple emulators (so QEMU in our case) and send pre-scripted keystrokes to bootstrap an SSH server. Once the SSH connection is established a script can be started for further provisioning.
+
+Create a template for automating the base installation:
+```sh
+mkdir -p packer
+cat > packer/template.json << 'EOF'
+{
+ "provisioners": [
+ {
+ "type": "shell",
+ "override": {
+ "qemu": {
+ "scripts": ["scripts/provision.sh"]
+ }
+ }
+ }
+ ],
+ "builders": [
+ {
+ "accelerator": "kvm",
+ "type": "qemu",
+ "boot_command": [
+ "",
+ "dhcpcd",
+ "echo root:root | chpasswd",
+ "systemctl start sshd"
+ ],
+ "headless": true,
+ "boot_wait": "10s",
+ "disk_size": 1500,
+ "disk_interface": "ide",
+ "iso_url": "https://mirror.archlinux32.org/archisos/archlinux32-2021.12.01-i686.iso",
+ "iso_checksum": "90c6f5aecb095d5578f6c9970539da7c5e9324ec",
+ "iso_checksum_type": "sha1",
+ "ssh_wait_timeout": "120s",
+ "ssh_pty": true,
+ "ssh_username": "root",
+ "ssh_password": "root",
+ "ssh_port": 22,
+ "format": "raw",
+ "vm_name": "archlinux",
+ "disk_detect_zeroes": "unmap",
+ "memory": 2048,
+ "vnc_bind_address": "0.0.0.0"
+ }
+ ]
+}
+EOF
+```
+
+You can tweak the options a bit to match your situation. For debugging, you can set `headless` to `false`. That will show you the VNC connection instead of running the `boot_command` in the background. For a `base` pacstrap, using a 2 GB disk image should be sufficient. The `raw` disk format is important. v86 does not read qcow2 images, only raw disk images. If your system does not support KVM (the default accelerator), you can change `"accelerator": "none"` to the settings, in macos you may use `"accelerator": "hvf"`. Other accelerator options can be found [here](https://www.packer.io/docs/builders/qemu.html#accelerator).
+
+After gaining SSH connectivity to the VM, packer will run the `scripts/provisioning.sh` script in the guest.
+
+### Creating the Arch Linux installation script
+
+Create a script for your Arch Linux installation. This runs in the live Arch Linux environment, so you need to partition the disk, do a pacstrap, and install a bootloader.
+```sh
+mkdir -p packer/scripts
+### Write your own or copy paste the example below
+vim packer/scripts/provision.sh
+```
+
+An example script to install Arch Linux with the root mounted using the 9p network filesystem:
+```sh
+#!/bin/bash
+echo "Creating a GPT partition on /dev/sda1"
+echo -e "g\nn\n\n\n\nw" | fdisk /dev/sda
+
+# In case you might want to create a DOS partition instead. It doesn't really matter.
+#echo "Creating a DOS partition on /dev/sda1"
+#echo -e "o\nn\np\n1\n\n\nw" | fdisk /dev/sda
+
+echo "Formatting /dev/sda1 to ext4"
+mkfs -t ext4 /dev/sda1
+
+echo "Mounting new filesystem"
+mount -t ext4 /dev/sda1 /mnt
+
+echo "Create pacman package cache dir"
+mkdir -p /mnt/var/cache/pacman/pkg
+
+# We don't want the pacman cache to fill up the image. After reboot whatever tarballs pacman has cached are gone.
+echo "Mount the package cache dir in memory so it doesn't fill up the image"
+mount -t tmpfs none /mnt/var/cache/pacman/pkg
+
+echo "Updating archlinux-keyring"
+pacman -Sy archlinux-keyring --noconfirm
+
+# uncomment to remove signing if unable to resolve signing errors
+sed -i 's/SigLevel.*/SigLevel = Never/g' /etc/pacman.conf
+
+# Install the Arch Linux base system, feel free to add packages you need here
+echo "Performing pacstrap"
+pacstrap -i /mnt base linux dhcpcd curl openssh --noconfirm
+
+echo "Writing fstab"
+genfstab -p /mnt >> /mnt/etc/fstab
+
+# When the Linux boots we want it to automatically log in on tty1 as root
+echo "Ensuring root autologin on tty1"
+mkdir -p /mnt/etc/systemd/system/getty@tty1.service.d
+cat << 'EOF' > /mnt/etc/systemd/system/getty@tty1.service.d/override.conf
+[Service]
+ExecStart=
+ExecStart=-/usr/bin/agetty --autologin root --noclear %I $TERM
+EOF
+
+# This is the tricky part. The current root will be mounted on /dev/sda1 but after we reboot
+# it will try to mount root during boot using the 9p network filesystem. This means the emulator
+# will request all files over the network using XMLHttpRequests from the server. This is great
+# because then you only need to provide the client with a saved state (the memory) and the
+# session will start instantly and load needed files on the fly. This is fast and it saves bandwidth.
+echo "Ensuring root is remounted using 9p after reboot"
+mkdir -p /mnt/etc/initcpio/hooks
+cat << 'EOF' > /mnt/etc/initcpio/hooks/9p_root
+run_hook() {
+ mount_handler="mount_9p_root"
+}
+
+mount_9p_root() {
+ msg ":: mounting '$root' on real root (9p)"
+ # Note the host9p. We won't mount /dev/sda1 on root anymore,
+ # instead we mount the network filesystem and the emulator will
+ # retrieve the files on the fly.
+ if ! mount -t 9p host9p "$1"; then
+ echo "You are now being dropped into an emergency shell."
+ launch_interactive_shell
+ msg "Trying to continue (this will most likely fail) ..."
+ fi
+}
+EOF
+
+echo "Adding initcpio build hook for 9p root remount"
+mkdir -p /mnt/etc/initcpio/install
+cat << 'EOF' > /mnt/etc/initcpio/install/9p_root
+#!/bin/bash
+build() {
+ add_runscript
+}
+EOF
+
+# We need to load some modules into the kernel for it to play nice with the emulator
+# The atkbd and i8042 modules are for keyboard input in the browser. If you do not
+# want to use the network filesystem you only need these. The 9p, 9pnet and 9pnet_virtio
+# modules are needed for being able to mount 9p network filesystems using the emulator.
+echo "Configure mkinitcpio for 9p"
+sed -i 's/MODULES=()/MODULES=(atkbd i8042 libps2 serio serio_raw psmouse virtio_pci virtio_pci_modern_dev 9p 9pnet 9pnet_virtio fscache netfs)/g' /mnt/etc/mkinitcpio.conf
+
+# Because we want to mount the root filesystem over the network during boot, we need to
+# hook into initcpio. If you do not want to mount the root filesystem during boot but
+# only want to mount a 9p filesystem later, you can leave this out. Once the system
+# has been booted you should be able to mount 9p filesystems with mount -t 9p host9p /blabla
+# without this hook.
+sed -i 's/fsck"/fsck 9p_root"/g' /mnt/etc/mkinitcpio.conf
+
+# enable ssh password auth and root login
+sed -i 's/#PermitRootLogin.*/PermitRootLogin yes/g' /etc/ssh/sshd_config
+sed -i 's/#PasswordAuthentication.*/PasswordAuthentication yes/g' /etc/ssh/sshd_config
+
+echo "Writing the installation script"
+cat << 'EOF' > /mnt/bootstrap.sh
+#!/usr/bin/bash
+echo "Re-generate initial ramdisk environment"
+mkinitcpio -p linux
+
+# uncomment to remove signing if you are unable to resolve signing errors otherwise
+sed -i 's/SigLevel.*/SigLevel = Never/g' /etc/pacman.conf
+
+pacman -S --noconfirm syslinux gptfdisk
+syslinux-install_update -i -a -m
+
+# disabling ldconfig to speed up boot (to remove Rebuild dynamic linker cache...)
+# you may want to comment this out
+echo "Disabling ldconfig service"
+systemctl mask ldconfig.service
+
+sync
+EOF
+
+echo "Chrooting and bootstrapping the installation"
+arch-chroot /mnt bash bootstrap.sh
+
+
+cat << 'EOF' > /mnt/boot/syslinux/syslinux.cfg
+# Config file for Syslinux -
+# /boot/syslinux/syslinux.cfg
+#
+# Comboot modules:
+# * menu.c32 - provides a text menu
+# * vesamenu.c32 - provides a graphical menu
+# * chain.c32 - chainload MBRs, partition boot sectors, Windows bootloaders
+# * hdt.c32 - hardware detection tool
+# * reboot.c32 - reboots the system
+#
+# To Use: Copy the respective files from /usr/lib/syslinux to /boot/syslinux.
+# If /usr and /boot are on the same file system, symlink the files instead
+# of copying them.
+#
+# If you do not use a menu, a 'boot:' prompt will be shown and the system
+# will boot automatically after 5 seconds.
+#
+# Please review the wiki: https://wiki.archlinux.org/index.php/Syslinux
+# The wiki provides further configuration examples
+
+DEFAULT arch
+PROMPT 0 # Set to 1 if you always want to display the boot: prompt
+TIMEOUT 100
+
+# Menu Configuration
+# Either menu.c32 or vesamenu32.c32 must be copied to /boot/syslinux
+UI menu.c32
+#UI vesamenu.c32
+
+# Refer to http://syslinux.zytor.com/wiki/index.php/Doc/menu
+MENU TITLE Arch Linux
+#MENU BACKGROUND splash.png
+MENU COLOR border 30;44 #40ffffff #a0000000 std
+MENU COLOR title 1;36;44 #9033ccff #a0000000 std
+MENU COLOR sel 7;37;40 #e0ffffff #20ffffff all
+MENU COLOR unsel 37;44 #50ffffff #a0000000 std
+MENU COLOR help 37;40 #c0ffffff #a0000000 std
+MENU COLOR timeout_msg 37;40 #80ffffff #00000000 std
+MENU COLOR timeout 1;37;40 #c0ffffff #00000000 std
+MENU COLOR msg07 37;40 #90ffffff #a0000000 std
+MENU COLOR tabmsg 31;40 #30ffffff #00000000 std
+
+# boot sections follow
+#
+# TIP: If you want a 1024x768 framebuffer, add "vga=773" to your kernel line.
+#
+#-*
+
+LABEL arch
+ MENU LABEL Arch Linux 9p
+ LINUX ../vmlinuz-linux
+ APPEND root=/dev/sda1 rw quiet
+ INITRD ../initramfs-linux.img
+
+LABEL arch2
+ MENU LABEL Arch Linux Disk
+ LINUX ../vmlinuz-linux
+ APPEND root=/dev/sda1 rw quiet disablehooks=9p_root
+ INITRD ../initramfs-linux.img
+
+LABEL hdt
+ MENU LABEL HDT (Hardware Detection Tool)
+ COM32 hdt.c32
+
+LABEL reboot
+ MENU LABEL Reboot
+ COM32 reboot.c32
+
+LABEL poweroff
+ MENU LABEL Poweroff
+ COM32 poweroff.c32
+EOF
+umount -R /mnt
+```
+
+With the packer template and the script you have enough to create an image that can be booted by v86. But because this example script installs an Arch Linux that wants to mount root over the network with 9p, we need to host that filesystem first. If you do not want to use 9p, you can just run `(cd packer && packer build -force template.json)` to build the image.
+
+### Creating the 9p filesystem
+
+Now that we have an image that contains a filesystem, we can convert that filesystem into something we can host on the webserver together with the v86 library.
+
+To do so, we need to mount the image once and create a json mapping of the filesystem. The following script shows how to map the filesystem in an automated fashion.
+
+Create a script to builds the image and then creates v86 compatible artifacts:
+```sh
+vim build.sh
+```
+
+Example script:
+
+```sh
+#!/bin/sh
+
+SRC=packer
+TARGET=output
+
+# build the boxfile from the iso
+(cd $SRC && sudo PACKER_LOG=1 PACKER_LOG_PATH="./packer.log" packer build -force template.json)
+
+# test if there is a boxfile where we expected it
+if [ ! -f $SRC/output-qemu/archlinux ]; then
+ echo "Looks like something went wrong building the image, maybe try again?"
+ exit 1
+fi;
+
+# clean up any previous loops and mounts
+echo "Making sure mountpoint is empty"
+LOOP_DEV=$(sudo losetup -f)
+
+sudo umount diskmount -f || /bin/true
+sudo kpartx -d $LOOP_DEV || /bin/true
+sudo losetup -d $LOOP_DEV || /bin/true
+
+# mount the generated raw image, we do that so we can create
+# a json mapping of it and copy it to host on the webserver
+mkdir -p diskmount
+echo "Mounting the created image so we can convert it to a p9 image"
+sudo losetup $LOOP_DEV $SRC/output-qemu/archlinux
+sudo kpartx -a $LOOP_DEV
+sudo mount /dev/mapper/$(basename $LOOP_DEV)p1 diskmount
+
+# make images dir
+mkdir -p $TARGET
+mkdir -p $TARGET/images
+mkdir -p $TARGET/images/arch
+
+# map the filesystem to json with fs2json
+sudo ./tools/fs2json.py --out $TARGET/images/fs.json diskmount
+sudo ./tools/copy-to-sha256.py diskmount $TARGET/images/arch
+
+# copy the filesystem and chown to nonroot user
+echo "Copying the filesystem to $TARGET/arch"
+mkdir $TARGET/arch -p
+sudo rsync -q -av diskmount/ $TARGET/arch
+sudo chown -R $(whoami):$(whoami) $TARGET/arch
+
+# clean up mount
+echo "Cleaning up mounts"
+sudo umount diskmount -f
+sudo kpartx -d $LOOP_DEV
+sudo losetup -d $LOOP_DEV
+
+# Move the image to the images dir
+sudo mv $SRC/output-qemu/archlinux $TARGET/images/arch.img
+```
+
+Given that the packer template and provision.sh is rooted at `packer` (adjust the value of `$SRC` otherwise), run the `build.sh` at root of your `v86` repo:
+
+```
+chmod +x build.sh
+./build.sh
+```
+
+Generated artifacts are now available for serving from `output`.
+
+### Using the created artifacts in v86
+
+Now that we have everything we need to host a server that serves an Arch Linux environment over the network.
+
+Create a checkout of v86 and run `make build/libv86.js`.
+We can then edit `examples/arch.html`, we have two options:
+
+1. Boot Arch Linux from the 9p filesystem (generated .bin artifacts at `/output/images/arch`):
+
+ ```sh
+ filesystem: {
+ baseurl: "../output/images/arch/",
+ basefs: "../output/images/fs.json",
+ },
+
+ bzimage_initrd_from_filesystem: true,
+
+ cmdline: [
+ "rw",
+ "root=host9p rootfstype=9p rootflags=trans=virtio,cache=loose",
+ ].join(" "),
+
+ acpi: false,
+ autostart: true,
+ ```
+2. Boot the Arch Linux from the qemu raw disk image:
+
+ ```sh
+ hda: {
+ url: "../output/images/arch.img",
+ # set to true if you want to load it asynchrously during runtime (for this option we need to run a webserver that supports the Range header)
+ # NOTE: async: false is slow but proved to be more realiable
+ async: false,
+
+ # This needs to be the size of the raw disk.
+ size: 1.5 * 1024 * 1024 * 1024,
+ # See the `disk_size` item in the packer template.
+ },
+
+ acpi: false,
+ autostart: true,
+ ```
+
+Next, we need a webserver that supports the Range header. For example [this extension of the SimpleHTTPServer](https://github.com/smgoller/rangehttpserver). At your `v86` root, run:
+
+```sh
+wget https://raw.githubusercontent.com/smgoller/rangehttpserver/master/RangeHTTPServer.py
+python2 RangeHTTPServer.py
+```
+
+Now that the webserver is running, point your browser to `http://localhost:8000/examples/arch.html`. Wait for the Linux to boot. When the system is up, click 'Save state to file'. Your browser will download a `v86state.bin` file. Copy that file to `/your/v86/dir/images`. You can then edit `examples/arch.html` again and add a 'state' key to the `V86` array.
+
+```sh
+initial_state: {
+ "url": "http://localhost:8000/images/v86state.bin",
+},
+```
+
+If you refresh `http://localhost:8000/examples/arch.html` you will see that the state is restored instantly and all required files are loaded over the network on the fly.
+
+### Networking
+
+The emulator can emulate a network card. For more information [look at the networking documentation](https://github.com/copy/v86/blob/master/docs/networking.md). To set up networking in the VM, add the following item to the `V86` array in the `examples/arch.html` file:
+```sh
+network_relay_url: "ws://localhost:8080/",
+```
+
+This will make the emulator try to connect to a [WebSockets proxy](https://github.com/benjamincburns/websockproxy). Running the proxy is very easy if you use the Docker container.
+
+```sh
+sudo docker run --privileged -p 8080:80 --name relay bennottelling/websockproxy
+```
+**NOTE:** original `benjamincburns/jor1k-relay:latest` has throttling built-in by default which will degrade the networking. `bennottelling/websockproxy` has this throttling removed via [websockproxy/issues/4#issuecomment-317255890](https://github.com/benjamincburns/websockproxy/issues/4#issuecomment-317255890).
+
+You can check if the relay is running correctly by going to `http://localhost:8080/` in your browser. There you should see a message that reads `Can "Upgrade" only to "Websocket".`.
+
+Now you should be able to get network connectivity in the virtual machine. If you are restoring from a saved state, you might need to first run:
+```sh
+ip link set enp0s5 down
+rmmod ne2k-pci
+```
+
+To bring the network up, run:
+```sh
+modprobe ne2k-pci
+dhcpcd -w4 enp0s5
+```
+
+It might take a while for a carrier to become available on the interface. If the `dhcpcd` command fails shortly after booting, wait a bit and try again a bit later. If you are using the 9p network filesystem you can use the developer tools networking tab (in chrome) to get a sense of what is going on by looking at the files that are being downloaded.
+
+When the network is up you should be able to curl a website. To check, run `curl icanhazip.com`. There you should see the public IP of the machine running the proxy.
+
+You can't do inbound traffic into the VM with the websockproxy Docker container because it uses a basic NAT. To SSH into the VM running in the browser, you can create a reverse SSH tunnel to expose the SSH port of the sshd in the VM to the outside world. You may need to start `sshd` first, it may also be reasonable to change root password:
+
+```sh
+passwd root
+systemctl start sshd
+```
+
+then create a reverse SSH tunnel:
+
+```sh
+# This will create a port 1122 on the example.com server
+# which forwards to the SSH in the VM
+ssh root@example.com -R 1122:localhost:22
+```
+
+Now on the `example.com` server you should be able to SSH into your browser tab by running `ssh root@localhost -p 1122`.
diff --git a/docs/cpu-idling.md b/docs/cpu-idling.md
new file mode 100644
index 0000000000000000000000000000000000000000..01cde508b11560148dc1fc88cc059db4307bf95b
--- /dev/null
+++ b/docs/cpu-idling.md
@@ -0,0 +1,26 @@
+Some operating systems don't support `hlt` instruction, because of this, the CPU spin loops instead of idling.
+Here are some solutions for different OSes:
+
+## MS-DOS (using DOSIdle)
+1. Download `DOSID251.zip` from https://www.vogons.org/viewtopic.php?p=438763#p438763
+2. Unzip DOSIDLE.EXE from archive in any location (recommended to root of C:).
+3. Run `edit C:\autoexec.bat`
+4. Add to file: `C:\path\to\dosidle.exe`
+5. Save changes (*press Alt + F and x*) and restart the VM.
+
+**Note:** To hide output when starting DOSIdle, change `C:\path\to\dosidle.exe` to `C:\path\to\dosidle.exe > nul` on step №4.
+
+## FreeDOS ([source](https://narkive.com/UGrcO8wU.2))
+1. Run `edit C:\fdconfig.sys` (or `edit C:\config.sys`)
+2. Add to file: `IDLEHALT=1`
+3. Save changes (*press Alt + F and x*) and restart FreeDOS.
+
+## Windows 9x (using AmnHLT)
+1. Download `amnhltm.zip` from http://toogam.com/software/archive/drivers/cpu/cpuidle/amnhltm.zip ([mirror](https://web.archive.org/web/20060212132151/http://www.user.cityline.ru/~maxamn/amnhltm.zip))
+2. Unzip the archive in any location.
+3. **Note**: If you have installed VBE9x, restart Windows, press F8 on boot, select *Command prompt only*, run `cd C:\path\to\amnhlt\`, and follow to the next step.
+4. Run `AMNHLT.BAT`
+5. Restart Windows, and AmnHLT will start automatically on next boot (you can safely delete archive and unpacked folder).
+
+## Windows 98+ and Unix-like
+These systems are already supports `hlt`, no further action is required.
diff --git a/docs/filesystem.md b/docs/filesystem.md
new file mode 100644
index 0000000000000000000000000000000000000000..d247a013727c67e5b49decd84bdbe5cd45f634fc
--- /dev/null
+++ b/docs/filesystem.md
@@ -0,0 +1,97 @@
+A 9p filesystem is supported by v86, using a virtio transport. There are several
+ways it can be set up.
+
+### Guest mount
+
+In all cases, the filesystem is mounted in the guest system using the `9p`
+filesystem type and the `host9p` device tag. Typically you want to be specific
+with the version and transport options:
+
+```sh
+mount -t 9p -o trans=virtio,version=9p2000.L host9p /mnt/9p/
+```
+
+Here are kernel arguments you can use to boot directly off the 9p filesystem:
+
+```
+rw root=host9p rootfstype=9p rootflags=trans=virtio,version=9p2000.L
+```
+
+The `aname` option can be used to pick the directory from 9p to mount. The `rw`
+argument makes this a read-write root filesystem.
+
+
+### JSON/HTTP Filesystem
+
+This is the standard way to setup the 9p filesystem. It loads files over
+HTTP on-demand into an in-memory filesystem in JS. This allows files to be
+exchanged with the guest OS. See `create_file` and `read_file` in
+[`starter.js`](https://github.com/copy/v86/blob/master/src/browser/starter.js).
+
+This mode is enabled by passing the following options to `V86`:
+
+```javascript
+filesystem: {
+ basefs: "../9p/fs.json",
+ baseurl: "../9p/base/",
+}
+```
+
+Here, `basefs` is a json file created using
+[fs2json.py](tools/fs2json.py) and the `baseurl` directory is created using
+[copy-to-sha256.py](tools/copy-to-sha256.py).
+
+If `basefs` and `baseurl` are omitted, an empty 9p filesystem is created. Unless
+you configure one of the alternative modes.
+
+
+### Function Handler
+
+You can handle 9p messages directly in JavaScript yourself by providing a
+function as `handle9p` under `filesystem`:
+
+```javascript
+filesystem: {
+ handle9p: async (reqBuf, reply) => {
+ // reqBuf is a Uint8Array of the entire request frame.
+ // you can parse these bytes using a library or reading the 9p spec.
+ // once you formulate a response, you send the reply frame as a
+ // Uint8Array by passing it to reply: reply(respBuf)
+ }
+}
+```
+
+This allows you to implement a 9p server or custom proxy in JS. However, this
+filesystem will not be cached (unless cached in the guest OS), functions like
+`create_file` and `read_file` will not be available, and you will be responsible
+for keeping its state in sync with any machine save states.
+
+
+### WebSocket Proxy
+
+You can also back the 9p virtio filesystem with a 9p server over WebSocket by
+providing a WS proxy URL:
+
+```javascript
+filesystem: {
+ proxy_url: "ws://localhost:8080/"
+}
+```
+
+Simlar to using `handle9p`, this filesystem will not be available in JS and
+will need to be re-mounted after restoring state.
+
+The WS proxy just needs to hand off messages with a connection to a normal 9p
+server. Each binary WebSocket message is the full buffer of a request or a
+reply.
+
+To implement, request message bytes can just be sent directly to the 9p
+connection, but the 9p reply stream needs to be buffered into a single binary
+WebSocket message. The proxy must at least parse the first 4 bytes to get the
+message size and use it to buffer a full message before sending over WebSocket.
+
+The [wanix](https://github.com/tractordev/wanix) CLI has a `serve` command that
+not only serves a directory over HTTP, but also over 9P via WebSocket. You can
+see how it [implements a proxy][1] in Go.
+
+[1]: https://github.com/tractordev/wanix/blob/main/cmd/wanix/serve.go#L117-L177
diff --git a/docs/how-it-works.md b/docs/how-it-works.md
new file mode 100644
index 0000000000000000000000000000000000000000..e5c9bf7d2cf198068447e1f5ace1c37393b1534b
--- /dev/null
+++ b/docs/how-it-works.md
@@ -0,0 +1,81 @@
+Here's an overview of v86's workings. For details, check the
+[source](https://github.com/copy/v86/tree/master/src).
+
+The major limitations of WebAssembly are (for the purpose of making emulators with jit):
+
+- structured control flow (no arbitrary jumps)
+- no control over registers (you can't keep hardware registers in wasm locals across functions)
+- no mmap (paging needs to be fully emulated)
+- no patching
+- module generation is fairly slow, but at least it's asynchronous, so other things can keep running
+- there is some memory overhead per module, so you can't generate more than a few thousand
+
+v86 has an interpreted mode, which collects entry points (targets of function
+calls and indirect jumps). It also measures the hotness per page, so that
+compilation is focused on code that is often executed. Once a page is
+considered hot, code is generated for the entire page and up to `MAX_PAGES`
+that are directly reachable from it.
+
+v86 generates a single function with a big switch statement (brtable), to
+ensure that all functions and targets of indirect jumps are reachable from
+other modules. The remaining control flow is handled using the "stackifier"
+algorithm (well-explained in
+[this blog post](https://medium.com/leaningtech/solving-the-structured-control-flow-problem-once-and-for-all-5123117b1ee2)).
+At the moment, there is no linking of wasm modules. The current module is
+exited, and the main loop detects if a new module can be entered.
+
+In practice, I found that browsers don't handle this structure (deep brtables,
+with locals being used across the entire function) very well, and `MAX_PAGES`
+has to be set to fairly low, otherwise memory usage blows up. It's likely that
+improvements are possible (generating fewer entry points, splitting code across
+multiple functions).
+
+Code-generation happens in two passes. The first pass finds all basic block
+boundaries, the second generates code for each basic block. Instruction
+decoding is generated by a [set of
+scripts](https://github.com/copy/v86/tree/master/gen) from a [table of
+instructions](https://github.com/copy/v86/blob/master/gen/x86_table.js). It's
+also used to [generate
+tests](https://github.com/copy/v86/blob/master/tests/nasm/create_tests.js).
+
+To handle paging, v86 generates code similar to this (see `gen_safe_read`):
+
+```
+entry <- tlb[addr >> 12 << 2]
+if entry & MASK == TLB_VALID && (addr & 0xFFF) <= 0xFFC - bytes: goto fast
+entry <- safe_read_jit_slow(addr, instruction_pointer)
+if page_fault: goto exit-with-pagefault
+fast: mem[(entry & ~0xFFF) ^ addr]
+```
+
+There is a 4 MB cache that acts like a tlb. It contains the physical address,
+read-only bit, whether the page contains code (in order to invalidate it on
+write) and whether the page points to mmio. Any of those cases are handled in
+the slow path (`safe_read_jit_slow`), as well as walking the page tables and
+triggering page faults. The fast path is taken in the vast majority of times.
+
+The remaining code generation is mostly a straight-forward, 1-to-1 translation
+of x86 to wasm. The only analysis done is to optimise generation of condional
+jumps immediately after arithmetic instructions, e.g.:
+
+```
+cmp eax, 52
+setb eax
+```
+
+becomes:
+
+```
+... // code for cmp
+eax <- eax < 52
+```
+
+A lazy flag mechanism is used to speed arithmetic (applies to both jit and
+interpreted mode, see
+[`arith.rs`](https://github.com/copy/v86/blob/master/src/rust/cpu/arith.rs) and
+[`misc_instr.rs`](https://github.com/copy/v86/blob/master/src/rust/cpu/misc_instr.rs)).
+There's a wip that tries to elide most lazy-flags updates:
+https://github.com/copy/v86/pull/466
+
+FPU instructions are emulated using softfloat (very slow, but unfortunately
+some code relies on 80 bit floats).
diff --git a/docs/linux-9p-image.md b/docs/linux-9p-image.md
new file mode 100644
index 0000000000000000000000000000000000000000..80c625416e7c4c0f0044984960df528052804934
--- /dev/null
+++ b/docs/linux-9p-image.md
@@ -0,0 +1,58 @@
+In order to create a Linux image that can mount the 9p file system, add the following lines to the kernel configuration:
+
+```
+CONFIG_NET_9P=y
+CONFIG_NET_9P_VIRTIO=y
+CONFIG_NET_9P_DEBUG=y
+CONFIG_VIRTIO=y
+CONFIG_VIRTIO_PCI=y
+CONFIG_9P_FS=y
+CONFIG_9P_FSCACHE=y
+CONFIG_9P_FS_POSIX_ACL=y
+```
+
+A Dockerfile for this build is here: https://github.com/ysangkok/build-v86-9p-linux
+
+Using initcpio
+--------------
+
+This allows you to remount the root file system using 9p. No changes are necessary if you only want to mount a 9p filesystem after booting.
+
+Add the following files:
+
+`/etc/initcpio/hooks/9p_root`
+
+```bash
+#!/usr/bin/bash
+
+run_hook() {
+ mount_handler="mount_9p_root"
+}
+
+mount_9p_root() {
+ msg ":: mounting '$root' on real root (9p)"
+ if ! mount -t 9p host9p "$1"; then
+ echo "You are now being dropped into an emergency shell."
+ launch_interactive_shell
+ msg "Trying to continue (this will most likely fail) ..."
+ fi
+}
+```
+
+
+
+`/etc/initcpio/install/9p_root`
+
+```bash
+#!/bin/bash
+build() {
+ add_runscript
+}
+```
+
+Change the following options in `/etc/mkinitcpio.conf`:
+
+```bash
+MODULES="virtio_pci 9p 9pnet 9pnet_virtio"
+HOOKS="base udev autodetect modconf block filesystems keyboard fsck 9p_root" # appended 9p_root
+```
diff --git a/docs/networking.md b/docs/networking.md
new file mode 100644
index 0000000000000000000000000000000000000000..d9ec124d61c03ba2503baf4324f5b8c31657a3fb
--- /dev/null
+++ b/docs/networking.md
@@ -0,0 +1,218 @@
+# v86 networking
+
+User guide to networking in v86.
+
+## Introduction
+
+On the most basic level, networking in v86 is comprised of two components:
+
+* an emulation of the guest's [Network Interface Controller](https://en.wikipedia.org/wiki/Network_interface_controller) (NIC), and
+* a network backend which passes ethernet frames between the NIC and a virtual and/or physical [ethernet network](https://en.wikipedia.org/wiki/Ethernet).
+
+There are two **NIC emulations** supported by v86 to chose from, either **`ne2k`** (NE2000/RTL8390-compatible NIC) or **`virtio`** ([VirtIO](http://wiki.osdev.org/Virtio)-compatible device). The right choice simply depends on the driver support in the guest OS, older OSes like FreeDOS only support NE2000, more modern ones usually support VirtIO. In case both are supported by the guest OS it's recommended to try VirtIO first and only fall back to NE2000 if that fails. In some cases it will also be necessary to manually load a driver or similar to activate the NIC and/or networking in the guest OS, yet modern systems usually auto-detect an available NIC during installation and when booting.
+
+There are also several **network backends** to chose from which emulate the network that the virtual NIC is connected to, they differ in their requirements and in the degree of network access and services provided to guests. Some provide only limited network access, others full access to a physical network which may include a gateway to the Internet. Backends may require a specific type of proxy server to operate.
+
+### Backend URL schemes
+
+The active network backend is configured through a user-specified **backend URL**. Each backend has at least one distinct URL scheme as specified below, where `PROXY` is the DNS hostname or IP address of a compatible proxy server, `PORT` its optional TCP port number (and its default), and `QUERY` is some HTTP query field fragment:
+
+| Backend | Backend URL scheme(s) | Example(s) |
+| :------ | :-------------------- | :--------- |
+| **[inbrowser](#the-inbrowser-backend)** | `inbrowser` | `inbrowser` |
+| **[wsproxy](#the-wsproxy-backend)** | `"ws://" PROXY [":" PORT=80] ["/" ...]` `"wss://" PROXY [":" PORT=443] ["/" ...]` | `wss://relay.widgetry.org/` |
+| **[wisp](#the-wisp-backend)** | `"wisp://" PROXY [":" PORT=80] ["/" ...]` `"wisps://" PROXY [":" PORT=443] ["/" ...]` | `wisp://localhost:12345` |
+| **[fetch](#the-fetch-backend)** | `"fetch" [ "://" PROXY [":" PORT] ["/" QUERY] ]` | `fetch` `fetch://localhost:1234/?url=` |
+
+Note that `wss://` and `wisps://` are the TLS-secured transports of `ws://` and `wisp://`, respectively.
+
+> [!TIP]
+> Since public proxy servers provide only limited bandwidth it is recommended to install and use a local, private proxy server for best results. All proxy servers allow to be executed on the local machine, in a VM running on the local machine, in a local network or even publicly on the Internet (which is generally not recommended, of course). Many proxy servers are distributed as Docker containers which is the recommended way of installing them, otherwise install into a VM.
+
+## Network setup
+
+### Web interface setup
+
+Network setup in the v86 web interface at **https://copy.sh/v86/** is straightforward, simply copy the backend URL into the text box named **`Networking proxy`** or select one of the presets to configure the network backend. The guest's NIC emulation (NE2000 or VirtIO) is automatically configured when selecting the guest image in the web interface.
+
+### Embedded v86 setup
+
+JavaScript applications that do not use the v86 web interface (but instead embed V86 into their architecture) setup their network by using the common `config` object that they pass to the V86 constructor. Network settings are members of the object **`config.net_device`**, all settings are optional except for `relay_url`.
+
+#### General `net_device` settings
+
+Common options in `config.net_device`:
+
+| net_device | type | description |
+| :------------ | :--- | :--- |
+| **type** | str | The type of emulated NIC provided to the guest OS, either `ne2k` or `virtio`. Default: `ne2k`. |
+| **relay_url** | str | The network backend URL, see [Backend URL schemes](#backend-url-schemes) for details. Note that the CORS proxy server of the `fetch` backend is defined in field `cors_proxy` below. This option is required. |
+| **id** | int | Network id, all v86 network instances with the same id share the same network namespace. Default: `0`. *(TODO: class `NetworkAdapter` should also get options.net_device as an argument, at least options.net_device.id).* |
+
+#### Special `net_device` settings
+
+Backends `fetch` and `wisp` support a couple of special settings in `config.net_device` to control virtual network components emulated by the backend:
+
+| net_device | type | description |
+| :------------- | :--- | :--- |
+| **router_mac** | str | MAC address of virtual network peers (ARP, PING, DHCP, DNS, NTP, UDP echo and TCP peers) in common MAC address notation. Default `52:54:0:1:2:3`. |
+| **router_ip** | str | IP address of virtual network peers (ARP, PING, DHCP, DNS and TCP peers) in dotted IP notation. Default `192.168.86.1`. |
+| **vm_ip** | str | IP address to be assigned to the guest by DHCP in dotted IP notation. Default `192.168.86.100`. |
+| **masquerade** | bool | If `True`, announce `router_ip` as the router's and DNS server's IP addresses in generated DHCP replies, and also generate ARP replies to IPs outside the router's subnet `255.255.255.0`. Default: `True`. |
+| **dns_method** | str | DNS method to use, either `static` or `doh`. `static`: use built-in DNS server, `doh`: use [DNS-over-HTTPS](https://en.wikipedia.org/wiki/DNS_over_HTTPS) (DoH). Defaults to `static` for `fetch` and to `doh` for `wisp` backend. |
+| **doh_server** | str | Host name or IP address (and optional port number) of the DoH server if `dns_method` is `doh`. The value is expanded to the URL `https://DOH_SERVER/dns-query`. Default: `cloudflare-dns.com`. |
+| **cors_proxy** | str | CORS proxy server URL, do not use a proxy if undefined. Default: undefined (`fetch` backend only). |
+
+#### Example `net_device` settings
+
+* **Example 1:** Provide an emulated NE2000 NIC to the guest OS and use the `wsproxy` backend with a secure wsproxy server at public host `relay.widgetry.org` listening at default TLS port 443:
+ ```javascript
+ let example_1 = new V86({
+ net_device: {
+ relay_url: "wss://relay.widgetry.org/"
+ },
+ // ...
+ });
+ ```
+
+* **Example 2:** Provide a VirtIO NIC to the guest OS and use the `fetch` backend with a CORS proxy server at the local machine listening at port number 23456:
+ ```javascript
+ let example_2 = new V86({
+ net_device: {
+ type: "virtio",
+ relay_url: "fetch",
+ cors_proxy: "https://localhost:23456/?url="
+ },
+ // ...
+ });
+ ```
+
+## Network backends
+
+One way to compare the different network backends is how they operate on different layers of the TCP/IP Model (see [Wikipedia](https://en.wikipedia.org/wiki/OSI_model#Comparison_with_TCP/IP_model) for a comparison to the OSI model), approximately:
+
+ Network Peer Backend v86 Guest
+
+ [ Application ] <---- fetch ----> +-----+ [ Application ]
+ [ Transport ] <---- wisp -----> | v86 | [ Transport ]
+ [ Network ] | | [ Network ]
+ [ Access ] <--- wsproxy ---> +-----+ <---> [ Access ]
+ and inbrowser
+
+ Fig. 1: Network backends in v86
+
+v86 guests strictly expect to exchange raw ethernet frames with their (emulated) network card, hence the higher the layer that a v86 network backend operates on the more virtualized the network becomes and the more work has to be done by the backend to fill in for the missing layers.
+
+In order to facilitate this for backend implementations, v86 provides helper functions to encode/decode ethernet frames, ARP and IPv4 packets, UDP datagrams, TCP streams and HTTP requests/responses. v86 can also provide minimal but sufficient ARP, ICMP-echo, DHCP, DNS (including DoH) and NTP services to guests.
+
+The v86 architecture is open for additional network backend implementations, for a basic example see [examples/two_instances.html](../examples/two_instances.html).
+
+### The `inbrowser` backend
+
+This backend provides raw ethernet services for multiple v86 guests running within the same browser process (meaning within the same web page and/or in separate browser tabs). It works standalone without a proxy server, but it also does not provide any access to external networks.
+
+The `inbrowser` backend is implemented using the browser-internal [BroadcastChannel](https://developer.mozilla.org/en-US/docs/Web/API/BroadcastChannel) API, due to its simplicity it is the most efficient backend, however all VMs have to share the same browser resources.
+
+### The `wsproxy` backend
+
+A backend based on a proxy server that provides raw ethernet services to guests using the [WebSocket](https://en.wikipedia.org/wiki/WebSocket) protocol for transport. It depends on the specific proxy server what kind of network configuration it presents to guests, but usually a separate IP subnet with DHCP and DNS services and optional access to the server's physical network and possibly Internet are provided.
+
+Since this backend (including its proxy server) only forwards unmodified ethernet frames it is inherently efficient while providing full physical network emulation to guests.
+
+**Proxy server**
+
+* **[websockproxy](https://github.com/benjamincburns/websockproxy)** -- one TAP device for all clients, integrates dnsmasq for DHCP/DNS, no TLS, original server by benjamincburns
+ * Docker container [`benjamincburns/jor1k-relay`](https://hub.docker.com/r/benjamincburns/jor1k-relay) is throttled, see [this comment](https://github.com/benjamincburns/websockproxy/issues/4#issuecomment-317255890)
+ * Docker container [`bellenottelling/websockproxy`](https://hub.docker.com/r/bellenottelling/websockproxy) is unthrottled
+ * [See here](https://github.com/copy/v86/discussions/1175#discussioncomment-11199254) for step-by-step instructions on how to unthrottle websockproxy manually.
+* **[go-websockproxy](https://github.com/gdm85/go-websockproxy)** -- one TAP device for all clients, written in Go, without integraded DHCP but with integrated TLS support
+* **[node-relay](https://github.com/krishenriksen/node-relay)** -- like websockproxy but written for NodeJS (dnsmasq/no TLS), see [New websocket ethernet switch built using Node.js #777](https://github.com/copy/v86/discussions/777)
+* **[wsnic](https://github.com/chschnell/wsnic)** -- uses a single bridge and one TAP device per client, integrates dnsmasq for DHCP/DNS and stunnel for TLS
+
+[See here](https://github.com/copy/v86/discussions/1199#discussioncomment-12026845) for a benchmark comparing the download performance of these proxy servers.
+
+### The `wisp` backend
+
+The `wisp` backend implements the client side of the [WISP protocol](https://github.com/MercuryWorkshop/wisp-protocol). WISP is a client/server protocol designed to exchange messages containing UDP and TCP payloads between a WebSocket client and a WISP-compatible proxy server. Note that WISP transports only the packet payloads, not the raw UDP or TCP packets.
+
+This backend monitors outbound traffic from guests and wraps/unwraps TCP payload data in WISP messages. A TCP state machine is included to terminate the guest's TCP stream. In addition to the TCP stream, virtual replies to ARP, DHCP, DNS, NTP, ICMP-Ping and UDP-Echo requests from guests are generated (to a certain degree). See PR [#1097](https://github.com/copy/v86/pull/1097) for additional information about this backend.
+
+v86 guests are isolated from each other when using the `wisp` backend.
+
+**WISP-compatible proxy server**
+
+* **[wisp-js](https://www.npmjs.com/package/@mercuryworkshop/wisp-js)**
+* **[epoxy-tls](https://github.com/MercuryWorkshop/epoxy-tls)**
+
+> [!NOTE]
+> The WISP protocol only supports UDP and TCP client sockets in the v86 guest, any server sockets listening in the guest are not supported.
+
+> [!NOTE]
+> This WISP implementation does not support UDP, only TCP. Once UDP is added, regular DNS over UDP will become the default (instead of DoH), and the builtin NTP and UDP-Echo servers will be removed.
+
+### The `fetch` backend
+
+The `fetch` backend uses the browser's [`fetch()`](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API) API to allow guests to send HTTP requests to external HTTP servers and to receive related HTTP responses. This is however complicated by the fact that browsers add [CORS headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) to HTTP requests initiated by `fetch()`, and that they check the CORS headers of related HTTP responses to block access to external web resources not authorized to `fetch()` in the given context.
+
+This backend is efficient and very useful in cases where CORS is not in the way, otherwise (and in general) a CORS proxy server must be used to provide access to HTTP servers on the open Internet.
+
+Like the [`wisp`](#the-wisp-backend) backend, the `fetch` backend handles DHCP and ARP requests from guests internally, and additionally monitors the guest's outbound traffic for HTTP requests which it translates into calls to `fetch()`. NTP, ICMP pings and UDP echo packets are handled to a certain degree. Note that `fetch()` performs the DNS lookup using the browser's internal DNS client. See PR [#1061](https://github.com/copy/v86/pull/1061) for additional technical details.
+
+Starting with PR [#1233](https://github.com/copy/v86/pull/1233), the TCP guest listener can be accessed from JS API, see the [examples/tcp_terminal.html](../examples/tcp_terminal.html) example.
+
+v86 guests are isolated from each other when using the `fetch` backend.
+
+v86 guests have HTTP access to the host's `localhost` using the URL `http://.external` (e.g. `1234.external` -> `localhost:1234`).
+
+**CORS proxy server**
+
+* **[cors-anywhere](https://github.com/Rob--W/cors-anywhere)** -- NodeJS
+* **[uncors](https://github.com/chschnell/uncors)** -- A simple PHP-based CORS proxy server for Apache2.
+
+> [!TIP]
+> You can pass the following flags to **chromium** to allow browsing without restrictions when using the fetch backend:
+>
+> --disable-web-security --user-data-dir=/tmp/test
+>
+> **NOTE:** This turns off the same-origin policy and should only be used temporarily!
+
+## Related topics
+
+### v86 run-time state images
+
+v86 supports saving and restoring the guest's and emulator's run-time state in **state image** files.
+
+When restoring a state image, v86 randomises the restored guest's MAC address to make sure that multiple VMs restored from the same state image use different MAC addresses. However, the restored guest OS is unaware that its NIC's MAC address has changed which prevents it from sending and receiving packets correctly. There are several workarounds:
+
+- Unload the network driver before saving the state. On Linux, unloading can be
+ done using `rmmod ne2k-pci` or `echo 0000:00:05.0 >
+ /sys/bus/pci/drivers/ne2k-pci/unbind` and loading (after the state has been
+ loaded) using `modprobe ne2k-pci` or `echo 0000:00:05.0 >
+ /sys/bus/pci/drivers/ne2k-pci/bind`
+- Pass `preserve_mac_from_state_image: true` to the V86 constructor. This
+ causes MAC addresses to be shared between all VMs with the same state image.
+- Pass `mac_address_translation: true` to the V86 constructor. This causes v86
+ to present the old MAC address to the guest OS, but translate it to a
+ randomised MAC address in outgoing packets (and vice-versa for incoming
+ packets). This mechanism currently only supports the ethernet, ipv4, dhcp and
+ arp protcols. See `translate_mac_address` in
+ [`src/ne2k.js`](https://github.com/copy/v86/blob/master/src/ne2k.js). This is
+ currently used in Windows, ReactOS and SerenityOS profiles.
+- Some OSes don't cache the MAC address when the driver loads and therefore
+ don't need any of the above workarounds. This seems to be the case for Haiku,
+ OpenBSD and FreeBSD.
+
+Note that the same applies to IP addresses, so a DHCP client should only be run
+after the state has been loaded.
+
+### NodeJS
+
+Network backends `wsproxy` and `wisp` depend on a browser-compatible `WebSocket` constructor being present which is the case since NodeJS v22, backends `inbrowser` and `fetch` should work straightaway.
+
+## Links
+
+* [`examples/two_instances.html`](../examples/two_instances.html), example code that shows how to connect two VMs in a web page with a virtual ethernet crossover cable.
+* [`examples/broadcast-network.html`](../examples/broadcast-network.html), example code that shows the raw packet API.
+* [`examples/tcp_terminal.html`](../examples/tcp_terminal.html), example code that shows how to communicate with a guest TCP port on the `fetch` backend.
+* [DC through windows OS for experimental lab #1195](https://github.com/copy/v86/discussions/1195), demonstrates how to setup a Domain Controller for two Windows VMs (XP and Server 2003) using a virtual crossover cable.
+* [Working on a new cross-platform network relay that is a full virtualized network #1064](https://github.com/copy/v86/discussions/1064) (used in [env86 #1085](https://github.com/copy/v86/discussions/1085))
diff --git a/docs/profiling.md b/docs/profiling.md
new file mode 100644
index 0000000000000000000000000000000000000000..86968c074f942a2787a45df67e3ff5ef61773955
--- /dev/null
+++ b/docs/profiling.md
@@ -0,0 +1,7 @@
+v86 has a built-in profiler, which instruments generated code to count certain
+events and types of instructions. It can be used by building with `make
+debug-with-profiler` and opening debug.html.
+
+For debugging networking, packet logging is available in the UI in both debug
+and release builds. The resulting `traffic.hex` file can be loaded in Wireshark
+using file -> import from hex -> tick direction indication, timestamp %s.%f.
diff --git a/docs/sse-shifts.txt b/docs/sse-shifts.txt
new file mode 100644
index 0000000000000000000000000000000000000000..7fb5b2c622cf2216296639e58b6ed72aa7c6402b
--- /dev/null
+++ b/docs/sse-shifts.txt
@@ -0,0 +1,39 @@
+ 0F F1 PSLLW mm mm/m64 mmx Shift Packed Data Left Logical
+66 0F F1 PSLLW xmm xmm/m128 sse2 Shift Packed Data Left Logical
+ 0F F2 PSLLD mm mm/m64 mmx Shift Packed Data Left Logical
+66 0F F2 PSLLD xmm xmm/m128 sse2 Shift Packed Data Left Logical
+ 0F F3 PSLLQ mm mm/m64 mmx Shift Packed Data Left Logical
+66 0F F3 PSLLQ xmm xmm/m128 sse2 Shift Packed Data Left Logical
+
+ 0F E1 PSRAW mm mm/m64 mmx Shift Packed Data Right Arithmetic
+66 0F E1 PSRAW xmm xmm/m128 sse2 Shift Packed Data Right Arithmetic
+ 0F E2 PSRAD mm mm/m64 mmx Shift Packed Data Right Arithmetic
+66 0F E2 PSRAD xmm xmm/m128 sse2 Shift Packed Data Right Arithmetic
+
+ 0F D1 PSRLW mm mm/m64 mmx Shift Packed Data Right Logical
+66 0F D1 PSRLW xmm xmm/m128 sse2 Shift Packed Data Right Logical
+ 0F D2 PSRLD mm mm/m64 mmx Shift Packed Data Right Logical
+66 0F D2 PSRLD xmm xmm/m128 sse2 Shift Packed Data Right Logical
+ 0F D3 PSRLQ mm mm/m64 mmx Shift Packed Data Right Logical
+66 0F D3 PSRLQ xmm xmm/m128 sse2 Shift Packed Data Right Logical
+
+ 0F 71 PSRLW mm imm8 mmx Shift Packed Data Right Logical
+66 0F 71 PSRLW xmm imm8 sse2 Shift Packed Data Right Logical
+ 0F 71 PSRAW mm imm8 mmx Shift Packed Data Right Arithmetic
+66 0F 71 PSRAW xmm imm8 sse2 Shift Packed Data Right Arithmetic
+ 0F 71 PSLLW mm imm8 mmx Shift Packed Data Left Logical
+66 0F 71 PSLLW xmm imm8 sse2 Shift Packed Data Left Logical
+
+ 0F 72 PSRLD mm imm8 mmx Shift Double Quadword Right Logical
+66 0F 72 PSRLD xmm imm8 sse2 Shift Double Quadword Right Logical
+ 0F 72 PSRAD mm imm8 mmx Shift Packed Data Right Arithmetic
+66 0F 72 PSRAD xmm imm8 sse2 Shift Packed Data Right Arithmetic
+ 0F 72 PSLLD mm imm8 mmx Shift Packed Data Left Logical
+66 0F 72 PSLLD xmm imm8 sse2 Shift Packed Data Left Logical
+
+ 0F 73 PSRLQ mm imm8 mmx Shift Packed Data Right Logical
+66 0F 73 PSRLQ xmm imm8 sse2 Shift Packed Data Right Logical
+66 0F 73 PSRLDQ xmm imm8 sse2 Shift Double Quadword Right Logical
+ 0F 73 PSLLQ mm imm8 mmx Shift Packed Data Left Logical
+66 0F 73 PSLLQ xmm imm8 sse2 Shift Packed Data Left Logical
+66 0F 73 PSLLDQ xmm imm8 sse2 Shift Double Quadword Left Logical
diff --git a/docs/windows-9x.md b/docs/windows-9x.md
new file mode 100644
index 0000000000000000000000000000000000000000..118e7961c2bbdeb93f163d862158d1e106690da6
--- /dev/null
+++ b/docs/windows-9x.md
@@ -0,0 +1,106 @@
+## Installing using QEMU
+
+Recommended versions:
+ - Windows 95 OSR2(.5)
+ - Windows 98 Second Edition (SE)
+
+-------------
+
+1. Create a disk image (up to 2 GB):
+```sh
+qemu-img create -f raw hdd.img M
+```
+2. Run QEMU with the following settings:
+```sh
+qemu-system-i386 -m 128 -M pc,acpi=off -hda hdd.img
+```
+ - add `-cdrom /path/to/installCD.iso`, if you use a CD version.
+ - add `-fda /path/to/boot_floppy.img -boot a`, if you use a floppy version or your install CD is non-bootable.
+ - (optionally) add `-device sb16` to enable sound
+ - (optionally) add `-nic user,model=ne2k_pci` or `-device ne2k_pci,netdev=<...>` to enable networking
+
+3. For Windows 98: select "Start Windows 98 Setup from CD-ROM". For Windows 95: select "Load NEC IDE CDROM driver" and run `fdisk` to create partition, restart emulator, run `format c:` and `D:\WIN95\SETUP`.
+
+4. To change floppy disk, press *Ctrl+Alt+2* to switch to the QEMU Monitor, run `change floppy0 /path/to/new_floppy_image` and press *Ctrl+Alt+1* to switch to VGA.
+5. Follow the installation guide on the screen.
+6. (optionally) If "Windows protection" errors appears on startup, apply [FIX95CPU](http://lonecrusader.x10host.com/fix95cpu.html) or [patcher9x](https://github.com/JHRobotics/patcher9x#installation).
+
+> [!TIP]
+> For transfer files from host to guest, use [genisoimage](https://wiki.debian.org/genisoimage) ([UltraISO](https://www.ultraiso.com/) and [PowerISO](https://www.poweriso.com/) for Windows and Mac) for creating CD-ISO image or [dosfstools](https://github.com/dosfstools/dosfstools) ([WinImage](https://www.winimage.com/download.htm) for Windows) for creating floppy disk images, then mount the created image to QEMU.
+
+## Floppy disk support
+
+Currently, the floppy drive in v86 works only with MS-DOS compatibility mode.
+
+To check this: open the Start menu, click on "Control Panel" and "System", select "Performance" tab.
+If it says *"Drive A is using MS-DOS compatibility mode file system"*, the floppy drive should work properly in v86. If not, try this solution:
+
+1. Click on "Device Manager" in "System Properties".
+2. Open "Floppy disk controllers", select "Standard Floppy Disk Controller" and press "Remove" at the bottom.
+3. Restart Windows.
+
+## Enabling True Color (32 bpp)
+
+The default VGA display driver only supports 640x480x8 video mode, to fix this, install **Universal VBE9x Video Display Driver**.
+
+> [!WARNING]
+> After installing, DOS Mode (and other programs and games that require it) may not work properly.
+> This is a problem in VBE9x, not v86, see [#110](https://github.com/copy/v86/issues/110).
+> Also, this driver doesn't support DirectX, DirectDraw and OpenGL.
+
+1. Download driver from https://bearwindows.zcm.com.au/vbe9x.htm and unpack into Windows.
+2. Right-click on the Desktop, click on "Properties".
+3. Click "Advanced" > "Adapter" > "Change".
+4. Press "Next", select "Display a of all the drivers in a specific location..." and press again "Next".
+5. Press "Have Disk...", click "Browse" and go to folder with unpacked driver. Inside the folder with driver, should be folders like `032mb`, `064mb`, `128mb`. Choose a version based on needed video memory size (for example, `032mb`), then select `vbemp.inf` inside.
+6. Select "VBE Miniport" adapter, press "OK" and "Next".
+7. After installing, restart Windows.
+
+## CPU idling on Windows 95
+See about [installing AmnHLT](cpu-idling.md#windows-9x-using-amnhlt).
+
+## Enabling networking on Windows 95 (requires install CD)
+
+1. Open the Start menu, click on "Control Panel" and "Add New Hardware".
+2. Press "Next", select "No" and select next options:
+
+```
+Hardware type: Network adapters
+Manufacturers: Novell
+Models: NE2000 Compatible
+```
+
+3. Press "Next" and restart Windows.
+4. After restarting, right-click on "My computer", select "Propeties".
+5. Open "Device Manager" tab, select "NE2000 Compatible" (in "Network adapters") and press "Properties"
+6. Open "Resources", change values by selecting the properties and click on "Change Setting":
+
+```
+Interrupt Request: 10
+Input/Output Range: 0300 - 031F
+```
+
+7. In "Control Panel", open "Network", click on "Add", choose "Protocol" and select the following options:
+
+```
+Manufacturers: Microsoft
+Network Protocols: TCP/IP
+```
+
+8. (optionally) Set "Primary Network Logon" to `Windows Logon`.
+
+## Enabling sound manually
+
+> [!NOTE]
+> If you don't have an install CD, use the Sound Blaster 16 driver from https://www.claunia.com/qemu/drivers/index.html.
+
+1. Open "Start" menu, click on "Control Panel" and "Add New Hardware".
+2. Press "Next", select "No" and select the following options:
+
+```
+Hardware type: Sound, video and game cotrollers
+Manufacturers: Creative Labs
+Models: Creative Labs Sound Blaster 16 or AWE-32
+```
+
+3. Restart Windows.
diff --git a/docs/windows-nt.md b/docs/windows-nt.md
new file mode 100644
index 0000000000000000000000000000000000000000..e347488044e24115ac9458d911996b02e2c1b3c1
--- /dev/null
+++ b/docs/windows-nt.md
@@ -0,0 +1,169 @@
+
+ - [Windows NT 3.1](#windows-nt-31) / [3.51](#windows-nt-351) / [4.0](#windows-nt-40)
+ - [Windows 2000/XP](#windows-2000xp)
+ - [Windows Vista and newer](#windows-vista-and-newer)
+
+------------------------
+## Windows NT 3.1
+
+### Installing using QEMU
+
+1. Install MS-DOS and [Oak CD-ROM Driver](https://www.dosdays.co.uk/topics/Software/optical_downloads.php).
+2. Create 4 blank floppy disk images:
+
+ - run `qemu-img create -f raw floppy.img 1440K`
+ - mount (`-fda floppy.img`) and run `format A:` in a VM
+
+3. Run QEMU with the following settings for installation:
+
+```sh
+qemu-system-i386 -m 64 -hda hdd.img -cpu pentium -M pc,acpi=off -cdrom InstallCD.iso
+```
+
+4. Run `xcopy /v :\I386\ C:\install\` in a VM to copy all files, disable the CD-ROM driver.
+5. Run QEMU with the following settings:
+
+```sh
+qemu-system-i386 -m 64 -hda hdd.img -cpu pentium -M pc,acpi=off
+```
+
+6. Run `C:\install\winnt /F /C` in a VM.
+7. Follow the setup instructions. To change floppy disk, press *Ctrl+Alt+2* to switch to the QEMU Monitor, run `change floppy0 /path/to/new_floppy_image` and press *Ctrl+Alt+1* to switch to VGA.
+
+
+## Windows NT 3.51
+
+### Installing
+
+> [!NOTE]
+> In newer versions of QEMU, the Windows Setup may not work, you can use an older version of QEMU, PCem, 86Box or PCBox instead.
+
+1. If you install via MS-DOS, install [the Oak CD-ROM Driver](https://www.dosdays.co.uk/topics/Software/optical_downloads.php) and run `:\I386\WINNT /B`.
+2. Follow the setup instructions.
+3. After installing, download NT 3.51 SuperPack ([here](https://bearwindows.zcm.com.au/winnt351.htm#4) or [here](https://alter.org.ua/en/soft/nt_spack/nt3/)), unpack the archive into a Windows and copy files from `FAT32` (`SYS\FAT32`) and `RENEW` (`SYS\RENEW`) folders in `C:\WINNT35\system32\drivers` with replacing.
+
+### Enabling networking
+
+1. Open "Control Panel" > "Network", install Windows NT Networking (installation CD required).
+2. In "Network Adapter Card Detection", press Continue three times, set `Network Adapter Card: Novell NE2000 Compatible Adapter`.
+3. Set the following settings and click Continue:
+
+```
+IRQ Level: 10
+I/O Port Address: 0x300
+```
+
+4. In "Bus Location", press OK. Check the boxes "TCP/IP Transport" and "Enable Automatic DHCP Configuration" in the next window.
+5. In "TCP/IP Configuration", check the box "Enable Automatic DHCP Configuration".
+6. Restart the VM.
+
+
+## Windows NT 4.0
+
+Recommended version: Windows NT 4.0 SP1
+
+### Installing using QEMU
+
+1. Run QEMU with the following settings for installation:
+
+```sh
+qemu-system-i386 -m 64 -hda hdd.img -cdrom InstallCD.iso -cpu pentium -M pc,acpi=off
+```
+
+2. On setup startup, press F5 and select "Standard PC".
+3. Follow the setup instructions.
+
+### Running in v86
+
+Due to a problem with CPUID, you need to add `cpuid_level: 2` and `acpi: false` to the V86 constructor (not supported in the UI):
+
+```js
+var emulator = new V86({
+ ...
+ cpuid_level: 2,
+ acpi: false
+});
+```
+
+
+## Windows 2000/XP
+
+### Installing using QEMU
+
+1. Run QEMU with the following settings for installation:
+
+```sh
+qemu-system-i386 -m 512 -hda hdd.img -cdrom InstallCD.iso
+```
+
+Optional:
+ - add `-device sb16` to enable sound
+ - add `-nic user,model=ne2k_pci` or `-device ne2k_pci,netdev=<...>` to enable networking
+
+2. Follow the setup instructions.
+3. This step fixes the error `Uncaught RangeError: Maximum call stack size exceeded` in Chromium during Windows 2000/XP startup in v86.
+
+After installation, change the computer type to "Standard PC" as described [here](http://web.archive.org/web/20220528021535/https://www.scm-pc-card.de/file/manual/FAQ/acpi_uninstallation_windows_xp_english.pdf):
+1. Open Start menu, right-click on "My Computer", select "Manage"
+2. Open Device Manager, open Computer, right-click on "ACPI Uniprocessor PC"
+3. Select "Update Driver..." > "No, not this time"
+4. Select "Install from a list or specific location (Advanced)" > Next > "Don't search. I will choose the driver to install."
+5. Choose "Standard PC", press Next > Finish.
+6. Restart the VM, follow multiple "Found New Hardware Wizard" dialogs with default options.
+
+### Enabling True Color (for Windows 2000)
+
+> [!NOTE]
+> This driver doesn't support DirectX, DirectDraw and OpenGL.
+
+1. Download driver from https://bearwindows.zcm.com.au/vbemp.htm and unpack into Windows.
+2. Open Start menu, right-click on "My Computer", select "Manage"
+3. Open Device Manager, open Computer and right-click on "Video Controller".
+4. Press "Properties", select "Driver" tab and press "Update Driver".
+5. Select "Display a list of the known drivers for this device...", choose "Display adapters".
+5. Press "Have Disk...", click "Browse" and go to folder with unpacked driver. Go to `VBE20\W2K\PNP`, then select `vbemppnp.inf` inside.
+6. Select "VBE Miniport" adapter, press "Yes" and "Next".
+7. After installing, restart the VM.
+
+### Enabling sound
+
+*Source: [#1049](https://github.com/copy/v86/issues/1049)*
+
+1. Right-click on "My computer" > "System Properties", select "Hardware" tab, press "Hardware Wizard"
+2. Press "Next" > "Add/Troubleshoot a device" > "Add a new device"
+3. Select "No, I want to select the hardware from a list" > "Sound, video and game controllers"
+4. Select the following options and press "Next":
+
+```
+Hardware type: Sound, video and game cotrollers
+Manufacturers: Creative Technology Ltd.
+Models: Sound Blaster 16 or AWE32 or compatible (WDM)
+```
+
+
+## Windows Vista and newer
+
+### Installing using QEMU
+
+1. Run QEMU with the following settings for installation:
+
+```sh
+qemu-system-i386 -m 1024 -hda hdd.img -cdrom InstallCD.iso
+```
+
+Optionally add `-accel kvm` (for Linux host), `-accel whpx` (for Windows host) or `-accel hvf` (for MacOS host) to use hypervisor acceleration.
+
+2. Follow the setup instructions.
+
+### Running in v86
+
+Enable ACPI and set the memory size to 512 MB or more.
+
+### Enabling networking (ne2k)
+
+*Source: https://phaq.phunsites.net/2007/05/21/vista-on-xen-using-ne2000-in-favor-to-rtl8139/*
+
+1. Download https://phaq.phunsites.net/files/2007/05/drivercd.iso_.zip, unpack the archive, mount the ISO to the VM (`-cdrom path/to/drivercd.iso` or `change ide1-cd0 path/to/drivercd.iso` in QEMU Monitor), unpack the archive from CDROM into Windows.
+2. Open Start Menu > "Control Panel" > "System" > "Device Manager"
+3. Right-click on "Ethernet Controller" > "Update Driver Software", press "Browse my computer for driver software".
+4. Click "Browse" and go to folder with unpacked driver, select `WIN2000` folder, press "Install this driver software anyway".
diff --git a/eslint.config.mjs b/eslint.config.mjs
new file mode 100644
index 0000000000000000000000000000000000000000..a2691db3be3f1a7c102811f4ba785d15c9c7fde1
--- /dev/null
+++ b/eslint.config.mjs
@@ -0,0 +1,140 @@
+export default [
+ {
+ "languageOptions": {
+ "globals": {
+ "process": "readonly",
+ "window": "writable",
+ "navigator": "writable",
+ "location": "writable",
+ "document": "readonly",
+ "console": "readonly",
+ "crypto": "readonly",
+ "alert": "readonly",
+ "performance": "readonly",
+ "URL": "readonly",
+ "WebAssembly": "readonly",
+
+ "setTimeout": "readonly",
+ "setInterval": "readonly",
+ "clearTimeout": "readonly",
+ "clearInterval": "readonly",
+ "requestAnimationFrame": "readonly",
+ "cancelAnimationFrame": "readonly",
+
+ "Buffer": "readonly",
+ "FileReader": "readonly",
+ "TextEncoder": "readonly",
+ "TextDecoder": "readonly",
+ "fetch": "readonly",
+ "Headers": "readonly",
+ "Response": "readonly",
+ "WebSocket": "readonly",
+ "Blob": "readonly",
+ "File": "readonly",
+ "XMLHttpRequest": "readonly",
+ "URLSearchParams": "readonly",
+ "ImageData": "readonly",
+ "Image": "readonly",
+ "OffscreenCanvas": "readonly",
+ "BroadcastChannel": "readonly",
+
+ "AudioContext": "readonly",
+ "AudioWorkletProcessor": "readonly",
+ "webkitAudioContext": "readonly",
+ "AudioWorkletNode": "readonly",
+ "Worker": "readonly",
+ "postMessage": "readonly",
+ "importScripts": "readonly",
+
+ "DEBUG": "writable"
+ }
+ },
+ rules: {
+ "eol-last": "error",
+ //"no-extra-parens": "error",
+ "no-trailing-spaces": "error",
+ "no-extra-semi": "error",
+ "no-tabs": "error",
+ "quotes": ["error", "double", { "avoidEscape": true, "allowTemplateLiterals": true }],
+ "keyword-spacing": ["error", { "overrides": {
+ "if": { "after": false },
+ "for": { "after": false },
+ "while": { "after": false },
+ "switch": { "after": false },
+ "catch": { "after": false },
+ } }],
+ "semi": "error",
+ "no-useless-return": "error",
+ "eqeqeq": "error",
+ "no-multiple-empty-lines": ["error", { "max": 2, "maxBOF": 0, "maxEOF": 0 }],
+ //"no-var": "error",
+ "radix": "error",
+ "comma-style": ["error", "last"],
+ //"comma-dangle": ["error", "always-multiline"],
+ "no-sequences": "error",
+ //"one-var": ["error", "never"],
+ "constructor-super": "error",
+ "for-direction": "error",
+ "getter-return": "error",
+ "no-async-promise-executor": "error",
+ //"no-case-declarations": "error",
+ "no-class-assign": "error",
+ "no-compare-neg-zero": "error",
+ "no-cond-assign": "error",
+ "no-const-assign": "error",
+ "no-constant-binary-expression": "error",
+ //"no-constant-condition": "error",
+ //"no-control-regex": "error",
+ //"no-debugger": "error",
+ "no-delete-var": "error",
+ "no-dupe-args": "error",
+ "no-dupe-class-members": "error",
+ //"no-dupe-else-if": "error",
+ "no-dupe-keys": "error",
+ "no-duplicate-case": "error",
+ //"no-empty": "error",
+ "no-empty-character-class": "error",
+ "no-empty-pattern": "error",
+ "no-empty-static-block": "error",
+ "no-ex-assign": "error",
+ "no-extra-boolean-cast": "error",
+ "no-fallthrough": "error",
+ "no-func-assign": "error",
+ "no-global-assign": "error",
+ "no-import-assign": "error",
+ "no-invalid-regexp": "error",
+ "no-irregular-whitespace": "error",
+ "no-loss-of-precision": "error",
+ "no-misleading-character-class": "error",
+ "no-new-native-nonconstructor": "error",
+ "no-nonoctal-decimal-escape": "error",
+ "no-obj-calls": "error",
+ "no-octal": "error",
+ "no-prototype-builtins": "error",
+ //"no-redeclare": "error",
+ "no-regex-spaces": "error",
+ "no-self-assign": "error",
+ "no-setter-return": "error",
+ "no-shadow-restricted-names": "error",
+ "no-sparse-arrays": "error",
+ "no-this-before-super": "error",
+ "no-undef": "error",
+ "no-unexpected-multiline": "error",
+ //"no-unreachable": "error",
+ "no-unsafe-finally": "error",
+ "no-unsafe-negation": "error",
+ "no-unsafe-optional-chaining": "error",
+ "no-unused-labels": "error",
+ "no-unused-private-class-members": "error",
+ //"no-unused-vars": "error",
+ "no-useless-backreference": "error",
+ "no-useless-catch": "error",
+ //"no-useless-escape": "error",
+ "no-with": "error",
+ "require-yield": "error",
+ "use-isnan": "error",
+ "valid-typeof": "error",
+ "strict": "error"
+ }
+ }
+];
diff --git a/examples/alpine.html b/examples/alpine.html
new file mode 100644
index 0000000000000000000000000000000000000000..3973947e81242a9265c1f7e2563323fa849e285b
--- /dev/null
+++ b/examples/alpine.html
@@ -0,0 +1,29 @@
+
+Alpine
+
+
+
diff --git a/examples/broadcast-network.html b/examples/broadcast-network.html
new file mode 100644
index 0000000000000000000000000000000000000000..212891268b8447d0e0b5edf364aa11198956e644
--- /dev/null
+++ b/examples/broadcast-network.html
@@ -0,0 +1,61 @@
+
+Networking via Broadcast Channel API
+
+
+
+
+
+
+
+
+
+
+# This example allows network across multiple browser tabs by using BroadcastChannels.
+
+# Configure a static IP
+ifconfig eth0 up arp 10.5.0.x
+
+# Ping by IP
+ping 10.5.0.x
+
+# Run a DNS server and send a query (10.5.0.x for server, 10.5.0.y for record)
+echo "anotherhost 10.5.0.y" | dnsd -c - -v - server
+nslookup -type=a anotherhost 10.5.0.x - client
+
+# Telnet calculator
+socat TCP-L:23,fork exec:bc
+
+# Simple HTTP server
+socat TCP-L:80,crlf,fork system:'echo HTTP/1.1 200 OK;echo;lua /root/test.lua'
+
+
+
+
+
+
+
+
+Version: 98e7110c2 (Feb 16, 2021 12:02)
+
+
+Enable debug
+—
+Readme
+—
+Project on Github
+—
+Compatibility
diff --git a/lib/9p.js b/lib/9p.js
new file mode 100644
index 0000000000000000000000000000000000000000..246e1084ec2c4fa3786f6df36a73ba0db7d9bc89
--- /dev/null
+++ b/lib/9p.js
@@ -0,0 +1,1170 @@
+// -------------------------------------------------
+// --------------------- 9P ------------------------
+// -------------------------------------------------
+// Implementation of the 9p filesystem device following the
+// 9P2000.L protocol ( https://code.google.com/p/diod/wiki/protocol )
+
+import { LOG_9P } from "./../src/const.js";
+import { VirtIO, VIRTIO_F_VERSION_1, VIRTIO_F_RING_EVENT_IDX, VIRTIO_F_RING_INDIRECT_DESC } from "../src/virtio.js";
+import { S_IFREG, S_IFDIR, STATUS_UNLINKED } from "./filesystem.js";
+import * as marshall from "../lib/marshall.js";
+import { dbg_log, dbg_assert } from "../src/log.js";
+import { h } from "../src/lib.js";
+
+// For Types Only
+import { CPU } from "../src/cpu.js";
+import { BusConnector } from "../src/bus.js";
+import { FS } from "./filesystem.js";
+
+/**
+ * @const
+ * More accurate filenames in 9p debug messages at the cost of performance.
+ */
+const TRACK_FILENAMES = false;
+
+// Feature bit (bit position) for mount tag.
+const VIRTIO_9P_F_MOUNT_TAG = 0;
+// Assumed max tag length in bytes.
+const VIRTIO_9P_MAX_TAGLEN = 254;
+
+const MAX_REPLYBUFFER_SIZE = 16 * 1024 * 1024;
+
+// TODO
+// flush
+
+export const EPERM = 1; /* Operation not permitted */
+export const ENOENT = 2; /* No such file or directory */
+export const EEXIST = 17; /* File exists */
+export const EINVAL = 22; /* Invalid argument */
+export const EOPNOTSUPP = 95; /* Operation is not supported */
+export const ENOTEMPTY = 39; /* Directory not empty */
+export const EPROTO = 71; /* Protocol error */
+
+var P9_SETATTR_MODE = 0x00000001;
+var P9_SETATTR_UID = 0x00000002;
+var P9_SETATTR_GID = 0x00000004;
+var P9_SETATTR_SIZE = 0x00000008;
+var P9_SETATTR_ATIME = 0x00000010;
+var P9_SETATTR_MTIME = 0x00000020;
+var P9_SETATTR_CTIME = 0x00000040;
+var P9_SETATTR_ATIME_SET = 0x00000080;
+var P9_SETATTR_MTIME_SET = 0x00000100;
+
+var P9_STAT_MODE_DIR = 0x80000000;
+var P9_STAT_MODE_APPEND = 0x40000000;
+var P9_STAT_MODE_EXCL = 0x20000000;
+var P9_STAT_MODE_MOUNT = 0x10000000;
+var P9_STAT_MODE_AUTH = 0x08000000;
+var P9_STAT_MODE_TMP = 0x04000000;
+var P9_STAT_MODE_SYMLINK = 0x02000000;
+var P9_STAT_MODE_LINK = 0x01000000;
+var P9_STAT_MODE_DEVICE = 0x00800000;
+var P9_STAT_MODE_NAMED_PIPE = 0x00200000;
+var P9_STAT_MODE_SOCKET = 0x00100000;
+var P9_STAT_MODE_SETUID = 0x00080000;
+var P9_STAT_MODE_SETGID = 0x00040000;
+var P9_STAT_MODE_SETVTX = 0x00010000;
+
+export const P9_LOCK_TYPE_RDLCK = 0;
+export const P9_LOCK_TYPE_WRLCK = 1;
+export const P9_LOCK_TYPE_UNLCK = 2;
+const P9_LOCK_TYPES = ["shared", "exclusive", "unlock"];
+
+const P9_LOCK_FLAGS_BLOCK = 1;
+const P9_LOCK_FLAGS_RECLAIM = 2;
+
+export const P9_LOCK_SUCCESS = 0;
+export const P9_LOCK_BLOCKED = 1;
+export const P9_LOCK_ERROR = 2;
+export const P9_LOCK_GRACE = 3;
+
+var FID_NONE = -1;
+var FID_INODE = 1;
+var FID_XATTR = 2;
+
+function range(size)
+{
+ return Array.from(Array(size).keys());
+}
+
+/**
+ * @param {CPU} cpu
+ * @param {Function} receive
+ */
+function init_virtio(cpu, configspace_taglen, configspace_tagname, receive)
+{
+ const virtio = new VirtIO(cpu,
+ {
+ name: "virtio-9p",
+ pci_id: 0x06 << 3,
+ device_id: 0x1049,
+ subsystem_device_id: 9,
+ common:
+ {
+ initial_port: 0xA800,
+ queues:
+ [
+ {
+ size_supported: 32,
+ notify_offset: 0,
+ },
+ ],
+ features:
+ [
+ VIRTIO_9P_F_MOUNT_TAG,
+ VIRTIO_F_VERSION_1,
+ VIRTIO_F_RING_EVENT_IDX,
+ VIRTIO_F_RING_INDIRECT_DESC,
+ ],
+ on_driver_ok: () => {},
+ },
+ notification:
+ {
+ initial_port: 0xA900,
+ single_handler: false,
+ handlers:
+ [
+ (queue_id) =>
+ {
+ if(queue_id !== 0)
+ {
+ dbg_assert(false, "Virtio9P Notified for non-existent queue: " + queue_id +
+ " (expected queue_id of 0)");
+ return;
+ }
+ const virtqueue = virtio.queues[0];
+ while(virtqueue.has_request())
+ {
+ const bufchain = virtqueue.pop_request();
+ receive(bufchain);
+ }
+ virtqueue.notify_me_after(0);
+ // Don't flush replies here: async replies are not completed yet.
+ },
+ ],
+ },
+ isr_status:
+ {
+ initial_port: 0xA700,
+ },
+ device_specific:
+ {
+ initial_port: 0xA600,
+ struct:
+ [
+ {
+ bytes: 2,
+ name: "mount tag length",
+ read: () => configspace_taglen,
+ write: data => { /* read only */ },
+ },
+ ].concat(range(VIRTIO_9P_MAX_TAGLEN).map(index =>
+ ({
+ bytes: 1,
+ name: "mount tag name " + index,
+ // Note: configspace_tagname may have changed after set_state
+ read: () => configspace_tagname[index] || 0,
+ write: data => { /* read only */ },
+ })
+ )),
+ },
+ });
+ return virtio;
+}
+
+/**
+ * @constructor
+ *
+ * @param {FS} filesystem
+ * @param {CPU} cpu
+ */
+export function Virtio9p(filesystem, cpu, bus) {
+ /** @type {FS} */
+ this.fs = filesystem;
+
+ /** @const @type {BusConnector} */
+ this.bus = bus;
+
+ this.configspace_tagname = [0x68, 0x6F, 0x73, 0x74, 0x39, 0x70]; // "host9p" string
+ this.configspace_taglen = this.configspace_tagname.length; // num bytes
+
+ this.virtio = init_virtio(cpu, this.configspace_taglen, this.configspace_tagname, this.ReceiveRequest.bind(this));
+ this.virtqueue = this.virtio.queues[0];
+
+ this.VERSION = "9P2000.L";
+ this.BLOCKSIZE = 8192; // Let's define one page.
+ this.msize = 8192; // maximum message size
+ this.replybuffer = new Uint8Array(this.msize*2); // Twice the msize to stay on the safe site
+ this.replybuffersize = 0;
+ this.fids = [];
+}
+
+Virtio9p.prototype.get_state = function()
+{
+ var state = [];
+
+ state[0] = this.configspace_tagname;
+ state[1] = this.configspace_taglen;
+ state[2] = this.virtio;
+ state[3] = this.VERSION;
+ state[4] = this.BLOCKSIZE;
+ state[5] = this.msize;
+ state[6] = this.replybuffer;
+ state[7] = this.replybuffersize;
+ state[8] = this.fids.map(function(f) { return [f.inodeid, f.type, f.uid, f.dbg_name]; });
+ state[9] = this.fs;
+
+ return state;
+};
+
+Virtio9p.prototype.set_state = function(state)
+{
+ this.configspace_tagname = state[0];
+ this.configspace_taglen = state[1];
+ this.virtio.set_state(state[2]);
+ this.virtqueue = this.virtio.queues[0];
+ this.VERSION = state[3];
+ this.BLOCKSIZE = state[4];
+ this.msize = state[5];
+ this.replybuffer = state[6];
+ this.replybuffersize = state[7];
+ this.fids = state[8].map(function(f)
+ {
+ return { inodeid: f[0], type: f[1], uid: f[2], dbg_name: f[3] };
+ });
+ this.fs.set_state(state[9]);
+};
+
+// Note: dbg_name is only used for debugging messages and may not be the same as the filename,
+// since it is not synchronised with renames done outside of 9p. Hard-links, linking and unlinking
+// operations also mean that having a single filename no longer makes sense.
+// Set TRACK_FILENAMES = true to sync dbg_name during 9p renames.
+Virtio9p.prototype.Createfid = function(inodeid, type, uid, dbg_name) {
+ return {inodeid, type, uid, dbg_name};
+};
+
+Virtio9p.prototype.update_dbg_name = function(idx, newname)
+{
+ for(const fid of this.fids)
+ {
+ if(fid.inodeid === idx) fid.dbg_name = newname;
+ }
+};
+
+Virtio9p.prototype.reset = function()
+{
+ this.fids = [];
+ this.virtio.reset();
+};
+
+Virtio9p.prototype.BuildReply = function(id, tag, payloadsize) {
+ dbg_assert(payloadsize >= 0, "9P: Negative payload size");
+ marshall.Marshall(["w", "b", "h"], [payloadsize+7, id+1, tag], this.replybuffer, 0);
+ if((payloadsize+7) >= this.replybuffer.length) {
+ dbg_log("Error in 9p: payloadsize exceeds maximum length", LOG_9P);
+ }
+ //for(var i=0; i= 0, "9P: Negative replybuffersize");
+ bufchain.set_next_blob(this.replybuffer.subarray(0, this.replybuffersize));
+ this.virtqueue.push_reply(bufchain);
+ this.virtqueue.flush_replies();
+};
+
+Virtio9p.prototype.ReceiveRequest = async function (bufchain) {
+ // TODO: split into header + data blobs to avoid unnecessary copying.
+ const buffer = new Uint8Array(bufchain.length_readable);
+ bufchain.get_next_blob(buffer);
+
+ const state = { offset : 0 };
+ var header = marshall.Unmarshall(["w", "b", "h"], buffer, state);
+ var size = header[0];
+ var id = header[1];
+ var tag = header[2];
+ //dbg_log("size:" + size + " id:" + id + " tag:" + tag, LOG_9P);
+
+ switch(id)
+ {
+ case 8: // statfs
+ size = this.fs.GetTotalSize(); // size used by all files
+ var space = this.fs.GetSpace();
+ var req = [];
+ req[0] = 0x01021997;
+ req[1] = this.BLOCKSIZE; // optimal transfer block size
+ req[2] = Math.floor(space/req[1]); // free blocks
+ req[3] = req[2] - Math.floor(size/req[1]); // free blocks in fs
+ req[4] = req[2] - Math.floor(size/req[1]); // free blocks avail to non-superuser
+ req[5] = this.fs.CountUsedInodes(); // total number of inodes
+ req[6] = this.fs.CountFreeInodes();
+ req[7] = 0; // file system id?
+ req[8] = 256; // maximum length of filenames
+
+ size = marshall.Marshall(["w", "w", "d", "d", "d", "d", "d", "d", "w"], req, this.replybuffer, 7);
+ this.BuildReply(id, tag, size);
+ this.SendReply(bufchain);
+ break;
+
+ case 112: // topen
+ case 12: // tlopen
+ var req = marshall.Unmarshall(["w", "w"], buffer, state);
+ var fid = req[0];
+ var mode = req[1];
+ dbg_log("[open] fid=" + fid + ", mode=" + mode, LOG_9P);
+ var idx = this.fids[fid].inodeid;
+ var inode = this.fs.GetInode(idx);
+ dbg_log("file open " + this.fids[fid].dbg_name + " tag:"+tag, LOG_9P);
+ await this.fs.OpenInode(idx, mode);
+
+ req = [];
+ req[0] = inode.qid;
+ req[1] = this.msize - 24;
+ marshall.Marshall(["Q", "w"], req, this.replybuffer, 7);
+ this.BuildReply(id, tag, 13+4);
+ this.SendReply(bufchain);
+ break;
+
+ case 70: // link
+ var req = marshall.Unmarshall(["w", "w", "s"], buffer, state);
+ var dfid = req[0];
+ var fid = req[1];
+ var name = req[2];
+ dbg_log("[link] dfid=" + dfid + ", name=" + name, LOG_9P);
+
+ var ret = this.fs.Link(this.fids[dfid].inodeid, this.fids[fid].inodeid, name);
+
+ if(ret < 0)
+ {
+ let error_message = "";
+ if(ret === -EPERM) error_message = "Operation not permitted";
+ else
+ {
+ error_message = "Unknown error: " + (-ret);
+ dbg_assert(false, "[link]: Unexpected error code: " + (-ret));
+ }
+ this.SendError(tag, error_message, -ret);
+ this.SendReply(bufchain);
+ break;
+ }
+
+ this.BuildReply(id, tag, 0);
+ this.SendReply(bufchain);
+ break;
+
+ case 16: // symlink
+ var req = marshall.Unmarshall(["w", "s", "s", "w"], buffer, state);
+ var fid = req[0];
+ var name = req[1];
+ var symgt = req[2];
+ var gid = req[3];
+ dbg_log("[symlink] fid=" + fid + ", name=" + name + ", symgt=" + symgt + ", gid=" + gid, LOG_9P);
+ var idx = this.fs.CreateSymlink(name, this.fids[fid].inodeid, symgt);
+ var inode = this.fs.GetInode(idx);
+ inode.uid = this.fids[fid].uid;
+ inode.gid = gid;
+ marshall.Marshall(["Q"], [inode.qid], this.replybuffer, 7);
+ this.BuildReply(id, tag, 13);
+ this.SendReply(bufchain);
+ break;
+
+ case 18: // mknod
+ var req = marshall.Unmarshall(["w", "s", "w", "w", "w", "w"], buffer, state);
+ var fid = req[0];
+ var name = req[1];
+ var mode = req[2];
+ var major = req[3];
+ var minor = req[4];
+ var gid = req[5];
+ dbg_log("[mknod] fid=" + fid + ", name=" + name + ", major=" + major + ", minor=" + minor+ "", LOG_9P);
+ var idx = this.fs.CreateNode(name, this.fids[fid].inodeid, major, minor);
+ var inode = this.fs.GetInode(idx);
+ inode.mode = mode;
+ //inode.mode = mode | S_IFCHR; // XXX: fails "Mknod - fifo" test
+ inode.uid = this.fids[fid].uid;
+ inode.gid = gid;
+ marshall.Marshall(["Q"], [inode.qid], this.replybuffer, 7);
+ this.BuildReply(id, tag, 13);
+ this.SendReply(bufchain);
+ break;
+
+
+ case 22: // TREADLINK
+ var req = marshall.Unmarshall(["w"], buffer, state);
+ var fid = req[0];
+ var inode = this.fs.GetInode(this.fids[fid].inodeid);
+ dbg_log("[readlink] fid=" + fid + " name=" + this.fids[fid].dbg_name + " target=" + inode.symlink, LOG_9P);
+ size = marshall.Marshall(["s"], [inode.symlink], this.replybuffer, 7);
+ this.BuildReply(id, tag, size);
+ this.SendReply(bufchain);
+ break;
+
+
+ case 72: // tmkdir
+ var req = marshall.Unmarshall(["w", "s", "w", "w"], buffer, state);
+ var fid = req[0];
+ var name = req[1];
+ var mode = req[2];
+ var gid = req[3];
+ dbg_log("[mkdir] fid=" + fid + ", name=" + name + ", mode=" + mode + ", gid=" + gid, LOG_9P);
+ var idx = this.fs.CreateDirectory(name, this.fids[fid].inodeid);
+ var inode = this.fs.GetInode(idx);
+ inode.mode = mode | S_IFDIR;
+ inode.uid = this.fids[fid].uid;
+ inode.gid = gid;
+ marshall.Marshall(["Q"], [inode.qid], this.replybuffer, 7);
+ this.BuildReply(id, tag, 13);
+ this.SendReply(bufchain);
+ break;
+
+ case 14: // tlcreate
+ var req = marshall.Unmarshall(["w", "s", "w", "w", "w"], buffer, state);
+ var fid = req[0];
+ var name = req[1];
+ var flags = req[2];
+ var mode = req[3];
+ var gid = req[4];
+ this.bus.send("9p-create", [name, this.fids[fid].inodeid]);
+ dbg_log("[create] fid=" + fid + ", name=" + name + ", flags=" + flags + ", mode=" + mode + ", gid=" + gid, LOG_9P);
+ var idx = this.fs.CreateFile(name, this.fids[fid].inodeid);
+ this.fids[fid].inodeid = idx;
+ this.fids[fid].type = FID_INODE;
+ this.fids[fid].dbg_name = name;
+ var inode = this.fs.GetInode(idx);
+ inode.uid = this.fids[fid].uid;
+ inode.gid = gid;
+ inode.mode = mode | S_IFREG;
+ marshall.Marshall(["Q", "w"], [inode.qid, this.msize - 24], this.replybuffer, 7);
+ this.BuildReply(id, tag, 13+4);
+ this.SendReply(bufchain);
+ break;
+
+ case 52: // lock
+ var req = marshall.Unmarshall(["w", "b", "w", "d", "d", "w", "s"], buffer, state);
+ var fid = req[0];
+ var flags = req[2];
+ var lock_length = req[4] === 0 ? Infinity : req[4];
+ var lock_request = this.fs.DescribeLock(req[1], req[3], lock_length, req[5], req[6]);
+ dbg_log("[lock] fid=" + fid +
+ ", type=" + P9_LOCK_TYPES[lock_request.type] + ", start=" + lock_request.start +
+ ", length=" + lock_request.length + ", proc_id=" + lock_request.proc_id);
+
+ var ret = this.fs.Lock(this.fids[fid].inodeid, lock_request, flags);
+
+ marshall.Marshall(["b"], [ret], this.replybuffer, 7);
+ this.BuildReply(id, tag, 1);
+ this.SendReply(bufchain);
+ break;
+
+ case 54: // getlock
+ var req = marshall.Unmarshall(["w", "b", "d", "d", "w", "s"], buffer, state);
+ var fid = req[0];
+ var lock_length = req[3] === 0 ? Infinity : req[3];
+ var lock_request = this.fs.DescribeLock(req[1], req[2], lock_length, req[4], req[5]);
+ dbg_log("[getlock] fid=" + fid +
+ ", type=" + P9_LOCK_TYPES[lock_request.type] + ", start=" + lock_request.start +
+ ", length=" + lock_request.length + ", proc_id=" + lock_request.proc_id);
+
+ var ret = this.fs.GetLock(this.fids[fid].inodeid, lock_request);
+
+ if(!ret)
+ {
+ ret = lock_request;
+ ret.type = P9_LOCK_TYPE_UNLCK;
+ }
+
+ var ret_length = ret.length === Infinity ? 0 : ret.length;
+
+ size = marshall.Marshall(["b", "d", "d", "w", "s"],
+ [ret.type, ret.start, ret_length, ret.proc_id, ret.client_id],
+ this.replybuffer, 7);
+
+ this.BuildReply(id, tag, size);
+ this.SendReply(bufchain);
+ break;
+
+ case 24: // getattr
+ var req = marshall.Unmarshall(["w", "d"], buffer, state);
+ var fid = req[0];
+ var inode = this.fs.GetInode(this.fids[fid].inodeid);
+ dbg_log("[getattr]: fid=" + fid + " name=" + this.fids[fid].dbg_name + " request mask=" + req[1], LOG_9P);
+ if(!inode || inode.status === STATUS_UNLINKED)
+ {
+ dbg_log("getattr: unlinked", LOG_9P);
+ this.SendError(tag, "No such file or directory", ENOENT);
+ this.SendReply(bufchain);
+ break;
+ }
+ req[0] = req[1]; // request mask
+ req[1] = inode.qid;
+
+ req[2] = inode.mode;
+ req[3] = inode.uid; // user id
+ req[4] = inode.gid; // group id
+
+ req[5] = inode.nlinks; // number of hard links
+ req[6] = (inode.major<<8) | (inode.minor); // device id low
+ req[7] = inode.size; // size low
+ req[8] = this.BLOCKSIZE;
+ req[9] = Math.floor(inode.size/512+1); // blk size low
+ req[10] = inode.atime; // atime
+ req[11] = 0x0;
+ req[12] = inode.mtime; // mtime
+ req[13] = 0x0;
+ req[14] = inode.ctime; // ctime
+ req[15] = 0x0;
+ req[16] = 0x0; // btime
+ req[17] = 0x0;
+ req[18] = 0x0; // st_gen
+ req[19] = 0x0; // data_version
+ marshall.Marshall([
+ "d", "Q",
+ "w",
+ "w", "w",
+ "d", "d",
+ "d", "d", "d",
+ "d", "d", // atime
+ "d", "d", // mtime
+ "d", "d", // ctime
+ "d", "d", // btime
+ "d", "d",
+ ], req, this.replybuffer, 7);
+ this.BuildReply(id, tag, 8 + 13 + 4 + 4+ 4 + 8*15);
+ this.SendReply(bufchain);
+ break;
+
+ case 26: // setattr
+ var req = marshall.Unmarshall(["w", "w",
+ "w", // mode
+ "w", "w", // uid, gid
+ "d", // size
+ "d", "d", // atime
+ "d", "d", // mtime
+ ], buffer, state);
+ var fid = req[0];
+ var inode = this.fs.GetInode(this.fids[fid].inodeid);
+ dbg_log("[setattr]: fid=" + fid + " request mask=" + req[1] + " name=" + this.fids[fid].dbg_name, LOG_9P);
+ if(req[1] & P9_SETATTR_MODE) {
+ // XXX: check mode (S_IFREG or S_IFDIR or similar should be set)
+ inode.mode = req[2];
+ }
+ if(req[1] & P9_SETATTR_UID) {
+ inode.uid = req[3];
+ }
+ if(req[1] & P9_SETATTR_GID) {
+ inode.gid = req[4];
+ }
+ if(req[1] & P9_SETATTR_ATIME) {
+ inode.atime = Math.floor((new Date()).getTime()/1000);
+ }
+ if(req[1] & P9_SETATTR_MTIME) {
+ inode.mtime = Math.floor((new Date()).getTime()/1000);
+ }
+ if(req[1] & P9_SETATTR_CTIME) {
+ inode.ctime = Math.floor((new Date()).getTime()/1000);
+ }
+ if(req[1] & P9_SETATTR_ATIME_SET) {
+ inode.atime = req[6];
+ }
+ if(req[1] & P9_SETATTR_MTIME_SET) {
+ inode.mtime = req[8];
+ }
+ if(req[1] & P9_SETATTR_SIZE) {
+ await this.fs.ChangeSize(this.fids[fid].inodeid, req[5]);
+ }
+ this.BuildReply(id, tag, 0);
+ this.SendReply(bufchain);
+ break;
+
+ case 50: // fsync
+ var req = marshall.Unmarshall(["w", "d"], buffer, state);
+ var fid = req[0];
+ this.BuildReply(id, tag, 0);
+ this.SendReply(bufchain);
+ break;
+
+ case 40: // TREADDIR
+ case 116: // read
+ var req = marshall.Unmarshall(["w", "d", "w"], buffer, state);
+ var fid = req[0];
+ var offset = req[1];
+ var count = req[2];
+ var inode = this.fs.GetInode(this.fids[fid].inodeid);
+ if(id === 40) dbg_log("[treaddir]: fid=" + fid + " offset=" + offset + " count=" + count, LOG_9P);
+ if(id === 116) dbg_log("[read]: fid=" + fid + " (" + this.fids[fid].dbg_name + ") offset=" + offset + " count=" + count + " fidtype=" + this.fids[fid].type, LOG_9P);
+ if(!inode || inode.status === STATUS_UNLINKED)
+ {
+ dbg_log("read/treaddir: unlinked", LOG_9P);
+ this.SendError(tag, "No such file or directory", ENOENT);
+ this.SendReply(bufchain);
+ break;
+ }
+ if(this.fids[fid].type === FID_XATTR) {
+ if(inode.caps.length < offset+count) count = inode.caps.length - offset;
+ for(var i=0; i inode.size)
+ {
+ // offset can be greater than available - should return count of zero.
+ // See http://ericvh.github.io/9p-rfc/rfc9p2000.html#anchor30
+ count = 0;
+ }
+
+ this.bus.send("9p-read-start", [this.fids[fid].dbg_name]);
+
+ const data = await this.fs.Read(inodeid, offset, count);
+
+ this.bus.send("9p-read-end", [this.fids[fid].dbg_name, count]);
+
+ if(data) {
+ this.replybuffer.set(data, 7 + 4);
+ }
+ marshall.Marshall(["w"], [count], this.replybuffer, 7);
+ this.BuildReply(id, tag, 4 + count);
+ this.SendReply(bufchain);
+ }
+ break;
+
+ case 118: // write
+ var req = marshall.Unmarshall(["w", "d", "w"], buffer, state);
+ var fid = req[0];
+ var offset = req[1];
+ var count = req[2];
+
+ const filename = this.fids[fid].dbg_name;
+
+ dbg_log("[write]: fid=" + fid + " (" + filename + ") offset=" + offset + " count=" + count + " fidtype=" + this.fids[fid].type, LOG_9P);
+ if(this.fids[fid].type === FID_XATTR)
+ {
+ // XXX: xattr not supported yet. Ignore write.
+ this.SendError(tag, "Setxattr not supported", EOPNOTSUPP);
+ this.SendReply(bufchain);
+ break;
+ }
+ else
+ {
+ // XXX: Size of the subarray is unchecked
+ await this.fs.Write(this.fids[fid].inodeid, offset, count, buffer.subarray(state.offset));
+ }
+
+ this.bus.send("9p-write-end", [filename, count]);
+
+ marshall.Marshall(["w"], [count], this.replybuffer, 7);
+ this.BuildReply(id, tag, 4);
+ this.SendReply(bufchain);
+ break;
+
+ case 74: // RENAMEAT
+ var req = marshall.Unmarshall(["w", "s", "w", "s"], buffer, state);
+ var olddirfid = req[0];
+ var oldname = req[1];
+ var newdirfid = req[2];
+ var newname = req[3];
+ dbg_log("[renameat]: oldname=" + oldname + " newname=" + newname, LOG_9P);
+ var ret = await this.fs.Rename(this.fids[olddirfid].inodeid, oldname, this.fids[newdirfid].inodeid, newname);
+ if(ret < 0) {
+ let error_message = "";
+ if(ret === -ENOENT) error_message = "No such file or directory";
+ else if(ret === -EPERM) error_message = "Operation not permitted";
+ else if(ret === -ENOTEMPTY) error_message = "Directory not empty";
+ else
+ {
+ error_message = "Unknown error: " + (-ret);
+ dbg_assert(false, "[renameat]: Unexpected error code: " + (-ret));
+ }
+ this.SendError(tag, error_message, -ret);
+ this.SendReply(bufchain);
+ break;
+ }
+ if(TRACK_FILENAMES)
+ {
+ const newidx = this.fs.Search(this.fids[newdirfid].inodeid, newname);
+ this.update_dbg_name(newidx, newname);
+ }
+ this.BuildReply(id, tag, 0);
+ this.SendReply(bufchain);
+ break;
+
+ case 76: // TUNLINKAT
+ var req = marshall.Unmarshall(["w", "s", "w"], buffer, state);
+ var dirfd = req[0];
+ var name = req[1];
+ var flags = req[2];
+ dbg_log("[unlink]: dirfd=" + dirfd + " name=" + name + " flags=" + flags, LOG_9P);
+ var fid = this.fs.Search(this.fids[dirfd].inodeid, name);
+ if(fid === -1) {
+ this.SendError(tag, "No such file or directory", ENOENT);
+ this.SendReply(bufchain);
+ break;
+ }
+ var ret = this.fs.Unlink(this.fids[dirfd].inodeid, name);
+ if(ret < 0) {
+ let error_message = "";
+ if(ret === -ENOTEMPTY) error_message = "Directory not empty";
+ else if(ret === -EPERM) error_message = "Operation not permitted";
+ else
+ {
+ error_message = "Unknown error: " + (-ret);
+ dbg_assert(false, "[unlink]: Unexpected error code: " + (-ret));
+ }
+ this.SendError(tag, error_message, -ret);
+ this.SendReply(bufchain);
+ break;
+ }
+ this.BuildReply(id, tag, 0);
+ this.SendReply(bufchain);
+ break;
+
+ case 100: // version
+ var version = marshall.Unmarshall(["w", "s"], buffer, state);
+ dbg_log("[version]: msize=" + version[0] + " version=" + version[1], LOG_9P);
+ if(this.msize !== version[0])
+ {
+ this.msize = version[0];
+ this.replybuffer = new Uint8Array(Math.min(MAX_REPLYBUFFER_SIZE, this.msize*2));
+ }
+ size = marshall.Marshall(["w", "s"], [this.msize, this.VERSION], this.replybuffer, 7);
+ this.BuildReply(id, tag, size);
+ this.SendReply(bufchain);
+ break;
+
+ case 104: // attach
+ // return root directorie's QID
+ var req = marshall.Unmarshall(["w", "w", "s", "s", "w"], buffer, state);
+ var fid = req[0];
+ var uid = req[4];
+ dbg_log("[attach]: fid=" + fid + " afid=" + h(req[1]) + " uname=" + req[2] + " aname=" + req[3], LOG_9P);
+ this.fids[fid] = this.Createfid(0, FID_INODE, uid, "");
+ var inode = this.fs.GetInode(this.fids[fid].inodeid);
+ marshall.Marshall(["Q"], [inode.qid], this.replybuffer, 7);
+ this.BuildReply(id, tag, 13);
+ this.SendReply(bufchain);
+ this.bus.send("9p-attach");
+ break;
+
+ case 108: // tflush
+ var req = marshall.Unmarshall(["h"], buffer, state);
+ var oldtag = req[0];
+ dbg_log("[flush] " + tag, LOG_9P);
+ //marshall.Marshall(["Q"], [inode.qid], this.replybuffer, 7);
+ this.BuildReply(id, tag, 0);
+ this.SendReply(bufchain);
+ break;
+
+
+ case 110: // walk
+ var req = marshall.Unmarshall(["w", "w", "h"], buffer, state);
+ var fid = req[0];
+ var nwfid = req[1];
+ var nwname = req[2];
+ dbg_log("[walk]: fid=" + req[0] + " nwfid=" + req[1] + " nwname=" + nwname, LOG_9P);
+ if(nwname === 0) {
+ this.fids[nwfid] = this.Createfid(this.fids[fid].inodeid, FID_INODE, this.fids[fid].uid, this.fids[fid].dbg_name);
+ //this.fids[nwfid].inodeid = this.fids[fid].inodeid;
+ marshall.Marshall(["h"], [0], this.replybuffer, 7);
+ this.BuildReply(id, tag, 2);
+ this.SendReply(bufchain);
+ break;
+ }
+ var wnames = [];
+ for(var i=0; i {
+ // TODO: split into header + data blobs to avoid unnecessary copying.
+ const reqbuf = new Uint8Array(bufchain.length_readable);
+ bufchain.get_next_blob(reqbuf);
+
+ var reqheader = marshall.Unmarshall(["w", "b", "h"], reqbuf, { offset : 0 });
+ var reqtag = reqheader[2];
+
+ this.tag_bufchain.set(reqtag, bufchain);
+ this.handle_fn(reqbuf, (replybuf) => {
+ var replyheader = marshall.Unmarshall(["w", "b", "h"], replybuf, { offset: 0 });
+ var replytag = replyheader[2];
+
+ const bufchain = this.tag_bufchain.get(replytag);
+ if(!bufchain)
+ {
+ console.error("No bufchain found for tag: " + replytag);
+ return;
+ }
+
+ bufchain.set_next_blob(replybuf);
+ this.virtqueue.push_reply(bufchain);
+ this.virtqueue.flush_replies();
+
+ this.tag_bufchain.delete(replytag);
+ });
+ }
+ );
+ this.virtqueue = this.virtio.queues[0];
+}
+
+Virtio9pHandler.prototype.get_state = function()
+{
+ var state = [];
+
+ state[0] = this.configspace_tagname;
+ state[1] = this.configspace_taglen;
+ state[2] = this.virtio;
+ state[3] = this.tag_bufchain;
+
+ return state;
+};
+
+Virtio9pHandler.prototype.set_state = function(state)
+{
+ this.configspace_tagname = state[0];
+ this.configspace_taglen = state[1];
+ this.virtio.set_state(state[2]);
+ this.virtqueue = this.virtio.queues[0];
+ this.tag_bufchain = state[3];
+};
+
+
+Virtio9pHandler.prototype.reset = function()
+{
+ this.virtio.reset();
+};
+
+
+/**
+ * @constructor
+ *
+ * @param {string} url
+ * @param {CPU} cpu
+ */
+export function Virtio9pProxy(url, cpu)
+{
+ this.socket = undefined;
+ this.cpu = cpu;
+
+ // TODO: circular buffer?
+ this.send_queue = [];
+ this.url = url;
+
+ this.reconnect_interval = 10000;
+ this.last_connect_attempt = Date.now() - this.reconnect_interval;
+ this.send_queue_limit = 64;
+ this.destroyed = false;
+
+ this.tag_bufchain = new Map();
+
+ this.configspace_tagname = [0x68, 0x6F, 0x73, 0x74, 0x39, 0x70]; // "host9p" string
+ this.configspace_taglen = this.configspace_tagname.length; // num bytes
+
+ this.virtio = init_virtio(
+ cpu,
+ this.configspace_taglen,
+ this.configspace_tagname,
+ async (bufchain) => {
+ // TODO: split into header + data blobs to avoid unnecessary copying.
+ const reqbuf = new Uint8Array(bufchain.length_readable);
+ bufchain.get_next_blob(reqbuf);
+
+ const reqheader = marshall.Unmarshall(["w", "b", "h"], reqbuf, { offset : 0 });
+ const reqtag = reqheader[2];
+
+ this.tag_bufchain.set(reqtag, bufchain);
+ this.send(reqbuf);
+ }
+ );
+ this.virtqueue = this.virtio.queues[0];
+}
+
+Virtio9pProxy.prototype.get_state = function()
+{
+ var state = [];
+
+ state[0] = this.configspace_tagname;
+ state[1] = this.configspace_taglen;
+ state[2] = this.virtio;
+ state[3] = this.tag_bufchain;
+
+ return state;
+};
+
+Virtio9pProxy.prototype.set_state = function(state)
+{
+ this.configspace_tagname = state[0];
+ this.configspace_taglen = state[1];
+ this.virtio.set_state(state[2]);
+ this.virtqueue = this.virtio.queues[0];
+ this.tag_bufchain = state[3];
+};
+
+Virtio9pProxy.prototype.reset = function() {
+ this.virtio.reset();
+};
+
+Virtio9pProxy.prototype.handle_message = function(e)
+{
+ const replybuf = new Uint8Array(e.data);
+ const replyheader = marshall.Unmarshall(["w", "b", "h"], replybuf, { offset: 0 });
+ const replytag = replyheader[2];
+
+ const bufchain = this.tag_bufchain.get(replytag);
+ if(!bufchain)
+ {
+ console.error("Virtio9pProxy: No bufchain found for tag: " + replytag);
+ return;
+ }
+
+ bufchain.set_next_blob(replybuf);
+ this.virtqueue.push_reply(bufchain);
+ this.virtqueue.flush_replies();
+
+ this.tag_bufchain.delete(replytag);
+};
+
+Virtio9pProxy.prototype.handle_close = function(e)
+{
+ //console.log("onclose", e);
+
+ if(!this.destroyed)
+ {
+ this.connect();
+ setTimeout(this.connect.bind(this), this.reconnect_interval);
+ }
+};
+
+Virtio9pProxy.prototype.handle_open = function(e)
+{
+ //console.log("open", e);
+
+ for(var i = 0; i < this.send_queue.length; i++)
+ {
+ this.send(this.send_queue[i]);
+ }
+
+ this.send_queue = [];
+};
+
+Virtio9pProxy.prototype.handle_error = function(e)
+{
+ //console.log("onerror", e);
+};
+
+Virtio9pProxy.prototype.destroy = function()
+{
+ this.destroyed = true;
+ if(this.socket)
+ {
+ this.socket.close();
+ }
+};
+
+Virtio9pProxy.prototype.connect = function()
+{
+ if(typeof WebSocket === "undefined")
+ {
+ return;
+ }
+
+ if(this.socket)
+ {
+ var state = this.socket.readyState;
+
+ if(state === 0 || state === 1)
+ {
+ // already or almost there
+ return;
+ }
+ }
+
+ var now = Date.now();
+
+ if(this.last_connect_attempt + this.reconnect_interval > now)
+ {
+ return;
+ }
+
+ this.last_connect_attempt = Date.now();
+
+ try
+ {
+ this.socket = new WebSocket(this.url);
+ }
+ catch(e)
+ {
+ console.error(e);
+ return;
+ }
+
+ this.socket.binaryType = "arraybuffer";
+
+ this.socket.onopen = this.handle_open.bind(this);
+ this.socket.onmessage = this.handle_message.bind(this);
+ this.socket.onclose = this.handle_close.bind(this);
+ this.socket.onerror = this.handle_error.bind(this);
+};
+
+Virtio9pProxy.prototype.send = function(data)
+{
+ //console.log("send", data);
+
+ if(!this.socket || this.socket.readyState !== 1)
+ {
+ this.send_queue.push(data);
+
+ if(this.send_queue.length > 2 * this.send_queue_limit)
+ {
+ this.send_queue = this.send_queue.slice(-this.send_queue_limit);
+ }
+
+ this.connect();
+ }
+ else
+ {
+ this.socket.send(data);
+ }
+};
+
+Virtio9pProxy.prototype.change_proxy = function(url)
+{
+ this.url = url;
+
+ if(this.socket)
+ {
+ this.socket.onclose = function() {};
+ this.socket.onerror = function() {};
+ this.socket.close();
+ this.socket = undefined;
+ }
+};
diff --git a/lib/filesystem.js b/lib/filesystem.js
new file mode 100644
index 0000000000000000000000000000000000000000..6d9262aa97135e5c10319096d790021c08d585df
--- /dev/null
+++ b/lib/filesystem.js
@@ -0,0 +1,1969 @@
+// -------------------------------------------------
+// ----------------- FILESYSTEM---------------------
+// -------------------------------------------------
+// Implementation of a unix filesystem in memory.
+
+
+import { LOG_9P } from "../src/const.js";
+import { h } from "../src/lib.js";
+import { dbg_assert, dbg_log } from "../src/log.js";
+import * as marshall from "../lib/marshall.js";
+import { EEXIST, ENOTEMPTY, ENOENT, EPERM } from "./9p.js";
+import { P9_LOCK_SUCCESS, P9_LOCK_BLOCKED, P9_LOCK_TYPE_UNLCK, P9_LOCK_TYPE_WRLCK, P9_LOCK_TYPE_RDLCK } from "./9p.js";
+
+// For Types Only
+import { FileStorageInterface } from "../src/browser/filestorage.js";
+
+export const S_IRWXUGO = 0x1FF;
+export const S_IFMT = 0xF000;
+export const S_IFSOCK = 0xC000;
+export const S_IFLNK = 0xA000;
+export const S_IFREG = 0x8000;
+export const S_IFBLK = 0x6000;
+export const S_IFDIR = 0x4000;
+export const S_IFCHR = 0x2000;
+
+//var S_IFIFO 0010000
+//var S_ISUID 0004000
+//var S_ISGID 0002000
+//var S_ISVTX 0001000
+
+var O_RDONLY = 0x0000; // open for reading only
+var O_WRONLY = 0x0001; // open for writing only
+var O_RDWR = 0x0002; // open for reading and writing
+var O_ACCMODE = 0x0003; // mask for above modes
+
+export const STATUS_INVALID = -0x1;
+export const STATUS_OK = 0x0;
+export const STATUS_ON_STORAGE = 0x2;
+export const STATUS_UNLINKED = 0x4;
+export const STATUS_FORWARDING = 0x5;
+
+const texten = new TextEncoder();
+
+/** @const */ var JSONFS_VERSION = 3;
+
+
+/** @const */ var JSONFS_IDX_NAME = 0;
+/** @const */ var JSONFS_IDX_SIZE = 1;
+/** @const */ var JSONFS_IDX_MTIME = 2;
+/** @const */ var JSONFS_IDX_MODE = 3;
+/** @const */ var JSONFS_IDX_UID = 4;
+/** @const */ var JSONFS_IDX_GID = 5;
+/** @const */ var JSONFS_IDX_TARGET = 6;
+/** @const */ var JSONFS_IDX_SHA256 = 6;
+
+
+/**
+ * @constructor
+ * @param {!FileStorageInterface} storage
+ * @param {{ last_qidnumber: number }=} qidcounter Another fs's qidcounter to synchronise with.
+ */
+export function FS(storage, qidcounter) {
+ /** @type {Array.} */
+ this.inodes = [];
+
+ this.storage = storage;
+
+ this.qidcounter = qidcounter || { last_qidnumber: 0 };
+
+ //this.tar = new TAR(this);
+
+ this.inodedata = {};
+
+ this.total_size = 256 * 1024 * 1024 * 1024;
+ this.used_size = 0;
+
+ /** @type {!Array} */
+ this.mounts = [];
+
+ //RegisterMessage("LoadFilesystem", this.LoadFilesystem.bind(this) );
+ //RegisterMessage("MergeFile", this.MergeFile.bind(this) );
+ //RegisterMessage("tar",
+ // function(data) {
+ // SendToMaster("tar", this.tar.Pack(data));
+ // }.bind(this)
+ //);
+ //RegisterMessage("sync",
+ // function(data) {
+ // SendToMaster("sync", this.tar.Pack(data));
+ // }.bind(this)
+ //);
+
+ // root entry
+ this.CreateDirectory("", -1);
+}
+
+FS.prototype.get_state = function()
+{
+ let state = [];
+
+ state[0] = this.inodes;
+ state[1] = this.qidcounter.last_qidnumber;
+ state[2] = [];
+ for(const [id, data] of Object.entries(this.inodedata))
+ {
+ if((this.inodes[id].mode & S_IFDIR) === 0)
+ {
+ state[2].push([id, data]);
+ }
+ }
+ state[3] = this.total_size;
+ state[4] = this.used_size;
+ state = state.concat(this.mounts);
+
+ return state;
+};
+
+FS.prototype.set_state = function(state)
+{
+ this.inodes = state[0].map(state => { const inode = new Inode(0); inode.set_state(state); return inode; });
+ this.qidcounter.last_qidnumber = state[1];
+ this.inodedata = {};
+ for(let [key, value] of state[2])
+ {
+ if(value.buffer.byteLength !== value.byteLength)
+ {
+ // make a copy if we didn't get one
+ value = value.slice();
+ }
+
+ this.inodedata[key] = value;
+ }
+ this.total_size = state[3];
+ this.used_size = state[4];
+ this.mounts = state.slice(5);
+};
+
+
+// -----------------------------------------------------
+
+FS.prototype.load_from_json = function(fs)
+{
+ dbg_assert(fs, "Invalid fs passed to load_from_json");
+
+ if(fs["version"] !== JSONFS_VERSION)
+ {
+ throw "The filesystem JSON format has changed. Please recreate the filesystem JSON.";
+ }
+
+ var fsroot = fs["fsroot"];
+ this.used_size = fs["size"];
+
+ for(var i = 0; i < fsroot.length; i++) {
+ this.LoadRecursive(fsroot[i], 0);
+ }
+
+ //if(DEBUG)
+ //{
+ // this.Check();
+ //}
+};
+
+FS.prototype.LoadRecursive = function(data, parentid)
+{
+ var inode = this.CreateInode();
+
+ const name = data[JSONFS_IDX_NAME];
+ inode.size = data[JSONFS_IDX_SIZE];
+ inode.mtime = data[JSONFS_IDX_MTIME];
+ inode.ctime = inode.mtime;
+ inode.atime = inode.mtime;
+ inode.mode = data[JSONFS_IDX_MODE];
+ inode.uid = data[JSONFS_IDX_UID];
+ inode.gid = data[JSONFS_IDX_GID];
+
+ var ifmt = inode.mode & S_IFMT;
+
+ if(ifmt === S_IFDIR)
+ {
+ this.PushInode(inode, parentid, name);
+ this.LoadDir(this.inodes.length - 1, data[JSONFS_IDX_TARGET]);
+ }
+ else if(ifmt === S_IFREG)
+ {
+ inode.status = STATUS_ON_STORAGE;
+ inode.sha256sum = data[JSONFS_IDX_SHA256];
+ dbg_assert(inode.sha256sum);
+ this.PushInode(inode, parentid, name);
+ }
+ else if(ifmt === S_IFLNK)
+ {
+ inode.symlink = data[JSONFS_IDX_TARGET];
+ this.PushInode(inode, parentid, name);
+ }
+ else if(ifmt === S_IFSOCK)
+ {
+ // socket: ignore
+ }
+ else
+ {
+ dbg_log("Unexpected ifmt: " + h(ifmt) + " (" + name + ")", LOG_9P);
+ }
+};
+
+FS.prototype.LoadDir = function(parentid, children)
+{
+ for(var i = 0; i < children.length; i++) {
+ this.LoadRecursive(children[i], parentid);
+ }
+};
+
+
+// -----------------------------------------------------
+
+/**
+ * @private
+ * @param {Inode} inode
+ * @return {boolean}
+ */
+FS.prototype.should_be_linked = function(inode)
+{
+ // Note: Non-root forwarder inode could still have a non-forwarder parent, so don't use
+ // parent inode to check.
+ return !this.is_forwarder(inode) || inode.foreign_id === 0;
+};
+
+/**
+ * @private
+ * @param {number} parentid
+ * @param {number} idx
+ * @param {string} name
+ */
+FS.prototype.link_under_dir = function(parentid, idx, name)
+{
+ const inode = this.inodes[idx];
+ const parent_inode = this.inodes[parentid];
+
+ dbg_assert(!this.is_forwarder(parent_inode),
+ "Filesystem: Shouldn't link under fowarder parents");
+ dbg_assert(this.IsDirectory(parentid),
+ "Filesystem: Can't link under non-directories");
+ dbg_assert(this.should_be_linked(inode),
+ "Filesystem: Can't link across filesystems apart from their root");
+ dbg_assert(inode.nlinks >= 0,
+ "Filesystem: Found negative nlinks value of " + inode.nlinks);
+ dbg_assert(!parent_inode.direntries.has(name),
+ "Filesystem: Name '" + name + "' is already taken");
+
+ parent_inode.direntries.set(name, idx);
+ inode.nlinks++;
+
+ if(this.IsDirectory(idx))
+ {
+ dbg_assert(!inode.direntries.has(".."),
+ "Filesystem: Cannot link a directory twice");
+
+ if(!inode.direntries.has(".")) inode.nlinks++;
+ inode.direntries.set(".", idx);
+
+ inode.direntries.set("..", parentid);
+ parent_inode.nlinks++;
+ }
+};
+
+/**
+ * @private
+ * @param {number} parentid
+ * @param {string} name
+ */
+FS.prototype.unlink_from_dir = function(parentid, name)
+{
+ const idx = this.Search(parentid, name);
+ const inode = this.inodes[idx];
+ const parent_inode = this.inodes[parentid];
+
+ dbg_assert(!this.is_forwarder(parent_inode), "Filesystem: Can't unlink from forwarders");
+ dbg_assert(this.IsDirectory(parentid), "Filesystem: Can't unlink from non-directories");
+
+ const exists = parent_inode.direntries.delete(name);
+ if(!exists)
+ {
+ dbg_assert(false, "Filesystem: Can't unlink non-existent file: " + name);
+ return;
+ }
+
+ inode.nlinks--;
+
+ if(this.IsDirectory(idx))
+ {
+ dbg_assert(inode.direntries.get("..") === parentid,
+ "Filesystem: Found directory with bad parent id");
+
+ inode.direntries.delete("..");
+ parent_inode.nlinks--;
+ }
+
+ dbg_assert(inode.nlinks >= 0,
+ "Filesystem: Found negative nlinks value of " + inode.nlinks);
+};
+
+FS.prototype.PushInode = function(inode, parentid, name) {
+ if(parentid !== -1) {
+ this.inodes.push(inode);
+ inode.fid = this.inodes.length - 1;
+ this.link_under_dir(parentid, inode.fid, name);
+ return;
+ } else {
+ if(this.inodes.length === 0) { // if root directory
+ this.inodes.push(inode);
+ inode.direntries.set(".", 0);
+ inode.direntries.set("..", 0);
+ inode.nlinks = 2;
+ return;
+ }
+ }
+
+ dbg_assert(false, "Error in Filesystem: Pushed inode with name = "+ name + " has no parent");
+};
+
+/** @constructor */
+function Inode(qidnumber)
+{
+ this.direntries = new Map(); // maps filename to inode id
+ this.status = 0;
+ this.size = 0x0;
+ this.uid = 0x0;
+ this.gid = 0x0;
+ this.fid = 0;
+ this.ctime = 0;
+ this.atime = 0;
+ this.mtime = 0;
+ this.major = 0x0;
+ this.minor = 0x0;
+ this.symlink = "";
+ this.mode = 0x01ED;
+ this.qid = {
+ type: 0,
+ version: 0,
+ path: qidnumber,
+ };
+ this.caps = undefined;
+ this.nlinks = 0;
+ this.sha256sum = "";
+
+ /** @type{!Array} */
+ this.locks = []; // lock regions applied to the file, sorted by starting offset.
+
+ // For forwarders:
+ this.mount_id = -1; // which fs in this.mounts does this inode forward to?
+ this.foreign_id = -1; // which foreign inode id does it represent?
+
+ //this.qid_type = 0;
+ //this.qid_version = 0;
+ //this.qid_path = qidnumber;
+}
+
+Inode.prototype.get_state = function()
+{
+ const state = [];
+ state[0] = this.mode;
+
+ if((this.mode & S_IFMT) === S_IFDIR)
+ {
+ state[1] = [...this.direntries];
+ }
+ else if((this.mode & S_IFMT) === S_IFREG)
+ {
+ state[1] = this.sha256sum;
+ }
+ else if((this.mode & S_IFMT) === S_IFLNK)
+ {
+ state[1] = this.symlink;
+ }
+ else if((this.mode & S_IFMT) === S_IFSOCK)
+ {
+ state[1] = [this.minor, this.major];
+ }
+ else
+ {
+ state[1] = null;
+ }
+
+ state[2] = this.locks;
+ state[3] = this.status;
+ state[4] = this.size;
+ state[5] = this.uid;
+ state[6] = this.gid;
+ state[7] = this.fid;
+ state[8] = this.ctime;
+ state[9] = this.atime;
+ state[10] = this.mtime;
+ state[11] = this.qid.version;
+ state[12] = this.qid.path;
+ state[13] = this.nlinks;
+
+ //state[23] = this.mount_id;
+ //state[24] = this.foreign_id;
+ //state[25] = this.caps; // currently not writable
+ return state;
+};
+
+Inode.prototype.set_state = function(state)
+{
+ this.mode = state[0];
+
+ if((this.mode & S_IFMT) === S_IFDIR)
+ {
+ this.direntries = new Map();
+ for(const [name, entry] of state[1])
+ {
+ this.direntries.set(name, entry);
+ }
+ }
+ else if((this.mode & S_IFMT) === S_IFREG)
+ {
+ this.sha256sum = state[1];
+ }
+ else if((this.mode & S_IFMT) === S_IFLNK)
+ {
+ this.symlink = state[1];
+ }
+ else if((this.mode & S_IFMT) === S_IFSOCK)
+ {
+ [this.minor, this.major] = state[1];
+ }
+ else
+ {
+ // Nothing
+ }
+
+ this.locks = [];
+ for(const lock_state of state[2])
+ {
+ const lock = new FSLockRegion();
+ lock.set_state(lock_state);
+ this.locks.push(lock);
+ }
+ this.status = state[3];
+ this.size = state[4];
+ this.uid = state[5];
+ this.gid = state[6];
+ this.fid = state[7];
+ this.ctime = state[8];
+ this.atime = state[9];
+ this.mtime = state[10];
+ this.qid.type = (this.mode & S_IFMT) >> 8;
+ this.qid.version = state[11];
+ this.qid.path = state[12];
+ this.nlinks = state[13];
+
+ //this.mount_id = state[23];
+ //this.foreign_id = state[24];
+ //this.caps = state[20];
+};
+
+/**
+ * Clones given inode to new idx, effectively diverting the inode to new idx value.
+ * Hence, original idx value is now free to use without losing the original information.
+ * @private
+ * @param {number} parentid Parent of target to divert.
+ * @param {string} filename Name of target to divert.
+ * @return {number} New idx of diversion.
+ */
+FS.prototype.divert = function(parentid, filename)
+{
+ const old_idx = this.Search(parentid, filename);
+ const old_inode = this.inodes[old_idx];
+ const new_inode = new Inode(-1);
+
+ dbg_assert(old_inode, "Filesystem divert: name (" + filename + ") not found");
+ dbg_assert(this.IsDirectory(old_idx) || old_inode.nlinks <= 1,
+ "Filesystem: can't divert hardlinked file '" + filename + "' with nlinks=" +
+ old_inode.nlinks);
+
+ // Shallow copy is alright.
+ Object.assign(new_inode, old_inode);
+
+ const idx = this.inodes.length;
+ this.inodes.push(new_inode);
+ new_inode.fid = idx;
+
+ // Relink references
+ if(this.is_forwarder(old_inode))
+ {
+ this.mounts[old_inode.mount_id].backtrack.set(old_inode.foreign_id, idx);
+ }
+ if(this.should_be_linked(old_inode))
+ {
+ this.unlink_from_dir(parentid, filename);
+ this.link_under_dir(parentid, idx, filename);
+ }
+
+ // Update children
+ if(this.IsDirectory(old_idx) && !this.is_forwarder(old_inode))
+ {
+ for(const [name, child_id] of new_inode.direntries)
+ {
+ if(name === "." || name === "..") continue;
+ if(this.IsDirectory(child_id))
+ {
+ this.inodes[child_id].direntries.set("..", idx);
+ }
+ }
+ }
+
+ // Relocate local data if any.
+ this.inodedata[idx] = this.inodedata[old_idx];
+ delete this.inodedata[old_idx];
+
+ // Retire old reference information.
+ old_inode.direntries = new Map();
+ old_inode.nlinks = 0;
+
+ return idx;
+};
+
+/**
+ * Copy all non-redundant info.
+ * References left untouched: local idx value and links
+ * @private
+ * @param {!Inode} src_inode
+ * @param {!Inode} dest_inode
+ */
+FS.prototype.copy_inode = function(src_inode, dest_inode)
+{
+ Object.assign(dest_inode, src_inode, {
+ fid: dest_inode.fid,
+ direntries: dest_inode.direntries,
+ nlinks: dest_inode.nlinks,
+ });
+};
+
+FS.prototype.CreateInode = function() {
+ //console.log("CreateInode", Error().stack);
+ const now = Math.round(Date.now() / 1000);
+ const inode = new Inode(++this.qidcounter.last_qidnumber);
+ inode.atime = inode.ctime = inode.mtime = now;
+ return inode;
+};
+
+
+// Note: parentid = -1 for initial root directory.
+FS.prototype.CreateDirectory = function(name, parentid) {
+ const parent_inode = this.inodes[parentid];
+ if(parentid >= 0 && this.is_forwarder(parent_inode))
+ {
+ const foreign_parentid = parent_inode.foreign_id;
+ const foreign_id = this.follow_fs(parent_inode).CreateDirectory(name, foreign_parentid);
+ return this.create_forwarder(parent_inode.mount_id, foreign_id);
+ }
+ var x = this.CreateInode();
+ x.mode = 0x01FF | S_IFDIR;
+ if(parentid >= 0) {
+ x.uid = this.inodes[parentid].uid;
+ x.gid = this.inodes[parentid].gid;
+ x.mode = (this.inodes[parentid].mode & 0x1FF) | S_IFDIR;
+ }
+ x.qid.type = S_IFDIR >> 8;
+ this.PushInode(x, parentid, name);
+ this.NotifyListeners(this.inodes.length-1, "newdir");
+ return this.inodes.length-1;
+};
+
+FS.prototype.CreateFile = function(filename, parentid) {
+ const parent_inode = this.inodes[parentid];
+ if(this.is_forwarder(parent_inode))
+ {
+ const foreign_parentid = parent_inode.foreign_id;
+ const foreign_id = this.follow_fs(parent_inode).CreateFile(filename, foreign_parentid);
+ return this.create_forwarder(parent_inode.mount_id, foreign_id);
+ }
+ var x = this.CreateInode();
+ x.uid = this.inodes[parentid].uid;
+ x.gid = this.inodes[parentid].gid;
+ x.qid.type = S_IFREG >> 8;
+ x.mode = (this.inodes[parentid].mode & 0x1B6) | S_IFREG;
+ this.PushInode(x, parentid, filename);
+ this.NotifyListeners(this.inodes.length-1, "newfile");
+ return this.inodes.length-1;
+};
+
+
+FS.prototype.CreateNode = function(filename, parentid, major, minor) {
+ const parent_inode = this.inodes[parentid];
+ if(this.is_forwarder(parent_inode))
+ {
+ const foreign_parentid = parent_inode.foreign_id;
+ const foreign_id =
+ this.follow_fs(parent_inode).CreateNode(filename, foreign_parentid, major, minor);
+ return this.create_forwarder(parent_inode.mount_id, foreign_id);
+ }
+ var x = this.CreateInode();
+ x.major = major;
+ x.minor = minor;
+ x.uid = this.inodes[parentid].uid;
+ x.gid = this.inodes[parentid].gid;
+ x.qid.type = S_IFSOCK >> 8;
+ x.mode = (this.inodes[parentid].mode & 0x1B6);
+ this.PushInode(x, parentid, filename);
+ return this.inodes.length-1;
+};
+
+FS.prototype.CreateSymlink = function(filename, parentid, symlink) {
+ const parent_inode = this.inodes[parentid];
+ if(this.is_forwarder(parent_inode))
+ {
+ const foreign_parentid = parent_inode.foreign_id;
+ const foreign_id =
+ this.follow_fs(parent_inode).CreateSymlink(filename, foreign_parentid, symlink);
+ return this.create_forwarder(parent_inode.mount_id, foreign_id);
+ }
+ var x = this.CreateInode();
+ x.uid = this.inodes[parentid].uid;
+ x.gid = this.inodes[parentid].gid;
+ x.qid.type = S_IFLNK >> 8;
+ x.symlink = symlink;
+ x.mode = S_IFLNK;
+ this.PushInode(x, parentid, filename);
+ return this.inodes.length-1;
+};
+
+FS.prototype.CreateTextFile = async function(filename, parentid, str) {
+ const parent_inode = this.inodes[parentid];
+ if(this.is_forwarder(parent_inode))
+ {
+ const foreign_parentid = parent_inode.foreign_id;
+ const foreign_id = await
+ this.follow_fs(parent_inode).CreateTextFile(filename, foreign_parentid, str);
+ return this.create_forwarder(parent_inode.mount_id, foreign_id);
+ }
+ var id = this.CreateFile(filename, parentid);
+ var x = this.inodes[id];
+ var data = new Uint8Array(str.length);
+ x.size = str.length;
+ for(var j = 0; j < str.length; j++) {
+ data[j] = str.charCodeAt(j);
+ }
+ await this.set_data(id, data);
+ return id;
+};
+
+/**
+ * @param {Uint8Array} buffer
+ */
+FS.prototype.CreateBinaryFile = async function(filename, parentid, buffer) {
+ const parent_inode = this.inodes[parentid];
+ if(this.is_forwarder(parent_inode))
+ {
+ const foreign_parentid = parent_inode.foreign_id;
+ const foreign_id = await
+ this.follow_fs(parent_inode).CreateBinaryFile(filename, foreign_parentid, buffer);
+ return this.create_forwarder(parent_inode.mount_id, foreign_id);
+ }
+ var id = this.CreateFile(filename, parentid);
+ var x = this.inodes[id];
+ var data = new Uint8Array(buffer.length);
+ data.set(buffer);
+ await this.set_data(id, data);
+ x.size = buffer.length;
+ return id;
+};
+
+
+FS.prototype.OpenInode = async function(id, mode) {
+ var inode = this.inodes[id];
+ if(this.is_forwarder(inode))
+ {
+ return await this.follow_fs(inode).OpenInode(inode.foreign_id, mode);
+ }
+ if((inode.mode&S_IFMT) === S_IFDIR) {
+ this.FillDirectory(id);
+ }
+ /*
+ var type = "";
+ switch(inode.mode&S_IFMT) {
+ case S_IFREG: type = "File"; break;
+ case S_IFBLK: type = "Block Device"; break;
+ case S_IFDIR: type = "Directory"; break;
+ case S_IFCHR: type = "Character Device"; break;
+ }
+ */
+ //dbg_log("open:" + this.GetFullPath(id) + " type: " + inode.mode + " status:" + inode.status, LOG_9P);
+};
+
+FS.prototype.CloseInode = async function(id) {
+ //dbg_log("close: " + this.GetFullPath(id), LOG_9P);
+ var inode = this.inodes[id];
+ if(this.is_forwarder(inode))
+ {
+ return await this.follow_fs(inode).CloseInode(inode.foreign_id);
+ }
+ if(inode.status === STATUS_ON_STORAGE)
+ {
+ this.storage.uncache(inode.sha256sum);
+ }
+ if(inode.status === STATUS_UNLINKED) {
+ //dbg_log("Filesystem: Delete unlinked file", LOG_9P);
+ inode.status = STATUS_INVALID;
+ await this.DeleteData(id);
+ }
+};
+
+/**
+ * @return {!Promise} 0 if success, or -errno if failured.
+ */
+FS.prototype.Rename = async function(olddirid, oldname, newdirid, newname) {
+ // dbg_log("Rename " + oldname + " to " + newname, LOG_9P);
+ if((olddirid === newdirid) && (oldname === newname)) {
+ return 0;
+ }
+ var oldid = this.Search(olddirid, oldname);
+ if(oldid === -1)
+ {
+ return -ENOENT;
+ }
+
+ // For event notification near end of method.
+ var oldpath = this.GetFullPath(olddirid) + "/" + oldname;
+
+ var newid = this.Search(newdirid, newname);
+ if(newid !== -1) {
+ const ret = this.Unlink(newdirid, newname);
+ if(ret < 0) return ret;
+ }
+
+ var idx = oldid; // idx contains the id which we want to rename
+ var inode = this.inodes[idx];
+ const olddir = this.inodes[olddirid];
+ const newdir = this.inodes[newdirid];
+
+ if(!this.is_forwarder(olddir) && !this.is_forwarder(newdir))
+ {
+ // Move inode within current filesystem.
+
+ this.unlink_from_dir(olddirid, oldname);
+ this.link_under_dir(newdirid, idx, newname);
+
+ inode.qid.version++;
+ }
+ else if(this.is_forwarder(olddir) && olddir.mount_id === newdir.mount_id)
+ {
+ // Move inode within the same child filesystem.
+
+ const ret = await
+ this.follow_fs(olddir).Rename(olddir.foreign_id, oldname, newdir.foreign_id, newname);
+
+ if(ret < 0) return ret;
+ }
+ else if(this.is_a_root(idx))
+ {
+ // The actual inode is a root of some descendant filesystem.
+ // Moving mountpoint across fs not supported - needs to update all corresponding forwarders.
+ dbg_log("XXX: Attempted to move mountpoint (" + oldname + ") - skipped", LOG_9P);
+ return -EPERM;
+ }
+ else if(!this.IsDirectory(idx) && this.GetInode(idx).nlinks > 1)
+ {
+ // Move hardlinked inode vertically in mount tree.
+ dbg_log("XXX: Attempted to move hardlinked file (" + oldname + ") " +
+ "across filesystems - skipped", LOG_9P);
+ return -EPERM;
+ }
+ else
+ {
+ // Jump between filesystems.
+
+ // Can't work with both old and new inode information without first diverting the old
+ // information into a new idx value.
+ const diverted_old_idx = this.divert(olddirid, oldname);
+ const old_real_inode = this.GetInode(idx);
+
+ const data = await this.Read(diverted_old_idx, 0, old_real_inode.size);
+
+ if(this.is_forwarder(newdir))
+ {
+ // Create new inode.
+ const foreign_fs = this.follow_fs(newdir);
+ const foreign_id = this.IsDirectory(diverted_old_idx) ?
+ foreign_fs.CreateDirectory(newname, newdir.foreign_id) :
+ foreign_fs.CreateFile(newname, newdir.foreign_id);
+
+ const new_real_inode = foreign_fs.GetInode(foreign_id);
+ this.copy_inode(old_real_inode, new_real_inode);
+
+ // Point to this new location.
+ this.set_forwarder(idx, newdir.mount_id, foreign_id);
+ }
+ else
+ {
+ // Replace current forwarder with real inode.
+ this.delete_forwarder(inode);
+ this.copy_inode(old_real_inode, inode);
+
+ // Link into new location in this filesystem.
+ this.link_under_dir(newdirid, idx, newname);
+ }
+
+ // Rewrite data to newly created destination.
+ await this.ChangeSize(idx, old_real_inode.size);
+ if(data && data.length)
+ {
+ await this.Write(idx, 0, data.length, data);
+ }
+
+ // Move children to newly created destination.
+ if(this.IsDirectory(idx))
+ {
+ for(const child_filename of this.GetChildren(diverted_old_idx))
+ {
+ const ret = await this.Rename(diverted_old_idx, child_filename, idx, child_filename);
+ if(ret < 0) return ret;
+ }
+ }
+
+ // Perform destructive changes only after migration succeeded.
+ await this.DeleteData(diverted_old_idx);
+ const ret = this.Unlink(olddirid, oldname);
+ if(ret < 0) return ret;
+ }
+
+ this.NotifyListeners(idx, "rename", {oldpath: oldpath});
+
+ return 0;
+};
+
+FS.prototype.Write = async function(id, offset, count, buffer) {
+ this.NotifyListeners(id, "write");
+ var inode = this.inodes[id];
+
+ if(this.is_forwarder(inode))
+ {
+ const foreign_id = inode.foreign_id;
+ await this.follow_fs(inode).Write(foreign_id, offset, count, buffer);
+ return;
+ }
+
+ var data = await this.get_buffer(id);
+
+ if(!data || data.length < (offset+count)) {
+ await this.ChangeSize(id, Math.floor(((offset+count)*3)/2));
+ inode.size = offset + count;
+ data = await this.get_buffer(id);
+ } else
+ if(inode.size < (offset+count)) {
+ inode.size = offset + count;
+ }
+ if(buffer)
+ {
+ data.set(buffer.subarray(0, count), offset);
+ }
+ await this.set_data(id, data);
+};
+
+FS.prototype.Read = async function(inodeid, offset, count)
+{
+ const inode = this.inodes[inodeid];
+ if(this.is_forwarder(inode))
+ {
+ const foreign_id = inode.foreign_id;
+ return await this.follow_fs(inode).Read(foreign_id, offset, count);
+ }
+
+ return await this.get_data(inodeid, offset, count);
+};
+
+FS.prototype.Search = function(parentid, name) {
+ const parent_inode = this.inodes[parentid];
+
+ if(this.is_forwarder(parent_inode))
+ {
+ const foreign_parentid = parent_inode.foreign_id;
+ const foreign_id = this.follow_fs(parent_inode).Search(foreign_parentid, name);
+ if(foreign_id === -1) return -1;
+ return this.get_forwarder(parent_inode.mount_id, foreign_id);
+ }
+
+ const childid = parent_inode.direntries.get(name);
+ return childid === undefined ? -1 : childid;
+};
+
+FS.prototype.CountUsedInodes = function()
+{
+ let count = this.inodes.length;
+ for(const { fs, backtrack } of this.mounts)
+ {
+ count += fs.CountUsedInodes();
+
+ // Forwarder inodes don't count.
+ count -= backtrack.size;
+ }
+ return count;
+};
+
+FS.prototype.CountFreeInodes = function()
+{
+ let count = 1024 * 1024;
+ for(const { fs } of this.mounts)
+ {
+ count += fs.CountFreeInodes();
+ }
+ return count;
+};
+
+FS.prototype.GetTotalSize = function() {
+ let size = this.used_size;
+ for(const { fs } of this.mounts)
+ {
+ size += fs.GetTotalSize();
+ }
+ return size;
+ //var size = 0;
+ //for(var i=0; i} The buffer that contains the file contents, which may be larger
+ * than the data itself. To ensure that any modifications done to this buffer is reflected
+ * to the file, call set_data with the modified buffer.
+ */
+FS.prototype.get_buffer = async function(idx)
+{
+ const inode = this.inodes[idx];
+ dbg_assert(inode, `Filesystem get_buffer: idx ${idx} does not point to an inode`);
+
+ if(this.inodedata[idx])
+ {
+ return this.inodedata[idx];
+ }
+ else if(inode.status === STATUS_ON_STORAGE)
+ {
+ dbg_assert(inode.sha256sum, "Filesystem get_data: found inode on server without sha256sum");
+ return await this.storage.read(inode.sha256sum, 0, inode.size);
+ }
+ else
+ {
+ return null;
+ }
+};
+
+/**
+ * @private
+ * @param {number} idx
+ * @param {number} offset
+ * @param {number} count
+ * @return {!Promise}
+ */
+FS.prototype.get_data = async function(idx, offset, count)
+{
+ const inode = this.inodes[idx];
+ dbg_assert(inode, `Filesystem get_data: idx ${idx} does not point to an inode`);
+
+ if(this.inodedata[idx])
+ {
+ return this.inodedata[idx].subarray(offset, offset + count);
+ }
+ else if(inode.status === STATUS_ON_STORAGE)
+ {
+ dbg_assert(inode.sha256sum, "Filesystem get_data: found inode on server without sha256sum");
+ return await this.storage.read(inode.sha256sum, offset, count);
+ }
+ else
+ {
+ return null;
+ }
+};
+
+/**
+ * @private
+ * @param {number} idx
+ * @param {Uint8Array} buffer
+ */
+FS.prototype.set_data = async function(idx, buffer)
+{
+ // Current scheme: Save all modified buffers into local inodedata.
+ this.inodedata[idx] = buffer;
+ if(this.inodes[idx].status === STATUS_ON_STORAGE)
+ {
+ this.inodes[idx].status = STATUS_OK;
+ this.storage.uncache(this.inodes[idx].sha256sum);
+ }
+};
+
+/**
+ * @param {number} idx
+ * @return {!Inode}
+ */
+FS.prototype.GetInode = function(idx)
+{
+ dbg_assert(!isNaN(idx), "Filesystem GetInode: NaN idx");
+ dbg_assert(idx >= 0 && idx < this.inodes.length, "Filesystem GetInode: out of range idx:" + idx);
+
+ const inode = this.inodes[idx];
+ if(this.is_forwarder(inode))
+ {
+ return this.follow_fs(inode).GetInode(inode.foreign_id);
+ }
+
+ return inode;
+};
+
+FS.prototype.ChangeSize = async function(idx, newsize)
+{
+ var inode = this.GetInode(idx);
+ var temp = await this.get_data(idx, 0, inode.size);
+ //dbg_log("change size to: " + newsize, LOG_9P);
+ if(newsize === inode.size) return;
+ var data = new Uint8Array(newsize);
+ inode.size = newsize;
+ if(temp)
+ {
+ var size = Math.min(temp.length, inode.size);
+ data.set(temp.subarray(0, size), 0);
+ }
+ await this.set_data(idx, data);
+};
+
+FS.prototype.SearchPath = function(path) {
+ //path = path.replace(/\/\//g, "/");
+ path = path.replace("//", "/");
+ var walk = path.split("/");
+ if(walk.length > 0 && walk[walk.length - 1].length === 0) walk.pop();
+ if(walk.length > 0 && walk[0].length === 0) walk.shift();
+ const n = walk.length;
+
+ var parentid = -1;
+ var id = 0;
+ let forward_path = null;
+ for(var i=0; i} list
+ */
+FS.prototype.GetRecursiveList = function(dirid, list) {
+ if(this.is_forwarder(this.inodes[dirid]))
+ {
+ const foreign_fs = this.follow_fs(this.inodes[dirid]);
+ const foreign_dirid = this.inodes[dirid].foreign_id;
+ const mount_id = this.inodes[dirid].mount_id;
+
+ const foreign_start = list.length;
+ foreign_fs.GetRecursiveList(foreign_dirid, list);
+ for(let i = foreign_start; i < list.length; i++)
+ {
+ list[i].parentid = this.get_forwarder(mount_id, list[i].parentid);
+ }
+ return;
+ }
+ for(const [name, id] of this.inodes[dirid].direntries)
+ {
+ if(name !== "." && name !== "..")
+ {
+ list.push({ parentid: dirid, name });
+ if(this.IsDirectory(id))
+ {
+ this.GetRecursiveList(id, list);
+ }
+ }
+ }
+};
+
+FS.prototype.RecursiveDelete = function(path) {
+ var toDelete = [];
+ var ids = this.SearchPath(path);
+ if(ids.id === -1) return;
+
+ this.GetRecursiveList(ids.id, toDelete);
+
+ for(var i=toDelete.length-1; i>=0; i--)
+ {
+ const ret = this.Unlink(toDelete[i].parentid, toDelete[i].name);
+ dbg_assert(ret === 0, "Filesystem RecursiveDelete failed at parent=" + toDelete[i].parentid +
+ ", name='" + toDelete[i].name + "' with error code: " + (-ret));
+ }
+};
+
+FS.prototype.DeleteNode = function(path) {
+ var ids = this.SearchPath(path);
+ if(ids.id === -1) return;
+
+ if((this.inodes[ids.id].mode&S_IFMT) === S_IFREG){
+ const ret = this.Unlink(ids.parentid, ids.name);
+ dbg_assert(ret === 0, "Filesystem DeleteNode failed with error code: " + (-ret));
+ }
+ else if((this.inodes[ids.id].mode&S_IFMT) === S_IFDIR){
+ this.RecursiveDelete(path);
+ const ret = this.Unlink(ids.parentid, ids.name);
+ dbg_assert(ret === 0, "Filesystem DeleteNode failed with error code: " + (-ret));
+ }
+};
+
+/** @param {*=} info */
+FS.prototype.NotifyListeners = function(id, action, info) {
+ //if(info==undefined)
+ // info = {};
+
+ //var path = this.GetFullPath(id);
+ //if (this.watchFiles[path] === true && action=='write') {
+ // message.Send("WatchFileEvent", path);
+ //}
+ //for (var directory of this.watchDirectories) {
+ // if (this.watchDirectories.hasOwnProperty(directory)) {
+ // var indexOf = path.indexOf(directory)
+ // if(indexOf === 0 || indexOf === 1)
+ // message.Send("WatchDirectoryEvent", {path: path, event: action, info: info});
+ // }
+ //}
+};
+
+
+FS.prototype.Check = function() {
+ for(var i=1; i> 12,
+ name],
+ data, offset);
+ }
+};
+
+FS.prototype.RoundToDirentry = function(dirid, offset_target)
+{
+ const data = this.inodedata[dirid];
+ dbg_assert(data, `FS directory data for dirid=${dirid} should be generated`);
+ dbg_assert(data.length, "FS directory should have at least an entry");
+
+ if(offset_target >= data.length)
+ {
+ return data.length;
+ }
+
+ let offset = 0;
+ while(true)
+ {
+ const next_offset = marshall.Unmarshall(["Q", "d"], data, { offset })[1];
+ if(next_offset > offset_target) break;
+ offset = next_offset;
+ }
+
+ return offset;
+};
+
+/**
+ * @param {number} idx
+ * @return {boolean}
+ */
+FS.prototype.IsDirectory = function(idx)
+{
+ const inode = this.inodes[idx];
+ if(this.is_forwarder(inode))
+ {
+ return this.follow_fs(inode).IsDirectory(inode.foreign_id);
+ }
+ return (inode.mode & S_IFMT) === S_IFDIR;
+};
+
+/**
+ * @param {number} idx
+ * @return {boolean}
+ */
+FS.prototype.IsEmpty = function(idx)
+{
+ const inode = this.inodes[idx];
+ if(this.is_forwarder(inode))
+ {
+ return this.follow_fs(inode).IsDirectory(inode.foreign_id);
+ }
+ for(const name of inode.direntries.keys())
+ {
+ if(name !== "." && name !== "..") return false;
+ }
+ return true;
+};
+
+/**
+ * @param {number} idx
+ * @return {!Array} List of children names
+ */
+FS.prototype.GetChildren = function(idx)
+{
+ dbg_assert(this.IsDirectory(idx), "Filesystem: cannot get children of non-directory inode");
+ const inode = this.inodes[idx];
+ if(this.is_forwarder(inode))
+ {
+ return this.follow_fs(inode).GetChildren(inode.foreign_id);
+ }
+ const children = [];
+ for(const name of inode.direntries.keys())
+ {
+ if(name !== "." && name !== "..")
+ {
+ children.push(name);
+ }
+ }
+ return children;
+};
+
+/**
+ * @param {number} idx
+ * @return {number} Local idx of parent
+ */
+FS.prototype.GetParent = function(idx)
+{
+ dbg_assert(this.IsDirectory(idx), "Filesystem: cannot get parent of non-directory inode");
+
+ const inode = this.inodes[idx];
+
+ if(this.should_be_linked(inode))
+ {
+ return inode.direntries.get("..");
+ }
+ else
+ {
+ const foreign_dirid = this.follow_fs(inode).GetParent(inode.foreign_id);
+ dbg_assert(foreign_dirid !== -1, "Filesystem: should not have invalid parent ids");
+ return this.get_forwarder(inode.mount_id, foreign_dirid);
+ }
+};
+
+
+// -----------------------------------------------------
+
+// only support for security.capabilities
+// should return a "struct vfs_cap_data" defined in
+// linux/capability for format
+// check also:
+// sys/capability.h
+// http://lxr.free-electrons.com/source/security/commoncap.c#L376
+// http://man7.org/linux/man-pages/man7/capabilities.7.html
+// http://man7.org/linux/man-pages/man8/getcap.8.html
+// http://man7.org/linux/man-pages/man3/libcap.3.html
+FS.prototype.PrepareCAPs = function(id) {
+ var inode = this.GetInode(id);
+ if(inode.caps) return inode.caps.length;
+ inode.caps = new Uint8Array(20);
+ // format is little endian
+ // note: getxattr returns -EINVAL if using revision 1 format.
+ // note: getxattr presents revision 3 as revision 2 when revision 3 is not needed.
+ // magic_etc (revision=0x02: 20 bytes)
+ inode.caps[0] = 0x00;
+ inode.caps[1] = 0x00;
+ inode.caps[2] = 0x00;
+ inode.caps[3] = 0x02;
+
+ // lower
+ // permitted (first 32 capabilities)
+ inode.caps[4] = 0xFF;
+ inode.caps[5] = 0xFF;
+ inode.caps[6] = 0xFF;
+ inode.caps[7] = 0xFF;
+ // inheritable (first 32 capabilities)
+ inode.caps[8] = 0xFF;
+ inode.caps[9] = 0xFF;
+ inode.caps[10] = 0xFF;
+ inode.caps[11] = 0xFF;
+
+ // higher
+ // permitted (last 6 capabilities)
+ inode.caps[12] = 0x3F;
+ inode.caps[13] = 0x00;
+ inode.caps[14] = 0x00;
+ inode.caps[15] = 0x00;
+ // inheritable (last 6 capabilities)
+ inode.caps[16] = 0x3F;
+ inode.caps[17] = 0x00;
+ inode.caps[18] = 0x00;
+ inode.caps[19] = 0x00;
+
+ return inode.caps.length;
+};
+
+// -----------------------------------------------------
+
+/**
+ * @constructor
+ * @param {FS} filesystem
+ */
+function FSMountInfo(filesystem)
+{
+ /** @type {FS}*/
+ this.fs = filesystem;
+
+ /**
+ * Maps foreign inode id back to local inode id.
+ * @type {!Map}
+ */
+ this.backtrack = new Map();
+}
+
+FSMountInfo.prototype.get_state = function()
+{
+ const state = [];
+
+ state[0] = this.fs;
+ state[1] = [...this.backtrack];
+
+ return state;
+};
+
+FSMountInfo.prototype.set_state = function(state)
+{
+ this.fs = state[0];
+ this.backtrack = new Map(state[1]);
+};
+
+/**
+ * @private
+ * @param {number} idx Local idx of inode.
+ * @param {number} mount_id Mount number of the destination fs.
+ * @param {number} foreign_id Foreign idx of destination inode.
+ */
+FS.prototype.set_forwarder = function(idx, mount_id, foreign_id)
+{
+ const inode = this.inodes[idx];
+
+ dbg_assert(inode.nlinks === 0,
+ "Filesystem: attempted to convert an inode into forwarder before unlinking the inode");
+
+ if(this.is_forwarder(inode))
+ {
+ this.mounts[inode.mount_id].backtrack.delete(inode.foreign_id);
+ }
+
+ inode.status = STATUS_FORWARDING;
+ inode.mount_id = mount_id;
+ inode.foreign_id = foreign_id;
+
+ this.mounts[mount_id].backtrack.set(foreign_id, idx);
+};
+
+/**
+ * @private
+ * @param {number} mount_id Mount number of the destination fs.
+ * @param {number} foreign_id Foreign idx of destination inode.
+ * @return {number} Local idx of newly created forwarder.
+ */
+FS.prototype.create_forwarder = function(mount_id, foreign_id)
+{
+ const inode = this.CreateInode();
+
+ const idx = this.inodes.length;
+ this.inodes.push(inode);
+ inode.fid = idx;
+
+ this.set_forwarder(idx, mount_id, foreign_id);
+ return idx;
+};
+
+/**
+ * @private
+ * @param {Inode} inode
+ * @return {boolean}
+ */
+FS.prototype.is_forwarder = function(inode)
+{
+ return inode.status === STATUS_FORWARDING;
+};
+
+/**
+ * Whether the inode it points to is a root of some filesystem.
+ * @private
+ * @param {number} idx
+ * @return {boolean}
+ */
+FS.prototype.is_a_root = function(idx)
+{
+ return this.GetInode(idx).fid === 0;
+};
+
+/**
+ * Ensures forwarder exists, and returns such forwarder, for the described foreign inode.
+ * @private
+ * @param {number} mount_id
+ * @param {number} foreign_id
+ * @return {number} Local idx of a forwarder to described inode.
+ */
+FS.prototype.get_forwarder = function(mount_id, foreign_id)
+{
+ const mount = this.mounts[mount_id];
+
+ dbg_assert(foreign_id >= 0, "Filesystem get_forwarder: invalid foreign_id: " + foreign_id);
+ dbg_assert(mount, "Filesystem get_forwarder: invalid mount number: " + mount_id);
+
+ const result = mount.backtrack.get(foreign_id);
+
+ if(result === undefined)
+ {
+ // Create if not already exists.
+ return this.create_forwarder(mount_id, foreign_id);
+ }
+
+ return result;
+};
+
+/**
+ * @private
+ * @param {Inode} inode
+ */
+FS.prototype.delete_forwarder = function(inode)
+{
+ dbg_assert(this.is_forwarder(inode), "Filesystem delete_forwarder: expected forwarder");
+
+ inode.status = STATUS_INVALID;
+ this.mounts[inode.mount_id].backtrack.delete(inode.foreign_id);
+};
+
+/**
+ * @private
+ * @param {Inode} inode
+ * @return {FS}
+ */
+FS.prototype.follow_fs = function(inode)
+{
+ const mount = this.mounts[inode.mount_id];
+
+ dbg_assert(this.is_forwarder(inode),
+ "Filesystem follow_fs: inode should be a forwarding inode");
+ dbg_assert(mount, "Filesystem follow_fs: inode should point to valid mounted FS");
+
+ return mount.fs;
+};
+
+/**
+ * Mount another filesystem to given path.
+ * @param {string} path
+ * @param {FS} fs
+ * @return {number} inode id of mount point if successful, or -errno if mounting failed.
+ */
+FS.prototype.Mount = function(path, fs)
+{
+ dbg_assert(fs.qidcounter === this.qidcounter,
+ "Cannot mount filesystem whose qid numbers aren't synchronised with current filesystem.");
+
+ const path_infos = this.SearchPath(path);
+
+ if(path_infos.parentid === -1)
+ {
+ dbg_log("Mount failed: parent for path not found: " + path, LOG_9P);
+ return -ENOENT;
+ }
+ if(path_infos.id !== -1)
+ {
+ dbg_log("Mount failed: file already exists at path: " + path, LOG_9P);
+ return -EEXIST;
+ }
+ if(path_infos.forward_path)
+ {
+ const parent = this.inodes[path_infos.parentid];
+ const ret = this.follow_fs(parent).Mount(path_infos.forward_path, fs);
+ if(ret < 0) return ret;
+ return this.get_forwarder(parent.mount_id, ret);
+ }
+
+ const mount_id = this.mounts.length;
+ this.mounts.push(new FSMountInfo(fs));
+
+ const idx = this.create_forwarder(mount_id, 0);
+ this.link_under_dir(path_infos.parentid, idx, path_infos.name);
+
+ return idx;
+};
+
+/**
+ * @constructor
+ */
+function FSLockRegion()
+{
+ this.type = P9_LOCK_TYPE_UNLCK;
+ this.start = 0;
+ this.length = Infinity;
+ this.proc_id = -1;
+ this.client_id = "";
+}
+
+FSLockRegion.prototype.get_state = function()
+{
+ const state = [];
+
+ state[0] = this.type;
+ state[1] = this.start;
+ // Infinity is not JSON.stringify-able
+ state[2] = this.length === Infinity ? 0 : this.length;
+ state[3] = this.proc_id;
+ state[4] = this.client_id;
+
+ return state;
+};
+
+FSLockRegion.prototype.set_state = function(state)
+{
+ this.type = state[0];
+ this.start = state[1];
+ this.length = state[2] === 0 ? Infinity : state[2];
+ this.proc_id = state[3];
+ this.client_id = state[4];
+};
+
+/**
+ * @return {FSLockRegion}
+ */
+FSLockRegion.prototype.clone = function()
+{
+ const new_region = new FSLockRegion();
+ new_region.set_state(this.get_state());
+ return new_region;
+};
+
+/**
+ * @param {FSLockRegion} region
+ * @return {boolean}
+ */
+FSLockRegion.prototype.conflicts_with = function(region)
+{
+ if(this.proc_id === region.proc_id && this.client_id === region.client_id) return false;
+ if(this.type === P9_LOCK_TYPE_UNLCK || region.type === P9_LOCK_TYPE_UNLCK) return false;
+ if(this.type !== P9_LOCK_TYPE_WRLCK && region.type !== P9_LOCK_TYPE_WRLCK) return false;
+ if(this.start + this.length <= region.start) return false;
+ if(region.start + region.length <= this.start) return false;
+ return true;
+};
+
+/**
+ * @param {FSLockRegion} region
+ * @return {boolean}
+ */
+FSLockRegion.prototype.is_alike = function(region)
+{
+ return region.proc_id === this.proc_id &&
+ region.client_id === this.client_id &&
+ region.type === this.type;
+};
+
+/**
+ * @param {FSLockRegion} region
+ * @return {boolean}
+ */
+FSLockRegion.prototype.may_merge_after = function(region)
+{
+ return this.is_alike(region) && region.start + region.length === this.start;
+};
+
+/**
+ * @param {number} type
+ * @param {number} start
+ * @param {number} length
+ * @param {number} proc_id
+ * @param {string} client_id
+ * @return {!FSLockRegion}
+ */
+FS.prototype.DescribeLock = function(type, start, length, proc_id, client_id)
+{
+ dbg_assert(type === P9_LOCK_TYPE_RDLCK ||
+ type === P9_LOCK_TYPE_WRLCK ||
+ type === P9_LOCK_TYPE_UNLCK,
+ "Filesystem: Invalid lock type: " + type);
+ dbg_assert(start >= 0, "Filesystem: Invalid negative lock starting offset: " + start);
+ dbg_assert(length > 0, "Filesystem: Invalid non-positive lock length: " + length);
+
+ const lock = new FSLockRegion();
+ lock.type = type;
+ lock.start = start;
+ lock.length = length;
+ lock.proc_id = proc_id;
+ lock.client_id = client_id;
+
+ return lock;
+};
+
+/**
+ * @param {number} id
+ * @param {FSLockRegion} request
+ * @return {FSLockRegion} The first conflicting lock found, or null if requested lock is possible.
+ */
+FS.prototype.GetLock = function(id, request)
+{
+ const inode = this.inodes[id];
+
+ if(this.is_forwarder(inode))
+ {
+ const foreign_id = inode.foreign_id;
+ return this.follow_fs(inode).GetLock(foreign_id, request);
+ }
+
+ for(const region of inode.locks)
+ {
+ if(request.conflicts_with(region))
+ {
+ return region.clone();
+ }
+ }
+ return null;
+};
+
+/**
+ * @param {number} id
+ * @param {FSLockRegion} request
+ * @param {number} flags
+ * @return {number} One of P9_LOCK_SUCCESS / P9_LOCK_BLOCKED / P9_LOCK_ERROR / P9_LOCK_GRACE.
+ */
+FS.prototype.Lock = function(id, request, flags)
+{
+ const inode = this.inodes[id];
+
+ if(this.is_forwarder(inode))
+ {
+ const foreign_id = inode.foreign_id;
+ return this.follow_fs(inode).Lock(foreign_id, request, flags);
+ }
+
+ request = request.clone();
+
+ // (1) Check whether lock is possible before any modification.
+ if(request.type !== P9_LOCK_TYPE_UNLCK && this.GetLock(id, request))
+ {
+ return P9_LOCK_BLOCKED;
+ }
+
+ // (2) Subtract requested region from locks of the same owner.
+ for(let i = 0; i < inode.locks.length; i++)
+ {
+ const region = inode.locks[i];
+
+ dbg_assert(region.length > 0,
+ "Filesystem: Found non-positive lock region length: " + region.length);
+ dbg_assert(region.type === P9_LOCK_TYPE_RDLCK || region.type === P9_LOCK_TYPE_WRLCK,
+ "Filesystem: Found invalid lock type: " + region.type);
+ dbg_assert(!inode.locks[i-1] || inode.locks[i-1].start <= region.start,
+ "Filesystem: Locks should be sorted by starting offset");
+
+ // Skip to requested region.
+ if(region.start + region.length <= request.start) continue;
+
+ // Check whether we've skipped past the requested region.
+ if(request.start + request.length <= region.start) break;
+
+ // Skip over locks of different owners.
+ if(region.proc_id !== request.proc_id || region.client_id !== request.client_id)
+ {
+ dbg_assert(!region.conflicts_with(request),
+ "Filesytem: Found conflicting lock region, despite already checked for conflicts");
+ continue;
+ }
+
+ // Pretend region would be split into parts 1 and 2.
+ const start1 = region.start;
+ const start2 = request.start + request.length;
+ const length1 = request.start - start1;
+ const length2 = region.start + region.length - start2;
+
+ if(length1 > 0 && length2 > 0 && region.type === request.type)
+ {
+ // Requested region is already locked with the required type.
+ // Return early - no need to modify anything.
+ return P9_LOCK_SUCCESS;
+ }
+
+ if(length1 > 0)
+ {
+ // Shrink from right / first half of the split.
+ region.length = length1;
+ }
+
+ if(length1 <= 0 && length2 > 0)
+ {
+ // Shrink from left.
+ region.start = start2;
+ region.length = length2;
+ }
+ else if(length2 > 0)
+ {
+ // Add second half of the split.
+
+ // Fast-forward to correct location.
+ while(i < inode.locks.length && inode.locks[i].start < start2) i++;
+
+ inode.locks.splice(i, 0,
+ this.DescribeLock(region.type, start2, length2, region.proc_id, region.client_id));
+ }
+ else if(length1 <= 0)
+ {
+ // Requested region completely covers this region. Delete.
+ inode.locks.splice(i, 1);
+ i--;
+ }
+ }
+
+ // (3) Insert requested lock region as a whole.
+ // No point in adding the requested lock region as fragmented bits in the above loop
+ // and having to merge them all back into one.
+ if(request.type !== P9_LOCK_TYPE_UNLCK)
+ {
+ let new_region = request;
+ let has_merged = false;
+ let i = 0;
+
+ // Fast-forward to requested position, and try merging with previous region.
+ for(; i < inode.locks.length; i++)
+ {
+ if(new_region.may_merge_after(inode.locks[i]))
+ {
+ inode.locks[i].length += request.length;
+ new_region = inode.locks[i];
+ has_merged = true;
+ }
+ if(request.start <= inode.locks[i].start) break;
+ }
+
+ if(!has_merged)
+ {
+ inode.locks.splice(i, 0, new_region);
+ i++;
+ }
+
+ // Try merging with the subsequent alike region.
+ for(; i < inode.locks.length; i++)
+ {
+ if(!inode.locks[i].is_alike(new_region)) continue;
+
+ if(inode.locks[i].may_merge_after(new_region))
+ {
+ new_region.length += inode.locks[i].length;
+ inode.locks.splice(i, 1);
+ }
+
+ // No more mergable regions after this.
+ break;
+ }
+ }
+
+ return P9_LOCK_SUCCESS;
+};
+
+FS.prototype.read_dir = function(path)
+{
+ const p = this.SearchPath(path);
+
+ if(p.id === -1)
+ {
+ return undefined;
+ }
+
+ const dir = this.GetInode(p.id);
+
+ return Array.from(dir.direntries.keys()).filter(path => path !== "." && path !== "..");
+};
+
+FS.prototype.read_file = function(file)
+{
+ const p = this.SearchPath(file);
+
+ if(p.id === -1)
+ {
+ return Promise.resolve(null);
+ }
+
+ const inode = this.GetInode(p.id);
+
+ return this.Read(p.id, 0, inode.size);
+};
diff --git a/lib/marshall.js b/lib/marshall.js
new file mode 100644
index 0000000000000000000000000000000000000000..548172bec9b9b39a9c92d3ee87a38691520986ac
--- /dev/null
+++ b/lib/marshall.js
@@ -0,0 +1,128 @@
+// -------------------------------------------------
+// ------------------ Marshall ---------------------
+// -------------------------------------------------
+// helper functions for virtio and 9p.
+
+import { dbg_log } from "./../src/log.js";
+
+const textde = new TextDecoder();
+const texten = new TextEncoder();
+
+// Inserts data from an array to a byte aligned struct in memory
+export function Marshall(typelist, input, struct, offset) {
+ var item;
+ var size = 0;
+ for(var i=0; i < typelist.length; i++) {
+ item = input[i];
+ switch(typelist[i]) {
+ case "w":
+ struct[offset++] = item & 0xFF;
+ struct[offset++] = (item >> 8) & 0xFF;
+ struct[offset++] = (item >> 16) & 0xFF;
+ struct[offset++] = (item >> 24) & 0xFF;
+ size += 4;
+ break;
+ case "d": // double word
+ struct[offset++] = item & 0xFF;
+ struct[offset++] = (item >> 8) & 0xFF;
+ struct[offset++] = (item >> 16) & 0xFF;
+ struct[offset++] = (item >> 24) & 0xFF;
+ struct[offset++] = 0x0;
+ struct[offset++] = 0x0;
+ struct[offset++] = 0x0;
+ struct[offset++] = 0x0;
+ size += 8;
+ break;
+ case "h":
+ struct[offset++] = item & 0xFF;
+ struct[offset++] = item >> 8;
+ size += 2;
+ break;
+ case "b":
+ struct[offset++] = item;
+ size += 1;
+ break;
+ case "s":
+ var lengthoffset = offset;
+ var length = 0;
+ struct[offset++] = 0; // set the length later
+ struct[offset++] = 0;
+ size += 2;
+
+ var stringBytes = texten.encode(item);
+ size += stringBytes.byteLength;
+ length += stringBytes.byteLength;
+ struct.set(stringBytes, offset);
+ offset += stringBytes.byteLength;
+
+ struct[lengthoffset+0] = length & 0xFF;
+ struct[lengthoffset+1] = (length >> 8) & 0xFF;
+ break;
+ case "Q":
+ Marshall(["b", "w", "d"], [item.type, item.version, item.path], struct, offset);
+ offset += 13;
+ size += 13;
+ break;
+ default:
+ dbg_log("Marshall: Unknown type=" + typelist[i]);
+ break;
+ }
+ }
+ return size;
+}
+
+
+// Extracts data from a byte aligned struct in memory to an array
+export function Unmarshall(typelist, struct, state) {
+ let offset = state.offset;
+ var output = [];
+ for(var i=0; i < typelist.length; i++) {
+ switch(typelist[i]) {
+ case "w":
+ var val = struct[offset++];
+ val += struct[offset++] << 8;
+ val += struct[offset++] << 16;
+ val += (struct[offset++] << 24) >>> 0;
+ output.push(val);
+ break;
+ case "d":
+ var val = struct[offset++];
+ val += struct[offset++] << 8;
+ val += struct[offset++] << 16;
+ val += (struct[offset++] << 24) >>> 0;
+ offset += 4;
+ output.push(val);
+ break;
+ case "h":
+ var val = struct[offset++];
+ output.push(val + (struct[offset++] << 8));
+ break;
+ case "b":
+ output.push(struct[offset++]);
+ break;
+ case "s":
+ var len = struct[offset++];
+ len += struct[offset++] << 8;
+
+ var stringBytes = struct.slice(offset, offset + len);
+ offset += len;
+ output.push(textde.decode(stringBytes));
+ break;
+ case "Q":
+ state.offset = offset;
+ const qid = Unmarshall(["b", "w", "d"], struct, state);
+ offset = state.offset;
+ output.push({
+ type: qid[0],
+ version: qid[1],
+ path: qid[2],
+ });
+ break;
+ default:
+ dbg_log("Error in Unmarshall: Unknown type=" + typelist[i]);
+ break;
+ }
+ }
+ state.offset = offset;
+ return output;
+}
diff --git a/lib/softfloat/softfloat.c b/lib/softfloat/softfloat.c
new file mode 100644
index 0000000000000000000000000000000000000000..a95347ed54b25b53c4b58189bb4ba853a13717a4
--- /dev/null
+++ b/lib/softfloat/softfloat.c
@@ -0,0 +1,32501 @@
+/**** start inlining ../../source/8086-SSE/softfloat_raiseFlags.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+/**** start inlining platform.h ****/
+
+/*============================================================================
+
+This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+#define LITTLEENDIAN 1
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+#ifdef __GNUC_STDC_INLINE__
+#define INLINE inline
+#else
+#define INLINE extern inline
+#endif
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+#define SOFTFLOAT_BUILTIN_CLZ 1
+#define SOFTFLOAT_INTRINSIC_INT128 1
+/**** start inlining opts-GCC.h ****/
+
+/*============================================================================
+
+This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2017 The Regents of the University of California. All rights
+reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#ifndef opts_GCC_h
+#define opts_GCC_h 1
+
+#ifdef INLINE
+
+#include
+/**** start inlining primitiveTypes.h ****/
+
+/*============================================================================
+
+This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#ifndef primitiveTypes_h
+#define primitiveTypes_h 1
+
+#include
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+#ifdef LITTLEENDIAN
+struct uint128 { uint64_t v0, v64; };
+struct uint64_extra { uint64_t extra, v; };
+struct uint128_extra { uint64_t extra; struct uint128 v; };
+#else
+struct uint128 { uint64_t v64, v0; };
+struct uint64_extra { uint64_t v, extra; };
+struct uint128_extra { struct uint128 v; uint64_t extra; };
+#endif
+
+#endif
+
+/*----------------------------------------------------------------------------
+| These macros are used to isolate the differences in word order between big-
+| endian and little-endian platforms.
+*----------------------------------------------------------------------------*/
+#ifdef LITTLEENDIAN
+#define wordIncr 1
+#define indexWord( total, n ) (n)
+#define indexWordHi( total ) ((total) - 1)
+#define indexWordLo( total ) 0
+#define indexMultiword( total, m, n ) (n)
+#define indexMultiwordHi( total, n ) ((total) - (n))
+#define indexMultiwordLo( total, n ) 0
+#define indexMultiwordHiBut( total, n ) (n)
+#define indexMultiwordLoBut( total, n ) 0
+#define INIT_UINTM4( v3, v2, v1, v0 ) { v0, v1, v2, v3 }
+#else
+#define wordIncr -1
+#define indexWord( total, n ) ((total) - 1 - (n))
+#define indexWordHi( total ) 0
+#define indexWordLo( total ) ((total) - 1)
+#define indexMultiword( total, m, n ) ((total) - 1 - (m))
+#define indexMultiwordHi( total, n ) 0
+#define indexMultiwordLo( total, n ) ((total) - (n))
+#define indexMultiwordHiBut( total, n ) 0
+#define indexMultiwordLoBut( total, n ) (n)
+#define INIT_UINTM4( v3, v2, v1, v0 ) { v3, v2, v1, v0 }
+#endif
+
+#endif
+
+/**** ended inlining primitiveTypes.h ****/
+
+#ifdef SOFTFLOAT_BUILTIN_CLZ
+
+INLINE uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
+ { return a ? __builtin_clz( a ) - 16 : 16; }
+#define softfloat_countLeadingZeros16 softfloat_countLeadingZeros16
+
+INLINE uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
+ { return a ? __builtin_clz( a ) : 32; }
+#define softfloat_countLeadingZeros32 softfloat_countLeadingZeros32
+
+INLINE uint_fast8_t softfloat_countLeadingZeros64( uint64_t a )
+ { return a ? __builtin_clzll( a ) : 64; }
+#define softfloat_countLeadingZeros64 softfloat_countLeadingZeros64
+
+#endif
+
+#ifdef SOFTFLOAT_INTRINSIC_INT128
+
+INLINE struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b )
+{
+ union { unsigned __int128 ui; struct uint128 s; } uZ;
+ uZ.ui = (unsigned __int128) a * ((uint_fast64_t) b<<32);
+ return uZ.s;
+}
+#define softfloat_mul64ByShifted32To128 softfloat_mul64ByShifted32To128
+
+INLINE struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b )
+{
+ union { unsigned __int128 ui; struct uint128 s; } uZ;
+ uZ.ui = (unsigned __int128) a * b;
+ return uZ.s;
+}
+#define softfloat_mul64To128 softfloat_mul64To128
+
+INLINE
+struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
+{
+ union { unsigned __int128 ui; struct uint128 s; } uZ;
+ uZ.ui = ((unsigned __int128) a64<<64 | a0) * b;
+ return uZ.s;
+}
+#define softfloat_mul128By32 softfloat_mul128By32
+
+INLINE
+void
+ softfloat_mul128To256M(
+ uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr )
+{
+ unsigned __int128 z0, mid1, mid, z128;
+ z0 = (unsigned __int128) a0 * b0;
+ mid1 = (unsigned __int128) a64 * b0;
+ mid = mid1 + (unsigned __int128) a0 * b64;
+ z128 = (unsigned __int128) a64 * b64;
+ z128 += (unsigned __int128) (mid < mid1)<<64 | mid>>64;
+ mid <<= 64;
+ z0 += mid;
+ z128 += (z0 < mid);
+ zPtr[indexWord( 4, 0 )] = z0;
+ zPtr[indexWord( 4, 1 )] = z0>>64;
+ zPtr[indexWord( 4, 2 )] = z128;
+ zPtr[indexWord( 4, 3 )] = z128>>64;
+}
+#define softfloat_mul128To256M softfloat_mul128To256M
+
+#endif
+
+#endif
+
+#endif
+
+/**** ended inlining opts-GCC.h ****/
+
+/**** ended inlining platform.h ****/
+/**** start inlining softfloat.h ****/
+
+/*============================================================================
+
+This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+
+/*============================================================================
+| Note: If SoftFloat is made available as a general library for programs to
+| use, it is strongly recommended that a platform-specific version of this
+| header, "softfloat.h", be created that folds in "softfloat_types.h" and that
+| eliminates all dependencies on compile-time macros.
+*============================================================================*/
+
+
+#ifndef softfloat_h
+#define softfloat_h 1
+
+#include
+#include
+/**** start inlining softfloat_types.h ****/
+
+/*============================================================================
+
+This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#ifndef softfloat_types_h
+#define softfloat_types_h 1
+
+#include
+
+/*----------------------------------------------------------------------------
+| Types used to pass 16-bit, 32-bit, 64-bit, and 128-bit floating-point
+| arguments and results to/from functions. These types must be exactly
+| 16 bits, 32 bits, 64 bits, and 128 bits in size, respectively. Where a
+| platform has "native" support for IEEE-Standard floating-point formats,
+| the types below may, if desired, be defined as aliases for the native types
+| (typically 'float' and 'double', and possibly 'long double').
+*----------------------------------------------------------------------------*/
+typedef struct { uint16_t v; } float16_t;
+typedef struct { uint32_t v; } float32_t;
+typedef struct { uint64_t v; } float64_t;
+typedef struct { uint64_t v[2]; } float128_t;
+
+/*----------------------------------------------------------------------------
+| The format of an 80-bit extended floating-point number in memory. This
+| structure must contain a 16-bit field named 'signExp' and a 64-bit field
+| named 'signif'.
+*----------------------------------------------------------------------------*/
+#ifdef LITTLEENDIAN
+struct extFloat80M { uint64_t signif; uint16_t signExp; };
+#else
+struct extFloat80M { uint16_t signExp; uint64_t signif; };
+#endif
+
+/*----------------------------------------------------------------------------
+| The type used to pass 80-bit extended floating-point arguments and
+| results to/from functions. This type must have size identical to
+| 'struct extFloat80M'. Type 'extFloat80_t' can be defined as an alias for
+| 'struct extFloat80M'. Alternatively, if a platform has "native" support
+| for IEEE-Standard 80-bit extended floating-point, it may be possible,
+| if desired, to define 'extFloat80_t' as an alias for the native type
+| (presumably either 'long double' or a nonstandard compiler-intrinsic type).
+| In that case, the 'signif' and 'signExp' fields of 'struct extFloat80M'
+| must align exactly with the locations in memory of the sign, exponent, and
+| significand of the native type.
+*----------------------------------------------------------------------------*/
+typedef struct extFloat80M extFloat80_t;
+
+#endif
+
+/**** ended inlining softfloat_types.h ****/
+
+#ifndef THREAD_LOCAL
+#define THREAD_LOCAL
+#endif
+
+/*----------------------------------------------------------------------------
+| Software floating-point underflow tininess-detection mode.
+*----------------------------------------------------------------------------*/
+extern THREAD_LOCAL uint_fast8_t softfloat_detectTininess;
+enum {
+ softfloat_tininess_beforeRounding = 0,
+ softfloat_tininess_afterRounding = 1
+};
+
+/*----------------------------------------------------------------------------
+| Software floating-point rounding mode. (Mode "odd" is supported only if
+| SoftFloat is compiled with macro 'SOFTFLOAT_ROUND_ODD' defined.)
+*----------------------------------------------------------------------------*/
+extern THREAD_LOCAL uint_fast8_t softfloat_roundingMode;
+enum {
+ softfloat_round_near_even = 0,
+ softfloat_round_minMag = 1,
+ softfloat_round_min = 2,
+ softfloat_round_max = 3,
+ softfloat_round_near_maxMag = 4,
+ softfloat_round_odd = 6
+};
+
+/*----------------------------------------------------------------------------
+| Software floating-point exception flags.
+*----------------------------------------------------------------------------*/
+extern THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags;
+enum {
+ softfloat_flag_inexact = 1,
+ softfloat_flag_underflow = 2,
+ softfloat_flag_overflow = 4,
+ softfloat_flag_infinite = 8,
+ softfloat_flag_invalid = 16
+};
+
+/*----------------------------------------------------------------------------
+| Routine to raise any or all of the software floating-point exception flags.
+*----------------------------------------------------------------------------*/
+void softfloat_raiseFlags( uint_fast8_t );
+
+/*----------------------------------------------------------------------------
+| Integer-to-floating-point conversion routines.
+*----------------------------------------------------------------------------*/
+float16_t ui32_to_f16( uint32_t );
+float32_t ui32_to_f32( uint32_t );
+float64_t ui32_to_f64( uint32_t );
+#ifdef SOFTFLOAT_FAST_INT64
+extFloat80_t ui32_to_extF80( uint32_t );
+float128_t ui32_to_f128( uint32_t );
+#endif
+void ui32_to_extF80M( uint32_t, extFloat80_t * );
+void ui32_to_f128M( uint32_t, float128_t * );
+float16_t ui64_to_f16( uint64_t );
+float32_t ui64_to_f32( uint64_t );
+float64_t ui64_to_f64( uint64_t );
+#ifdef SOFTFLOAT_FAST_INT64
+extFloat80_t ui64_to_extF80( uint64_t );
+float128_t ui64_to_f128( uint64_t );
+#endif
+void ui64_to_extF80M( uint64_t, extFloat80_t * );
+void ui64_to_f128M( uint64_t, float128_t * );
+float16_t i32_to_f16( int32_t );
+float32_t i32_to_f32( int32_t );
+float64_t i32_to_f64( int32_t );
+#ifdef SOFTFLOAT_FAST_INT64
+extFloat80_t i32_to_extF80( int32_t );
+float128_t i32_to_f128( int32_t );
+#endif
+void i32_to_extF80M( int32_t, extFloat80_t * );
+void i32_to_f128M( int32_t, float128_t * );
+float16_t i64_to_f16( int64_t );
+float32_t i64_to_f32( int64_t );
+float64_t i64_to_f64( int64_t );
+#ifdef SOFTFLOAT_FAST_INT64
+extFloat80_t i64_to_extF80( int64_t );
+float128_t i64_to_f128( int64_t );
+#endif
+void i64_to_extF80M( int64_t, extFloat80_t * );
+void i64_to_f128M( int64_t, float128_t * );
+
+/*----------------------------------------------------------------------------
+| 16-bit (half-precision) floating-point operations.
+*----------------------------------------------------------------------------*/
+uint_fast32_t f16_to_ui32( float16_t, uint_fast8_t, bool );
+uint_fast64_t f16_to_ui64( float16_t, uint_fast8_t, bool );
+int_fast32_t f16_to_i32( float16_t, uint_fast8_t, bool );
+int_fast64_t f16_to_i64( float16_t, uint_fast8_t, bool );
+uint_fast32_t f16_to_ui32_r_minMag( float16_t, bool );
+uint_fast64_t f16_to_ui64_r_minMag( float16_t, bool );
+int_fast32_t f16_to_i32_r_minMag( float16_t, bool );
+int_fast64_t f16_to_i64_r_minMag( float16_t, bool );
+float32_t f16_to_f32( float16_t );
+float64_t f16_to_f64( float16_t );
+#ifdef SOFTFLOAT_FAST_INT64
+extFloat80_t f16_to_extF80( float16_t );
+float128_t f16_to_f128( float16_t );
+#endif
+void f16_to_extF80M( float16_t, extFloat80_t * );
+void f16_to_f128M( float16_t, float128_t * );
+float16_t f16_roundToInt( float16_t, uint_fast8_t, bool );
+float16_t f16_add( float16_t, float16_t );
+float16_t f16_sub( float16_t, float16_t );
+float16_t f16_mul( float16_t, float16_t );
+float16_t f16_mulAdd( float16_t, float16_t, float16_t );
+float16_t f16_div( float16_t, float16_t );
+float16_t f16_rem( float16_t, float16_t );
+float16_t f16_sqrt( float16_t );
+bool f16_eq( float16_t, float16_t );
+bool f16_le( float16_t, float16_t );
+bool f16_lt( float16_t, float16_t );
+bool f16_eq_signaling( float16_t, float16_t );
+bool f16_le_quiet( float16_t, float16_t );
+bool f16_lt_quiet( float16_t, float16_t );
+bool f16_isSignalingNaN( float16_t );
+
+/*----------------------------------------------------------------------------
+| 32-bit (single-precision) floating-point operations.
+*----------------------------------------------------------------------------*/
+uint_fast32_t f32_to_ui32( float32_t, uint_fast8_t, bool );
+uint_fast64_t f32_to_ui64( float32_t, uint_fast8_t, bool );
+int_fast32_t f32_to_i32( float32_t, uint_fast8_t, bool );
+int_fast64_t f32_to_i64( float32_t, uint_fast8_t, bool );
+uint_fast32_t f32_to_ui32_r_minMag( float32_t, bool );
+uint_fast64_t f32_to_ui64_r_minMag( float32_t, bool );
+int_fast32_t f32_to_i32_r_minMag( float32_t, bool );
+int_fast64_t f32_to_i64_r_minMag( float32_t, bool );
+float16_t f32_to_f16( float32_t );
+float64_t f32_to_f64( float32_t );
+#ifdef SOFTFLOAT_FAST_INT64
+extFloat80_t f32_to_extF80( float32_t );
+float128_t f32_to_f128( float32_t );
+#endif
+void f32_to_extF80M( float32_t, extFloat80_t * );
+void f32_to_f128M( float32_t, float128_t * );
+float32_t f32_roundToInt( float32_t, uint_fast8_t, bool );
+float32_t f32_add( float32_t, float32_t );
+float32_t f32_sub( float32_t, float32_t );
+float32_t f32_mul( float32_t, float32_t );
+float32_t f32_mulAdd( float32_t, float32_t, float32_t );
+float32_t f32_div( float32_t, float32_t );
+float32_t f32_rem( float32_t, float32_t );
+float32_t f32_sqrt( float32_t );
+bool f32_eq( float32_t, float32_t );
+bool f32_le( float32_t, float32_t );
+bool f32_lt( float32_t, float32_t );
+bool f32_eq_signaling( float32_t, float32_t );
+bool f32_le_quiet( float32_t, float32_t );
+bool f32_lt_quiet( float32_t, float32_t );
+bool f32_isSignalingNaN( float32_t );
+
+/*----------------------------------------------------------------------------
+| 64-bit (double-precision) floating-point operations.
+*----------------------------------------------------------------------------*/
+uint_fast32_t f64_to_ui32( float64_t, uint_fast8_t, bool );
+uint_fast64_t f64_to_ui64( float64_t, uint_fast8_t, bool );
+int_fast32_t f64_to_i32( float64_t, uint_fast8_t, bool );
+int_fast64_t f64_to_i64( float64_t, uint_fast8_t, bool );
+uint_fast32_t f64_to_ui32_r_minMag( float64_t, bool );
+uint_fast64_t f64_to_ui64_r_minMag( float64_t, bool );
+int_fast32_t f64_to_i32_r_minMag( float64_t, bool );
+int_fast64_t f64_to_i64_r_minMag( float64_t, bool );
+float16_t f64_to_f16( float64_t );
+float32_t f64_to_f32( float64_t );
+#ifdef SOFTFLOAT_FAST_INT64
+extFloat80_t f64_to_extF80( float64_t );
+float128_t f64_to_f128( float64_t );
+#endif
+void f64_to_extF80M( float64_t, extFloat80_t * );
+void f64_to_f128M( float64_t, float128_t * );
+float64_t f64_roundToInt( float64_t, uint_fast8_t, bool );
+float64_t f64_add( float64_t, float64_t );
+float64_t f64_sub( float64_t, float64_t );
+float64_t f64_mul( float64_t, float64_t );
+float64_t f64_mulAdd( float64_t, float64_t, float64_t );
+float64_t f64_div( float64_t, float64_t );
+float64_t f64_rem( float64_t, float64_t );
+float64_t f64_sqrt( float64_t );
+bool f64_eq( float64_t, float64_t );
+bool f64_le( float64_t, float64_t );
+bool f64_lt( float64_t, float64_t );
+bool f64_eq_signaling( float64_t, float64_t );
+bool f64_le_quiet( float64_t, float64_t );
+bool f64_lt_quiet( float64_t, float64_t );
+bool f64_isSignalingNaN( float64_t );
+
+/*----------------------------------------------------------------------------
+| Rounding precision for 80-bit extended double-precision floating-point.
+| Valid values are 32, 64, and 80.
+*----------------------------------------------------------------------------*/
+extern THREAD_LOCAL uint_fast8_t extF80_roundingPrecision;
+
+/*----------------------------------------------------------------------------
+| 80-bit extended double-precision floating-point operations.
+*----------------------------------------------------------------------------*/
+#ifdef SOFTFLOAT_FAST_INT64
+uint_fast32_t extF80_to_ui32( extFloat80_t, uint_fast8_t, bool );
+uint_fast64_t extF80_to_ui64( extFloat80_t, uint_fast8_t, bool );
+int_fast32_t extF80_to_i32( extFloat80_t, uint_fast8_t, bool );
+int_fast64_t extF80_to_i64( extFloat80_t, uint_fast8_t, bool );
+uint_fast32_t extF80_to_ui32_r_minMag( extFloat80_t, bool );
+uint_fast64_t extF80_to_ui64_r_minMag( extFloat80_t, bool );
+int_fast32_t extF80_to_i32_r_minMag( extFloat80_t, bool );
+int_fast64_t extF80_to_i64_r_minMag( extFloat80_t, bool );
+float16_t extF80_to_f16( extFloat80_t );
+float32_t extF80_to_f32( extFloat80_t );
+float64_t extF80_to_f64( extFloat80_t );
+float128_t extF80_to_f128( extFloat80_t );
+extFloat80_t extF80_roundToInt( extFloat80_t, uint_fast8_t, bool );
+extFloat80_t extF80_add( extFloat80_t, extFloat80_t );
+extFloat80_t extF80_sub( extFloat80_t, extFloat80_t );
+extFloat80_t extF80_mul( extFloat80_t, extFloat80_t );
+extFloat80_t extF80_div( extFloat80_t, extFloat80_t );
+extFloat80_t extF80_rem( extFloat80_t, extFloat80_t );
+extFloat80_t extF80_sqrt( extFloat80_t );
+bool extF80_eq( extFloat80_t, extFloat80_t );
+bool extF80_le( extFloat80_t, extFloat80_t );
+bool extF80_lt( extFloat80_t, extFloat80_t );
+bool extF80_eq_signaling( extFloat80_t, extFloat80_t );
+bool extF80_le_quiet( extFloat80_t, extFloat80_t );
+bool extF80_lt_quiet( extFloat80_t, extFloat80_t );
+bool extF80_isSignalingNaN( extFloat80_t );
+#endif
+uint_fast32_t extF80M_to_ui32( const extFloat80_t *, uint_fast8_t, bool );
+uint_fast64_t extF80M_to_ui64( const extFloat80_t *, uint_fast8_t, bool );
+int_fast32_t extF80M_to_i32( const extFloat80_t *, uint_fast8_t, bool );
+int_fast64_t extF80M_to_i64( const extFloat80_t *, uint_fast8_t, bool );
+uint_fast32_t extF80M_to_ui32_r_minMag( const extFloat80_t *, bool );
+uint_fast64_t extF80M_to_ui64_r_minMag( const extFloat80_t *, bool );
+int_fast32_t extF80M_to_i32_r_minMag( const extFloat80_t *, bool );
+int_fast64_t extF80M_to_i64_r_minMag( const extFloat80_t *, bool );
+float16_t extF80M_to_f16( const extFloat80_t * );
+float32_t extF80M_to_f32( const extFloat80_t * );
+float64_t extF80M_to_f64( const extFloat80_t * );
+void extF80M_to_f128M( const extFloat80_t *, float128_t * );
+void
+ extF80M_roundToInt(
+ const extFloat80_t *, uint_fast8_t, bool, extFloat80_t * );
+void extF80M_add( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
+void extF80M_sub( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
+void extF80M_mul( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
+void extF80M_div( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
+void extF80M_rem( const extFloat80_t *, const extFloat80_t *, extFloat80_t * );
+void extF80M_sqrt( const extFloat80_t *, extFloat80_t * );
+bool extF80M_eq( const extFloat80_t *, const extFloat80_t * );
+bool extF80M_le( const extFloat80_t *, const extFloat80_t * );
+bool extF80M_lt( const extFloat80_t *, const extFloat80_t * );
+bool extF80M_eq_signaling( const extFloat80_t *, const extFloat80_t * );
+bool extF80M_le_quiet( const extFloat80_t *, const extFloat80_t * );
+bool extF80M_lt_quiet( const extFloat80_t *, const extFloat80_t * );
+bool extF80M_isSignalingNaN( const extFloat80_t * );
+
+/*----------------------------------------------------------------------------
+| 128-bit (quadruple-precision) floating-point operations.
+*----------------------------------------------------------------------------*/
+#ifdef SOFTFLOAT_FAST_INT64
+uint_fast32_t f128_to_ui32( float128_t, uint_fast8_t, bool );
+uint_fast64_t f128_to_ui64( float128_t, uint_fast8_t, bool );
+int_fast32_t f128_to_i32( float128_t, uint_fast8_t, bool );
+int_fast64_t f128_to_i64( float128_t, uint_fast8_t, bool );
+uint_fast32_t f128_to_ui32_r_minMag( float128_t, bool );
+uint_fast64_t f128_to_ui64_r_minMag( float128_t, bool );
+int_fast32_t f128_to_i32_r_minMag( float128_t, bool );
+int_fast64_t f128_to_i64_r_minMag( float128_t, bool );
+float16_t f128_to_f16( float128_t );
+float32_t f128_to_f32( float128_t );
+float64_t f128_to_f64( float128_t );
+extFloat80_t f128_to_extF80( float128_t );
+float128_t f128_roundToInt( float128_t, uint_fast8_t, bool );
+float128_t f128_add( float128_t, float128_t );
+float128_t f128_sub( float128_t, float128_t );
+float128_t f128_mul( float128_t, float128_t );
+float128_t f128_mulAdd( float128_t, float128_t, float128_t );
+float128_t f128_div( float128_t, float128_t );
+float128_t f128_rem( float128_t, float128_t );
+float128_t f128_sqrt( float128_t );
+bool f128_eq( float128_t, float128_t );
+bool f128_le( float128_t, float128_t );
+bool f128_lt( float128_t, float128_t );
+bool f128_eq_signaling( float128_t, float128_t );
+bool f128_le_quiet( float128_t, float128_t );
+bool f128_lt_quiet( float128_t, float128_t );
+bool f128_isSignalingNaN( float128_t );
+#endif
+uint_fast32_t f128M_to_ui32( const float128_t *, uint_fast8_t, bool );
+uint_fast64_t f128M_to_ui64( const float128_t *, uint_fast8_t, bool );
+int_fast32_t f128M_to_i32( const float128_t *, uint_fast8_t, bool );
+int_fast64_t f128M_to_i64( const float128_t *, uint_fast8_t, bool );
+uint_fast32_t f128M_to_ui32_r_minMag( const float128_t *, bool );
+uint_fast64_t f128M_to_ui64_r_minMag( const float128_t *, bool );
+int_fast32_t f128M_to_i32_r_minMag( const float128_t *, bool );
+int_fast64_t f128M_to_i64_r_minMag( const float128_t *, bool );
+float16_t f128M_to_f16( const float128_t * );
+float32_t f128M_to_f32( const float128_t * );
+float64_t f128M_to_f64( const float128_t * );
+void f128M_to_extF80M( const float128_t *, extFloat80_t * );
+void f128M_roundToInt( const float128_t *, uint_fast8_t, bool, float128_t * );
+void f128M_add( const float128_t *, const float128_t *, float128_t * );
+void f128M_sub( const float128_t *, const float128_t *, float128_t * );
+void f128M_mul( const float128_t *, const float128_t *, float128_t * );
+void
+ f128M_mulAdd(
+ const float128_t *, const float128_t *, const float128_t *, float128_t *
+ );
+void f128M_div( const float128_t *, const float128_t *, float128_t * );
+void f128M_rem( const float128_t *, const float128_t *, float128_t * );
+void f128M_sqrt( const float128_t *, float128_t * );
+bool f128M_eq( const float128_t *, const float128_t * );
+bool f128M_le( const float128_t *, const float128_t * );
+bool f128M_lt( const float128_t *, const float128_t * );
+bool f128M_eq_signaling( const float128_t *, const float128_t * );
+bool f128M_le_quiet( const float128_t *, const float128_t * );
+bool f128M_lt_quiet( const float128_t *, const float128_t * );
+bool f128M_isSignalingNaN( const float128_t * );
+
+#endif
+
+/**** ended inlining softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+| Raises the exceptions specified by `flags'. Floating-point traps can be
+| defined here if desired. It is currently not possible for such a trap
+| to substitute a result value. If traps are not implemented, this routine
+| should be simply `softfloat_exceptionFlags |= flags;'.
+*----------------------------------------------------------------------------*/
+void softfloat_raiseFlags( uint_fast8_t flags )
+{
+
+ softfloat_exceptionFlags |= flags;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/softfloat_raiseFlags.c ****/
+/**** start inlining ../../source/8086-SSE/s_f16UIToCommonNaN.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** start inlining specialize.h ****/
+
+/*============================================================================
+
+This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2018 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#ifndef specialize_h
+#define specialize_h 1
+
+#include
+#include
+/**** skipping file: primitiveTypes.h ****/
+/**** skipping file: softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+| Default value for 'softfloat_detectTininess'.
+*----------------------------------------------------------------------------*/
+#define init_detectTininess softfloat_tininess_afterRounding
+
+/*----------------------------------------------------------------------------
+| The values to return on conversions to 32-bit integer formats that raise an
+| invalid exception.
+*----------------------------------------------------------------------------*/
+#define ui32_fromPosOverflow 0xFFFFFFFF
+#define ui32_fromNegOverflow 0xFFFFFFFF
+#define ui32_fromNaN 0xFFFFFFFF
+#define i32_fromPosOverflow (-0x7FFFFFFF - 1)
+#define i32_fromNegOverflow (-0x7FFFFFFF - 1)
+#define i32_fromNaN (-0x7FFFFFFF - 1)
+
+/*----------------------------------------------------------------------------
+| The values to return on conversions to 64-bit integer formats that raise an
+| invalid exception.
+*----------------------------------------------------------------------------*/
+#define ui64_fromPosOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
+#define ui64_fromNegOverflow UINT64_C( 0xFFFFFFFFFFFFFFFF )
+#define ui64_fromNaN UINT64_C( 0xFFFFFFFFFFFFFFFF )
+#define i64_fromPosOverflow (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
+#define i64_fromNegOverflow (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
+#define i64_fromNaN (-INT64_C( 0x7FFFFFFFFFFFFFFF ) - 1)
+
+/*----------------------------------------------------------------------------
+| "Common NaN" structure, used to transfer NaN representations from one format
+| to another.
+*----------------------------------------------------------------------------*/
+struct commonNaN {
+ bool sign;
+#ifdef LITTLEENDIAN
+ uint64_t v0, v64;
+#else
+ uint64_t v64, v0;
+#endif
+};
+
+/*----------------------------------------------------------------------------
+| The bit pattern for a default generated 16-bit floating-point NaN.
+*----------------------------------------------------------------------------*/
+#define defaultNaNF16UI 0xFE00
+
+/*----------------------------------------------------------------------------
+| Returns true when 16-bit unsigned integer 'uiA' has the bit pattern of a
+| 16-bit floating-point signaling NaN.
+| Note: This macro evaluates its argument more than once.
+*----------------------------------------------------------------------------*/
+#define softfloat_isSigNaNF16UI( uiA ) ((((uiA) & 0x7E00) == 0x7C00) && ((uiA) & 0x01FF))
+
+/*----------------------------------------------------------------------------
+| Assuming 'uiA' has the bit pattern of a 16-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr );
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by 'aPtr' into a 16-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr );
+
+/*----------------------------------------------------------------------------
+| Interpreting 'uiA' and 'uiB' as the bit patterns of two 16-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+uint_fast16_t
+ softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB );
+
+/*----------------------------------------------------------------------------
+| The bit pattern for a default generated 32-bit floating-point NaN.
+*----------------------------------------------------------------------------*/
+#define defaultNaNF32UI 0xFFC00000
+
+/*----------------------------------------------------------------------------
+| Returns true when 32-bit unsigned integer 'uiA' has the bit pattern of a
+| 32-bit floating-point signaling NaN.
+| Note: This macro evaluates its argument more than once.
+*----------------------------------------------------------------------------*/
+#define softfloat_isSigNaNF32UI( uiA ) ((((uiA) & 0x7FC00000) == 0x7F800000) && ((uiA) & 0x003FFFFF))
+
+/*----------------------------------------------------------------------------
+| Assuming 'uiA' has the bit pattern of a 32-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr );
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by 'aPtr' into a 32-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr );
+
+/*----------------------------------------------------------------------------
+| Interpreting 'uiA' and 'uiB' as the bit patterns of two 32-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+uint_fast32_t
+ softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB );
+
+/*----------------------------------------------------------------------------
+| The bit pattern for a default generated 64-bit floating-point NaN.
+*----------------------------------------------------------------------------*/
+#define defaultNaNF64UI UINT64_C( 0xFFF8000000000000 )
+
+/*----------------------------------------------------------------------------
+| Returns true when 64-bit unsigned integer 'uiA' has the bit pattern of a
+| 64-bit floating-point signaling NaN.
+| Note: This macro evaluates its argument more than once.
+*----------------------------------------------------------------------------*/
+#define softfloat_isSigNaNF64UI( uiA ) ((((uiA) & UINT64_C( 0x7FF8000000000000 )) == UINT64_C( 0x7FF0000000000000 )) && ((uiA) & UINT64_C( 0x0007FFFFFFFFFFFF )))
+
+/*----------------------------------------------------------------------------
+| Assuming 'uiA' has the bit pattern of a 64-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr );
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by 'aPtr' into a 64-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr );
+
+/*----------------------------------------------------------------------------
+| Interpreting 'uiA' and 'uiB' as the bit patterns of two 64-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either 'uiA' or 'uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+uint_fast64_t
+ softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB );
+
+/*----------------------------------------------------------------------------
+| The bit pattern for a default generated 80-bit extended floating-point NaN.
+*----------------------------------------------------------------------------*/
+#define defaultNaNExtF80UI64 0xFFFF
+#define defaultNaNExtF80UI0 UINT64_C( 0xC000000000000000 )
+
+/*----------------------------------------------------------------------------
+| Returns true when the 80-bit unsigned integer formed from concatenating
+| 16-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of an 80-bit extended
+| floating-point signaling NaN.
+| Note: This macro evaluates its arguments more than once.
+*----------------------------------------------------------------------------*/
+#define softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ((((uiA64) & 0x7FFF) == 0x7FFF) && ! ((uiA0) & UINT64_C( 0x4000000000000000 )) && ((uiA0) & UINT64_C( 0x3FFFFFFFFFFFFFFF )))
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+/*----------------------------------------------------------------------------
+| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
+| defined.
+*----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
+| has the bit pattern of an 80-bit extended floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_extF80UIToCommonNaN(
+ uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
+| floating-point NaN, and returns the bit pattern of this value as an unsigned
+| integer.
+*----------------------------------------------------------------------------*/
+struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr );
+
+/*----------------------------------------------------------------------------
+| Interpreting the unsigned integer formed from concatenating 'uiA64' and
+| 'uiA0' as an 80-bit extended floating-point value, and likewise interpreting
+| the unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
+| 80-bit extended floating-point value, and assuming at least on of these
+| floating-point values is a NaN, returns the bit pattern of the combined NaN
+| result. If either original floating-point value is a signaling NaN, the
+| invalid exception is raised.
+*----------------------------------------------------------------------------*/
+struct uint128
+ softfloat_propagateNaNExtF80UI(
+ uint_fast16_t uiA64,
+ uint_fast64_t uiA0,
+ uint_fast16_t uiB64,
+ uint_fast64_t uiB0
+ );
+
+/*----------------------------------------------------------------------------
+| The bit pattern for a default generated 128-bit floating-point NaN.
+*----------------------------------------------------------------------------*/
+#define defaultNaNF128UI64 UINT64_C( 0xFFFF800000000000 )
+#define defaultNaNF128UI0 UINT64_C( 0 )
+
+/*----------------------------------------------------------------------------
+| Returns true when the 128-bit unsigned integer formed from concatenating
+| 64-bit 'uiA64' and 64-bit 'uiA0' has the bit pattern of a 128-bit floating-
+| point signaling NaN.
+| Note: This macro evaluates its arguments more than once.
+*----------------------------------------------------------------------------*/
+#define softfloat_isSigNaNF128UI( uiA64, uiA0 ) ((((uiA64) & UINT64_C( 0x7FFF800000000000 )) == UINT64_C( 0x7FFF000000000000 )) && ((uiA0) || ((uiA64) & UINT64_C( 0x00007FFFFFFFFFFF ))))
+
+/*----------------------------------------------------------------------------
+| Assuming the unsigned integer formed from concatenating 'uiA64' and 'uiA0'
+| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
+| the common NaN form, and stores the resulting common NaN at the location
+| pointed to by 'zPtr'. If the NaN is a signaling NaN, the invalid exception
+| is raised.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_f128UIToCommonNaN(
+ uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr );
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN * );
+
+/*----------------------------------------------------------------------------
+| Interpreting the unsigned integer formed from concatenating 'uiA64' and
+| 'uiA0' as a 128-bit floating-point value, and likewise interpreting the
+| unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
+| 128-bit floating-point value, and assuming at least on of these floating-
+| point values is a NaN, returns the bit pattern of the combined NaN result.
+| If either original floating-point value is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+struct uint128
+ softfloat_propagateNaNF128UI(
+ uint_fast64_t uiA64,
+ uint_fast64_t uiA0,
+ uint_fast64_t uiB64,
+ uint_fast64_t uiB0
+ );
+
+#else
+
+/*----------------------------------------------------------------------------
+| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
+| defined.
+*----------------------------------------------------------------------------*/
+
+/*----------------------------------------------------------------------------
+| Assuming the 80-bit extended floating-point value pointed to by 'aSPtr' is
+| a NaN, converts this NaN to the common NaN form, and stores the resulting
+| common NaN at the location pointed to by 'zPtr'. If the NaN is a signaling
+| NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_extF80MToCommonNaN(
+ const struct extFloat80M *aSPtr, struct commonNaN *zPtr );
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by 'aPtr' into an 80-bit extended
+| floating-point NaN, and stores this NaN at the location pointed to by
+| 'zSPtr'.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_commonNaNToExtF80M(
+ const struct commonNaN *aPtr, struct extFloat80M *zSPtr );
+
+/*----------------------------------------------------------------------------
+| Assuming at least one of the two 80-bit extended floating-point values
+| pointed to by 'aSPtr' and 'bSPtr' is a NaN, stores the combined NaN result
+| at the location pointed to by 'zSPtr'. If either original floating-point
+| value is a signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_propagateNaNExtF80M(
+ const struct extFloat80M *aSPtr,
+ const struct extFloat80M *bSPtr,
+ struct extFloat80M *zSPtr
+ );
+
+/*----------------------------------------------------------------------------
+| The bit pattern for a default generated 128-bit floating-point NaN.
+*----------------------------------------------------------------------------*/
+#define defaultNaNF128UI96 0xFFFF8000
+#define defaultNaNF128UI64 0
+#define defaultNaNF128UI32 0
+#define defaultNaNF128UI0 0
+
+/*----------------------------------------------------------------------------
+| Assuming the 128-bit floating-point value pointed to by 'aWPtr' is a NaN,
+| converts this NaN to the common NaN form, and stores the resulting common
+| NaN at the location pointed to by 'zPtr'. If the NaN is a signaling NaN,
+| the invalid exception is raised. Argument 'aWPtr' points to an array of
+| four 32-bit elements that concatenate in the platform's normal endian order
+| to form a 128-bit floating-point value.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_f128MToCommonNaN( const uint32_t *aWPtr, struct commonNaN *zPtr );
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by 'aPtr' into a 128-bit floating-point
+| NaN, and stores this NaN at the location pointed to by 'zWPtr'. Argument
+| 'zWPtr' points to an array of four 32-bit elements that concatenate in the
+| platform's normal endian order to form a 128-bit floating-point value.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_commonNaNToF128M( const struct commonNaN *aPtr, uint32_t *zWPtr );
+
+/*----------------------------------------------------------------------------
+| Assuming at least one of the two 128-bit floating-point values pointed to by
+| 'aWPtr' and 'bWPtr' is a NaN, stores the combined NaN result at the location
+| pointed to by 'zWPtr'. If either original floating-point value is a
+| signaling NaN, the invalid exception is raised. Each of 'aWPtr', 'bWPtr',
+| and 'zWPtr' points to an array of four 32-bit elements that concatenate in
+| the platform's normal endian order to form a 128-bit floating-point value.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_propagateNaNF128M(
+ const uint32_t *aWPtr, const uint32_t *bWPtr, uint32_t *zWPtr );
+
+#endif
+
+#endif
+
+/**** ended inlining specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+| Assuming `uiA' has the bit pattern of a 16-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+void softfloat_f16UIToCommonNaN( uint_fast16_t uiA, struct commonNaN *zPtr )
+{
+
+ if ( softfloat_isSigNaNF16UI( uiA ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ }
+ zPtr->sign = uiA>>15;
+ zPtr->v64 = (uint_fast64_t) uiA<<54;
+ zPtr->v0 = 0;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_f16UIToCommonNaN.c ****/
+/**** start inlining ../../source/8086-SSE/s_commonNaNToF16UI.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: specialize.h ****/
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into a 16-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+uint_fast16_t softfloat_commonNaNToF16UI( const struct commonNaN *aPtr )
+{
+
+ return (uint_fast16_t) aPtr->sign<<15 | 0x7E00 | aPtr->v64>>54;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_commonNaNToF16UI.c ****/
+/**** start inlining ../../source/8086-SSE/s_propagateNaNF16UI.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** start inlining internals.h ****/
+
+/*============================================================================
+
+This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#ifndef internals_h
+#define internals_h 1
+
+#include
+#include
+/**** start inlining primitives.h ****/
+
+/*============================================================================
+
+This C header file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#ifndef primitives_h
+#define primitives_h 1
+
+#include
+#include
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_shortShiftRightJam64
+#define softfloat_shortShiftRightJam64 softfloat_shortShiftRightJam64
+/*----------------------------------------------------------------------------
+| Shifts 'a' right by the number of bits given in 'dist', which must be in
+| the range 1 to 63. If any nonzero bits are shifted off, they are "jammed"
+| into the least-significant bit of the shifted value by setting the least-
+| significant bit to 1. This shifted-and-jammed value is returned.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
+INLINE
+uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
+ { return a>>dist | ((a & (((uint_fast64_t) 1<>dist | ((uint32_t) (a<<(-dist & 31)) != 0) : (a != 0);
+}
+#else
+uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist );
+#endif
+#endif
+
+#ifndef softfloat_shiftRightJam64
+#define softfloat_shiftRightJam64 softfloat_shiftRightJam64
+/*----------------------------------------------------------------------------
+| Shifts 'a' right by the number of bits given in 'dist', which must not
+| be zero. If any nonzero bits are shifted off, they are "jammed" into the
+| least-significant bit of the shifted value by setting the least-significant
+| bit to 1. This shifted-and-jammed value is returned.
+| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
+| greater than 64, the result will be either 0 or 1, depending on whether 'a'
+| is zero or nonzero.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
+INLINE uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
+{
+ return
+ (dist < 63) ? a>>dist | ((uint64_t) (a<<(-dist & 63)) != 0) : (a != 0);
+}
+#else
+uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist );
+#endif
+#endif
+
+/*----------------------------------------------------------------------------
+| A constant table that translates an 8-bit unsigned integer (the array index)
+| into the number of leading 0 bits before the most-significant 1 of that
+| integer. For integer zero (index 0), the corresponding table element is 8.
+*----------------------------------------------------------------------------*/
+extern const uint_least8_t softfloat_countLeadingZeros8[256];
+
+#ifndef softfloat_countLeadingZeros16
+#define softfloat_countLeadingZeros16 softfloat_countLeadingZeros16
+/*----------------------------------------------------------------------------
+| Returns the number of leading 0 bits before the most-significant 1 bit of
+| 'a'. If 'a' is zero, 16 is returned.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
+INLINE uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
+{
+ uint_fast8_t count = 8;
+ if ( 0x100 <= a ) {
+ count = 0;
+ a >>= 8;
+ }
+ count += softfloat_countLeadingZeros8[a];
+ return count;
+}
+#else
+uint_fast8_t softfloat_countLeadingZeros16( uint16_t a );
+#endif
+#endif
+
+#ifndef softfloat_countLeadingZeros32
+#define softfloat_countLeadingZeros32 softfloat_countLeadingZeros32
+/*----------------------------------------------------------------------------
+| Returns the number of leading 0 bits before the most-significant 1 bit of
+| 'a'. If 'a' is zero, 32 is returned.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
+INLINE uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
+{
+ uint_fast8_t count = 0;
+ if ( a < 0x10000 ) {
+ count = 16;
+ a <<= 16;
+ }
+ if ( a < 0x1000000 ) {
+ count += 8;
+ a <<= 8;
+ }
+ count += softfloat_countLeadingZeros8[a>>24];
+ return count;
+}
+#else
+uint_fast8_t softfloat_countLeadingZeros32( uint32_t a );
+#endif
+#endif
+
+#ifndef softfloat_countLeadingZeros64
+#define softfloat_countLeadingZeros64 softfloat_countLeadingZeros64
+/*----------------------------------------------------------------------------
+| Returns the number of leading 0 bits before the most-significant 1 bit of
+| 'a'. If 'a' is zero, 64 is returned.
+*----------------------------------------------------------------------------*/
+uint_fast8_t softfloat_countLeadingZeros64( uint64_t a );
+#endif
+
+extern const uint16_t softfloat_approxRecip_1k0s[16];
+extern const uint16_t softfloat_approxRecip_1k1s[16];
+
+#ifndef softfloat_approxRecip32_1
+/*----------------------------------------------------------------------------
+| Returns an approximation to the reciprocal of the number represented by 'a',
+| where 'a' is interpreted as an unsigned fixed-point number with one integer
+| bit and 31 fraction bits. The 'a' input must be "normalized", meaning that
+| its most-significant bit (bit 31) must be 1. Thus, if A is the value of
+| the fixed-point interpretation of 'a', then 1 <= A < 2. The returned value
+| is interpreted as a pure unsigned fraction, having no integer bits and 32
+| fraction bits. The approximation returned is never greater than the true
+| reciprocal 1/A, and it differs from the true reciprocal by at most 2.006 ulp
+| (units in the last place).
+*----------------------------------------------------------------------------*/
+#ifdef SOFTFLOAT_FAST_DIV64TO32
+#define softfloat_approxRecip32_1( a ) ((uint32_t) (UINT64_C( 0x7FFFFFFFFFFFFFFF ) / (uint32_t) (a)))
+#else
+uint32_t softfloat_approxRecip32_1( uint32_t a );
+#endif
+#endif
+
+extern const uint16_t softfloat_approxRecipSqrt_1k0s[16];
+extern const uint16_t softfloat_approxRecipSqrt_1k1s[16];
+
+#ifndef softfloat_approxRecipSqrt32_1
+/*----------------------------------------------------------------------------
+| Returns an approximation to the reciprocal of the square root of the number
+| represented by 'a', where 'a' is interpreted as an unsigned fixed-point
+| number either with one integer bit and 31 fraction bits or with two integer
+| bits and 30 fraction bits. The format of 'a' is determined by 'oddExpA',
+| which must be either 0 or 1. If 'oddExpA' is 1, 'a' is interpreted as
+| having one integer bit, and if 'oddExpA' is 0, 'a' is interpreted as having
+| two integer bits. The 'a' input must be "normalized", meaning that its
+| most-significant bit (bit 31) must be 1. Thus, if A is the value of the
+| fixed-point interpretation of 'a', it follows that 1 <= A < 2 when 'oddExpA'
+| is 1, and 2 <= A < 4 when 'oddExpA' is 0.
+| The returned value is interpreted as a pure unsigned fraction, having
+| no integer bits and 32 fraction bits. The approximation returned is never
+| greater than the true reciprocal 1/sqrt(A), and it differs from the true
+| reciprocal by at most 2.06 ulp (units in the last place). The approximation
+| returned is also always within the range 0.5 to 1; thus, the most-
+| significant bit of the result is always set.
+*----------------------------------------------------------------------------*/
+uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a );
+#endif
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+/*----------------------------------------------------------------------------
+| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is
+| defined.
+*----------------------------------------------------------------------------*/
+
+#ifndef softfloat_eq128
+#define softfloat_eq128 softfloat_eq128
+/*----------------------------------------------------------------------------
+| Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
+| and 'a0' is equal to the 128-bit unsigned integer formed by concatenating
+| 'b64' and 'b0'.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
+INLINE
+bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+ { return (a64 == b64) && (a0 == b0); }
+#else
+bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
+#endif
+#endif
+
+#ifndef softfloat_le128
+#define softfloat_le128 softfloat_le128
+/*----------------------------------------------------------------------------
+| Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
+| and 'a0' is less than or equal to the 128-bit unsigned integer formed by
+| concatenating 'b64' and 'b0'.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
+INLINE
+bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+ { return (a64 < b64) || ((a64 == b64) && (a0 <= b0)); }
+#else
+bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
+#endif
+#endif
+
+#ifndef softfloat_lt128
+#define softfloat_lt128 softfloat_lt128
+/*----------------------------------------------------------------------------
+| Returns true if the 128-bit unsigned integer formed by concatenating 'a64'
+| and 'a0' is less than the 128-bit unsigned integer formed by concatenating
+| 'b64' and 'b0'.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
+INLINE
+bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+ { return (a64 < b64) || ((a64 == b64) && (a0 < b0)); }
+#else
+bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
+#endif
+#endif
+
+#ifndef softfloat_shortShiftLeft128
+#define softfloat_shortShiftLeft128 softfloat_shortShiftLeft128
+/*----------------------------------------------------------------------------
+| Shifts the 128 bits formed by concatenating 'a64' and 'a0' left by the
+| number of bits given in 'dist', which must be in the range 1 to 63.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
+INLINE
+struct uint128
+ softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
+{
+ struct uint128 z;
+ z.v64 = a64<>(-dist & 63);
+ z.v0 = a0<>dist;
+ z.v0 = a64<<(-dist & 63) | a0>>dist;
+ return z;
+}
+#else
+struct uint128
+ softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist );
+#endif
+#endif
+
+#ifndef softfloat_shortShiftRightJam64Extra
+#define softfloat_shortShiftRightJam64Extra softfloat_shortShiftRightJam64Extra
+/*----------------------------------------------------------------------------
+| This function is the same as 'softfloat_shiftRightJam64Extra' (below),
+| except that 'dist' must be in the range 1 to 63.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
+INLINE
+struct uint64_extra
+ softfloat_shortShiftRightJam64Extra(
+ uint64_t a, uint64_t extra, uint_fast8_t dist )
+{
+ struct uint64_extra z;
+ z.v = a>>dist;
+ z.extra = a<<(-dist & 63) | (extra != 0);
+ return z;
+}
+#else
+struct uint64_extra
+ softfloat_shortShiftRightJam64Extra(
+ uint64_t a, uint64_t extra, uint_fast8_t dist );
+#endif
+#endif
+
+#ifndef softfloat_shortShiftRightJam128
+#define softfloat_shortShiftRightJam128 softfloat_shortShiftRightJam128
+/*----------------------------------------------------------------------------
+| Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
+| number of bits given in 'dist', which must be in the range 1 to 63. If any
+| nonzero bits are shifted off, they are "jammed" into the least-significant
+| bit of the shifted value by setting the least-significant bit to 1. This
+| shifted-and-jammed value is returned.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
+INLINE
+struct uint128
+ softfloat_shortShiftRightJam128(
+ uint64_t a64, uint64_t a0, uint_fast8_t dist )
+{
+ uint_fast8_t negDist = -dist;
+ struct uint128 z;
+ z.v64 = a64>>dist;
+ z.v0 =
+ a64<<(negDist & 63) | a0>>dist
+ | ((uint64_t) (a0<<(negDist & 63)) != 0);
+ return z;
+}
+#else
+struct uint128
+ softfloat_shortShiftRightJam128(
+ uint64_t a64, uint64_t a0, uint_fast8_t dist );
+#endif
+#endif
+
+#ifndef softfloat_shortShiftRightJam128Extra
+#define softfloat_shortShiftRightJam128Extra softfloat_shortShiftRightJam128Extra
+/*----------------------------------------------------------------------------
+| This function is the same as 'softfloat_shiftRightJam128Extra' (below),
+| except that 'dist' must be in the range 1 to 63.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
+INLINE
+struct uint128_extra
+ softfloat_shortShiftRightJam128Extra(
+ uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist )
+{
+ uint_fast8_t negDist = -dist;
+ struct uint128_extra z;
+ z.v.v64 = a64>>dist;
+ z.v.v0 = a64<<(negDist & 63) | a0>>dist;
+ z.extra = a0<<(negDist & 63) | (extra != 0);
+ return z;
+}
+#else
+struct uint128_extra
+ softfloat_shortShiftRightJam128Extra(
+ uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist );
+#endif
+#endif
+
+#ifndef softfloat_shiftRightJam64Extra
+#define softfloat_shiftRightJam64Extra softfloat_shiftRightJam64Extra
+/*----------------------------------------------------------------------------
+| Shifts the 128 bits formed by concatenating 'a' and 'extra' right by 64
+| _plus_ the number of bits given in 'dist', which must not be zero. This
+| shifted value is at most 64 nonzero bits and is returned in the 'v' field
+| of the 'struct uint64_extra' result. The 64-bit 'extra' field of the result
+| contains a value formed as follows from the bits that were shifted off: The
+| _last_ bit shifted off is the most-significant bit of the 'extra' field, and
+| the other 63 bits of the 'extra' field are all zero if and only if _all_but_
+| _the_last_ bits shifted off were all zero.
+| (This function makes more sense if 'a' and 'extra' are considered to form
+| an unsigned fixed-point number with binary point between 'a' and 'extra'.
+| This fixed-point value is shifted right by the number of bits given in
+| 'dist', and the integer part of this shifted value is returned in the 'v'
+| field of the result. The fractional part of the shifted value is modified
+| as described above and returned in the 'extra' field of the result.)
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
+INLINE
+struct uint64_extra
+ softfloat_shiftRightJam64Extra(
+ uint64_t a, uint64_t extra, uint_fast32_t dist )
+{
+ struct uint64_extra z;
+ if ( dist < 64 ) {
+ z.v = a>>dist;
+ z.extra = a<<(-dist & 63);
+ } else {
+ z.v = 0;
+ z.extra = (dist == 64) ? a : (a != 0);
+ }
+ z.extra |= (extra != 0);
+ return z;
+}
+#else
+struct uint64_extra
+ softfloat_shiftRightJam64Extra(
+ uint64_t a, uint64_t extra, uint_fast32_t dist );
+#endif
+#endif
+
+#ifndef softfloat_shiftRightJam128
+//#define softfloat_shiftRightJam128 softfloat_shiftRightJam128
+/*----------------------------------------------------------------------------
+| Shifts the 128 bits formed by concatenating 'a64' and 'a0' right by the
+| number of bits given in 'dist', which must not be zero. If any nonzero bits
+| are shifted off, they are "jammed" into the least-significant bit of the
+| shifted value by setting the least-significant bit to 1. This shifted-and-
+| jammed value is returned.
+| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
+| greater than 128, the result will be either 0 or 1, depending on whether the
+| original 128 bits are all zeros.
+*----------------------------------------------------------------------------*/
+struct uint128
+ softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist );
+#endif
+
+#ifndef softfloat_shiftRightJam128Extra
+#define softfloat_shiftRightJam128Extra softfloat_shiftRightJam128Extra
+/*----------------------------------------------------------------------------
+| Shifts the 192 bits formed by concatenating 'a64', 'a0', and 'extra' right
+| by 64 _plus_ the number of bits given in 'dist', which must not be zero.
+| This shifted value is at most 128 nonzero bits and is returned in the 'v'
+| field of the 'struct uint128_extra' result. The 64-bit 'extra' field of the
+| result contains a value formed as follows from the bits that were shifted
+| off: The _last_ bit shifted off is the most-significant bit of the 'extra'
+| field, and the other 63 bits of the 'extra' field are all zero if and only
+| if _all_but_the_last_ bits shifted off were all zero.
+| (This function makes more sense if 'a64', 'a0', and 'extra' are considered
+| to form an unsigned fixed-point number with binary point between 'a0' and
+| 'extra'. This fixed-point value is shifted right by the number of bits
+| given in 'dist', and the integer part of this shifted value is returned
+| in the 'v' field of the result. The fractional part of the shifted value
+| is modified as described above and returned in the 'extra' field of the
+| result.)
+*----------------------------------------------------------------------------*/
+struct uint128_extra
+ softfloat_shiftRightJam128Extra(
+ uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t dist );
+#endif
+
+#ifndef softfloat_shiftRightJam256M
+#define softfloat_shiftRightJam256M softfloat_shiftRightJam256M
+/*----------------------------------------------------------------------------
+| Shifts the 256-bit unsigned integer pointed to by 'aPtr' right by the number
+| of bits given in 'dist', which must not be zero. If any nonzero bits are
+| shifted off, they are "jammed" into the least-significant bit of the shifted
+| value by setting the least-significant bit to 1. This shifted-and-jammed
+| value is stored at the location pointed to by 'zPtr'. Each of 'aPtr' and
+| 'zPtr' points to an array of four 64-bit elements that concatenate in the
+| platform's normal endian order to form a 256-bit integer.
+| The value of 'dist' can be arbitrarily large. In particular, if 'dist'
+| is greater than 256, the stored result will be either 0 or 1, depending on
+| whether the original 256 bits are all zeros.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_shiftRightJam256M(
+ const uint64_t *aPtr, uint_fast32_t dist, uint64_t *zPtr );
+#endif
+
+#ifndef softfloat_add128
+#define softfloat_add128 softfloat_add128
+/*----------------------------------------------------------------------------
+| Returns the sum of the 128-bit integer formed by concatenating 'a64' and
+| 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'. The
+| addition is modulo 2^128, so any carry out is lost.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
+INLINE
+struct uint128
+ softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+{
+ struct uint128 z;
+ z.v0 = a0 + b0;
+ z.v64 = a64 + b64 + (z.v0 < a0);
+ return z;
+}
+#else
+struct uint128
+ softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
+#endif
+#endif
+
+#ifndef softfloat_add256M
+/*----------------------------------------------------------------------------
+| Adds the two 256-bit integers pointed to by 'aPtr' and 'bPtr'. The addition
+| is modulo 2^256, so any carry out is lost. The sum is stored at the
+| location pointed to by 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to
+| an array of four 64-bit elements that concatenate in the platform's normal
+| endian order to form a 256-bit integer.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_add256M(
+ const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr );
+#endif
+
+#ifndef softfloat_sub128
+#define softfloat_sub128 softfloat_sub128
+/*----------------------------------------------------------------------------
+| Returns the difference of the 128-bit integer formed by concatenating 'a64'
+| and 'a0' and the 128-bit integer formed by concatenating 'b64' and 'b0'.
+| The subtraction is modulo 2^128, so any borrow out (carry out) is lost.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
+INLINE
+struct uint128
+ softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+{
+ struct uint128 z;
+ z.v0 = a0 - b0;
+ z.v64 = a64 - b64;
+ z.v64 -= (a0 < b0);
+ return z;
+}
+#else
+struct uint128
+ softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 );
+#endif
+#endif
+
+#ifndef softfloat_sub256M
+/*----------------------------------------------------------------------------
+| Subtracts the 256-bit integer pointed to by 'bPtr' from the 256-bit integer
+| pointed to by 'aPtr'. The addition is modulo 2^256, so any borrow out
+| (carry out) is lost. The difference is stored at the location pointed to
+| by 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to an array of four
+| 64-bit elements that concatenate in the platform's normal endian order to
+| form a 256-bit integer.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_sub256M(
+ const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr );
+#endif
+
+#ifndef softfloat_mul64ByShifted32To128
+/*----------------------------------------------------------------------------
+| Returns the 128-bit product of 'a', 'b', and 2^32.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (3 <= INLINE_LEVEL)
+INLINE struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b )
+{
+ uint_fast64_t mid;
+ struct uint128 z;
+ mid = (uint_fast64_t) (uint32_t) a * b;
+ z.v0 = mid<<32;
+ z.v64 = (uint_fast64_t) (uint32_t) (a>>32) * b + (mid>>32);
+ return z;
+}
+#else
+struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b );
+#endif
+#endif
+
+#ifndef softfloat_mul64To128
+/*----------------------------------------------------------------------------
+| Returns the 128-bit product of 'a' and 'b'.
+*----------------------------------------------------------------------------*/
+struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b );
+#endif
+
+#ifndef softfloat_mul128By32
+/*----------------------------------------------------------------------------
+| Returns the product of the 128-bit integer formed by concatenating 'a64' and
+| 'a0', multiplied by 'b'. The multiplication is modulo 2^128; any overflow
+| bits are discarded.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (4 <= INLINE_LEVEL)
+INLINE
+struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
+{
+ struct uint128 z;
+ uint_fast64_t mid;
+ uint_fast32_t carry;
+ z.v0 = a0 * b;
+ mid = (uint_fast64_t) (uint32_t) (a0>>32) * b;
+ carry = (uint32_t) ((uint_fast32_t) (z.v0>>32) - (uint_fast32_t) mid);
+ z.v64 = a64 * b + (uint_fast32_t) ((mid + carry)>>32);
+ return z;
+}
+#else
+struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b );
+#endif
+#endif
+
+#ifndef softfloat_mul128To256M
+/*----------------------------------------------------------------------------
+| Multiplies the 128-bit unsigned integer formed by concatenating 'a64' and
+| 'a0' by the 128-bit unsigned integer formed by concatenating 'b64' and
+| 'b0'. The 256-bit product is stored at the location pointed to by 'zPtr'.
+| Argument 'zPtr' points to an array of four 64-bit elements that concatenate
+| in the platform's normal endian order to form a 256-bit integer.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_mul128To256M(
+ uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr );
+#endif
+
+#else
+
+/*----------------------------------------------------------------------------
+| The following functions are needed only when 'SOFTFLOAT_FAST_INT64' is not
+| defined.
+*----------------------------------------------------------------------------*/
+
+#ifndef softfloat_compare96M
+/*----------------------------------------------------------------------------
+| Compares the two 96-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
+| Returns -1 if the first integer (A) is less than the second (B); returns 0
+| if the two integers are equal; and returns +1 if the first integer (A)
+| is greater than the second (B). (The result is thus the signum of A - B.)
+| Each of 'aPtr' and 'bPtr' points to an array of three 32-bit elements that
+| concatenate in the platform's normal endian order to form a 96-bit integer.
+*----------------------------------------------------------------------------*/
+int_fast8_t softfloat_compare96M( const uint32_t *aPtr, const uint32_t *bPtr );
+#endif
+
+#ifndef softfloat_compare128M
+/*----------------------------------------------------------------------------
+| Compares the two 128-bit unsigned integers pointed to by 'aPtr' and 'bPtr'.
+| Returns -1 if the first integer (A) is less than the second (B); returns 0
+| if the two integers are equal; and returns +1 if the first integer (A)
+| is greater than the second (B). (The result is thus the signum of A - B.)
+| Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
+| concatenate in the platform's normal endian order to form a 128-bit integer.
+*----------------------------------------------------------------------------*/
+int_fast8_t
+ softfloat_compare128M( const uint32_t *aPtr, const uint32_t *bPtr );
+#endif
+
+#ifndef softfloat_shortShiftLeft64To96M
+/*----------------------------------------------------------------------------
+| Extends 'a' to 96 bits and shifts the value left by the number of bits given
+| in 'dist', which must be in the range 1 to 31. The result is stored at the
+| location pointed to by 'zPtr'. Argument 'zPtr' points to an array of three
+| 32-bit elements that concatenate in the platform's normal endian order to
+| form a 96-bit integer.
+*----------------------------------------------------------------------------*/
+#if defined INLINE_LEVEL && (2 <= INLINE_LEVEL)
+INLINE
+void
+ softfloat_shortShiftLeft64To96M(
+ uint64_t a, uint_fast8_t dist, uint32_t *zPtr )
+{
+ zPtr[indexWord( 3, 0 )] = (uint32_t) a<>= 32 - dist;
+ zPtr[indexWord( 3, 2 )] = a>>32;
+ zPtr[indexWord( 3, 1 )] = a;
+}
+#else
+void
+ softfloat_shortShiftLeft64To96M(
+ uint64_t a, uint_fast8_t dist, uint32_t *zPtr );
+#endif
+#endif
+
+#ifndef softfloat_shortShiftLeftM
+/*----------------------------------------------------------------------------
+| Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
+| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
+| must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
+| shifted N-bit result is stored at the location pointed to by 'zPtr'. Each
+| of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
+| that concatenate in the platform's normal endian order to form an N-bit
+| integer.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_shortShiftLeftM(
+ uint_fast8_t size_words,
+ const uint32_t *aPtr,
+ uint_fast8_t dist,
+ uint32_t *zPtr
+ );
+#endif
+
+#ifndef softfloat_shortShiftLeft96M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_shortShiftLeftM' with
+| 'size_words' = 3 (N = 96).
+*----------------------------------------------------------------------------*/
+#define softfloat_shortShiftLeft96M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 3, aPtr, dist, zPtr )
+#endif
+
+#ifndef softfloat_shortShiftLeft128M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_shortShiftLeftM' with
+| 'size_words' = 4 (N = 128).
+*----------------------------------------------------------------------------*/
+#define softfloat_shortShiftLeft128M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 4, aPtr, dist, zPtr )
+#endif
+
+#ifndef softfloat_shortShiftLeft160M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_shortShiftLeftM' with
+| 'size_words' = 5 (N = 160).
+*----------------------------------------------------------------------------*/
+#define softfloat_shortShiftLeft160M( aPtr, dist, zPtr ) softfloat_shortShiftLeftM( 5, aPtr, dist, zPtr )
+#endif
+
+#ifndef softfloat_shiftLeftM
+/*----------------------------------------------------------------------------
+| Shifts the N-bit unsigned integer pointed to by 'aPtr' left by the number
+| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
+| must not be zero. Any nonzero bits shifted off are lost. The shifted
+| N-bit result is stored at the location pointed to by 'zPtr'. Each of 'aPtr'
+| and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
+| concatenate in the platform's normal endian order to form an N-bit integer.
+| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
+| greater than N, the stored result will be 0.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_shiftLeftM(
+ uint_fast8_t size_words,
+ const uint32_t *aPtr,
+ uint32_t dist,
+ uint32_t *zPtr
+ );
+#endif
+
+#ifndef softfloat_shiftLeft96M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_shiftLeftM' with
+| 'size_words' = 3 (N = 96).
+*----------------------------------------------------------------------------*/
+#define softfloat_shiftLeft96M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 3, aPtr, dist, zPtr )
+#endif
+
+#ifndef softfloat_shiftLeft128M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_shiftLeftM' with
+| 'size_words' = 4 (N = 128).
+*----------------------------------------------------------------------------*/
+#define softfloat_shiftLeft128M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 4, aPtr, dist, zPtr )
+#endif
+
+#ifndef softfloat_shiftLeft160M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_shiftLeftM' with
+| 'size_words' = 5 (N = 160).
+*----------------------------------------------------------------------------*/
+#define softfloat_shiftLeft160M( aPtr, dist, zPtr ) softfloat_shiftLeftM( 5, aPtr, dist, zPtr )
+#endif
+
+#ifndef softfloat_shortShiftRightM
+/*----------------------------------------------------------------------------
+| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
+| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
+| must be in the range 1 to 31. Any nonzero bits shifted off are lost. The
+| shifted N-bit result is stored at the location pointed to by 'zPtr'. Each
+| of 'aPtr' and 'zPtr' points to a 'size_words'-long array of 32-bit elements
+| that concatenate in the platform's normal endian order to form an N-bit
+| integer.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_shortShiftRightM(
+ uint_fast8_t size_words,
+ const uint32_t *aPtr,
+ uint_fast8_t dist,
+ uint32_t *zPtr
+ );
+#endif
+
+#ifndef softfloat_shortShiftRight128M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_shortShiftRightM' with
+| 'size_words' = 4 (N = 128).
+*----------------------------------------------------------------------------*/
+#define softfloat_shortShiftRight128M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 4, aPtr, dist, zPtr )
+#endif
+
+#ifndef softfloat_shortShiftRight160M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_shortShiftRightM' with
+| 'size_words' = 5 (N = 160).
+*----------------------------------------------------------------------------*/
+#define softfloat_shortShiftRight160M( aPtr, dist, zPtr ) softfloat_shortShiftRightM( 5, aPtr, dist, zPtr )
+#endif
+
+#ifndef softfloat_shortShiftRightJamM
+/*----------------------------------------------------------------------------
+| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
+| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
+| must be in the range 1 to 31. If any nonzero bits are shifted off, they are
+| "jammed" into the least-significant bit of the shifted value by setting the
+| least-significant bit to 1. This shifted-and-jammed N-bit result is stored
+| at the location pointed to by 'zPtr'. Each of 'aPtr' and 'zPtr' points
+| to a 'size_words'-long array of 32-bit elements that concatenate in the
+| platform's normal endian order to form an N-bit integer.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_shortShiftRightJamM(
+ uint_fast8_t, const uint32_t *, uint_fast8_t, uint32_t * );
+#endif
+
+#ifndef softfloat_shortShiftRightJam160M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_shortShiftRightJamM' with
+| 'size_words' = 5 (N = 160).
+*----------------------------------------------------------------------------*/
+#define softfloat_shortShiftRightJam160M( aPtr, dist, zPtr ) softfloat_shortShiftRightJamM( 5, aPtr, dist, zPtr )
+#endif
+
+#ifndef softfloat_shiftRightM
+/*----------------------------------------------------------------------------
+| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
+| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
+| must not be zero. Any nonzero bits shifted off are lost. The shifted
+| N-bit result is stored at the location pointed to by 'zPtr'. Each of 'aPtr'
+| and 'zPtr' points to a 'size_words'-long array of 32-bit elements that
+| concatenate in the platform's normal endian order to form an N-bit integer.
+| The value of 'dist' can be arbitrarily large. In particular, if 'dist' is
+| greater than N, the stored result will be 0.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_shiftRightM(
+ uint_fast8_t size_words,
+ const uint32_t *aPtr,
+ uint32_t dist,
+ uint32_t *zPtr
+ );
+#endif
+
+#ifndef softfloat_shiftRight96M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_shiftRightM' with
+| 'size_words' = 3 (N = 96).
+*----------------------------------------------------------------------------*/
+#define softfloat_shiftRight96M( aPtr, dist, zPtr ) softfloat_shiftRightM( 3, aPtr, dist, zPtr )
+#endif
+
+#ifndef softfloat_shiftRightJamM
+/*----------------------------------------------------------------------------
+| Shifts the N-bit unsigned integer pointed to by 'aPtr' right by the number
+| of bits given in 'dist', where N = 'size_words' * 32. The value of 'dist'
+| must not be zero. If any nonzero bits are shifted off, they are "jammed"
+| into the least-significant bit of the shifted value by setting the least-
+| significant bit to 1. This shifted-and-jammed N-bit result is stored
+| at the location pointed to by 'zPtr'. Each of 'aPtr' and 'zPtr' points
+| to a 'size_words'-long array of 32-bit elements that concatenate in the
+| platform's normal endian order to form an N-bit integer.
+| The value of 'dist' can be arbitrarily large. In particular, if 'dist'
+| is greater than N, the stored result will be either 0 or 1, depending on
+| whether the original N bits are all zeros.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_shiftRightJamM(
+ uint_fast8_t size_words,
+ const uint32_t *aPtr,
+ uint32_t dist,
+ uint32_t *zPtr
+ );
+#endif
+
+#ifndef softfloat_shiftRightJam96M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_shiftRightJamM' with
+| 'size_words' = 3 (N = 96).
+*----------------------------------------------------------------------------*/
+#define softfloat_shiftRightJam96M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 3, aPtr, dist, zPtr )
+#endif
+
+#ifndef softfloat_shiftRightJam128M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_shiftRightJamM' with
+| 'size_words' = 4 (N = 128).
+*----------------------------------------------------------------------------*/
+#define softfloat_shiftRightJam128M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 4, aPtr, dist, zPtr )
+#endif
+
+#ifndef softfloat_shiftRightJam160M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_shiftRightJamM' with
+| 'size_words' = 5 (N = 160).
+*----------------------------------------------------------------------------*/
+#define softfloat_shiftRightJam160M( aPtr, dist, zPtr ) softfloat_shiftRightJamM( 5, aPtr, dist, zPtr )
+#endif
+
+#ifndef softfloat_addM
+/*----------------------------------------------------------------------------
+| Adds the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
+| 'size_words' * 32. The addition is modulo 2^N, so any carry out is lost.
+| The N-bit sum is stored at the location pointed to by 'zPtr'. Each of
+| 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long array of 32-bit
+| elements that concatenate in the platform's normal endian order to form an
+| N-bit integer.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_addM(
+ uint_fast8_t size_words,
+ const uint32_t *aPtr,
+ const uint32_t *bPtr,
+ uint32_t *zPtr
+ );
+#endif
+
+#ifndef softfloat_add96M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_addM' with 'size_words'
+| = 3 (N = 96).
+*----------------------------------------------------------------------------*/
+#define softfloat_add96M( aPtr, bPtr, zPtr ) softfloat_addM( 3, aPtr, bPtr, zPtr )
+#endif
+
+#ifndef softfloat_add128M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_addM' with 'size_words'
+| = 4 (N = 128).
+*----------------------------------------------------------------------------*/
+#define softfloat_add128M( aPtr, bPtr, zPtr ) softfloat_addM( 4, aPtr, bPtr, zPtr )
+#endif
+
+#ifndef softfloat_add160M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_addM' with 'size_words'
+| = 5 (N = 160).
+*----------------------------------------------------------------------------*/
+#define softfloat_add160M( aPtr, bPtr, zPtr ) softfloat_addM( 5, aPtr, bPtr, zPtr )
+#endif
+
+#ifndef softfloat_addCarryM
+/*----------------------------------------------------------------------------
+| Adds the two N-bit unsigned integers pointed to by 'aPtr' and 'bPtr', where
+| N = 'size_words' * 32, plus 'carry', which must be either 0 or 1. The N-bit
+| sum (modulo 2^N) is stored at the location pointed to by 'zPtr', and any
+| carry out is returned as the result. Each of 'aPtr', 'bPtr', and 'zPtr'
+| points to a 'size_words'-long array of 32-bit elements that concatenate in
+| the platform's normal endian order to form an N-bit integer.
+*----------------------------------------------------------------------------*/
+uint_fast8_t
+ softfloat_addCarryM(
+ uint_fast8_t size_words,
+ const uint32_t *aPtr,
+ const uint32_t *bPtr,
+ uint_fast8_t carry,
+ uint32_t *zPtr
+ );
+#endif
+
+#ifndef softfloat_addComplCarryM
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_addCarryM', except that
+| the value of the unsigned integer pointed to by 'bPtr' is bit-wise completed
+| before the addition.
+*----------------------------------------------------------------------------*/
+uint_fast8_t
+ softfloat_addComplCarryM(
+ uint_fast8_t size_words,
+ const uint32_t *aPtr,
+ const uint32_t *bPtr,
+ uint_fast8_t carry,
+ uint32_t *zPtr
+ );
+#endif
+
+#ifndef softfloat_addComplCarry96M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_addComplCarryM' with
+| 'size_words' = 3 (N = 96).
+*----------------------------------------------------------------------------*/
+#define softfloat_addComplCarry96M( aPtr, bPtr, carry, zPtr ) softfloat_addComplCarryM( 3, aPtr, bPtr, carry, zPtr )
+#endif
+
+#ifndef softfloat_negXM
+/*----------------------------------------------------------------------------
+| Replaces the N-bit unsigned integer pointed to by 'zPtr' by the
+| 2s-complement of itself, where N = 'size_words' * 32. Argument 'zPtr'
+| points to a 'size_words'-long array of 32-bit elements that concatenate in
+| the platform's normal endian order to form an N-bit integer.
+*----------------------------------------------------------------------------*/
+void softfloat_negXM( uint_fast8_t size_words, uint32_t *zPtr );
+#endif
+
+#ifndef softfloat_negX96M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_negXM' with 'size_words'
+| = 3 (N = 96).
+*----------------------------------------------------------------------------*/
+#define softfloat_negX96M( zPtr ) softfloat_negXM( 3, zPtr )
+#endif
+
+#ifndef softfloat_negX128M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_negXM' with 'size_words'
+| = 4 (N = 128).
+*----------------------------------------------------------------------------*/
+#define softfloat_negX128M( zPtr ) softfloat_negXM( 4, zPtr )
+#endif
+
+#ifndef softfloat_negX160M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_negXM' with 'size_words'
+| = 5 (N = 160).
+*----------------------------------------------------------------------------*/
+#define softfloat_negX160M( zPtr ) softfloat_negXM( 5, zPtr )
+#endif
+
+#ifndef softfloat_negX256M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_negXM' with 'size_words'
+| = 8 (N = 256).
+*----------------------------------------------------------------------------*/
+#define softfloat_negX256M( zPtr ) softfloat_negXM( 8, zPtr )
+#endif
+
+#ifndef softfloat_sub1XM
+/*----------------------------------------------------------------------------
+| Subtracts 1 from the N-bit integer pointed to by 'zPtr', where N =
+| 'size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry
+| out) is lost. Argument 'zPtr' points to a 'size_words'-long array of 32-bit
+| elements that concatenate in the platform's normal endian order to form an
+| N-bit integer.
+*----------------------------------------------------------------------------*/
+void softfloat_sub1XM( uint_fast8_t size_words, uint32_t *zPtr );
+#endif
+
+#ifndef softfloat_sub1X96M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
+| = 3 (N = 96).
+*----------------------------------------------------------------------------*/
+#define softfloat_sub1X96M( zPtr ) softfloat_sub1XM( 3, zPtr )
+#endif
+
+#ifndef softfloat_sub1X160M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_sub1XM' with 'size_words'
+| = 5 (N = 160).
+*----------------------------------------------------------------------------*/
+#define softfloat_sub1X160M( zPtr ) softfloat_sub1XM( 5, zPtr )
+#endif
+
+#ifndef softfloat_subM
+/*----------------------------------------------------------------------------
+| Subtracts the two N-bit integers pointed to by 'aPtr' and 'bPtr', where N =
+| 'size_words' * 32. The subtraction is modulo 2^N, so any borrow out (carry
+| out) is lost. The N-bit difference is stored at the location pointed to by
+| 'zPtr'. Each of 'aPtr', 'bPtr', and 'zPtr' points to a 'size_words'-long
+| array of 32-bit elements that concatenate in the platform's normal endian
+| order to form an N-bit integer.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_subM(
+ uint_fast8_t size_words,
+ const uint32_t *aPtr,
+ const uint32_t *bPtr,
+ uint32_t *zPtr
+ );
+#endif
+
+#ifndef softfloat_sub96M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_subM' with 'size_words'
+| = 3 (N = 96).
+*----------------------------------------------------------------------------*/
+#define softfloat_sub96M( aPtr, bPtr, zPtr ) softfloat_subM( 3, aPtr, bPtr, zPtr )
+#endif
+
+#ifndef softfloat_sub128M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_subM' with 'size_words'
+| = 4 (N = 128).
+*----------------------------------------------------------------------------*/
+#define softfloat_sub128M( aPtr, bPtr, zPtr ) softfloat_subM( 4, aPtr, bPtr, zPtr )
+#endif
+
+#ifndef softfloat_sub160M
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_subM' with 'size_words'
+| = 5 (N = 160).
+*----------------------------------------------------------------------------*/
+#define softfloat_sub160M( aPtr, bPtr, zPtr ) softfloat_subM( 5, aPtr, bPtr, zPtr )
+#endif
+
+#ifndef softfloat_mul64To128M
+/*----------------------------------------------------------------------------
+| Multiplies 'a' and 'b' and stores the 128-bit product at the location
+| pointed to by 'zPtr'. Argument 'zPtr' points to an array of four 32-bit
+| elements that concatenate in the platform's normal endian order to form a
+| 128-bit integer.
+*----------------------------------------------------------------------------*/
+void softfloat_mul64To128M( uint64_t a, uint64_t b, uint32_t *zPtr );
+#endif
+
+#ifndef softfloat_mul128MTo256M
+/*----------------------------------------------------------------------------
+| Multiplies the two 128-bit unsigned integers pointed to by 'aPtr' and
+| 'bPtr', and stores the 256-bit product at the location pointed to by 'zPtr'.
+| Each of 'aPtr' and 'bPtr' points to an array of four 32-bit elements that
+| concatenate in the platform's normal endian order to form a 128-bit integer.
+| Argument 'zPtr' points to an array of eight 32-bit elements that concatenate
+| to form a 256-bit integer.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_mul128MTo256M(
+ const uint32_t *aPtr, const uint32_t *bPtr, uint32_t *zPtr );
+#endif
+
+#ifndef softfloat_remStepMBy32
+/*----------------------------------------------------------------------------
+| Performs a "remainder reduction step" as follows: Arguments 'remPtr' and
+| 'bPtr' both point to N-bit unsigned integers, where N = 'size_words' * 32.
+| Defining R and B as the values of those integers, the expression (R<<'dist')
+| - B * q is computed modulo 2^N, and the N-bit result is stored at the
+| location pointed to by 'zPtr'. Each of 'remPtr', 'bPtr', and 'zPtr' points
+| to a 'size_words'-long array of 32-bit elements that concatenate in the
+| platform's normal endian order to form an N-bit integer.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_remStepMBy32(
+ uint_fast8_t size_words,
+ const uint32_t *remPtr,
+ uint_fast8_t dist,
+ const uint32_t *bPtr,
+ uint32_t q,
+ uint32_t *zPtr
+ );
+#endif
+
+#ifndef softfloat_remStep96MBy32
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_remStepMBy32' with
+| 'size_words' = 3 (N = 96).
+*----------------------------------------------------------------------------*/
+#define softfloat_remStep96MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 3, remPtr, dist, bPtr, q, zPtr )
+#endif
+
+#ifndef softfloat_remStep128MBy32
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_remStepMBy32' with
+| 'size_words' = 4 (N = 128).
+*----------------------------------------------------------------------------*/
+#define softfloat_remStep128MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 4, remPtr, dist, bPtr, q, zPtr )
+#endif
+
+#ifndef softfloat_remStep160MBy32
+/*----------------------------------------------------------------------------
+| This function or macro is the same as 'softfloat_remStepMBy32' with
+| 'size_words' = 5 (N = 160).
+*----------------------------------------------------------------------------*/
+#define softfloat_remStep160MBy32( remPtr, dist, bPtr, q, zPtr ) softfloat_remStepMBy32( 5, remPtr, dist, bPtr, q, zPtr )
+#endif
+
+#endif
+
+#endif
+
+/**** ended inlining primitives.h ****/
+/**** skipping file: softfloat_types.h ****/
+
+union ui16_f16 { uint16_t ui; float16_t f; };
+union ui32_f32 { uint32_t ui; float32_t f; };
+union ui64_f64 { uint64_t ui; float64_t f; };
+
+#ifdef SOFTFLOAT_FAST_INT64
+union extF80M_extF80 { struct extFloat80M fM; extFloat80_t f; };
+union ui128_f128 { struct uint128 ui; float128_t f; };
+#endif
+
+enum {
+ softfloat_mulAdd_subC = 1,
+ softfloat_mulAdd_subProd = 2
+};
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+uint_fast32_t softfloat_roundToUI32( bool, uint_fast64_t, uint_fast8_t, bool );
+
+#ifdef SOFTFLOAT_FAST_INT64
+uint_fast64_t
+ softfloat_roundToUI64(
+ bool, uint_fast64_t, uint_fast64_t, uint_fast8_t, bool );
+#else
+uint_fast64_t softfloat_roundMToUI64( bool, uint32_t *, uint_fast8_t, bool );
+#endif
+
+int_fast32_t softfloat_roundToI32( bool, uint_fast64_t, uint_fast8_t, bool );
+
+#ifdef SOFTFLOAT_FAST_INT64
+int_fast64_t
+ softfloat_roundToI64(
+ bool, uint_fast64_t, uint_fast64_t, uint_fast8_t, bool );
+#else
+int_fast64_t softfloat_roundMToI64( bool, uint32_t *, uint_fast8_t, bool );
+#endif
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+#define signF16UI( a ) ((bool) ((uint16_t) (a)>>15))
+#define expF16UI( a ) ((int_fast8_t) ((a)>>10) & 0x1F)
+#define fracF16UI( a ) ((a) & 0x03FF)
+#define packToF16UI( sign, exp, sig ) (((uint16_t) (sign)<<15) + ((uint16_t) (exp)<<10) + (sig))
+
+#define isNaNF16UI( a ) (((~(a) & 0x7C00) == 0) && ((a) & 0x03FF))
+
+struct exp8_sig16 { int_fast8_t exp; uint_fast16_t sig; };
+struct exp8_sig16 softfloat_normSubnormalF16Sig( uint_fast16_t );
+
+float16_t softfloat_roundPackToF16( bool, int_fast16_t, uint_fast16_t );
+float16_t softfloat_normRoundPackToF16( bool, int_fast16_t, uint_fast16_t );
+
+float16_t softfloat_addMagsF16( uint_fast16_t, uint_fast16_t );
+float16_t softfloat_subMagsF16( uint_fast16_t, uint_fast16_t );
+float16_t
+ softfloat_mulAddF16(
+ uint_fast16_t, uint_fast16_t, uint_fast16_t, uint_fast8_t );
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+#define signF32UI( a ) ((bool) ((uint32_t) (a)>>31))
+#define expF32UI( a ) ((int_fast16_t) ((a)>>23) & 0xFF)
+#define fracF32UI( a ) ((a) & 0x007FFFFF)
+#define packToF32UI( sign, exp, sig ) (((uint32_t) (sign)<<31) + ((uint32_t) (exp)<<23) + (sig))
+
+#define isNaNF32UI( a ) (((~(a) & 0x7F800000) == 0) && ((a) & 0x007FFFFF))
+
+struct exp16_sig32 { int_fast16_t exp; uint_fast32_t sig; };
+struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t );
+
+float32_t softfloat_roundPackToF32( bool, int_fast16_t, uint_fast32_t );
+float32_t softfloat_normRoundPackToF32( bool, int_fast16_t, uint_fast32_t );
+
+float32_t softfloat_addMagsF32( uint_fast32_t, uint_fast32_t );
+float32_t softfloat_subMagsF32( uint_fast32_t, uint_fast32_t );
+float32_t
+ softfloat_mulAddF32(
+ uint_fast32_t, uint_fast32_t, uint_fast32_t, uint_fast8_t );
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+#define signF64UI( a ) ((bool) ((uint64_t) (a)>>63))
+#define expF64UI( a ) ((int_fast16_t) ((a)>>52) & 0x7FF)
+#define fracF64UI( a ) ((a) & UINT64_C( 0x000FFFFFFFFFFFFF ))
+#define packToF64UI( sign, exp, sig ) ((uint64_t) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<52) + (sig)))
+
+#define isNaNF64UI( a ) (((~(a) & UINT64_C( 0x7FF0000000000000 )) == 0) && ((a) & UINT64_C( 0x000FFFFFFFFFFFFF )))
+
+struct exp16_sig64 { int_fast16_t exp; uint_fast64_t sig; };
+struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t );
+
+float64_t softfloat_roundPackToF64( bool, int_fast16_t, uint_fast64_t );
+float64_t softfloat_normRoundPackToF64( bool, int_fast16_t, uint_fast64_t );
+
+float64_t softfloat_addMagsF64( uint_fast64_t, uint_fast64_t, bool );
+float64_t softfloat_subMagsF64( uint_fast64_t, uint_fast64_t, bool );
+float64_t
+ softfloat_mulAddF64(
+ uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+#define signExtF80UI64( a64 ) ((bool) ((uint16_t) (a64)>>15))
+#define expExtF80UI64( a64 ) ((a64) & 0x7FFF)
+#define packToExtF80UI64( sign, exp ) ((uint_fast16_t) (sign)<<15 | (exp))
+
+#define isNaNExtF80UI( a64, a0 ) ((((a64) & 0x7FFF) == 0x7FFF) && ((a0) & UINT64_C( 0x7FFFFFFFFFFFFFFF )))
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+
+struct exp32_sig64 { int_fast32_t exp; uint64_t sig; };
+struct exp32_sig64 softfloat_normSubnormalExtF80Sig( uint_fast64_t );
+
+extFloat80_t
+ softfloat_roundPackToExtF80(
+ bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
+extFloat80_t
+ softfloat_normRoundPackToExtF80(
+ bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast8_t );
+
+extFloat80_t
+ softfloat_addMagsExtF80(
+ uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
+extFloat80_t
+ softfloat_subMagsExtF80(
+ uint_fast16_t, uint_fast64_t, uint_fast16_t, uint_fast64_t, bool );
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+#define signF128UI64( a64 ) ((bool) ((uint64_t) (a64)>>63))
+#define expF128UI64( a64 ) ((int_fast32_t) ((a64)>>48) & 0x7FFF)
+#define fracF128UI64( a64 ) ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))
+#define packToF128UI64( sign, exp, sig64 ) (((uint_fast64_t) (sign)<<63) + ((uint_fast64_t) (exp)<<48) + (sig64))
+
+#define isNaNF128UI( a64, a0 ) (((~(a64) & UINT64_C( 0x7FFF000000000000 )) == 0) && (a0 || ((a64) & UINT64_C( 0x0000FFFFFFFFFFFF ))))
+
+struct exp32_sig128 { int_fast32_t exp; struct uint128 sig; };
+struct exp32_sig128
+ softfloat_normSubnormalF128Sig( uint_fast64_t, uint_fast64_t );
+
+float128_t
+ softfloat_roundPackToF128(
+ bool, int_fast32_t, uint_fast64_t, uint_fast64_t, uint_fast64_t );
+float128_t
+ softfloat_normRoundPackToF128(
+ bool, int_fast32_t, uint_fast64_t, uint_fast64_t );
+
+float128_t
+ softfloat_addMagsF128(
+ uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
+float128_t
+ softfloat_subMagsF128(
+ uint_fast64_t, uint_fast64_t, uint_fast64_t, uint_fast64_t, bool );
+float128_t
+ softfloat_mulAddF128(
+ uint_fast64_t,
+ uint_fast64_t,
+ uint_fast64_t,
+ uint_fast64_t,
+ uint_fast64_t,
+ uint_fast64_t,
+ uint_fast8_t
+ );
+
+#else
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+
+bool
+ softfloat_tryPropagateNaNExtF80M(
+ const struct extFloat80M *,
+ const struct extFloat80M *,
+ struct extFloat80M *
+ );
+void softfloat_invalidExtF80M( struct extFloat80M * );
+
+int softfloat_normExtF80SigM( uint64_t * );
+
+void
+ softfloat_roundPackMToExtF80M(
+ bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M * );
+void
+ softfloat_normRoundPackMToExtF80M(
+ bool, int32_t, uint32_t *, uint_fast8_t, struct extFloat80M * );
+
+void
+ softfloat_addExtF80M(
+ const struct extFloat80M *,
+ const struct extFloat80M *,
+ struct extFloat80M *,
+ bool
+ );
+
+int
+ softfloat_compareNonnormExtF80M(
+ const struct extFloat80M *, const struct extFloat80M * );
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+#define signF128UI96( a96 ) ((bool) ((uint32_t) (a96)>>31))
+#define expF128UI96( a96 ) ((int32_t) ((a96)>>16) & 0x7FFF)
+#define fracF128UI96( a96 ) ((a96) & 0x0000FFFF)
+#define packToF128UI96( sign, exp, sig96 ) (((uint32_t) (sign)<<31) + ((uint32_t) (exp)<<16) + (sig96))
+
+bool softfloat_isNaNF128M( const uint32_t * );
+
+bool
+ softfloat_tryPropagateNaNF128M(
+ const uint32_t *, const uint32_t *, uint32_t * );
+void softfloat_invalidF128M( uint32_t * );
+
+int softfloat_shiftNormSigF128M( const uint32_t *, uint_fast8_t, uint32_t * );
+
+void softfloat_roundPackMToF128M( bool, int32_t, uint32_t *, uint32_t * );
+void softfloat_normRoundPackMToF128M( bool, int32_t, uint32_t *, uint32_t * );
+
+void
+ softfloat_addF128M( const uint32_t *, const uint32_t *, uint32_t *, bool );
+void
+ softfloat_mulAddF128M(
+ const uint32_t *,
+ const uint32_t *,
+ const uint32_t *,
+ uint32_t *,
+ uint_fast8_t
+ );
+
+#endif
+
+#endif
+
+/**** ended inlining internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+| Interpreting `uiA' and `uiB' as the bit patterns of two 16-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+uint_fast16_t
+ softfloat_propagateNaNF16UI( uint_fast16_t uiA, uint_fast16_t uiB )
+{
+ bool isSigNaNA;
+
+ isSigNaNA = softfloat_isSigNaNF16UI( uiA );
+ if ( isSigNaNA || softfloat_isSigNaNF16UI( uiB ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ if ( isSigNaNA ) return uiA | 0x0200;
+ }
+ return (isNaNF16UI( uiA ) ? uiA : uiB) | 0x0200;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_propagateNaNF16UI.c ****/
+/**** start inlining ../../source/8086-SSE/s_f32UIToCommonNaN.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+| Assuming `uiA' has the bit pattern of a 32-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+void softfloat_f32UIToCommonNaN( uint_fast32_t uiA, struct commonNaN *zPtr )
+{
+
+ if ( softfloat_isSigNaNF32UI( uiA ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ }
+ zPtr->sign = uiA>>31;
+ zPtr->v64 = (uint_fast64_t) uiA<<41;
+ zPtr->v0 = 0;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_f32UIToCommonNaN.c ****/
+/**** start inlining ../../source/8086-SSE/s_commonNaNToF32UI.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: specialize.h ****/
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into a 32-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+uint_fast32_t softfloat_commonNaNToF32UI( const struct commonNaN *aPtr )
+{
+
+ return (uint_fast32_t) aPtr->sign<<31 | 0x7FC00000 | aPtr->v64>>41;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_commonNaNToF32UI.c ****/
+/**** start inlining ../../source/8086-SSE/s_propagateNaNF32UI.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+| Interpreting `uiA' and `uiB' as the bit patterns of two 32-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+uint_fast32_t
+ softfloat_propagateNaNF32UI( uint_fast32_t uiA, uint_fast32_t uiB )
+{
+ bool isSigNaNA;
+
+ isSigNaNA = softfloat_isSigNaNF32UI( uiA );
+ if ( isSigNaNA || softfloat_isSigNaNF32UI( uiB ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ if ( isSigNaNA ) return uiA | 0x00400000;
+ }
+ return (isNaNF32UI( uiA ) ? uiA : uiB) | 0x00400000;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_propagateNaNF32UI.c ****/
+/**** start inlining ../../source/8086-SSE/s_f64UIToCommonNaN.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+| Assuming `uiA' has the bit pattern of a 64-bit floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+void softfloat_f64UIToCommonNaN( uint_fast64_t uiA, struct commonNaN *zPtr )
+{
+
+ if ( softfloat_isSigNaNF64UI( uiA ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ }
+ zPtr->sign = uiA>>63;
+ zPtr->v64 = uiA<<12;
+ zPtr->v0 = 0;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_f64UIToCommonNaN.c ****/
+/**** start inlining ../../source/8086-SSE/s_commonNaNToF64UI.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: specialize.h ****/
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into a 64-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+uint_fast64_t softfloat_commonNaNToF64UI( const struct commonNaN *aPtr )
+{
+
+ return
+ (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FF8000000000000 )
+ | aPtr->v64>>12;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_commonNaNToF64UI.c ****/
+/**** start inlining ../../source/8086-SSE/s_propagateNaNF64UI.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+| Interpreting `uiA' and `uiB' as the bit patterns of two 64-bit floating-
+| point values, at least one of which is a NaN, returns the bit pattern of
+| the combined NaN result. If either `uiA' or `uiB' has the pattern of a
+| signaling NaN, the invalid exception is raised.
+*----------------------------------------------------------------------------*/
+uint_fast64_t
+ softfloat_propagateNaNF64UI( uint_fast64_t uiA, uint_fast64_t uiB )
+{
+ bool isSigNaNA;
+
+ isSigNaNA = softfloat_isSigNaNF64UI( uiA );
+ if ( isSigNaNA || softfloat_isSigNaNF64UI( uiB ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ if ( isSigNaNA ) return uiA | UINT64_C( 0x0008000000000000 );
+ }
+ return (isNaNF64UI( uiA ) ? uiA : uiB) | UINT64_C( 0x0008000000000000 );
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_propagateNaNF64UI.c ****/
+/**** start inlining ../../source/8086-SSE/extF80M_isSignalingNaN.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+bool extF80M_isSignalingNaN( const extFloat80_t *aPtr )
+{
+ const struct extFloat80M *aSPtr;
+ uint64_t uiA0;
+
+ aSPtr = (const struct extFloat80M *) aPtr;
+ if ( (aSPtr->signExp & 0x7FFF) != 0x7FFF ) return false;
+ uiA0 = aSPtr->signif;
+ return
+ ! (uiA0 & UINT64_C( 0x4000000000000000 ))
+ && (uiA0 & UINT64_C( 0x3FFFFFFFFFFFFFFF));
+
+}
+
+/**** ended inlining ../../source/8086-SSE/extF80M_isSignalingNaN.c ****/
+/**** start inlining ../../source/8086-SSE/s_extF80UIToCommonNaN.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
+| has the bit pattern of an 80-bit extended floating-point NaN, converts
+| this NaN to the common NaN form, and stores the resulting common NaN at the
+| location pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_extF80UIToCommonNaN(
+ uint_fast16_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
+{
+
+ if ( softfloat_isSigNaNExtF80UI( uiA64, uiA0 ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ }
+ zPtr->sign = uiA64>>15;
+ zPtr->v64 = uiA0<<1;
+ zPtr->v0 = 0;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_extF80UIToCommonNaN.c ****/
+/**** start inlining ../../source/8086-SSE/s_commonNaNToExtF80UI.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitives.h ****/
+/**** skipping file: specialize.h ****/
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into an 80-bit extended
+| floating-point NaN, and returns the bit pattern of this value as an unsigned
+| integer.
+*----------------------------------------------------------------------------*/
+struct uint128 softfloat_commonNaNToExtF80UI( const struct commonNaN *aPtr )
+{
+ struct uint128 uiZ;
+
+ uiZ.v64 = (uint_fast16_t) aPtr->sign<<15 | 0x7FFF;
+ uiZ.v0 = UINT64_C( 0xC000000000000000 ) | aPtr->v64>>1;
+ return uiZ;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_commonNaNToExtF80UI.c ****/
+/**** start inlining ../../source/8086-SSE/s_propagateNaNExtF80UI.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2018 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+| Interpreting the unsigned integer formed from concatenating 'uiA64' and
+| 'uiA0' as an 80-bit extended floating-point value, and likewise interpreting
+| the unsigned integer formed from concatenating 'uiB64' and 'uiB0' as another
+| 80-bit extended floating-point value, and assuming at least on of these
+| floating-point values is a NaN, returns the bit pattern of the combined NaN
+| result. If either original floating-point value is a signaling NaN, the
+| invalid exception is raised.
+*----------------------------------------------------------------------------*/
+struct uint128
+ softfloat_propagateNaNExtF80UI(
+ uint_fast16_t uiA64,
+ uint_fast64_t uiA0,
+ uint_fast16_t uiB64,
+ uint_fast64_t uiB0
+ )
+{
+ bool isSigNaNA, isSigNaNB;
+ uint_fast64_t uiNonsigA0, uiNonsigB0;
+ uint_fast16_t uiMagA64, uiMagB64;
+ struct uint128 uiZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ isSigNaNA = softfloat_isSigNaNExtF80UI( uiA64, uiA0 );
+ isSigNaNB = softfloat_isSigNaNExtF80UI( uiB64, uiB0 );
+ /*------------------------------------------------------------------------
+ | Make NaNs non-signaling.
+ *------------------------------------------------------------------------*/
+ uiNonsigA0 = uiA0 | UINT64_C( 0xC000000000000000 );
+ uiNonsigB0 = uiB0 | UINT64_C( 0xC000000000000000 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( isSigNaNA | isSigNaNB ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ if ( isSigNaNA ) {
+ if ( isSigNaNB ) goto returnLargerMag;
+ if ( isNaNExtF80UI( uiB64, uiB0 ) ) goto returnB;
+ goto returnA;
+ } else {
+ if ( isNaNExtF80UI( uiA64, uiA0 ) ) goto returnA;
+ goto returnB;
+ }
+ }
+ returnLargerMag:
+ uiMagA64 = uiA64 & 0x7FFF;
+ uiMagB64 = uiB64 & 0x7FFF;
+ if ( uiMagA64 < uiMagB64 ) goto returnB;
+ if ( uiMagB64 < uiMagA64 ) goto returnA;
+ if ( uiA0 < uiB0 ) goto returnB;
+ if ( uiB0 < uiA0 ) goto returnA;
+ if ( uiA64 < uiB64 ) goto returnA;
+ returnB:
+ uiZ.v64 = uiB64;
+ uiZ.v0 = uiNonsigB0;
+ return uiZ;
+ returnA:
+ uiZ.v64 = uiA64;
+ uiZ.v0 = uiNonsigA0;
+ return uiZ;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_propagateNaNExtF80UI.c ****/
+/**** start inlining ../../source/8086-SSE/f128M_isSignalingNaN.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitives.h ****/
+/**** skipping file: softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+*----------------------------------------------------------------------------*/
+bool f128M_isSignalingNaN( const float128_t *aPtr )
+{
+ const uint32_t *aWPtr;
+ uint32_t uiA96;
+
+ aWPtr = (const uint32_t *) aPtr;
+ uiA96 = aWPtr[indexWordHi( 4 )];
+ if ( (uiA96 & 0x7FFF8000) != 0x7FFF0000 ) return false;
+ return
+ ((uiA96 & 0x00007FFF) != 0)
+ || ((aWPtr[indexWord( 4, 2 )] | aWPtr[indexWord( 4, 1 )]
+ | aWPtr[indexWord( 4, 0 )])
+ != 0);
+
+}
+
+/**** ended inlining ../../source/8086-SSE/f128M_isSignalingNaN.c ****/
+/**** start inlining ../../source/8086-SSE/s_f128UIToCommonNaN.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitives.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+| Assuming the unsigned integer formed from concatenating `uiA64' and `uiA0'
+| has the bit pattern of a 128-bit floating-point NaN, converts this NaN to
+| the common NaN form, and stores the resulting common NaN at the location
+| pointed to by `zPtr'. If the NaN is a signaling NaN, the invalid exception
+| is raised.
+*----------------------------------------------------------------------------*/
+void
+ softfloat_f128UIToCommonNaN(
+ uint_fast64_t uiA64, uint_fast64_t uiA0, struct commonNaN *zPtr )
+{
+ struct uint128 NaNSig;
+
+ if ( softfloat_isSigNaNF128UI( uiA64, uiA0 ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ }
+ NaNSig = softfloat_shortShiftLeft128( uiA64, uiA0, 16 );
+ zPtr->sign = uiA64>>63;
+ zPtr->v64 = NaNSig.v64;
+ zPtr->v0 = NaNSig.v0;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_f128UIToCommonNaN.c ****/
+/**** start inlining ../../source/8086-SSE/s_commonNaNToF128UI.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitives.h ****/
+/**** skipping file: specialize.h ****/
+
+/*----------------------------------------------------------------------------
+| Converts the common NaN pointed to by `aPtr' into a 128-bit floating-point
+| NaN, and returns the bit pattern of this value as an unsigned integer.
+*----------------------------------------------------------------------------*/
+struct uint128 softfloat_commonNaNToF128UI( const struct commonNaN *aPtr )
+{
+ struct uint128 uiZ;
+
+ uiZ = softfloat_shortShiftRight128( aPtr->v64, aPtr->v0, 16 );
+ uiZ.v64 |= (uint_fast64_t) aPtr->sign<<63 | UINT64_C( 0x7FFF800000000000 );
+ return uiZ;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_commonNaNToF128UI.c ****/
+/**** start inlining ../../source/8086-SSE/s_propagateNaNF128UI.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+/*----------------------------------------------------------------------------
+| Interpreting the unsigned integer formed from concatenating `uiA64' and
+| `uiA0' as a 128-bit floating-point value, and likewise interpreting the
+| unsigned integer formed from concatenating `uiB64' and `uiB0' as another
+| 128-bit floating-point value, and assuming at least on of these floating-
+| point values is a NaN, returns the bit pattern of the combined NaN result.
+| If either original floating-point value is a signaling NaN, the invalid
+| exception is raised.
+*----------------------------------------------------------------------------*/
+struct uint128
+ softfloat_propagateNaNF128UI(
+ uint_fast64_t uiA64,
+ uint_fast64_t uiA0,
+ uint_fast64_t uiB64,
+ uint_fast64_t uiB0
+ )
+{
+ bool isSigNaNA;
+ struct uint128 uiZ;
+
+ isSigNaNA = softfloat_isSigNaNF128UI( uiA64, uiA0 );
+ if ( isSigNaNA || softfloat_isSigNaNF128UI( uiB64, uiB0 ) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ if ( isSigNaNA ) goto returnNonsigA;
+ }
+ if ( isNaNF128UI( uiA64, uiA0 ) ) {
+ returnNonsigA:
+ uiZ.v64 = uiA64;
+ uiZ.v0 = uiA0;
+ } else {
+ uiZ.v64 = uiB64;
+ uiZ.v0 = uiB0;
+ }
+ uiZ.v64 |= UINT64_C( 0x0000800000000000 );
+ return uiZ;
+
+}
+
+/**** ended inlining ../../source/8086-SSE/s_propagateNaNF128UI.c ****/
+
+/**** start inlining ../../source/s_eq128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+
+#ifndef softfloat_eq128
+#define softfloat_eq128 softfloat_eq128
+
+bool softfloat_eq128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+{
+
+ return (a64 == b64) && (a0 == b0);
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_eq128.c ****/
+/**** start inlining ../../source/s_le128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+
+#ifndef softfloat_le128
+#define softfloat_le128 softfloat_le128
+
+bool softfloat_le128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+{
+
+ return (a64 < b64) || ((a64 == b64) && (a0 <= b0));
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_le128.c ****/
+/**** start inlining ../../source/s_lt128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+
+#ifndef softfloat_lt128
+#define softfloat_lt128 softfloat_lt128
+
+bool softfloat_lt128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+{
+
+ return (a64 < b64) || ((a64 == b64) && (a0 < b0));
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_lt128.c ****/
+/**** start inlining ../../source/s_shortShiftLeft128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_shortShiftLeft128
+#define softfloat_shortShiftLeft128 softfloat_shortShiftLeft128
+
+struct uint128
+ softfloat_shortShiftLeft128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
+{
+ struct uint128 z;
+
+ z.v64 = a64<>(-dist & 63);
+ z.v0 = a0<
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_shortShiftRight128
+#define softfloat_shortShiftRight128 softfloat_shortShiftRight128
+
+struct uint128
+ softfloat_shortShiftRight128( uint64_t a64, uint64_t a0, uint_fast8_t dist )
+{
+ struct uint128 z;
+
+ z.v64 = a64>>dist;
+ z.v0 = a64<<(-dist & 63) | a0>>dist;
+ return z;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_shortShiftRight128.c ****/
+/**** start inlining ../../source/s_shortShiftRightJam64.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+
+#ifndef softfloat_shortShiftRightJam64
+#define softfloat_shortShiftRightJam64 softfloat_shortShiftRightJam64
+
+uint64_t softfloat_shortShiftRightJam64( uint64_t a, uint_fast8_t dist )
+{
+
+ return a>>dist | ((a & (((uint_fast64_t) 1<
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_shortShiftRightJam64Extra
+#define softfloat_shortShiftRightJam64Extra softfloat_shortShiftRightJam64Extra
+
+struct uint64_extra
+ softfloat_shortShiftRightJam64Extra(
+ uint64_t a, uint64_t extra, uint_fast8_t dist )
+{
+ struct uint64_extra z;
+
+ z.v = a>>dist;
+ z.extra = a<<(-dist & 63) | (extra != 0);
+ return z;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_shortShiftRightJam64Extra.c ****/
+/**** start inlining ../../source/s_shortShiftRightJam128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_shortShiftRightJam128
+#define softfloat_shortShiftRightJam128 softfloat_shortShiftRightJam128
+
+struct uint128
+ softfloat_shortShiftRightJam128(
+ uint64_t a64, uint64_t a0, uint_fast8_t dist )
+{
+ uint_fast8_t uNegDist;
+ struct uint128 z;
+
+ uNegDist = -dist;
+ z.v64 = a64>>dist;
+ z.v0 =
+ a64<<(uNegDist & 63) | a0>>dist
+ | ((uint64_t) (a0<<(uNegDist & 63)) != 0);
+ return z;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_shortShiftRightJam128.c ****/
+/**** start inlining ../../source/s_shortShiftRightJam128Extra.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_shortShiftRightJam128Extra
+#define softfloat_shortShiftRightJam128Extra softfloat_shortShiftRightJam128Extra
+
+struct uint128_extra
+ softfloat_shortShiftRightJam128Extra(
+ uint64_t a64, uint64_t a0, uint64_t extra, uint_fast8_t dist )
+{
+ uint_fast8_t uNegDist;
+ struct uint128_extra z;
+
+ uNegDist = -dist;
+ z.v.v64 = a64>>dist;
+ z.v.v0 = a64<<(uNegDist & 63) | a0>>dist;
+ z.extra = a0<<(uNegDist & 63) | (extra != 0);
+ return z;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_shortShiftRightJam128Extra.c ****/
+/**** start inlining ../../source/s_shiftRightJam32.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+
+#ifndef softfloat_shiftRightJam32
+#define softfloat_shiftRightJam32 softfloat_shiftRightJam32
+
+uint32_t softfloat_shiftRightJam32( uint32_t a, uint_fast16_t dist )
+{
+
+ return
+ (dist < 31) ? a>>dist | ((uint32_t) (a<<(-dist & 31)) != 0) : (a != 0);
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_shiftRightJam32.c ****/
+/**** start inlining ../../source/s_shiftRightJam64.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+
+#ifndef softfloat_shiftRightJam64
+#define softfloat_shiftRightJam64 softfloat_shiftRightJam64
+
+uint64_t softfloat_shiftRightJam64( uint64_t a, uint_fast32_t dist )
+{
+
+ return
+ (dist < 63) ? a>>dist | ((uint64_t) (a<<(-dist & 63)) != 0) : (a != 0);
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_shiftRightJam64.c ****/
+/**** start inlining ../../source/s_shiftRightJam64Extra.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_shiftRightJam64Extra
+#define softfloat_shiftRightJam64Extra softfloat_shiftRightJam64Extra
+
+struct uint64_extra
+ softfloat_shiftRightJam64Extra(
+ uint64_t a, uint64_t extra, uint_fast32_t dist )
+{
+ struct uint64_extra z;
+
+ if ( dist < 64 ) {
+ z.v = a>>dist;
+ z.extra = a<<(-dist & 63);
+ } else {
+ z.v = 0;
+ z.extra = (dist == 64) ? a : (a != 0);
+ }
+ z.extra |= (extra != 0);
+ return z;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_shiftRightJam64Extra.c ****/
+/**** start inlining ../../source/s_shiftRightJam128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_shiftRightJam128
+
+struct uint128
+ softfloat_shiftRightJam128( uint64_t a64, uint64_t a0, uint_fast32_t dist )
+{
+ uint_fast8_t u8NegDist;
+ struct uint128 z;
+
+ if ( dist < 64 ) {
+ u8NegDist = -dist;
+ z.v64 = a64>>dist;
+ z.v0 =
+ a64<<(u8NegDist & 63) | a0>>dist
+ | ((uint64_t) (a0<<(u8NegDist & 63)) != 0);
+ } else {
+ z.v64 = 0;
+ z.v0 =
+ (dist < 127)
+ ? a64>>(dist & 63)
+ | (((a64 & (((uint_fast64_t) 1<<(dist & 63)) - 1)) | a0)
+ != 0)
+ : ((a64 | a0) != 0);
+ }
+ return z;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_shiftRightJam128.c ****/
+/**** start inlining ../../source/s_shiftRightJam128Extra.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_shiftRightJam128Extra
+
+struct uint128_extra
+ softfloat_shiftRightJam128Extra(
+ uint64_t a64, uint64_t a0, uint64_t extra, uint_fast32_t dist )
+{
+ uint_fast8_t u8NegDist;
+ struct uint128_extra z;
+
+ u8NegDist = -dist;
+ if ( dist < 64 ) {
+ z.v.v64 = a64>>dist;
+ z.v.v0 = a64<<(u8NegDist & 63) | a0>>dist;
+ z.extra = a0<<(u8NegDist & 63);
+ } else {
+ z.v.v64 = 0;
+ if ( dist == 64 ) {
+ z.v.v0 = a64;
+ z.extra = a0;
+ } else {
+ extra |= a0;
+ if ( dist < 128 ) {
+ z.v.v0 = a64>>(dist & 63);
+ z.extra = a64<<(u8NegDist & 63);
+ } else {
+ z.v.v0 = 0;
+ z.extra = (dist == 128) ? a64 : (a64 != 0);
+ }
+ }
+ }
+ z.extra |= (extra != 0);
+ return z;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_shiftRightJam128Extra.c ****/
+/**** start inlining ../../source/s_shiftRightJam256M.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_shiftRightJam256M
+
+static
+ void
+ softfloat_shortShiftRightJamM(
+ uint_fast8_t size_words,
+ const uint64_t *aPtr,
+ uint_fast8_t dist,
+ uint64_t *zPtr
+ )
+{
+ uint_fast8_t uNegDist;
+ unsigned int index, lastIndex;
+ uint64_t partWordZ, wordA;
+
+ uNegDist = -dist;
+ index = indexWordLo( size_words );
+ lastIndex = indexWordHi( size_words );
+ wordA = aPtr[index];
+ partWordZ = wordA>>dist;
+ if ( partWordZ<>dist;
+ }
+ zPtr[index] = partWordZ;
+
+}
+
+void
+ softfloat_shiftRightJam256M(
+ const uint64_t *aPtr, uint_fast32_t dist, uint64_t *zPtr )
+{
+ uint64_t wordJam;
+ uint_fast32_t wordDist;
+ uint64_t *ptr;
+ uint_fast8_t i, innerDist;
+
+ wordJam = 0;
+ wordDist = dist>>6;
+ if ( wordDist ) {
+ if ( 4 < wordDist ) wordDist = 4;
+ ptr = (uint64_t *) (aPtr + indexMultiwordLo( 4, wordDist ));
+ i = wordDist;
+ do {
+ wordJam = *ptr++;
+ if ( wordJam ) break;
+ --i;
+ } while ( i );
+ ptr = zPtr;
+ }
+ if ( wordDist < 4 ) {
+ aPtr += indexMultiwordHiBut( 4, wordDist );
+ innerDist = dist & 63;
+ if ( innerDist ) {
+ softfloat_shortShiftRightJamM(
+ 4 - wordDist,
+ aPtr,
+ innerDist,
+ zPtr + indexMultiwordLoBut( 4, wordDist )
+ );
+ if ( ! wordDist ) goto wordJam;
+ } else {
+ aPtr += indexWordLo( 4 - wordDist );
+ ptr = zPtr + indexWordLo( 4 );
+ for ( i = 4 - wordDist; i; --i ) {
+ *ptr = *aPtr;
+ aPtr += wordIncr;
+ ptr += wordIncr;
+ }
+ }
+ ptr = zPtr + indexMultiwordHi( 4, wordDist );
+ }
+ do {
+ *ptr++ = 0;
+ --wordDist;
+ } while ( wordDist );
+ wordJam:
+ if ( wordJam ) zPtr[indexWordLo( 4 )] |= 1;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_shiftRightJam256M.c ****/
+/**** start inlining ../../source/s_countLeadingZeros8.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitives.h ****/
+
+const uint_least8_t softfloat_countLeadingZeros8[256] = {
+ 8, 7, 6, 6, 5, 5, 5, 5, 4, 4, 4, 4, 4, 4, 4, 4,
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
+};
+
+/**** ended inlining ../../source/s_countLeadingZeros8.c ****/
+/**** start inlining ../../source/s_countLeadingZeros16.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+
+#ifndef softfloat_countLeadingZeros16
+
+#define softfloat_countLeadingZeros16 softfloat_countLeadingZeros16
+/**** skipping file: primitives.h ****/
+
+uint_fast8_t softfloat_countLeadingZeros16( uint16_t a )
+{
+ uint_fast8_t count;
+
+ count = 8;
+ if ( 0x100 <= a ) {
+ count = 0;
+ a >>= 8;
+ }
+ count += softfloat_countLeadingZeros8[a];
+ return count;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_countLeadingZeros16.c ****/
+/**** start inlining ../../source/s_countLeadingZeros32.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+
+#ifndef softfloat_countLeadingZeros32
+
+#define softfloat_countLeadingZeros32 softfloat_countLeadingZeros32
+/**** skipping file: primitives.h ****/
+
+uint_fast8_t softfloat_countLeadingZeros32( uint32_t a )
+{
+ uint_fast8_t count;
+
+ count = 0;
+ if ( a < 0x10000 ) {
+ count = 16;
+ a <<= 16;
+ }
+ if ( a < 0x1000000 ) {
+ count += 8;
+ a <<= 8;
+ }
+ count += softfloat_countLeadingZeros8[a>>24];
+ return count;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_countLeadingZeros32.c ****/
+/**** start inlining ../../source/s_countLeadingZeros64.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+
+#ifndef softfloat_countLeadingZeros64
+
+#define softfloat_countLeadingZeros64 softfloat_countLeadingZeros64
+/**** skipping file: primitives.h ****/
+
+uint_fast8_t softfloat_countLeadingZeros64( uint64_t a )
+{
+ uint_fast8_t count;
+ uint32_t a32;
+
+ count = 0;
+ a32 = a>>32;
+ if ( ! a32 ) {
+ count = 32;
+ a32 = a;
+ }
+ /*------------------------------------------------------------------------
+ | From here, result is current count + count leading zeros of `a32'.
+ *------------------------------------------------------------------------*/
+ if ( a32 < 0x10000 ) {
+ count += 16;
+ a32 <<= 16;
+ }
+ if ( a32 < 0x1000000 ) {
+ count += 8;
+ a32 <<= 8;
+ }
+ count += softfloat_countLeadingZeros8[a32>>24];
+ return count;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_countLeadingZeros64.c ****/
+/**** start inlining ../../source/s_add128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_add128
+
+struct uint128
+ softfloat_add128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+{
+ struct uint128 z;
+
+ z.v0 = a0 + b0;
+ z.v64 = a64 + b64 + (z.v0 < a0);
+ return z;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_add128.c ****/
+/**** start inlining ../../source/s_add256M.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_add256M
+
+void
+ softfloat_add256M(
+ const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr )
+{
+ unsigned int index;
+ uint_fast8_t carry;
+ uint64_t wordA, wordZ;
+
+ index = indexWordLo( 4 );
+ carry = 0;
+ for (;;) {
+ wordA = aPtr[index];
+ wordZ = wordA + bPtr[index] + carry;
+ zPtr[index] = wordZ;
+ if ( index == indexWordHi( 4 ) ) break;
+ if ( wordZ != wordA ) carry = (wordZ < wordA);
+ index += wordIncr;
+ }
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_add256M.c ****/
+/**** start inlining ../../source/s_sub128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_sub128
+#define softfloat_sub128 softfloat_sub128
+
+struct uint128
+ softfloat_sub128( uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0 )
+{
+ struct uint128 z;
+
+ z.v0 = a0 - b0;
+ z.v64 = a64 - b64 - (a0 < b0);
+ return z;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_sub128.c ****/
+/**** start inlining ../../source/s_sub256M.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_sub256M
+
+void
+ softfloat_sub256M(
+ const uint64_t *aPtr, const uint64_t *bPtr, uint64_t *zPtr )
+{
+ unsigned int index;
+ uint_fast8_t borrow;
+ uint64_t wordA, wordB;
+
+ index = indexWordLo( 4 );
+ borrow = 0;
+ for (;;) {
+ wordA = aPtr[index];
+ wordB = bPtr[index];
+ zPtr[index] = wordA - wordB - borrow;
+ if ( index == indexWordHi( 4 ) ) break;
+ borrow = borrow ? (wordA <= wordB) : (wordA < wordB);
+ index += wordIncr;
+ }
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_sub256M.c ****/
+/**** start inlining ../../source/s_mul64ByShifted32To128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_mul64ByShifted32To128
+
+struct uint128 softfloat_mul64ByShifted32To128( uint64_t a, uint32_t b )
+{
+ uint_fast64_t mid;
+ struct uint128 z;
+
+ mid = (uint_fast64_t) (uint32_t) a * b;
+ z.v0 = mid<<32;
+ z.v64 = (uint_fast64_t) (uint32_t) (a>>32) * b + (mid>>32);
+ return z;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_mul64ByShifted32To128.c ****/
+/**** start inlining ../../source/s_mul64To128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_mul64To128
+
+struct uint128 softfloat_mul64To128( uint64_t a, uint64_t b )
+{
+ uint32_t a32, a0, b32, b0;
+ struct uint128 z;
+ uint64_t mid1, mid;
+
+ a32 = a>>32;
+ a0 = a;
+ b32 = b>>32;
+ b0 = b;
+ z.v0 = (uint_fast64_t) a0 * b0;
+ mid1 = (uint_fast64_t) a32 * b0;
+ mid = mid1 + (uint_fast64_t) a0 * b32;
+ z.v64 = (uint_fast64_t) a32 * b32;
+ z.v64 += (uint_fast64_t) (mid < mid1)<<32 | mid>>32;
+ mid <<= 32;
+ z.v0 += mid;
+ z.v64 += (z.v0 < mid);
+ return z;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_mul64To128.c ****/
+/**** start inlining ../../source/s_mul128By32.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitiveTypes.h ****/
+
+#ifndef softfloat_mul128By32
+
+struct uint128 softfloat_mul128By32( uint64_t a64, uint64_t a0, uint32_t b )
+{
+ struct uint128 z;
+ uint_fast64_t mid;
+ uint_fast32_t carry;
+
+ z.v0 = a0 * b;
+ mid = (uint_fast64_t) (uint32_t) (a0>>32) * b;
+ carry = (uint32_t) ((uint_fast32_t) (z.v0>>32) - (uint_fast32_t) mid);
+ z.v64 = a64 * b + (uint_fast32_t) ((mid + carry)>>32);
+ return z;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_mul128By32.c ****/
+/**** start inlining ../../source/s_mul128To256M.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+
+#ifndef softfloat_mul128To256M
+
+#define softfloat_mul128To256M softfloat_mul128To256M
+/**** skipping file: primitives.h ****/
+
+void
+ softfloat_mul128To256M(
+ uint64_t a64, uint64_t a0, uint64_t b64, uint64_t b0, uint64_t *zPtr )
+{
+ struct uint128 p0, p64, p128;
+ uint_fast64_t z64, z128, z192;
+
+ p0 = softfloat_mul64To128( a0, b0 );
+ zPtr[indexWord( 4, 0 )] = p0.v0;
+ p64 = softfloat_mul64To128( a64, b0 );
+ z64 = p64.v0 + p0.v64;
+ z128 = p64.v64 + (z64 < p64.v0);
+ p128 = softfloat_mul64To128( a64, b64 );
+ z128 += p128.v0;
+ z192 = p128.v64 + (z128 < p128.v0);
+ p64 = softfloat_mul64To128( a0, b64 );
+ z64 += p64.v0;
+ zPtr[indexWord( 4, 1 )] = z64;
+ p64.v64 += (z64 < p64.v0);
+ z128 += p64.v64;
+ zPtr[indexWord( 4, 2 )] = z128;
+ zPtr[indexWord( 4, 3 )] = z192 + (z128 < p64.v64);
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_mul128To256M.c ****/
+/**** start inlining ../../source/s_approxRecip_1Ks.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitives.h ****/
+
+const uint16_t softfloat_approxRecip_1k0s[16] = {
+ 0xFFC4, 0xF0BE, 0xE363, 0xD76F, 0xCCAD, 0xC2F0, 0xBA16, 0xB201,
+ 0xAA97, 0xA3C6, 0x9D7A, 0x97A6, 0x923C, 0x8D32, 0x887E, 0x8417
+};
+const uint16_t softfloat_approxRecip_1k1s[16] = {
+ 0xF0F1, 0xD62C, 0xBFA1, 0xAC77, 0x9C0A, 0x8DDB, 0x8185, 0x76BA,
+ 0x6D3B, 0x64D4, 0x5D5C, 0x56B1, 0x50B6, 0x4B55, 0x4679, 0x4211
+};
+
+/**** ended inlining ../../source/s_approxRecip_1Ks.c ****/
+/**** start inlining ../../source/s_approxRecip32_1.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+
+#ifndef softfloat_approxRecip32_1
+
+extern const uint16_t softfloat_approxRecip_1k0s[16];
+extern const uint16_t softfloat_approxRecip_1k1s[16];
+
+uint32_t softfloat_approxRecip32_1( uint32_t a )
+{
+ int index;
+ uint16_t eps, r0;
+ uint32_t sigma0;
+ uint_fast32_t r;
+ uint32_t sqrSigma0;
+
+ index = a>>27 & 0xF;
+ eps = (uint16_t) (a>>11);
+ r0 = softfloat_approxRecip_1k0s[index]
+ - ((softfloat_approxRecip_1k1s[index] * (uint_fast32_t) eps)>>20);
+ sigma0 = ~(uint_fast32_t) ((r0 * (uint_fast64_t) a)>>7);
+ r = ((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) sigma0)>>24);
+ sqrSigma0 = ((uint_fast64_t) sigma0 * sigma0)>>32;
+ r += ((uint32_t) r * (uint_fast64_t) sqrSigma0)>>48;
+ return r;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_approxRecip32_1.c ****/
+/**** start inlining ../../source/s_approxRecipSqrt_1Ks.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: primitives.h ****/
+
+const uint16_t softfloat_approxRecipSqrt_1k0s[16] = {
+ 0xB4C9, 0xFFAB, 0xAA7D, 0xF11C, 0xA1C5, 0xE4C7, 0x9A43, 0xDA29,
+ 0x93B5, 0xD0E5, 0x8DED, 0xC8B7, 0x88C6, 0xC16D, 0x8424, 0xBAE1
+};
+const uint16_t softfloat_approxRecipSqrt_1k1s[16] = {
+ 0xA5A5, 0xEA42, 0x8C21, 0xC62D, 0x788F, 0xAA7F, 0x6928, 0x94B6,
+ 0x5CC7, 0x8335, 0x52A6, 0x74E2, 0x4A3E, 0x68FE, 0x432B, 0x5EFD
+};
+
+/**** ended inlining ../../source/s_approxRecipSqrt_1Ks.c ****/
+/**** start inlining ../../source/s_approxRecipSqrt32_1.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+
+#ifndef softfloat_approxRecipSqrt32_1
+
+extern const uint16_t softfloat_approxRecipSqrt_1k0s[];
+extern const uint16_t softfloat_approxRecipSqrt_1k1s[];
+
+uint32_t softfloat_approxRecipSqrt32_1( unsigned int oddExpA, uint32_t a )
+{
+ int index;
+ uint16_t eps, r0;
+ uint_fast32_t ESqrR0;
+ uint32_t sigma0;
+ uint_fast32_t r;
+ uint32_t sqrSigma0;
+
+ index = (a>>27 & 0xE) + oddExpA;
+ eps = (uint16_t) (a>>12);
+ r0 = softfloat_approxRecipSqrt_1k0s[index]
+ - ((softfloat_approxRecipSqrt_1k1s[index] * (uint_fast32_t) eps)
+ >>20);
+ ESqrR0 = (uint_fast32_t) r0 * r0;
+ if ( ! oddExpA ) ESqrR0 <<= 1;
+ sigma0 = ~(uint_fast32_t) (((uint32_t) ESqrR0 * (uint_fast64_t) a)>>23);
+ r = ((uint_fast32_t) r0<<16) + ((r0 * (uint_fast64_t) sigma0)>>25);
+ sqrSigma0 = ((uint_fast64_t) sigma0 * sigma0)>>32;
+ r += ((uint32_t) ((r>>1) + (r>>3) - ((uint_fast32_t) r0<<14))
+ * (uint_fast64_t) sqrSigma0)
+ >>48;
+ if ( ! (r & 0x80000000) ) r = 0x80000000;
+ return r;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_approxRecipSqrt32_1.c ****/
+/**** start inlining ../../source/s_roundToUI32.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+uint_fast32_t
+ softfloat_roundToUI32(
+ bool sign, uint_fast64_t sig, uint_fast8_t roundingMode, bool exact )
+{
+ uint_fast16_t roundIncrement, roundBits;
+ uint_fast32_t z;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ roundIncrement = 0x800;
+ if (
+ (roundingMode != softfloat_round_near_maxMag)
+ && (roundingMode != softfloat_round_near_even)
+ ) {
+ roundIncrement = 0;
+ if ( sign ) {
+ if ( !sig ) return 0;
+ if ( roundingMode == softfloat_round_min ) goto invalid;
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) goto invalid;
+#endif
+ } else {
+ if ( roundingMode == softfloat_round_max ) roundIncrement = 0xFFF;
+ }
+ }
+ roundBits = sig & 0xFFF;
+ sig += roundIncrement;
+ if ( sig & UINT64_C( 0xFFFFF00000000000 ) ) goto invalid;
+ z = sig>>12;
+ if (
+ (roundBits == 0x800) && (roundingMode == softfloat_round_near_even)
+ ) {
+ z &= ~(uint_fast32_t) 1;
+ }
+ if ( sign && z ) goto invalid;
+ if ( roundBits ) {
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) z |= 1;
+#endif
+ if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return z;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ invalid:
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
+
+}
+
+/**** ended inlining ../../source/s_roundToUI32.c ****/
+/**** start inlining ../../source/s_roundToUI64.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+uint_fast64_t
+ softfloat_roundToUI64(
+ bool sign,
+ uint_fast64_t sig,
+ uint_fast64_t sigExtra,
+ uint_fast8_t roundingMode,
+ bool exact
+ )
+{
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if (
+ (roundingMode == softfloat_round_near_maxMag)
+ || (roundingMode == softfloat_round_near_even)
+ ) {
+ if ( UINT64_C( 0x8000000000000000 ) <= sigExtra ) goto increment;
+ } else {
+ if ( sign ) {
+ if ( !(sig | sigExtra) ) return 0;
+ if ( roundingMode == softfloat_round_min ) goto invalid;
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) goto invalid;
+#endif
+ } else {
+ if ( (roundingMode == softfloat_round_max) && sigExtra ) {
+ increment:
+ ++sig;
+ if ( !sig ) goto invalid;
+ if (
+ (sigExtra == UINT64_C( 0x8000000000000000 ))
+ && (roundingMode == softfloat_round_near_even)
+ ) {
+ sig &= ~(uint_fast64_t) 1;
+ }
+ }
+ }
+ }
+ if ( sign && sig ) goto invalid;
+ if ( sigExtra ) {
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) sig |= 1;
+#endif
+ if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return sig;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ invalid:
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
+
+}
+
+/**** ended inlining ../../source/s_roundToUI64.c ****/
+/**** start inlining ../../source/s_roundToI32.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+int_fast32_t
+ softfloat_roundToI32(
+ bool sign, uint_fast64_t sig, uint_fast8_t roundingMode, bool exact )
+{
+ uint_fast16_t roundIncrement, roundBits;
+ uint_fast32_t sig32;
+ union { uint32_t ui; int32_t i; } uZ;
+ int_fast32_t z;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ roundIncrement = 0x800;
+ if (
+ (roundingMode != softfloat_round_near_maxMag)
+ && (roundingMode != softfloat_round_near_even)
+ ) {
+ roundIncrement = 0;
+ if (
+ sign
+ ? (roundingMode == softfloat_round_min)
+#ifdef SOFTFLOAT_ROUND_ODD
+ || (roundingMode == softfloat_round_odd)
+#endif
+ : (roundingMode == softfloat_round_max)
+ ) {
+ roundIncrement = 0xFFF;
+ }
+ }
+ roundBits = sig & 0xFFF;
+ sig += roundIncrement;
+ if ( sig & UINT64_C( 0xFFFFF00000000000 ) ) goto invalid;
+ sig32 = sig>>12;
+ if (
+ (roundBits == 0x800) && (roundingMode == softfloat_round_near_even)
+ ) {
+ sig32 &= ~(uint_fast32_t) 1;
+ }
+ uZ.ui = sign ? -sig32 : sig32;
+ z = uZ.i;
+ if ( z && ((z < 0) ^ sign) ) goto invalid;
+ if ( roundBits ) {
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) z |= 1;
+#endif
+ if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return z;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ invalid:
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return sign ? i32_fromNegOverflow : i32_fromPosOverflow;
+
+}
+
+/**** ended inlining ../../source/s_roundToI32.c ****/
+/**** start inlining ../../source/s_roundToI64.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+int_fast64_t
+ softfloat_roundToI64(
+ bool sign,
+ uint_fast64_t sig,
+ uint_fast64_t sigExtra,
+ uint_fast8_t roundingMode,
+ bool exact
+ )
+{
+ union { uint64_t ui; int64_t i; } uZ;
+ int_fast64_t z;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if (
+ (roundingMode == softfloat_round_near_maxMag)
+ || (roundingMode == softfloat_round_near_even)
+ ) {
+ if ( UINT64_C( 0x8000000000000000 ) <= sigExtra ) goto increment;
+ } else {
+ if (
+ sigExtra
+ && (sign
+ ? (roundingMode == softfloat_round_min)
+#ifdef SOFTFLOAT_ROUND_ODD
+ || (roundingMode == softfloat_round_odd)
+#endif
+ : (roundingMode == softfloat_round_max))
+ ) {
+ increment:
+ ++sig;
+ if ( !sig ) goto invalid;
+ if (
+ (sigExtra == UINT64_C( 0x8000000000000000 ))
+ && (roundingMode == softfloat_round_near_even)
+ ) {
+ sig &= ~(uint_fast64_t) 1;
+ }
+ }
+ }
+ uZ.ui = sign ? -sig : sig;
+ z = uZ.i;
+ if ( z && ((z < 0) ^ sign) ) goto invalid;
+ if ( sigExtra ) {
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) z |= 1;
+#endif
+ if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return z;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ invalid:
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return sign ? i64_fromNegOverflow : i64_fromPosOverflow;
+
+}
+
+/**** ended inlining ../../source/s_roundToI64.c ****/
+/**** start inlining ../../source/s_normSubnormalF16Sig.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+
+struct exp8_sig16 softfloat_normSubnormalF16Sig( uint_fast16_t sig )
+{
+ int_fast8_t shiftDist;
+ struct exp8_sig16 z;
+
+ shiftDist = softfloat_countLeadingZeros16( sig ) - 5;
+ z.exp = 1 - shiftDist;
+ z.sig = sig<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t
+ softfloat_roundPackToF16( bool sign, int_fast16_t exp, uint_fast16_t sig )
+{
+ uint_fast8_t roundingMode;
+ bool roundNearEven;
+ uint_fast8_t roundIncrement, roundBits;
+ bool isTiny;
+ uint_fast16_t uiZ;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ roundingMode = softfloat_roundingMode;
+ roundNearEven = (roundingMode == softfloat_round_near_even);
+ roundIncrement = 0x8;
+ if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
+ roundIncrement =
+ (roundingMode
+ == (sign ? softfloat_round_min : softfloat_round_max))
+ ? 0xF
+ : 0;
+ }
+ roundBits = sig & 0xF;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( 0x1D <= (unsigned int) exp ) {
+ if ( exp < 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ isTiny =
+ (softfloat_detectTininess == softfloat_tininess_beforeRounding)
+ || (exp < -1) || (sig + roundIncrement < 0x8000);
+ sig = softfloat_shiftRightJam32( sig, -exp );
+ exp = 0;
+ roundBits = sig & 0xF;
+ if ( isTiny && roundBits ) {
+ softfloat_raiseFlags( softfloat_flag_underflow );
+ }
+ } else if ( (0x1D < exp) || (0x8000 <= sig + roundIncrement) ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ softfloat_raiseFlags(
+ softfloat_flag_overflow | softfloat_flag_inexact );
+ uiZ = packToF16UI( sign, 0x1F, 0 ) - ! roundIncrement;
+ goto uiZ;
+ }
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig = (sig + roundIncrement)>>4;
+ if ( roundBits ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) {
+ sig |= 1;
+ goto packReturn;
+ }
+#endif
+ }
+ sig &= ~(uint_fast16_t) (! (roundBits ^ 8) & roundNearEven);
+ if ( ! sig ) exp = 0;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ packReturn:
+ uiZ = packToF16UI( sign, exp, sig );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_roundPackToF16.c ****/
+/**** start inlining ../../source/s_normRoundPackToF16.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+
+float16_t
+ softfloat_normRoundPackToF16( bool sign, int_fast16_t exp, uint_fast16_t sig )
+{
+ int_fast8_t shiftDist;
+ union ui16_f16 uZ;
+
+ shiftDist = softfloat_countLeadingZeros16( sig ) - 1;
+ exp -= shiftDist;
+ if ( (4 <= shiftDist) && ((unsigned int) exp < 0x1D) ) {
+ uZ.ui = packToF16UI( sign, sig ? exp : 0, sig<<(shiftDist - 4) );
+ return uZ.f;
+ } else {
+ return softfloat_roundPackToF16( sign, exp, sig<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t softfloat_addMagsF16( uint_fast16_t uiA, uint_fast16_t uiB )
+{
+ int_fast8_t expA;
+ uint_fast16_t sigA;
+ int_fast8_t expB;
+ uint_fast16_t sigB;
+ int_fast8_t expDiff;
+ uint_fast16_t uiZ;
+ bool signZ;
+ int_fast8_t expZ;
+ uint_fast16_t sigZ;
+ uint_fast16_t sigX, sigY;
+ int_fast8_t shiftDist;
+ uint_fast32_t sig32Z;
+ int_fast8_t roundingMode;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ expB = expF16UI( uiB );
+ sigB = fracF16UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( ! expA ) {
+ uiZ = uiA + sigB;
+ goto uiZ;
+ }
+ if ( expA == 0x1F ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ signZ = signF16UI( uiA );
+ expZ = expA;
+ sigZ = 0x0800 + sigA + sigB;
+ if ( ! (sigZ & 1) && (expZ < 0x1E) ) {
+ sigZ >>= 1;
+ goto pack;
+ }
+ sigZ <<= 3;
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ signZ = signF16UI( uiA );
+ if ( expDiff < 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ if ( expB == 0x1F ) {
+ if ( sigB ) goto propagateNaN;
+ uiZ = packToF16UI( signZ, 0x1F, 0 );
+ goto uiZ;
+ }
+ if ( expDiff <= -13 ) {
+ uiZ = packToF16UI( signZ, expB, sigB );
+ if ( expA | sigA ) goto addEpsilon;
+ goto uiZ;
+ }
+ expZ = expB;
+ sigX = sigB | 0x0400;
+ sigY = sigA + (expA ? 0x0400 : sigA);
+ shiftDist = 19 + expDiff;
+ } else {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ uiZ = uiA;
+ if ( expA == 0x1F ) {
+ if ( sigA ) goto propagateNaN;
+ goto uiZ;
+ }
+ if ( 13 <= expDiff ) {
+ if ( expB | sigB ) goto addEpsilon;
+ goto uiZ;
+ }
+ expZ = expA;
+ sigX = sigA | 0x0400;
+ sigY = sigB + (expB ? 0x0400 : sigB);
+ shiftDist = 19 - expDiff;
+ }
+ sig32Z =
+ ((uint_fast32_t) sigX<<19) + ((uint_fast32_t) sigY<>16;
+ if ( sig32Z & 0xFFFF ) {
+ sigZ |= 1;
+ } else {
+ if ( ! (sigZ & 0xF) && (expZ < 0x1E) ) {
+ sigZ >>= 4;
+ goto pack;
+ }
+ }
+ }
+ return softfloat_roundPackToF16( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ addEpsilon:
+ roundingMode = softfloat_roundingMode;
+ if ( roundingMode != softfloat_round_near_even ) {
+ if (
+ roundingMode
+ == (signF16UI( uiZ ) ? softfloat_round_min
+ : softfloat_round_max)
+ ) {
+ ++uiZ;
+ if ( (uint16_t) (uiZ<<1) == 0xF800 ) {
+ softfloat_raiseFlags(
+ softfloat_flag_overflow | softfloat_flag_inexact );
+ }
+ }
+#ifdef SOFTFLOAT_ROUND_ODD
+ else if ( roundingMode == softfloat_round_odd ) {
+ uiZ |= 1;
+ }
+#endif
+ }
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ pack:
+ uiZ = packToF16UI( signZ, expZ, sigZ );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_addMagsF16.c ****/
+/**** start inlining ../../source/s_subMagsF16.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t softfloat_subMagsF16( uint_fast16_t uiA, uint_fast16_t uiB )
+{
+ int_fast8_t expA;
+ uint_fast16_t sigA;
+ int_fast8_t expB;
+ uint_fast16_t sigB;
+ int_fast8_t expDiff;
+ uint_fast16_t uiZ;
+ int_fast16_t sigDiff;
+ bool signZ;
+ int_fast8_t shiftDist, expZ;
+ uint_fast16_t sigZ, sigX, sigY;
+ uint_fast32_t sig32Z;
+ int_fast8_t roundingMode;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ expB = expF16UI( uiB );
+ sigB = fracF16UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expA == 0x1F ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF16UI;
+ goto uiZ;
+ }
+ sigDiff = sigA - sigB;
+ if ( ! sigDiff ) {
+ uiZ =
+ packToF16UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
+ goto uiZ;
+ }
+ if ( expA ) --expA;
+ signZ = signF16UI( uiA );
+ if ( sigDiff < 0 ) {
+ signZ = ! signZ;
+ sigDiff = -sigDiff;
+ }
+ shiftDist = softfloat_countLeadingZeros16( sigDiff ) - 5;
+ expZ = expA - shiftDist;
+ if ( expZ < 0 ) {
+ shiftDist = expA;
+ expZ = 0;
+ }
+ sigZ = sigDiff<>16;
+ if ( sig32Z & 0xFFFF ) {
+ sigZ |= 1;
+ } else {
+ if ( ! (sigZ & 0xF) && ((unsigned int) expZ < 0x1E) ) {
+ sigZ >>= 4;
+ goto pack;
+ }
+ }
+ return softfloat_roundPackToF16( signZ, expZ, sigZ );
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ subEpsilon:
+ roundingMode = softfloat_roundingMode;
+ if ( roundingMode != softfloat_round_near_even ) {
+ if (
+ (roundingMode == softfloat_round_minMag)
+ || (roundingMode
+ == (signF16UI( uiZ ) ? softfloat_round_max
+ : softfloat_round_min))
+ ) {
+ --uiZ;
+ }
+#ifdef SOFTFLOAT_ROUND_ODD
+ else if ( roundingMode == softfloat_round_odd ) {
+ uiZ = (uiZ - 1) | 1;
+ }
+#endif
+ }
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ pack:
+ uiZ = packToF16UI( signZ, expZ, sigZ );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_subMagsF16.c ****/
+/**** start inlining ../../source/s_mulAddF16.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t
+ softfloat_mulAddF16(
+ uint_fast16_t uiA, uint_fast16_t uiB, uint_fast16_t uiC, uint_fast8_t op )
+{
+ bool signA;
+ int_fast8_t expA;
+ uint_fast16_t sigA;
+ bool signB;
+ int_fast8_t expB;
+ uint_fast16_t sigB;
+ bool signC;
+ int_fast8_t expC;
+ uint_fast16_t sigC;
+ bool signProd;
+ uint_fast16_t magBits, uiZ;
+ struct exp8_sig16 normExpSig;
+ int_fast8_t expProd;
+ uint_fast32_t sigProd;
+ bool signZ;
+ int_fast8_t expZ;
+ uint_fast16_t sigZ;
+ int_fast8_t expDiff;
+ uint_fast32_t sig32Z, sig32C;
+ int_fast8_t shiftDist;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ signA = signF16UI( uiA );
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ signB = signF16UI( uiB );
+ expB = expF16UI( uiB );
+ sigB = fracF16UI( uiB );
+ signC = signF16UI( uiC ) ^ (op == softfloat_mulAdd_subC);
+ expC = expF16UI( uiC );
+ sigC = fracF16UI( uiC );
+ signProd = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x1F ) {
+ if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN_ABC;
+ magBits = expB | sigB;
+ goto infProdArg;
+ }
+ if ( expB == 0x1F ) {
+ if ( sigB ) goto propagateNaN_ABC;
+ magBits = expA | sigA;
+ goto infProdArg;
+ }
+ if ( expC == 0x1F ) {
+ if ( sigC ) {
+ uiZ = 0;
+ goto propagateNaN_ZC;
+ }
+ uiZ = uiC;
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ if ( ! expB ) {
+ if ( ! sigB ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF16Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expProd = expA + expB - 0xE;
+ sigA = (sigA | 0x0400)<<4;
+ sigB = (sigB | 0x0400)<<4;
+ sigProd = (uint_fast32_t) sigA * sigB;
+ if ( sigProd < 0x20000000 ) {
+ --expProd;
+ sigProd <<= 1;
+ }
+ signZ = signProd;
+ if ( ! expC ) {
+ if ( ! sigC ) {
+ expZ = expProd - 1;
+ sigZ = sigProd>>15 | ((sigProd & 0x7FFF) != 0);
+ goto roundPack;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( sigC );
+ expC = normExpSig.exp;
+ sigC = normExpSig.sig;
+ }
+ sigC = (sigC | 0x0400)<<3;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expProd - expC;
+ if ( signProd == signC ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expDiff <= 0 ) {
+ expZ = expC;
+ sigZ = sigC + softfloat_shiftRightJam32( sigProd, 16 - expDiff );
+ } else {
+ expZ = expProd;
+ sig32Z =
+ sigProd
+ + softfloat_shiftRightJam32(
+ (uint_fast32_t) sigC<<16, expDiff );
+ sigZ = sig32Z>>16 | ((sig32Z & 0xFFFF) != 0 );
+ }
+ if ( sigZ < 0x4000 ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ sig32C = (uint_fast32_t) sigC<<16;
+ if ( expDiff < 0 ) {
+ signZ = signC;
+ expZ = expC;
+ sig32Z = sig32C - softfloat_shiftRightJam32( sigProd, -expDiff );
+ } else if ( ! expDiff ) {
+ expZ = expProd;
+ sig32Z = sigProd - sig32C;
+ if ( ! sig32Z ) goto completeCancellation;
+ if ( sig32Z & 0x80000000 ) {
+ signZ = ! signZ;
+ sig32Z = -sig32Z;
+ }
+ } else {
+ expZ = expProd;
+ sig32Z = sigProd - softfloat_shiftRightJam32( sig32C, expDiff );
+ }
+ shiftDist = softfloat_countLeadingZeros32( sig32Z ) - 1;
+ expZ -= shiftDist;
+ shiftDist -= 16;
+ if ( shiftDist < 0 ) {
+ sigZ =
+ sig32Z>>(-shiftDist)
+ | ((uint32_t) (sig32Z<<(shiftDist & 31)) != 0);
+ } else {
+ sigZ = (uint_fast16_t) sig32Z<
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+
+struct exp16_sig32 softfloat_normSubnormalF32Sig( uint_fast32_t sig )
+{
+ int_fast8_t shiftDist;
+ struct exp16_sig32 z;
+
+ shiftDist = softfloat_countLeadingZeros32( sig ) - 8;
+ z.exp = 1 - shiftDist;
+ z.sig = sig<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float32_t
+ softfloat_roundPackToF32( bool sign, int_fast16_t exp, uint_fast32_t sig )
+{
+ uint_fast8_t roundingMode;
+ bool roundNearEven;
+ uint_fast8_t roundIncrement, roundBits;
+ bool isTiny;
+ uint_fast32_t uiZ;
+ union ui32_f32 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ roundingMode = softfloat_roundingMode;
+ roundNearEven = (roundingMode == softfloat_round_near_even);
+ roundIncrement = 0x40;
+ if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
+ roundIncrement =
+ (roundingMode
+ == (sign ? softfloat_round_min : softfloat_round_max))
+ ? 0x7F
+ : 0;
+ }
+ roundBits = sig & 0x7F;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( 0xFD <= (unsigned int) exp ) {
+ if ( exp < 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ isTiny =
+ (softfloat_detectTininess == softfloat_tininess_beforeRounding)
+ || (exp < -1) || (sig + roundIncrement < 0x80000000);
+ sig = softfloat_shiftRightJam32( sig, -exp );
+ exp = 0;
+ roundBits = sig & 0x7F;
+ if ( isTiny && roundBits ) {
+ softfloat_raiseFlags( softfloat_flag_underflow );
+ }
+ } else if ( (0xFD < exp) || (0x80000000 <= sig + roundIncrement) ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ softfloat_raiseFlags(
+ softfloat_flag_overflow | softfloat_flag_inexact );
+ uiZ = packToF32UI( sign, 0xFF, 0 ) - ! roundIncrement;
+ goto uiZ;
+ }
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig = (sig + roundIncrement)>>7;
+ if ( roundBits ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) {
+ sig |= 1;
+ goto packReturn;
+ }
+#endif
+ }
+ sig &= ~(uint_fast32_t) (! (roundBits ^ 0x40) & roundNearEven);
+ if ( ! sig ) exp = 0;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ packReturn:
+ uiZ = packToF32UI( sign, exp, sig );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_roundPackToF32.c ****/
+/**** start inlining ../../source/s_normRoundPackToF32.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+
+float32_t
+ softfloat_normRoundPackToF32( bool sign, int_fast16_t exp, uint_fast32_t sig )
+{
+ int_fast8_t shiftDist;
+ union ui32_f32 uZ;
+
+ shiftDist = softfloat_countLeadingZeros32( sig ) - 1;
+ exp -= shiftDist;
+ if ( (7 <= shiftDist) && ((unsigned int) exp < 0xFD) ) {
+ uZ.ui = packToF32UI( sign, sig ? exp : 0, sig<<(shiftDist - 7) );
+ return uZ.f;
+ } else {
+ return softfloat_roundPackToF32( sign, exp, sig<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+
+float32_t softfloat_addMagsF32( uint_fast32_t uiA, uint_fast32_t uiB )
+{
+ int_fast16_t expA;
+ uint_fast32_t sigA;
+ int_fast16_t expB;
+ uint_fast32_t sigB;
+ int_fast16_t expDiff;
+ uint_fast32_t uiZ;
+ bool signZ;
+ int_fast16_t expZ;
+ uint_fast32_t sigZ;
+ union ui32_f32 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expF32UI( uiA );
+ sigA = fracF32UI( uiA );
+ expB = expF32UI( uiB );
+ sigB = fracF32UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( ! expA ) {
+ uiZ = uiA + sigB;
+ goto uiZ;
+ }
+ if ( expA == 0xFF ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ signZ = signF32UI( uiA );
+ expZ = expA;
+ sigZ = 0x01000000 + sigA + sigB;
+ if ( ! (sigZ & 1) && (expZ < 0xFE) ) {
+ uiZ = packToF32UI( signZ, expZ, sigZ>>1 );
+ goto uiZ;
+ }
+ sigZ <<= 6;
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ signZ = signF32UI( uiA );
+ sigA <<= 6;
+ sigB <<= 6;
+ if ( expDiff < 0 ) {
+ if ( expB == 0xFF ) {
+ if ( sigB ) goto propagateNaN;
+ uiZ = packToF32UI( signZ, 0xFF, 0 );
+ goto uiZ;
+ }
+ expZ = expB;
+ sigA += expA ? 0x20000000 : sigA;
+ sigA = softfloat_shiftRightJam32( sigA, -expDiff );
+ } else {
+ if ( expA == 0xFF ) {
+ if ( sigA ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ expZ = expA;
+ sigB += expB ? 0x20000000 : sigB;
+ sigB = softfloat_shiftRightJam32( sigB, expDiff );
+ }
+ sigZ = 0x20000000 + sigA + sigB;
+ if ( sigZ < 0x40000000 ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ }
+ return softfloat_roundPackToF32( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF32UI( uiA, uiB );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_addMagsF32.c ****/
+/**** start inlining ../../source/s_subMagsF32.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float32_t softfloat_subMagsF32( uint_fast32_t uiA, uint_fast32_t uiB )
+{
+ int_fast16_t expA;
+ uint_fast32_t sigA;
+ int_fast16_t expB;
+ uint_fast32_t sigB;
+ int_fast16_t expDiff;
+ uint_fast32_t uiZ;
+ int_fast32_t sigDiff;
+ bool signZ;
+ int_fast8_t shiftDist;
+ int_fast16_t expZ;
+ uint_fast32_t sigX, sigY;
+ union ui32_f32 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expF32UI( uiA );
+ sigA = fracF32UI( uiA );
+ expB = expF32UI( uiB );
+ sigB = fracF32UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expA == 0xFF ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF32UI;
+ goto uiZ;
+ }
+ sigDiff = sigA - sigB;
+ if ( ! sigDiff ) {
+ uiZ =
+ packToF32UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
+ goto uiZ;
+ }
+ if ( expA ) --expA;
+ signZ = signF32UI( uiA );
+ if ( sigDiff < 0 ) {
+ signZ = ! signZ;
+ sigDiff = -sigDiff;
+ }
+ shiftDist = softfloat_countLeadingZeros32( sigDiff ) - 8;
+ expZ = expA - shiftDist;
+ if ( expZ < 0 ) {
+ shiftDist = expA;
+ expZ = 0;
+ }
+ uiZ = packToF32UI( signZ, expZ, sigDiff<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float32_t
+ softfloat_mulAddF32(
+ uint_fast32_t uiA, uint_fast32_t uiB, uint_fast32_t uiC, uint_fast8_t op )
+{
+ bool signA;
+ int_fast16_t expA;
+ uint_fast32_t sigA;
+ bool signB;
+ int_fast16_t expB;
+ uint_fast32_t sigB;
+ bool signC;
+ int_fast16_t expC;
+ uint_fast32_t sigC;
+ bool signProd;
+ uint_fast32_t magBits, uiZ;
+ struct exp16_sig32 normExpSig;
+ int_fast16_t expProd;
+ uint_fast64_t sigProd;
+ bool signZ;
+ int_fast16_t expZ;
+ uint_fast32_t sigZ;
+ int_fast16_t expDiff;
+ uint_fast64_t sig64Z, sig64C;
+ int_fast8_t shiftDist;
+ union ui32_f32 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ signA = signF32UI( uiA );
+ expA = expF32UI( uiA );
+ sigA = fracF32UI( uiA );
+ signB = signF32UI( uiB );
+ expB = expF32UI( uiB );
+ sigB = fracF32UI( uiB );
+ signC = signF32UI( uiC ) ^ (op == softfloat_mulAdd_subC);
+ expC = expF32UI( uiC );
+ sigC = fracF32UI( uiC );
+ signProd = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0xFF ) {
+ if ( sigA || ((expB == 0xFF) && sigB) ) goto propagateNaN_ABC;
+ magBits = expB | sigB;
+ goto infProdArg;
+ }
+ if ( expB == 0xFF ) {
+ if ( sigB ) goto propagateNaN_ABC;
+ magBits = expA | sigA;
+ goto infProdArg;
+ }
+ if ( expC == 0xFF ) {
+ if ( sigC ) {
+ uiZ = 0;
+ goto propagateNaN_ZC;
+ }
+ uiZ = uiC;
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF32Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ if ( ! expB ) {
+ if ( ! sigB ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF32Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expProd = expA + expB - 0x7E;
+ sigA = (sigA | 0x00800000)<<7;
+ sigB = (sigB | 0x00800000)<<7;
+ sigProd = (uint_fast64_t) sigA * sigB;
+ if ( sigProd < UINT64_C( 0x2000000000000000 ) ) {
+ --expProd;
+ sigProd <<= 1;
+ }
+ signZ = signProd;
+ if ( ! expC ) {
+ if ( ! sigC ) {
+ expZ = expProd - 1;
+ sigZ = softfloat_shortShiftRightJam64( sigProd, 31 );
+ goto roundPack;
+ }
+ normExpSig = softfloat_normSubnormalF32Sig( sigC );
+ expC = normExpSig.exp;
+ sigC = normExpSig.sig;
+ }
+ sigC = (sigC | 0x00800000)<<6;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expProd - expC;
+ if ( signProd == signC ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expDiff <= 0 ) {
+ expZ = expC;
+ sigZ = sigC + softfloat_shiftRightJam64( sigProd, 32 - expDiff );
+ } else {
+ expZ = expProd;
+ sig64Z =
+ sigProd
+ + softfloat_shiftRightJam64(
+ (uint_fast64_t) sigC<<32, expDiff );
+ sigZ = softfloat_shortShiftRightJam64( sig64Z, 32 );
+ }
+ if ( sigZ < 0x40000000 ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ sig64C = (uint_fast64_t) sigC<<32;
+ if ( expDiff < 0 ) {
+ signZ = signC;
+ expZ = expC;
+ sig64Z = sig64C - softfloat_shiftRightJam64( sigProd, -expDiff );
+ } else if ( ! expDiff ) {
+ expZ = expProd;
+ sig64Z = sigProd - sig64C;
+ if ( ! sig64Z ) goto completeCancellation;
+ if ( sig64Z & UINT64_C( 0x8000000000000000 ) ) {
+ signZ = ! signZ;
+ sig64Z = -sig64Z;
+ }
+ } else {
+ expZ = expProd;
+ sig64Z = sigProd - softfloat_shiftRightJam64( sig64C, expDiff );
+ }
+ shiftDist = softfloat_countLeadingZeros64( sig64Z ) - 1;
+ expZ -= shiftDist;
+ shiftDist -= 32;
+ if ( shiftDist < 0 ) {
+ sigZ = softfloat_shortShiftRightJam64( sig64Z, -shiftDist );
+ } else {
+ sigZ = (uint_fast32_t) sig64Z<
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+
+struct exp16_sig64 softfloat_normSubnormalF64Sig( uint_fast64_t sig )
+{
+ int_fast8_t shiftDist;
+ struct exp16_sig64 z;
+
+ shiftDist = softfloat_countLeadingZeros64( sig ) - 11;
+ z.exp = 1 - shiftDist;
+ z.sig = sig<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float64_t
+ softfloat_roundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
+{
+ uint_fast8_t roundingMode;
+ bool roundNearEven;
+ uint_fast16_t roundIncrement, roundBits;
+ bool isTiny;
+ uint_fast64_t uiZ;
+ union ui64_f64 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ roundingMode = softfloat_roundingMode;
+ roundNearEven = (roundingMode == softfloat_round_near_even);
+ roundIncrement = 0x200;
+ if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
+ roundIncrement =
+ (roundingMode
+ == (sign ? softfloat_round_min : softfloat_round_max))
+ ? 0x3FF
+ : 0;
+ }
+ roundBits = sig & 0x3FF;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( 0x7FD <= (uint16_t) exp ) {
+ if ( exp < 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ isTiny =
+ (softfloat_detectTininess == softfloat_tininess_beforeRounding)
+ || (exp < -1)
+ || (sig + roundIncrement < UINT64_C( 0x8000000000000000 ));
+ sig = softfloat_shiftRightJam64( sig, -exp );
+ exp = 0;
+ roundBits = sig & 0x3FF;
+ if ( isTiny && roundBits ) {
+ softfloat_raiseFlags( softfloat_flag_underflow );
+ }
+ } else if (
+ (0x7FD < exp)
+ || (UINT64_C( 0x8000000000000000 ) <= sig + roundIncrement)
+ ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ softfloat_raiseFlags(
+ softfloat_flag_overflow | softfloat_flag_inexact );
+ uiZ = packToF64UI( sign, 0x7FF, 0 ) - ! roundIncrement;
+ goto uiZ;
+ }
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig = (sig + roundIncrement)>>10;
+ if ( roundBits ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) {
+ sig |= 1;
+ goto packReturn;
+ }
+#endif
+ }
+ sig &= ~(uint_fast64_t) (! (roundBits ^ 0x200) & roundNearEven);
+ if ( ! sig ) exp = 0;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ packReturn:
+ uiZ = packToF64UI( sign, exp, sig );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_roundPackToF64.c ****/
+/**** start inlining ../../source/s_normRoundPackToF64.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+
+float64_t
+ softfloat_normRoundPackToF64( bool sign, int_fast16_t exp, uint_fast64_t sig )
+{
+ int_fast8_t shiftDist;
+ union ui64_f64 uZ;
+
+ shiftDist = softfloat_countLeadingZeros64( sig ) - 1;
+ exp -= shiftDist;
+ if ( (10 <= shiftDist) && ((unsigned int) exp < 0x7FD) ) {
+ uZ.ui = packToF64UI( sign, sig ? exp : 0, sig<<(shiftDist - 10) );
+ return uZ.f;
+ } else {
+ return softfloat_roundPackToF64( sign, exp, sig<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+
+float64_t
+ softfloat_addMagsF64( uint_fast64_t uiA, uint_fast64_t uiB, bool signZ )
+{
+ int_fast16_t expA;
+ uint_fast64_t sigA;
+ int_fast16_t expB;
+ uint_fast64_t sigB;
+ int_fast16_t expDiff;
+ uint_fast64_t uiZ;
+ int_fast16_t expZ;
+ uint_fast64_t sigZ;
+ union ui64_f64 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expF64UI( uiA );
+ sigA = fracF64UI( uiA );
+ expB = expF64UI( uiB );
+ sigB = fracF64UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( ! expA ) {
+ uiZ = uiA + sigB;
+ goto uiZ;
+ }
+ if ( expA == 0x7FF ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ expZ = expA;
+ sigZ = UINT64_C( 0x0020000000000000 ) + sigA + sigB;
+ sigZ <<= 9;
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ sigA <<= 9;
+ sigB <<= 9;
+ if ( expDiff < 0 ) {
+ if ( expB == 0x7FF ) {
+ if ( sigB ) goto propagateNaN;
+ uiZ = packToF64UI( signZ, 0x7FF, 0 );
+ goto uiZ;
+ }
+ expZ = expB;
+ if ( expA ) {
+ sigA += UINT64_C( 0x2000000000000000 );
+ } else {
+ sigA <<= 1;
+ }
+ sigA = softfloat_shiftRightJam64( sigA, -expDiff );
+ } else {
+ if ( expA == 0x7FF ) {
+ if ( sigA ) goto propagateNaN;
+ uiZ = uiA;
+ goto uiZ;
+ }
+ expZ = expA;
+ if ( expB ) {
+ sigB += UINT64_C( 0x2000000000000000 );
+ } else {
+ sigB <<= 1;
+ }
+ sigB = softfloat_shiftRightJam64( sigB, expDiff );
+ }
+ sigZ = UINT64_C( 0x2000000000000000 ) + sigA + sigB;
+ if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ }
+ return softfloat_roundPackToF64( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_addMagsF64.c ****/
+/**** start inlining ../../source/s_subMagsF64.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float64_t
+ softfloat_subMagsF64( uint_fast64_t uiA, uint_fast64_t uiB, bool signZ )
+{
+ int_fast16_t expA;
+ uint_fast64_t sigA;
+ int_fast16_t expB;
+ uint_fast64_t sigB;
+ int_fast16_t expDiff;
+ uint_fast64_t uiZ;
+ int_fast64_t sigDiff;
+ int_fast8_t shiftDist;
+ int_fast16_t expZ;
+ uint_fast64_t sigZ;
+ union ui64_f64 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expF64UI( uiA );
+ sigA = fracF64UI( uiA );
+ expB = expF64UI( uiB );
+ sigB = fracF64UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expA == 0x7FF ) {
+ if ( sigA | sigB ) goto propagateNaN;
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF64UI;
+ goto uiZ;
+ }
+ sigDiff = sigA - sigB;
+ if ( ! sigDiff ) {
+ uiZ =
+ packToF64UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
+ goto uiZ;
+ }
+ if ( expA ) --expA;
+ if ( sigDiff < 0 ) {
+ signZ = ! signZ;
+ sigDiff = -sigDiff;
+ }
+ shiftDist = softfloat_countLeadingZeros64( sigDiff ) - 11;
+ expZ = expA - shiftDist;
+ if ( expZ < 0 ) {
+ shiftDist = expA;
+ expZ = 0;
+ }
+ uiZ = packToF64UI( signZ, expZ, sigDiff<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+float64_t
+ softfloat_mulAddF64(
+ uint_fast64_t uiA, uint_fast64_t uiB, uint_fast64_t uiC, uint_fast8_t op )
+{
+ bool signA;
+ int_fast16_t expA;
+ uint_fast64_t sigA;
+ bool signB;
+ int_fast16_t expB;
+ uint_fast64_t sigB;
+ bool signC;
+ int_fast16_t expC;
+ uint_fast64_t sigC;
+ bool signZ;
+ uint_fast64_t magBits, uiZ;
+ struct exp16_sig64 normExpSig;
+ int_fast16_t expZ;
+ struct uint128 sig128Z;
+ uint_fast64_t sigZ;
+ int_fast16_t expDiff;
+ struct uint128 sig128C;
+ int_fast8_t shiftDist;
+ union ui64_f64 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ signA = signF64UI( uiA );
+ expA = expF64UI( uiA );
+ sigA = fracF64UI( uiA );
+ signB = signF64UI( uiB );
+ expB = expF64UI( uiB );
+ sigB = fracF64UI( uiB );
+ signC = signF64UI( uiC ) ^ (op == softfloat_mulAdd_subC);
+ expC = expF64UI( uiC );
+ sigC = fracF64UI( uiC );
+ signZ = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x7FF ) {
+ if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN_ABC;
+ magBits = expB | sigB;
+ goto infProdArg;
+ }
+ if ( expB == 0x7FF ) {
+ if ( sigB ) goto propagateNaN_ABC;
+ magBits = expA | sigA;
+ goto infProdArg;
+ }
+ if ( expC == 0x7FF ) {
+ if ( sigC ) {
+ uiZ = 0;
+ goto propagateNaN_ZC;
+ }
+ uiZ = uiC;
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF64Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ if ( ! expB ) {
+ if ( ! sigB ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF64Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = expA + expB - 0x3FE;
+ sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
+ sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<10;
+ sig128Z = softfloat_mul64To128( sigA, sigB );
+ if ( sig128Z.v64 < UINT64_C( 0x2000000000000000 ) ) {
+ --expZ;
+ sig128Z =
+ softfloat_add128(
+ sig128Z.v64, sig128Z.v0, sig128Z.v64, sig128Z.v0 );
+ }
+ if ( ! expC ) {
+ if ( ! sigC ) {
+ --expZ;
+ sigZ = sig128Z.v64<<1 | (sig128Z.v0 != 0);
+ goto roundPack;
+ }
+ normExpSig = softfloat_normSubnormalF64Sig( sigC );
+ expC = normExpSig.exp;
+ sigC = normExpSig.sig;
+ }
+ sigC = (sigC | UINT64_C( 0x0010000000000000 ))<<9;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expZ - expC;
+ if ( expDiff < 0 ) {
+ expZ = expC;
+ if ( (signZ == signC) || (expDiff < -1) ) {
+ sig128Z.v64 = softfloat_shiftRightJam64( sig128Z.v64, -expDiff );
+ } else {
+ sig128Z =
+ softfloat_shortShiftRightJam128( sig128Z.v64, sig128Z.v0, 1 );
+ }
+ } else if ( expDiff ) {
+ sig128C = softfloat_shiftRightJam128( sigC, 0, expDiff );
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( signZ == signC ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expDiff <= 0 ) {
+ sigZ = (sigC + sig128Z.v64) | (sig128Z.v0 != 0);
+ } else {
+ sig128Z =
+ softfloat_add128(
+ sig128Z.v64, sig128Z.v0, sig128C.v64, sig128C.v0 );
+ sigZ = sig128Z.v64 | (sig128Z.v0 != 0);
+ }
+ if ( sigZ < UINT64_C( 0x4000000000000000 ) ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expDiff < 0 ) {
+ signZ = signC;
+ sig128Z = softfloat_sub128( sigC, 0, sig128Z.v64, sig128Z.v0 );
+ } else if ( ! expDiff ) {
+ sig128Z.v64 = sig128Z.v64 - sigC;
+ if ( ! (sig128Z.v64 | sig128Z.v0) ) goto completeCancellation;
+ if ( sig128Z.v64 & UINT64_C( 0x8000000000000000 ) ) {
+ signZ = ! signZ;
+ sig128Z = softfloat_sub128( 0, 0, sig128Z.v64, sig128Z.v0 );
+ }
+ } else {
+ sig128Z =
+ softfloat_sub128(
+ sig128Z.v64, sig128Z.v0, sig128C.v64, sig128C.v0 );
+ }
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( ! sig128Z.v64 ) {
+ expZ -= 64;
+ sig128Z.v64 = sig128Z.v0;
+ sig128Z.v0 = 0;
+ }
+ shiftDist = softfloat_countLeadingZeros64( sig128Z.v64 ) - 1;
+ expZ -= shiftDist;
+ if ( shiftDist < 0 ) {
+ sigZ = softfloat_shortShiftRightJam64( sig128Z.v64, -shiftDist );
+ } else {
+ sig128Z =
+ softfloat_shortShiftLeft128(
+ sig128Z.v64, sig128Z.v0, shiftDist );
+ sigZ = sig128Z.v64;
+ }
+ sigZ |= (sig128Z.v0 != 0);
+ }
+ roundPack:
+ return softfloat_roundPackToF64( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN_ABC:
+ uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
+ goto propagateNaN_ZC;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infProdArg:
+ if ( magBits ) {
+ uiZ = packToF64UI( signZ, 0x7FF, 0 );
+ if ( expC != 0x7FF ) goto uiZ;
+ if ( sigC ) goto propagateNaN_ZC;
+ if ( signZ == signC ) goto uiZ;
+ }
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF64UI;
+ propagateNaN_ZC:
+ uiZ = softfloat_propagateNaNF64UI( uiZ, uiC );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zeroProd:
+ uiZ = uiC;
+ if ( ! (expC | sigC) && (signZ != signC) ) {
+ completeCancellation:
+ uiZ =
+ packToF64UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
+ }
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+#else
+
+float64_t
+ softfloat_mulAddF64(
+ uint_fast64_t uiA, uint_fast64_t uiB, uint_fast64_t uiC, uint_fast8_t op )
+{
+ bool signA;
+ int_fast16_t expA;
+ uint64_t sigA;
+ bool signB;
+ int_fast16_t expB;
+ uint64_t sigB;
+ bool signC;
+ int_fast16_t expC;
+ uint64_t sigC;
+ bool signZ;
+ uint64_t magBits, uiZ;
+ struct exp16_sig64 normExpSig;
+ int_fast16_t expZ;
+ uint32_t sig128Z[4];
+ uint64_t sigZ;
+ int_fast16_t shiftDist, expDiff;
+ uint32_t sig128C[4];
+ union ui64_f64 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ signA = signF64UI( uiA );
+ expA = expF64UI( uiA );
+ sigA = fracF64UI( uiA );
+ signB = signF64UI( uiB );
+ expB = expF64UI( uiB );
+ sigB = fracF64UI( uiB );
+ signC = signF64UI( uiC ) ^ (op == softfloat_mulAdd_subC);
+ expC = expF64UI( uiC );
+ sigC = fracF64UI( uiC );
+ signZ = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x7FF ) {
+ if ( sigA || ((expB == 0x7FF) && sigB) ) goto propagateNaN_ABC;
+ magBits = expB | sigB;
+ goto infProdArg;
+ }
+ if ( expB == 0x7FF ) {
+ if ( sigB ) goto propagateNaN_ABC;
+ magBits = expA | sigA;
+ goto infProdArg;
+ }
+ if ( expC == 0x7FF ) {
+ if ( sigC ) {
+ uiZ = 0;
+ goto propagateNaN_ZC;
+ }
+ uiZ = uiC;
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF64Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ if ( ! expB ) {
+ if ( ! sigB ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF64Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = expA + expB - 0x3FE;
+ sigA = (sigA | UINT64_C( 0x0010000000000000 ))<<10;
+ sigB = (sigB | UINT64_C( 0x0010000000000000 ))<<11;
+ softfloat_mul64To128M( sigA, sigB, sig128Z );
+ sigZ =
+ (uint64_t) sig128Z[indexWord( 4, 3 )]<<32 | sig128Z[indexWord( 4, 2 )];
+ shiftDist = 0;
+ if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
+ --expZ;
+ shiftDist = -1;
+ }
+ if ( ! expC ) {
+ if ( ! sigC ) {
+ if ( shiftDist ) sigZ <<= 1;
+ goto sigZ;
+ }
+ normExpSig = softfloat_normSubnormalF64Sig( sigC );
+ expC = normExpSig.exp;
+ sigC = normExpSig.sig;
+ }
+ sigC = (sigC | UINT64_C( 0x0010000000000000 ))<<10;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expZ - expC;
+ if ( expDiff < 0 ) {
+ expZ = expC;
+ if ( (signZ == signC) || (expDiff < -1) ) {
+ shiftDist -= expDiff;
+ if ( shiftDist) {
+ sigZ = softfloat_shiftRightJam64( sigZ, shiftDist );
+ }
+ } else {
+ if ( ! shiftDist ) {
+ softfloat_shortShiftRight128M( sig128Z, 1, sig128Z );
+ }
+ }
+ } else {
+ if ( shiftDist ) softfloat_add128M( sig128Z, sig128Z, sig128Z );
+ if ( ! expDiff ) {
+ sigZ =
+ (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
+ | sig128Z[indexWord( 4, 2 )];
+ } else {
+ sig128C[indexWord( 4, 3 )] = sigC>>32;
+ sig128C[indexWord( 4, 2 )] = sigC;
+ sig128C[indexWord( 4, 1 )] = 0;
+ sig128C[indexWord( 4, 0 )] = 0;
+ softfloat_shiftRightJam128M( sig128C, expDiff, sig128C );
+ }
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( signZ == signC ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expDiff <= 0 ) {
+ sigZ += sigC;
+ } else {
+ softfloat_add128M( sig128Z, sig128C, sig128Z );
+ sigZ =
+ (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
+ | sig128Z[indexWord( 4, 2 )];
+ }
+ if ( sigZ & UINT64_C( 0x8000000000000000 ) ) {
+ ++expZ;
+ sigZ = softfloat_shortShiftRightJam64( sigZ, 1 );
+ }
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expDiff < 0 ) {
+ signZ = signC;
+ if ( expDiff < -1 ) {
+ sigZ = sigC - sigZ;
+ if (
+ sig128Z[indexWord( 4, 1 )] || sig128Z[indexWord( 4, 0 )]
+ ) {
+ sigZ = (sigZ - 1) | 1;
+ }
+ if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ goto roundPack;
+ } else {
+ sig128C[indexWord( 4, 3 )] = sigC>>32;
+ sig128C[indexWord( 4, 2 )] = sigC;
+ sig128C[indexWord( 4, 1 )] = 0;
+ sig128C[indexWord( 4, 0 )] = 0;
+ softfloat_sub128M( sig128C, sig128Z, sig128Z );
+ }
+ } else if ( ! expDiff ) {
+ sigZ -= sigC;
+ if (
+ ! sigZ && ! sig128Z[indexWord( 4, 1 )]
+ && ! sig128Z[indexWord( 4, 0 )]
+ ) {
+ goto completeCancellation;
+ }
+ sig128Z[indexWord( 4, 3 )] = sigZ>>32;
+ sig128Z[indexWord( 4, 2 )] = sigZ;
+ if ( sigZ & UINT64_C( 0x8000000000000000 ) ) {
+ signZ = ! signZ;
+ softfloat_negX128M( sig128Z );
+ }
+ } else {
+ softfloat_sub128M( sig128Z, sig128C, sig128Z );
+ if ( 1 < expDiff ) {
+ sigZ =
+ (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
+ | sig128Z[indexWord( 4, 2 )];
+ if ( ! (sigZ & UINT64_C( 0x4000000000000000 )) ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ goto sigZ;
+ }
+ }
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ shiftDist = 0;
+ sigZ =
+ (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
+ | sig128Z[indexWord( 4, 2 )];
+ if ( ! sigZ ) {
+ shiftDist = 64;
+ sigZ =
+ (uint64_t) sig128Z[indexWord( 4, 1 )]<<32
+ | sig128Z[indexWord( 4, 0 )];
+ }
+ shiftDist += softfloat_countLeadingZeros64( sigZ ) - 1;
+ if ( shiftDist ) {
+ expZ -= shiftDist;
+ softfloat_shiftLeft128M( sig128Z, shiftDist, sig128Z );
+ sigZ =
+ (uint64_t) sig128Z[indexWord( 4, 3 )]<<32
+ | sig128Z[indexWord( 4, 2 )];
+ }
+ }
+ sigZ:
+ if ( sig128Z[indexWord( 4, 1 )] || sig128Z[indexWord( 4, 0 )] ) sigZ |= 1;
+ roundPack:
+ return softfloat_roundPackToF64( signZ, expZ - 1, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN_ABC:
+ uiZ = softfloat_propagateNaNF64UI( uiA, uiB );
+ goto propagateNaN_ZC;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infProdArg:
+ if ( magBits ) {
+ uiZ = packToF64UI( signZ, 0x7FF, 0 );
+ if ( expC != 0x7FF ) goto uiZ;
+ if ( sigC ) goto propagateNaN_ZC;
+ if ( signZ == signC ) goto uiZ;
+ }
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF64UI;
+ propagateNaN_ZC:
+ uiZ = softfloat_propagateNaNF64UI( uiZ, uiC );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zeroProd:
+ uiZ = uiC;
+ if ( ! (expC | sigC) && (signZ != signC) ) {
+ completeCancellation:
+ uiZ =
+ packToF64UI(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
+ }
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/s_mulAddF64.c ****/
+/**** start inlining ../../source/s_normSubnormalExtF80Sig.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+
+struct exp32_sig64 softfloat_normSubnormalExtF80Sig( uint_fast64_t sig )
+{
+ int_fast8_t shiftDist;
+ struct exp32_sig64 z;
+
+ shiftDist = softfloat_countLeadingZeros64( sig );
+ z.exp = -shiftDist;
+ z.sig = sig<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+extFloat80_t
+ softfloat_roundPackToExtF80(
+ bool sign,
+ int_fast32_t exp,
+ uint_fast64_t sig,
+ uint_fast64_t sigExtra,
+ uint_fast8_t roundingPrecision
+ )
+{
+ uint_fast8_t roundingMode;
+ bool roundNearEven;
+ uint_fast64_t roundIncrement, roundMask, roundBits;
+ bool isTiny, doIncrement;
+ struct uint64_extra sig64Extra;
+ union { struct extFloat80M s; extFloat80_t f; } uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ roundingMode = softfloat_roundingMode;
+ roundNearEven = (roundingMode == softfloat_round_near_even);
+ if ( roundingPrecision == 80 ) goto precision80;
+ if ( roundingPrecision == 64 ) {
+ roundIncrement = UINT64_C( 0x0000000000000400 );
+ roundMask = UINT64_C( 0x00000000000007FF );
+ } else if ( roundingPrecision == 32 ) {
+ roundIncrement = UINT64_C( 0x0000008000000000 );
+ roundMask = UINT64_C( 0x000000FFFFFFFFFF );
+ } else {
+ goto precision80;
+ }
+ sig |= (sigExtra != 0);
+ if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
+ roundIncrement =
+ (roundingMode
+ == (sign ? softfloat_round_min : softfloat_round_max))
+ ? roundMask
+ : 0;
+ }
+ roundBits = sig & roundMask;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( 0x7FFD <= (uint32_t) (exp - 1) ) {
+ if ( exp <= 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ isTiny =
+ (softfloat_detectTininess
+ == softfloat_tininess_beforeRounding)
+ || (exp < 0)
+ || (sig <= (uint64_t) (sig + roundIncrement));
+ sig = softfloat_shiftRightJam64( sig, 1 - exp );
+ roundBits = sig & roundMask;
+ if ( roundBits ) {
+ if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) {
+ sig |= roundMask + 1;
+ }
+#endif
+ }
+ sig += roundIncrement;
+ exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
+ roundIncrement = roundMask + 1;
+ if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
+ roundMask |= roundIncrement;
+ }
+ sig &= ~roundMask;
+ goto packReturn;
+ }
+ if (
+ (0x7FFE < exp)
+ || ((exp == 0x7FFE) && ((uint64_t) (sig + roundIncrement) < sig))
+ ) {
+ goto overflow;
+ }
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( roundBits ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) {
+ sig = (sig & ~roundMask) | (roundMask + 1);
+ goto packReturn;
+ }
+#endif
+ }
+ sig = (uint64_t) (sig + roundIncrement);
+ if ( sig < roundIncrement ) {
+ ++exp;
+ sig = UINT64_C( 0x8000000000000000 );
+ }
+ roundIncrement = roundMask + 1;
+ if ( roundNearEven && (roundBits<<1 == roundIncrement) ) {
+ roundMask |= roundIncrement;
+ }
+ sig &= ~roundMask;
+ goto packReturn;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ precision80:
+ doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
+ if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
+ doIncrement =
+ (roundingMode
+ == (sign ? softfloat_round_min : softfloat_round_max))
+ && sigExtra;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( 0x7FFD <= (uint32_t) (exp - 1) ) {
+ if ( exp <= 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ isTiny =
+ (softfloat_detectTininess
+ == softfloat_tininess_beforeRounding)
+ || (exp < 0)
+ || ! doIncrement
+ || (sig < UINT64_C( 0xFFFFFFFFFFFFFFFF ));
+ sig64Extra =
+ softfloat_shiftRightJam64Extra( sig, sigExtra, 1 - exp );
+ exp = 0;
+ sig = sig64Extra.v;
+ sigExtra = sig64Extra.extra;
+ if ( sigExtra ) {
+ if ( isTiny ) softfloat_raiseFlags( softfloat_flag_underflow );
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) {
+ sig |= 1;
+ goto packReturn;
+ }
+#endif
+ }
+ doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
+ if (
+ ! roundNearEven
+ && (roundingMode != softfloat_round_near_maxMag)
+ ) {
+ doIncrement =
+ (roundingMode
+ == (sign ? softfloat_round_min : softfloat_round_max))
+ && sigExtra;
+ }
+ if ( doIncrement ) {
+ ++sig;
+ sig &=
+ ~(uint_fast64_t)
+ (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
+ & roundNearEven);
+ exp = ((sig & UINT64_C( 0x8000000000000000 )) != 0);
+ }
+ goto packReturn;
+ }
+ if (
+ (0x7FFE < exp)
+ || ((exp == 0x7FFE) && (sig == UINT64_C( 0xFFFFFFFFFFFFFFFF ))
+ && doIncrement)
+ ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ roundMask = 0;
+ overflow:
+ softfloat_raiseFlags(
+ softfloat_flag_overflow | softfloat_flag_inexact );
+ if (
+ roundNearEven
+ || (roundingMode == softfloat_round_near_maxMag)
+ || (roundingMode
+ == (sign ? softfloat_round_min : softfloat_round_max))
+ ) {
+ exp = 0x7FFF;
+ sig = UINT64_C( 0x8000000000000000 );
+ } else {
+ exp = 0x7FFE;
+ sig = ~roundMask;
+ }
+ goto packReturn;
+ }
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( sigExtra ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) {
+ sig |= 1;
+ goto packReturn;
+ }
+#endif
+ }
+ if ( doIncrement ) {
+ ++sig;
+ if ( ! sig ) {
+ ++exp;
+ sig = UINT64_C( 0x8000000000000000 );
+ } else {
+ sig &=
+ ~(uint_fast64_t)
+ (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
+ & roundNearEven);
+ }
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ packReturn:
+ uZ.s.signExp = packToExtF80UI64( sign, exp );
+ uZ.s.signif = sig;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_roundPackToExtF80.c ****/
+/**** start inlining ../../source/s_normRoundPackToExtF80.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+
+extFloat80_t
+ softfloat_normRoundPackToExtF80(
+ bool sign,
+ int_fast32_t exp,
+ uint_fast64_t sig,
+ uint_fast64_t sigExtra,
+ uint_fast8_t roundingPrecision
+ )
+{
+ int_fast8_t shiftDist;
+ struct uint128 sig128;
+
+ if ( ! sig ) {
+ exp -= 64;
+ sig = sigExtra;
+ sigExtra = 0;
+ }
+ shiftDist = softfloat_countLeadingZeros64( sig );
+ exp -= shiftDist;
+ if ( shiftDist ) {
+ sig128 = softfloat_shortShiftLeft128( sig, sigExtra, shiftDist );
+ sig = sig128.v64;
+ sigExtra = sig128.v0;
+ }
+ return
+ softfloat_roundPackToExtF80(
+ sign, exp, sig, sigExtra, roundingPrecision );
+
+}
+
+/**** ended inlining ../../source/s_normRoundPackToExtF80.c ****/
+/**** start inlining ../../source/s_addMagsExtF80.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+extFloat80_t
+ softfloat_addMagsExtF80(
+ uint_fast16_t uiA64,
+ uint_fast64_t uiA0,
+ uint_fast16_t uiB64,
+ uint_fast64_t uiB0,
+ bool signZ
+ )
+{
+ int_fast32_t expA;
+ uint_fast64_t sigA;
+ int_fast32_t expB;
+ uint_fast64_t sigB;
+ int_fast32_t expDiff;
+ uint_fast16_t uiZ64;
+ uint_fast64_t uiZ0, sigZ, sigZExtra;
+ struct exp32_sig64 normExpSig;
+ int_fast32_t expZ;
+ struct uint64_extra sig64Extra;
+ struct uint128 uiZ;
+ union { struct extFloat80M s; extFloat80_t f; } uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expExtF80UI64( uiA64 );
+ sigA = uiA0;
+ expB = expExtF80UI64( uiB64 );
+ sigB = uiB0;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ if ( expA == 0x7FFF ) {
+ if ( (sigA | sigB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
+ goto propagateNaN;
+ }
+ uiZ64 = uiA64;
+ uiZ0 = uiA0;
+ goto uiZ;
+ }
+ sigZ = sigA + sigB;
+ sigZExtra = 0;
+ if ( ! expA ) {
+ normExpSig = softfloat_normSubnormalExtF80Sig( sigZ );
+ expZ = normExpSig.exp + 1;
+ sigZ = normExpSig.sig;
+ goto roundAndPack;
+ }
+ expZ = expA;
+ goto shiftRight1;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expDiff < 0 ) {
+ if ( expB == 0x7FFF ) {
+ if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
+ uiZ64 = packToExtF80UI64( signZ, 0x7FFF );
+ uiZ0 = uiB0;
+ goto uiZ;
+ }
+ expZ = expB;
+ if ( ! expA ) {
+ ++expDiff;
+ sigZExtra = 0;
+ if ( ! expDiff ) goto newlyAligned;
+ }
+ sig64Extra = softfloat_shiftRightJam64Extra( sigA, 0, -expDiff );
+ sigA = sig64Extra.v;
+ sigZExtra = sig64Extra.extra;
+ } else {
+ if ( expA == 0x7FFF ) {
+ if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
+ uiZ64 = uiA64;
+ uiZ0 = uiA0;
+ goto uiZ;
+ }
+ expZ = expA;
+ if ( ! expB ) {
+ --expDiff;
+ sigZExtra = 0;
+ if ( ! expDiff ) goto newlyAligned;
+ }
+ sig64Extra = softfloat_shiftRightJam64Extra( sigB, 0, expDiff );
+ sigB = sig64Extra.v;
+ sigZExtra = sig64Extra.extra;
+ }
+ newlyAligned:
+ sigZ = sigA + sigB;
+ if ( sigZ & UINT64_C( 0x8000000000000000 ) ) goto roundAndPack;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ shiftRight1:
+ sig64Extra = softfloat_shortShiftRightJam64Extra( sigZ, sigZExtra, 1 );
+ sigZ = sig64Extra.v | UINT64_C( 0x8000000000000000 );
+ sigZExtra = sig64Extra.extra;
+ ++expZ;
+ roundAndPack:
+ return
+ softfloat_roundPackToExtF80(
+ signZ, expZ, sigZ, sigZExtra, extF80_roundingPrecision );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
+ uiZ64 = uiZ.v64;
+ uiZ0 = uiZ.v0;
+ uiZ:
+ uZ.s.signExp = uiZ64;
+ uZ.s.signif = uiZ0;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_addMagsExtF80.c ****/
+/**** start inlining ../../source/s_subMagsExtF80.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+extFloat80_t
+ softfloat_subMagsExtF80(
+ uint_fast16_t uiA64,
+ uint_fast64_t uiA0,
+ uint_fast16_t uiB64,
+ uint_fast64_t uiB0,
+ bool signZ
+ )
+{
+ int_fast32_t expA;
+ uint_fast64_t sigA;
+ int_fast32_t expB;
+ uint_fast64_t sigB;
+ int_fast32_t expDiff;
+ uint_fast16_t uiZ64;
+ uint_fast64_t uiZ0;
+ int_fast32_t expZ;
+ uint_fast64_t sigExtra;
+ struct uint128 sig128, uiZ;
+ union { struct extFloat80M s; extFloat80_t f; } uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expA = expExtF80UI64( uiA64 );
+ sigA = uiA0;
+ expB = expExtF80UI64( uiB64 );
+ sigB = uiB0;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expA - expB;
+ if ( 0 < expDiff ) goto expABigger;
+ if ( expDiff < 0 ) goto expBBigger;
+ if ( expA == 0x7FFF ) {
+ if ( (sigA | sigB) & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) {
+ goto propagateNaN;
+ }
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ64 = defaultNaNExtF80UI64;
+ uiZ0 = defaultNaNExtF80UI0;
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = expA;
+ if ( ! expZ ) expZ = 1;
+ sigExtra = 0;
+ if ( sigB < sigA ) goto aBigger;
+ if ( sigA < sigB ) goto bBigger;
+ uiZ64 =
+ packToExtF80UI64( (softfloat_roundingMode == softfloat_round_min), 0 );
+ uiZ0 = 0;
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expBBigger:
+ if ( expB == 0x7FFF ) {
+ if ( sigB & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
+ uiZ64 = packToExtF80UI64( signZ ^ 1, 0x7FFF );
+ uiZ0 = UINT64_C( 0x8000000000000000 );
+ goto uiZ;
+ }
+ if ( ! expA ) {
+ ++expDiff;
+ sigExtra = 0;
+ if ( ! expDiff ) goto newlyAlignedBBigger;
+ }
+ sig128 = softfloat_shiftRightJam128( sigA, 0, -expDiff );
+ sigA = sig128.v64;
+ sigExtra = sig128.v0;
+ newlyAlignedBBigger:
+ expZ = expB;
+ bBigger:
+ signZ = ! signZ;
+ sig128 = softfloat_sub128( sigB, 0, sigA, sigExtra );
+ goto normRoundPack;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expABigger:
+ if ( expA == 0x7FFF ) {
+ if ( sigA & UINT64_C( 0x7FFFFFFFFFFFFFFF ) ) goto propagateNaN;
+ uiZ64 = uiA64;
+ uiZ0 = uiA0;
+ goto uiZ;
+ }
+ if ( ! expB ) {
+ --expDiff;
+ sigExtra = 0;
+ if ( ! expDiff ) goto newlyAlignedABigger;
+ }
+ sig128 = softfloat_shiftRightJam128( sigB, 0, expDiff );
+ sigB = sig128.v64;
+ sigExtra = sig128.v0;
+ newlyAlignedABigger:
+ expZ = expA;
+ aBigger:
+ sig128 = softfloat_sub128( sigA, 0, sigB, sigExtra );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ normRoundPack:
+ return
+ softfloat_normRoundPackToExtF80(
+ signZ, expZ, sig128.v64, sig128.v0, extF80_roundingPrecision );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNExtF80UI( uiA64, uiA0, uiB64, uiB0 );
+ uiZ64 = uiZ.v64;
+ uiZ0 = uiZ.v0;
+ uiZ:
+ uZ.s.signExp = uiZ64;
+ uZ.s.signif = uiZ0;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_subMagsExtF80.c ****/
+/**** start inlining ../../source/s_normSubnormalF128Sig.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+
+struct exp32_sig128
+ softfloat_normSubnormalF128Sig( uint_fast64_t sig64, uint_fast64_t sig0 )
+{
+ int_fast8_t shiftDist;
+ struct exp32_sig128 z;
+
+ if ( ! sig64 ) {
+ shiftDist = softfloat_countLeadingZeros64( sig0 ) - 15;
+ z.exp = -63 - shiftDist;
+ if ( shiftDist < 0 ) {
+ z.sig.v64 = sig0>>-shiftDist;
+ z.sig.v0 = sig0<<(shiftDist & 63);
+ } else {
+ z.sig.v64 = sig0<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float128_t
+ softfloat_roundPackToF128(
+ bool sign,
+ int_fast32_t exp,
+ uint_fast64_t sig64,
+ uint_fast64_t sig0,
+ uint_fast64_t sigExtra
+ )
+{
+ uint_fast8_t roundingMode;
+ bool roundNearEven, doIncrement, isTiny;
+ struct uint128_extra sig128Extra;
+ uint_fast64_t uiZ64, uiZ0;
+ struct uint128 sig128;
+ union ui128_f128 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ roundingMode = softfloat_roundingMode;
+ roundNearEven = (roundingMode == softfloat_round_near_even);
+ doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
+ if ( ! roundNearEven && (roundingMode != softfloat_round_near_maxMag) ) {
+ doIncrement =
+ (roundingMode
+ == (sign ? softfloat_round_min : softfloat_round_max))
+ && sigExtra;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( 0x7FFD <= (uint32_t) exp ) {
+ if ( exp < 0 ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ isTiny =
+ (softfloat_detectTininess
+ == softfloat_tininess_beforeRounding)
+ || (exp < -1)
+ || ! doIncrement
+ || softfloat_lt128(
+ sig64,
+ sig0,
+ UINT64_C( 0x0001FFFFFFFFFFFF ),
+ UINT64_C( 0xFFFFFFFFFFFFFFFF )
+ );
+ sig128Extra =
+ softfloat_shiftRightJam128Extra( sig64, sig0, sigExtra, -exp );
+ sig64 = sig128Extra.v.v64;
+ sig0 = sig128Extra.v.v0;
+ sigExtra = sig128Extra.extra;
+ exp = 0;
+ if ( isTiny && sigExtra ) {
+ softfloat_raiseFlags( softfloat_flag_underflow );
+ }
+ doIncrement = (UINT64_C( 0x8000000000000000 ) <= sigExtra);
+ if (
+ ! roundNearEven
+ && (roundingMode != softfloat_round_near_maxMag)
+ ) {
+ doIncrement =
+ (roundingMode
+ == (sign ? softfloat_round_min : softfloat_round_max))
+ && sigExtra;
+ }
+ } else if (
+ (0x7FFD < exp)
+ || ((exp == 0x7FFD)
+ && softfloat_eq128(
+ sig64,
+ sig0,
+ UINT64_C( 0x0001FFFFFFFFFFFF ),
+ UINT64_C( 0xFFFFFFFFFFFFFFFF )
+ )
+ && doIncrement)
+ ) {
+ /*----------------------------------------------------------------
+ *----------------------------------------------------------------*/
+ softfloat_raiseFlags(
+ softfloat_flag_overflow | softfloat_flag_inexact );
+ if (
+ roundNearEven
+ || (roundingMode == softfloat_round_near_maxMag)
+ || (roundingMode
+ == (sign ? softfloat_round_min : softfloat_round_max))
+ ) {
+ uiZ64 = packToF128UI64( sign, 0x7FFF, 0 );
+ uiZ0 = 0;
+ } else {
+ uiZ64 =
+ packToF128UI64(
+ sign, 0x7FFE, UINT64_C( 0x0000FFFFFFFFFFFF ) );
+ uiZ0 = UINT64_C( 0xFFFFFFFFFFFFFFFF );
+ }
+ goto uiZ;
+ }
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( sigExtra ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) {
+ sig0 |= 1;
+ goto packReturn;
+ }
+#endif
+ }
+ if ( doIncrement ) {
+ sig128 = softfloat_add128( sig64, sig0, 0, 1 );
+ sig64 = sig128.v64;
+ sig0 =
+ sig128.v0
+ & ~(uint64_t)
+ (! (sigExtra & UINT64_C( 0x7FFFFFFFFFFFFFFF ))
+ & roundNearEven);
+ } else {
+ if ( ! (sig64 | sig0) ) exp = 0;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ packReturn:
+ uiZ64 = packToF128UI64( sign, exp, sig64 );
+ uiZ0 = sig0;
+ uiZ:
+ uZ.ui.v64 = uiZ64;
+ uZ.ui.v0 = uiZ0;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_roundPackToF128.c ****/
+/**** start inlining ../../source/s_normRoundPackToF128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+
+float128_t
+ softfloat_normRoundPackToF128(
+ bool sign, int_fast32_t exp, uint_fast64_t sig64, uint_fast64_t sig0 )
+{
+ int_fast8_t shiftDist;
+ struct uint128 sig128;
+ union ui128_f128 uZ;
+ uint_fast64_t sigExtra;
+ struct uint128_extra sig128Extra;
+
+ if ( ! sig64 ) {
+ exp -= 64;
+ sig64 = sig0;
+ sig0 = 0;
+ }
+ shiftDist = softfloat_countLeadingZeros64( sig64 ) - 15;
+ exp -= shiftDist;
+ if ( 0 <= shiftDist ) {
+ if ( shiftDist ) {
+ sig128 = softfloat_shortShiftLeft128( sig64, sig0, shiftDist );
+ sig64 = sig128.v64;
+ sig0 = sig128.v0;
+ }
+ if ( (uint32_t) exp < 0x7FFD ) {
+ uZ.ui.v64 = packToF128UI64( sign, sig64 | sig0 ? exp : 0, sig64 );
+ uZ.ui.v0 = sig0;
+ return uZ.f;
+ }
+ sigExtra = 0;
+ } else {
+ sig128Extra =
+ softfloat_shortShiftRightJam128Extra( sig64, sig0, 0, -shiftDist );
+ sig64 = sig128Extra.v.v64;
+ sig0 = sig128Extra.v.v0;
+ sigExtra = sig128Extra.extra;
+ }
+ return softfloat_roundPackToF128( sign, exp, sig64, sig0, sigExtra );
+
+}
+
+/**** ended inlining ../../source/s_normRoundPackToF128.c ****/
+/**** start inlining ../../source/s_addMagsF128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014 The Regents of the University of California.
+All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+
+float128_t
+ softfloat_addMagsF128(
+ uint_fast64_t uiA64,
+ uint_fast64_t uiA0,
+ uint_fast64_t uiB64,
+ uint_fast64_t uiB0,
+ bool signZ
+ )
+{
+ int_fast32_t expA;
+ struct uint128 sigA;
+ int_fast32_t expB;
+ struct uint128 sigB;
+ int_fast32_t expDiff;
+ struct uint128 uiZ, sigZ;
+ int_fast32_t expZ;
+ uint_fast64_t sigZExtra;
+ struct uint128_extra sig128Extra;
+ union ui128_f128 uZ;
+
+ expA = expF128UI64( uiA64 );
+ sigA.v64 = fracF128UI64( uiA64 );
+ sigA.v0 = uiA0;
+ expB = expF128UI64( uiB64 );
+ sigB.v64 = fracF128UI64( uiB64 );
+ sigB.v0 = uiB0;
+ expDiff = expA - expB;
+ if ( ! expDiff ) {
+ if ( expA == 0x7FFF ) {
+ if ( sigA.v64 | sigA.v0 | sigB.v64 | sigB.v0 ) goto propagateNaN;
+ uiZ.v64 = uiA64;
+ uiZ.v0 = uiA0;
+ goto uiZ;
+ }
+ sigZ = softfloat_add128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 );
+ if ( ! expA ) {
+ uiZ.v64 = packToF128UI64( signZ, 0, sigZ.v64 );
+ uiZ.v0 = sigZ.v0;
+ goto uiZ;
+ }
+ expZ = expA;
+ sigZ.v64 |= UINT64_C( 0x0002000000000000 );
+ sigZExtra = 0;
+ goto shiftRight1;
+ }
+ if ( expDiff < 0 ) {
+ if ( expB == 0x7FFF ) {
+ if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
+ uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
+ uiZ.v0 = 0;
+ goto uiZ;
+ }
+ expZ = expB;
+ if ( expA ) {
+ sigA.v64 |= UINT64_C( 0x0001000000000000 );
+ } else {
+ ++expDiff;
+ sigZExtra = 0;
+ if ( ! expDiff ) goto newlyAligned;
+ }
+ sig128Extra =
+ softfloat_shiftRightJam128Extra( sigA.v64, sigA.v0, 0, -expDiff );
+ sigA = sig128Extra.v;
+ sigZExtra = sig128Extra.extra;
+ } else {
+ if ( expA == 0x7FFF ) {
+ if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
+ uiZ.v64 = uiA64;
+ uiZ.v0 = uiA0;
+ goto uiZ;
+ }
+ expZ = expA;
+ if ( expB ) {
+ sigB.v64 |= UINT64_C( 0x0001000000000000 );
+ } else {
+ --expDiff;
+ sigZExtra = 0;
+ if ( ! expDiff ) goto newlyAligned;
+ }
+ sig128Extra =
+ softfloat_shiftRightJam128Extra( sigB.v64, sigB.v0, 0, expDiff );
+ sigB = sig128Extra.v;
+ sigZExtra = sig128Extra.extra;
+ }
+ newlyAligned:
+ sigZ =
+ softfloat_add128(
+ sigA.v64 | UINT64_C( 0x0001000000000000 ),
+ sigA.v0,
+ sigB.v64,
+ sigB.v0
+ );
+ --expZ;
+ if ( sigZ.v64 < UINT64_C( 0x0002000000000000 ) ) goto roundAndPack;
+ ++expZ;
+ shiftRight1:
+ sig128Extra =
+ softfloat_shortShiftRightJam128Extra(
+ sigZ.v64, sigZ.v0, sigZExtra, 1 );
+ sigZ = sig128Extra.v;
+ sigZExtra = sig128Extra.extra;
+ roundAndPack:
+ return
+ softfloat_roundPackToF128( signZ, expZ, sigZ.v64, sigZ.v0, sigZExtra );
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_addMagsF128.c ****/
+/**** start inlining ../../source/s_subMagsF128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float128_t
+ softfloat_subMagsF128(
+ uint_fast64_t uiA64,
+ uint_fast64_t uiA0,
+ uint_fast64_t uiB64,
+ uint_fast64_t uiB0,
+ bool signZ
+ )
+{
+ int_fast32_t expA;
+ struct uint128 sigA;
+ int_fast32_t expB;
+ struct uint128 sigB, sigZ;
+ int_fast32_t expDiff, expZ;
+ struct uint128 uiZ;
+ union ui128_f128 uZ;
+
+ expA = expF128UI64( uiA64 );
+ sigA.v64 = fracF128UI64( uiA64 );
+ sigA.v0 = uiA0;
+ expB = expF128UI64( uiB64 );
+ sigB.v64 = fracF128UI64( uiB64 );
+ sigB.v0 = uiB0;
+ sigA = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 4 );
+ sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 4 );
+ expDiff = expA - expB;
+ if ( 0 < expDiff ) goto expABigger;
+ if ( expDiff < 0 ) goto expBBigger;
+ if ( expA == 0x7FFF ) {
+ if ( sigA.v64 | sigA.v0 | sigB.v64 | sigB.v0 ) goto propagateNaN;
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ.v64 = defaultNaNF128UI64;
+ uiZ.v0 = defaultNaNF128UI0;
+ goto uiZ;
+ }
+ expZ = expA;
+ if ( ! expZ ) expZ = 1;
+ if ( sigB.v64 < sigA.v64 ) goto aBigger;
+ if ( sigA.v64 < sigB.v64 ) goto bBigger;
+ if ( sigB.v0 < sigA.v0 ) goto aBigger;
+ if ( sigA.v0 < sigB.v0 ) goto bBigger;
+ uiZ.v64 =
+ packToF128UI64(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
+ uiZ.v0 = 0;
+ goto uiZ;
+ expBBigger:
+ if ( expB == 0x7FFF ) {
+ if ( sigB.v64 | sigB.v0 ) goto propagateNaN;
+ uiZ.v64 = packToF128UI64( signZ ^ 1, 0x7FFF, 0 );
+ uiZ.v0 = 0;
+ goto uiZ;
+ }
+ if ( expA ) {
+ sigA.v64 |= UINT64_C( 0x0010000000000000 );
+ } else {
+ ++expDiff;
+ if ( ! expDiff ) goto newlyAlignedBBigger;
+ }
+ sigA = softfloat_shiftRightJam128( sigA.v64, sigA.v0, -expDiff );
+ newlyAlignedBBigger:
+ expZ = expB;
+ sigB.v64 |= UINT64_C( 0x0010000000000000 );
+ bBigger:
+ signZ = ! signZ;
+ sigZ = softfloat_sub128( sigB.v64, sigB.v0, sigA.v64, sigA.v0 );
+ goto normRoundPack;
+ expABigger:
+ if ( expA == 0x7FFF ) {
+ if ( sigA.v64 | sigA.v0 ) goto propagateNaN;
+ uiZ.v64 = uiA64;
+ uiZ.v0 = uiA0;
+ goto uiZ;
+ }
+ if ( expB ) {
+ sigB.v64 |= UINT64_C( 0x0010000000000000 );
+ } else {
+ --expDiff;
+ if ( ! expDiff ) goto newlyAlignedABigger;
+ }
+ sigB = softfloat_shiftRightJam128( sigB.v64, sigB.v0, expDiff );
+ newlyAlignedABigger:
+ expZ = expA;
+ sigA.v64 |= UINT64_C( 0x0010000000000000 );
+ aBigger:
+ sigZ = softfloat_sub128( sigA.v64, sigA.v0, sigB.v64, sigB.v0 );
+ normRoundPack:
+ return softfloat_normRoundPackToF128( signZ, expZ - 5, sigZ.v64, sigZ.v0 );
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_subMagsF128.c ****/
+/**** start inlining ../../source/s_mulAddF128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float128_t
+ softfloat_mulAddF128(
+ uint_fast64_t uiA64,
+ uint_fast64_t uiA0,
+ uint_fast64_t uiB64,
+ uint_fast64_t uiB0,
+ uint_fast64_t uiC64,
+ uint_fast64_t uiC0,
+ uint_fast8_t op
+ )
+{
+ bool signA;
+ int_fast32_t expA;
+ struct uint128 sigA;
+ bool signB;
+ int_fast32_t expB;
+ struct uint128 sigB;
+ bool signC;
+ int_fast32_t expC;
+ struct uint128 sigC;
+ bool signZ;
+ uint_fast64_t magBits;
+ struct uint128 uiZ;
+ struct exp32_sig128 normExpSig;
+ int_fast32_t expZ;
+ uint64_t sig256Z[4];
+ struct uint128 sigZ;
+ int_fast32_t shiftDist, expDiff;
+ struct uint128 x128;
+ uint64_t sig256C[4];
+ static uint64_t zero256[4] = INIT_UINTM4( 0, 0, 0, 0 );
+ uint_fast64_t sigZExtra, sig256Z0;
+ union ui128_f128 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ signA = signF128UI64( uiA64 );
+ expA = expF128UI64( uiA64 );
+ sigA.v64 = fracF128UI64( uiA64 );
+ sigA.v0 = uiA0;
+ signB = signF128UI64( uiB64 );
+ expB = expF128UI64( uiB64 );
+ sigB.v64 = fracF128UI64( uiB64 );
+ sigB.v0 = uiB0;
+ signC = signF128UI64( uiC64 ) ^ (op == softfloat_mulAdd_subC);
+ expC = expF128UI64( uiC64 );
+ sigC.v64 = fracF128UI64( uiC64 );
+ sigC.v0 = uiC0;
+ signZ = signA ^ signB ^ (op == softfloat_mulAdd_subProd);
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x7FFF ) {
+ if (
+ (sigA.v64 | sigA.v0) || ((expB == 0x7FFF) && (sigB.v64 | sigB.v0))
+ ) {
+ goto propagateNaN_ABC;
+ }
+ magBits = expB | sigB.v64 | sigB.v0;
+ goto infProdArg;
+ }
+ if ( expB == 0x7FFF ) {
+ if ( sigB.v64 | sigB.v0 ) goto propagateNaN_ABC;
+ magBits = expA | sigA.v64 | sigA.v0;
+ goto infProdArg;
+ }
+ if ( expC == 0x7FFF ) {
+ if ( sigC.v64 | sigC.v0 ) {
+ uiZ.v64 = 0;
+ uiZ.v0 = 0;
+ goto propagateNaN_ZC;
+ }
+ uiZ.v64 = uiC64;
+ uiZ.v0 = uiC0;
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! (sigA.v64 | sigA.v0) ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF128Sig( sigA.v64, sigA.v0 );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ if ( ! expB ) {
+ if ( ! (sigB.v64 | sigB.v0) ) goto zeroProd;
+ normExpSig = softfloat_normSubnormalF128Sig( sigB.v64, sigB.v0 );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = expA + expB - 0x3FFE;
+ sigA.v64 |= UINT64_C( 0x0001000000000000 );
+ sigB.v64 |= UINT64_C( 0x0001000000000000 );
+ sigA = softfloat_shortShiftLeft128( sigA.v64, sigA.v0, 8 );
+ sigB = softfloat_shortShiftLeft128( sigB.v64, sigB.v0, 15 );
+ softfloat_mul128To256M( sigA.v64, sigA.v0, sigB.v64, sigB.v0, sig256Z );
+ sigZ.v64 = sig256Z[indexWord( 4, 3 )];
+ sigZ.v0 = sig256Z[indexWord( 4, 2 )];
+ shiftDist = 0;
+ if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
+ --expZ;
+ shiftDist = -1;
+ }
+ if ( ! expC ) {
+ if ( ! (sigC.v64 | sigC.v0) ) {
+ shiftDist += 8;
+ goto sigZ;
+ }
+ normExpSig = softfloat_normSubnormalF128Sig( sigC.v64, sigC.v0 );
+ expC = normExpSig.exp;
+ sigC = normExpSig.sig;
+ }
+ sigC.v64 |= UINT64_C( 0x0001000000000000 );
+ sigC = softfloat_shortShiftLeft128( sigC.v64, sigC.v0, 8 );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expDiff = expZ - expC;
+ if ( expDiff < 0 ) {
+ expZ = expC;
+ if ( (signZ == signC) || (expDiff < -1) ) {
+ shiftDist -= expDiff;
+ if ( shiftDist ) {
+ sigZ =
+ softfloat_shiftRightJam128( sigZ.v64, sigZ.v0, shiftDist );
+ }
+ } else {
+ if ( ! shiftDist ) {
+ x128 =
+ softfloat_shortShiftRight128(
+ sig256Z[indexWord( 4, 1 )], sig256Z[indexWord( 4, 0 )],
+ 1
+ );
+ sig256Z[indexWord( 4, 1 )] = (sigZ.v0<<63) | x128.v64;
+ sig256Z[indexWord( 4, 0 )] = x128.v0;
+ sigZ = softfloat_shortShiftRight128( sigZ.v64, sigZ.v0, 1 );
+ sig256Z[indexWord( 4, 3 )] = sigZ.v64;
+ sig256Z[indexWord( 4, 2 )] = sigZ.v0;
+ }
+ }
+ } else {
+ if ( shiftDist ) softfloat_add256M( sig256Z, sig256Z, sig256Z );
+ if ( ! expDiff ) {
+ sigZ.v64 = sig256Z[indexWord( 4, 3 )];
+ sigZ.v0 = sig256Z[indexWord( 4, 2 )];
+ } else {
+ sig256C[indexWord( 4, 3 )] = sigC.v64;
+ sig256C[indexWord( 4, 2 )] = sigC.v0;
+ sig256C[indexWord( 4, 1 )] = 0;
+ sig256C[indexWord( 4, 0 )] = 0;
+ softfloat_shiftRightJam256M( sig256C, expDiff, sig256C );
+ }
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ shiftDist = 8;
+ if ( signZ == signC ) {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expDiff <= 0 ) {
+ sigZ = softfloat_add128( sigC.v64, sigC.v0, sigZ.v64, sigZ.v0 );
+ } else {
+ softfloat_add256M( sig256Z, sig256C, sig256Z );
+ sigZ.v64 = sig256Z[indexWord( 4, 3 )];
+ sigZ.v0 = sig256Z[indexWord( 4, 2 )];
+ }
+ if ( sigZ.v64 & UINT64_C( 0x0200000000000000 ) ) {
+ ++expZ;
+ shiftDist = 9;
+ }
+ } else {
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ if ( expDiff < 0 ) {
+ signZ = signC;
+ if ( expDiff < -1 ) {
+ sigZ =
+ softfloat_sub128( sigC.v64, sigC.v0, sigZ.v64, sigZ.v0 );
+ sigZExtra =
+ sig256Z[indexWord( 4, 1 )] | sig256Z[indexWord( 4, 0 )];
+ if ( sigZExtra ) {
+ sigZ = softfloat_sub128( sigZ.v64, sigZ.v0, 0, 1 );
+ }
+ if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
+ --expZ;
+ shiftDist = 7;
+ }
+ goto shiftRightRoundPack;
+ } else {
+ sig256C[indexWord( 4, 3 )] = sigC.v64;
+ sig256C[indexWord( 4, 2 )] = sigC.v0;
+ sig256C[indexWord( 4, 1 )] = 0;
+ sig256C[indexWord( 4, 0 )] = 0;
+ softfloat_sub256M( sig256C, sig256Z, sig256Z );
+ }
+ } else if ( ! expDiff ) {
+ sigZ = softfloat_sub128( sigZ.v64, sigZ.v0, sigC.v64, sigC.v0 );
+ if (
+ ! (sigZ.v64 | sigZ.v0) && ! sig256Z[indexWord( 4, 1 )]
+ && ! sig256Z[indexWord( 4, 0 )]
+ ) {
+ goto completeCancellation;
+ }
+ sig256Z[indexWord( 4, 3 )] = sigZ.v64;
+ sig256Z[indexWord( 4, 2 )] = sigZ.v0;
+ if ( sigZ.v64 & UINT64_C( 0x8000000000000000 ) ) {
+ signZ = ! signZ;
+ softfloat_sub256M( zero256, sig256Z, sig256Z );
+ }
+ } else {
+ softfloat_sub256M( sig256Z, sig256C, sig256Z );
+ if ( 1 < expDiff ) {
+ sigZ.v64 = sig256Z[indexWord( 4, 3 )];
+ sigZ.v0 = sig256Z[indexWord( 4, 2 )];
+ if ( ! (sigZ.v64 & UINT64_C( 0x0100000000000000 )) ) {
+ --expZ;
+ shiftDist = 7;
+ }
+ goto sigZ;
+ }
+ }
+ /*--------------------------------------------------------------------
+ *--------------------------------------------------------------------*/
+ sigZ.v64 = sig256Z[indexWord( 4, 3 )];
+ sigZ.v0 = sig256Z[indexWord( 4, 2 )];
+ sigZExtra = sig256Z[indexWord( 4, 1 )];
+ sig256Z0 = sig256Z[indexWord( 4, 0 )];
+ if ( sigZ.v64 ) {
+ if ( sig256Z0 ) sigZExtra |= 1;
+ } else {
+ expZ -= 64;
+ sigZ.v64 = sigZ.v0;
+ sigZ.v0 = sigZExtra;
+ sigZExtra = sig256Z0;
+ if ( ! sigZ.v64 ) {
+ expZ -= 64;
+ sigZ.v64 = sigZ.v0;
+ sigZ.v0 = sigZExtra;
+ sigZExtra = 0;
+ if ( ! sigZ.v64 ) {
+ expZ -= 64;
+ sigZ.v64 = sigZ.v0;
+ sigZ.v0 = 0;
+ }
+ }
+ }
+ shiftDist = softfloat_countLeadingZeros64( sigZ.v64 );
+ expZ += 7 - shiftDist;
+ shiftDist = 15 - shiftDist;
+ if ( 0 < shiftDist ) goto shiftRightRoundPack;
+ if ( shiftDist ) {
+ shiftDist = -shiftDist;
+ sigZ = softfloat_shortShiftLeft128( sigZ.v64, sigZ.v0, shiftDist );
+ x128 = softfloat_shortShiftLeft128( 0, sigZExtra, shiftDist );
+ sigZ.v0 |= x128.v64;
+ sigZExtra = x128.v0;
+ }
+ goto roundPack;
+ }
+ sigZ:
+ sigZExtra = sig256Z[indexWord( 4, 1 )] | sig256Z[indexWord( 4, 0 )];
+ shiftRightRoundPack:
+ sigZExtra = (uint64_t) (sigZ.v0<<(64 - shiftDist)) | (sigZExtra != 0);
+ sigZ = softfloat_shortShiftRight128( sigZ.v64, sigZ.v0, shiftDist );
+ roundPack:
+ return
+ softfloat_roundPackToF128(
+ signZ, expZ - 1, sigZ.v64, sigZ.v0, sigZExtra );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN_ABC:
+ uiZ = softfloat_propagateNaNF128UI( uiA64, uiA0, uiB64, uiB0 );
+ goto propagateNaN_ZC;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infProdArg:
+ if ( magBits ) {
+ uiZ.v64 = packToF128UI64( signZ, 0x7FFF, 0 );
+ uiZ.v0 = 0;
+ if ( expC != 0x7FFF ) goto uiZ;
+ if ( sigC.v64 | sigC.v0 ) goto propagateNaN_ZC;
+ if ( signZ == signC ) goto uiZ;
+ }
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ.v64 = defaultNaNF128UI64;
+ uiZ.v0 = defaultNaNF128UI0;
+ propagateNaN_ZC:
+ uiZ = softfloat_propagateNaNF128UI( uiZ.v64, uiZ.v0, uiC64, uiC0 );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zeroProd:
+ uiZ.v64 = uiC64;
+ uiZ.v0 = uiC0;
+ if ( ! (expC | sigC.v64 | sigC.v0) && (signZ != signC) ) {
+ completeCancellation:
+ uiZ.v64 =
+ packToF128UI64(
+ (softfloat_roundingMode == softfloat_round_min), 0, 0 );
+ uiZ.v0 = 0;
+ }
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/s_mulAddF128.c ****/
+/**** start inlining ../../source/softfloat_state.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+#ifndef THREAD_LOCAL
+#define THREAD_LOCAL
+#endif
+
+THREAD_LOCAL uint_fast8_t softfloat_roundingMode = softfloat_round_near_even;
+THREAD_LOCAL uint_fast8_t softfloat_detectTininess = init_detectTininess;
+THREAD_LOCAL uint_fast8_t softfloat_exceptionFlags = 0;
+
+THREAD_LOCAL uint_fast8_t extF80_roundingPrecision = 80;
+
+/**** ended inlining ../../source/softfloat_state.c ****/
+/**** start inlining ../../source/ui32_to_f16.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t ui32_to_f16( uint32_t a )
+{
+ int_fast8_t shiftDist;
+ union ui16_f16 u;
+ uint_fast16_t sig;
+
+ shiftDist = softfloat_countLeadingZeros32( a ) - 21;
+ if ( 0 <= shiftDist ) {
+ u.ui =
+ a ? packToF16UI(
+ 0, 0x18 - shiftDist, (uint_fast16_t) a<>(-shiftDist) | ((uint32_t) (a<<(shiftDist & 31)) != 0)
+ : (uint_fast16_t) a<
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float32_t ui32_to_f32( uint32_t a )
+{
+ union ui32_f32 uZ;
+
+ if ( ! a ) {
+ uZ.ui = 0;
+ return uZ.f;
+ }
+ if ( a & 0x80000000 ) {
+ return softfloat_roundPackToF32( 0, 0x9D, a>>1 | (a & 1) );
+ } else {
+ return softfloat_normRoundPackToF32( 0, 0x9C, a );
+ }
+
+}
+
+/**** ended inlining ../../source/ui32_to_f32.c ****/
+/**** start inlining ../../source/ui32_to_f64.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float64_t ui32_to_f64( uint32_t a )
+{
+ uint_fast64_t uiZ;
+ int_fast8_t shiftDist;
+ union ui64_f64 uZ;
+
+ if ( ! a ) {
+ uiZ = 0;
+ } else {
+ shiftDist = softfloat_countLeadingZeros32( a ) + 21;
+ uiZ =
+ packToF64UI( 0, 0x432 - shiftDist, (uint_fast64_t) a<
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+extFloat80_t ui32_to_extF80( uint32_t a )
+{
+ uint_fast16_t uiZ64;
+ int_fast8_t shiftDist;
+ union { struct extFloat80M s; extFloat80_t f; } uZ;
+
+ uiZ64 = 0;
+ if ( a ) {
+ shiftDist = softfloat_countLeadingZeros32( a );
+ uiZ64 = 0x401E - shiftDist;
+ a <<= shiftDist;
+ }
+ uZ.s.signExp = uiZ64;
+ uZ.s.signif = (uint_fast64_t) a<<32;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/ui32_to_extF80.c ****/
+/**** start inlining ../../source/ui32_to_extF80M.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+void ui32_to_extF80M( uint32_t a, extFloat80_t *zPtr )
+{
+
+ *zPtr = ui32_to_extF80( a );
+
+}
+
+#else
+
+void ui32_to_extF80M( uint32_t a, extFloat80_t *zPtr )
+{
+ struct extFloat80M *zSPtr;
+ uint_fast16_t uiZ64;
+ uint64_t sigZ;
+ int_fast8_t shiftDist;
+
+ zSPtr = (struct extFloat80M *) zPtr;
+ uiZ64 = 0;
+ sigZ = 0;
+ if ( a ) {
+ shiftDist = softfloat_countLeadingZeros32( a );
+ uiZ64 = packToExtF80UI64( 0, 0x401E - shiftDist );
+ sigZ = (uint64_t) (a<signExp = uiZ64;
+ zSPtr->signif = sigZ;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/ui32_to_extF80M.c ****/
+/**** start inlining ../../source/ui32_to_f128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float128_t ui32_to_f128( uint32_t a )
+{
+ uint_fast64_t uiZ64;
+ int_fast8_t shiftDist;
+ union ui128_f128 uZ;
+
+ uiZ64 = 0;
+ if ( a ) {
+ shiftDist = softfloat_countLeadingZeros32( a ) + 17;
+ uiZ64 =
+ packToF128UI64(
+ 0, 0x402E - shiftDist, (uint_fast64_t) a<
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+void ui32_to_f128M( uint32_t a, float128_t *zPtr )
+{
+
+ *zPtr = ui32_to_f128( a );
+
+}
+
+#else
+
+void ui32_to_f128M( uint32_t a, float128_t *zPtr )
+{
+ uint32_t *zWPtr, uiZ96, uiZ64;
+ int_fast8_t shiftDist;
+ uint64_t normA;
+
+ zWPtr = (uint32_t *) zPtr;
+ uiZ96 = 0;
+ uiZ64 = 0;
+ if ( a ) {
+ shiftDist = softfloat_countLeadingZeros32( a ) + 17;
+ normA = (uint64_t) a<>32 );
+ uiZ64 = normA;
+ }
+ zWPtr[indexWord( 4, 3 )] = uiZ96;
+ zWPtr[indexWord( 4, 2 )] = uiZ64;
+ zWPtr[indexWord( 4, 1 )] = 0;
+ zWPtr[indexWord( 4, 0 )] = 0;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/ui32_to_f128M.c ****/
+/**** start inlining ../../source/ui64_to_f16.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t ui64_to_f16( uint64_t a )
+{
+ int_fast8_t shiftDist;
+ union ui16_f16 u;
+ uint_fast16_t sig;
+
+ shiftDist = softfloat_countLeadingZeros64( a ) - 53;
+ if ( 0 <= shiftDist ) {
+ u.ui =
+ a ? packToF16UI(
+ 0, 0x18 - shiftDist, (uint_fast16_t) a<
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float32_t ui64_to_f32( uint64_t a )
+{
+ int_fast8_t shiftDist;
+ union ui32_f32 u;
+ uint_fast32_t sig;
+
+ shiftDist = softfloat_countLeadingZeros64( a ) - 40;
+ if ( 0 <= shiftDist ) {
+ u.ui =
+ a ? packToF32UI(
+ 0, 0x95 - shiftDist, (uint_fast32_t) a<
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float64_t ui64_to_f64( uint64_t a )
+{
+ union ui64_f64 uZ;
+
+ if ( ! a ) {
+ uZ.ui = 0;
+ return uZ.f;
+ }
+ if ( a & UINT64_C( 0x8000000000000000 ) ) {
+ return
+ softfloat_roundPackToF64(
+ 0, 0x43D, softfloat_shortShiftRightJam64( a, 1 ) );
+ } else {
+ return softfloat_normRoundPackToF64( 0, 0x43C, a );
+ }
+
+}
+
+/**** ended inlining ../../source/ui64_to_f64.c ****/
+/**** start inlining ../../source/ui64_to_extF80.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+extFloat80_t ui64_to_extF80( uint64_t a )
+{
+ uint_fast16_t uiZ64;
+ int_fast8_t shiftDist;
+ union { struct extFloat80M s; extFloat80_t f; } uZ;
+
+ uiZ64 = 0;
+ if ( a ) {
+ shiftDist = softfloat_countLeadingZeros64( a );
+ uiZ64 = 0x403E - shiftDist;
+ a <<= shiftDist;
+ }
+ uZ.s.signExp = uiZ64;
+ uZ.s.signif = a;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/ui64_to_extF80.c ****/
+/**** start inlining ../../source/ui64_to_extF80M.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+void ui64_to_extF80M( uint64_t a, extFloat80_t *zPtr )
+{
+
+ *zPtr = ui64_to_extF80( a );
+
+}
+
+#else
+
+void ui64_to_extF80M( uint64_t a, extFloat80_t *zPtr )
+{
+ struct extFloat80M *zSPtr;
+ uint_fast16_t uiZ64;
+ uint64_t sigZ;
+ int_fast8_t shiftDist;
+
+ zSPtr = (struct extFloat80M *) zPtr;
+ uiZ64 = 0;
+ sigZ = 0;
+ if ( a ) {
+ shiftDist = softfloat_countLeadingZeros64( a );
+ uiZ64 = packToExtF80UI64( 0, 0x403E - shiftDist );
+ sigZ = a<signExp = uiZ64;
+ zSPtr->signif = sigZ;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/ui64_to_extF80M.c ****/
+/**** start inlining ../../source/ui64_to_f128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float128_t ui64_to_f128( uint64_t a )
+{
+ uint_fast64_t uiZ64, uiZ0;
+ int_fast8_t shiftDist;
+ struct uint128 zSig;
+ union ui128_f128 uZ;
+
+ if ( ! a ) {
+ uiZ64 = 0;
+ uiZ0 = 0;
+ } else {
+ shiftDist = softfloat_countLeadingZeros64( a ) + 49;
+ if ( 64 <= shiftDist ) {
+ zSig.v64 = a<<(shiftDist - 64);
+ zSig.v0 = 0;
+ } else {
+ zSig = softfloat_shortShiftLeft128( 0, a, shiftDist );
+ }
+ uiZ64 = packToF128UI64( 0, 0x406E - shiftDist, zSig.v64 );
+ uiZ0 = zSig.v0;
+ }
+ uZ.ui.v64 = uiZ64;
+ uZ.ui.v0 = uiZ0;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/ui64_to_f128.c ****/
+/**** start inlining ../../source/ui64_to_f128M.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All Rights Reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+void ui64_to_f128M( uint64_t a, float128_t *zPtr )
+{
+
+ *zPtr = ui64_to_f128( a );
+
+}
+
+#else
+
+void ui64_to_f128M( uint64_t a, float128_t *zPtr )
+{
+ uint32_t *zWPtr, uiZ96, uiZ64;
+ uint_fast8_t shiftDist;
+ uint32_t *ptr;
+
+ zWPtr = (uint32_t *) zPtr;
+ uiZ96 = 0;
+ uiZ64 = 0;
+ zWPtr[indexWord( 4, 1 )] = 0;
+ zWPtr[indexWord( 4, 0 )] = 0;
+ if ( a ) {
+ shiftDist = softfloat_countLeadingZeros64( a ) + 17;
+ if ( shiftDist < 32 ) {
+ ptr = zWPtr + indexMultiwordHi( 4, 3 );
+ ptr[indexWord( 3, 2 )] = 0;
+ ptr[indexWord( 3, 1 )] = a>>32;
+ ptr[indexWord( 3, 0 )] = a;
+ softfloat_shortShiftLeft96M( ptr, shiftDist, ptr );
+ ptr[indexWordHi( 3 )] =
+ packToF128UI96( 0, 0x404E - shiftDist, ptr[indexWordHi( 3 )] );
+ return;
+ }
+ a <<= shiftDist - 32;
+ uiZ96 = packToF128UI96( 0, 0x404E - shiftDist, a>>32 );
+ uiZ64 = a;
+ }
+ zWPtr[indexWord( 4, 3 )] = uiZ96;
+ zWPtr[indexWord( 4, 2 )] = uiZ64;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/ui64_to_f128M.c ****/
+/**** start inlining ../../source/i32_to_f16.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t i32_to_f16( int32_t a )
+{
+ bool sign;
+ uint_fast32_t absA;
+ int_fast8_t shiftDist;
+ union ui16_f16 u;
+ uint_fast16_t sig;
+
+ sign = (a < 0);
+ absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
+ shiftDist = softfloat_countLeadingZeros32( absA ) - 21;
+ if ( 0 <= shiftDist ) {
+ u.ui =
+ a ? packToF16UI(
+ sign, 0x18 - shiftDist, (uint_fast16_t) absA<>(-shiftDist)
+ | ((uint32_t) (absA<<(shiftDist & 31)) != 0)
+ : (uint_fast16_t) absA<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float32_t i32_to_f32( int32_t a )
+{
+ bool sign;
+ union ui32_f32 uZ;
+ uint_fast32_t absA;
+
+ sign = (a < 0);
+ if ( ! (a & 0x7FFFFFFF) ) {
+ uZ.ui = sign ? packToF32UI( 1, 0x9E, 0 ) : 0;
+ return uZ.f;
+ }
+ absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
+ return softfloat_normRoundPackToF32( sign, 0x9C, absA );
+
+}
+
+/**** ended inlining ../../source/i32_to_f32.c ****/
+/**** start inlining ../../source/i32_to_f64.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float64_t i32_to_f64( int32_t a )
+{
+ uint_fast64_t uiZ;
+ bool sign;
+ uint_fast32_t absA;
+ int_fast8_t shiftDist;
+ union ui64_f64 uZ;
+
+ if ( ! a ) {
+ uiZ = 0;
+ } else {
+ sign = (a < 0);
+ absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
+ shiftDist = softfloat_countLeadingZeros32( absA ) + 21;
+ uiZ =
+ packToF64UI(
+ sign, 0x432 - shiftDist, (uint_fast64_t) absA<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+extFloat80_t i32_to_extF80( int32_t a )
+{
+ uint_fast16_t uiZ64;
+ uint_fast32_t absA;
+ bool sign;
+ int_fast8_t shiftDist;
+ union { struct extFloat80M s; extFloat80_t f; } uZ;
+
+ uiZ64 = 0;
+ absA = 0;
+ if ( a ) {
+ sign = (a < 0);
+ absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
+ shiftDist = softfloat_countLeadingZeros32( absA );
+ uiZ64 = packToExtF80UI64( sign, 0x401E - shiftDist );
+ absA <<= shiftDist;
+ }
+ uZ.s.signExp = uiZ64;
+ uZ.s.signif = (uint_fast64_t) absA<<32;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/i32_to_extF80.c ****/
+/**** start inlining ../../source/i32_to_extF80M.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+void i32_to_extF80M( int32_t a, extFloat80_t *zPtr )
+{
+
+ *zPtr = i32_to_extF80( a );
+
+}
+
+#else
+
+void i32_to_extF80M( int32_t a, extFloat80_t *zPtr )
+{
+ struct extFloat80M *zSPtr;
+ uint_fast16_t uiZ64;
+ uint64_t sigZ;
+ bool sign;
+ uint32_t absA;
+ int_fast8_t shiftDist;
+
+ zSPtr = (struct extFloat80M *) zPtr;
+ uiZ64 = 0;
+ sigZ = 0;
+ if ( a ) {
+ sign = (a < 0);
+ absA = sign ? -(uint32_t) a : (uint32_t) a;
+ shiftDist = softfloat_countLeadingZeros32( absA );
+ uiZ64 = packToExtF80UI64( sign, 0x401E - shiftDist );
+ sigZ = (uint64_t) (absA<signExp = uiZ64;
+ zSPtr->signif = sigZ;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/i32_to_extF80M.c ****/
+/**** start inlining ../../source/i32_to_f128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float128_t i32_to_f128( int32_t a )
+{
+ uint_fast64_t uiZ64;
+ bool sign;
+ uint_fast32_t absA;
+ int_fast8_t shiftDist;
+ union ui128_f128 uZ;
+
+ uiZ64 = 0;
+ if ( a ) {
+ sign = (a < 0);
+ absA = sign ? -(uint_fast32_t) a : (uint_fast32_t) a;
+ shiftDist = softfloat_countLeadingZeros32( absA ) + 17;
+ uiZ64 =
+ packToF128UI64(
+ sign, 0x402E - shiftDist, (uint_fast64_t) absA<
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+void i32_to_f128M( int32_t a, float128_t *zPtr )
+{
+
+ *zPtr = i32_to_f128( a );
+
+}
+
+#else
+
+void i32_to_f128M( int32_t a, float128_t *zPtr )
+{
+ uint32_t *zWPtr;
+ uint32_t uiZ96, uiZ64;
+ bool sign;
+ uint32_t absA;
+ int_fast8_t shiftDist;
+ uint64_t normAbsA;
+
+ zWPtr = (uint32_t *) zPtr;
+ uiZ96 = 0;
+ uiZ64 = 0;
+ if ( a ) {
+ sign = (a < 0);
+ absA = sign ? -(uint32_t) a : (uint32_t) a;
+ shiftDist = softfloat_countLeadingZeros32( absA ) + 17;
+ normAbsA = (uint64_t) absA<>32 );
+ uiZ64 = normAbsA;
+ }
+ zWPtr[indexWord( 4, 3 )] = uiZ96;
+ zWPtr[indexWord( 4, 2 )] = uiZ64;
+ zWPtr[indexWord( 4, 1 )] = 0;
+ zWPtr[indexWord( 4, 0 )] = 0;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/i32_to_f128M.c ****/
+/**** start inlining ../../source/i64_to_f16.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t i64_to_f16( int64_t a )
+{
+ bool sign;
+ uint_fast64_t absA;
+ int_fast8_t shiftDist;
+ union ui16_f16 u;
+ uint_fast16_t sig;
+
+ sign = (a < 0);
+ absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
+ shiftDist = softfloat_countLeadingZeros64( absA ) - 53;
+ if ( 0 <= shiftDist ) {
+ u.ui =
+ a ? packToF16UI(
+ sign, 0x18 - shiftDist, (uint_fast16_t) absA<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float32_t i64_to_f32( int64_t a )
+{
+ bool sign;
+ uint_fast64_t absA;
+ int_fast8_t shiftDist;
+ union ui32_f32 u;
+ uint_fast32_t sig;
+
+ sign = (a < 0);
+ absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
+ shiftDist = softfloat_countLeadingZeros64( absA ) - 40;
+ if ( 0 <= shiftDist ) {
+ u.ui =
+ a ? packToF32UI(
+ sign, 0x95 - shiftDist, (uint_fast32_t) absA<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float64_t i64_to_f64( int64_t a )
+{
+ bool sign;
+ union ui64_f64 uZ;
+ uint_fast64_t absA;
+
+ sign = (a < 0);
+ if ( ! (a & UINT64_C( 0x7FFFFFFFFFFFFFFF )) ) {
+ uZ.ui = sign ? packToF64UI( 1, 0x43E, 0 ) : 0;
+ return uZ.f;
+ }
+ absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
+ return softfloat_normRoundPackToF64( sign, 0x43C, absA );
+
+}
+
+/**** ended inlining ../../source/i64_to_f64.c ****/
+/**** start inlining ../../source/i64_to_extF80.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+extFloat80_t i64_to_extF80( int64_t a )
+{
+ uint_fast16_t uiZ64;
+ uint_fast64_t absA;
+ bool sign;
+ int_fast8_t shiftDist;
+ union { struct extFloat80M s; extFloat80_t f; } uZ;
+
+ uiZ64 = 0;
+ absA = 0;
+ if ( a ) {
+ sign = (a < 0);
+ absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
+ shiftDist = softfloat_countLeadingZeros64( absA );
+ uiZ64 = packToExtF80UI64( sign, 0x403E - shiftDist );
+ absA <<= shiftDist;
+ }
+ uZ.s.signExp = uiZ64;
+ uZ.s.signif = absA;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/i64_to_extF80.c ****/
+/**** start inlining ../../source/i64_to_extF80M.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+void i64_to_extF80M( int64_t a, extFloat80_t *zPtr )
+{
+
+ *zPtr = i64_to_extF80( a );
+
+}
+
+#else
+
+void i64_to_extF80M( int64_t a, extFloat80_t *zPtr )
+{
+ struct extFloat80M *zSPtr;
+ uint_fast16_t uiZ64;
+ uint64_t sigZ;
+ bool sign;
+ uint64_t absA;
+ int_fast8_t shiftDist;
+
+ zSPtr = (struct extFloat80M *) zPtr;
+ uiZ64 = 0;
+ sigZ = 0;
+ if ( a ) {
+ sign = (a < 0);
+ absA = sign ? -(uint64_t) a : (uint64_t) a;
+ shiftDist = softfloat_countLeadingZeros64( absA );
+ uiZ64 = packToExtF80UI64( sign, 0x403E - shiftDist );
+ sigZ = absA<signExp = uiZ64;
+ zSPtr->signif = sigZ;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/i64_to_extF80M.c ****/
+/**** start inlining ../../source/i64_to_f128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float128_t i64_to_f128( int64_t a )
+{
+ uint_fast64_t uiZ64, uiZ0;
+ bool sign;
+ uint_fast64_t absA;
+ int_fast8_t shiftDist;
+ struct uint128 zSig;
+ union ui128_f128 uZ;
+
+ if ( ! a ) {
+ uiZ64 = 0;
+ uiZ0 = 0;
+ } else {
+ sign = (a < 0);
+ absA = sign ? -(uint_fast64_t) a : (uint_fast64_t) a;
+ shiftDist = softfloat_countLeadingZeros64( absA ) + 49;
+ if ( 64 <= shiftDist ) {
+ zSig.v64 = absA<<(shiftDist - 64);
+ zSig.v0 = 0;
+ } else {
+ zSig = softfloat_shortShiftLeft128( 0, absA, shiftDist );
+ }
+ uiZ64 = packToF128UI64( sign, 0x406E - shiftDist, zSig.v64 );
+ uiZ0 = zSig.v0;
+ }
+ uZ.ui.v64 = uiZ64;
+ uZ.ui.v0 = uiZ0;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/i64_to_f128.c ****/
+/**** start inlining ../../source/i64_to_f128M.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+void i64_to_f128M( int64_t a, float128_t *zPtr )
+{
+
+ *zPtr = i64_to_f128( a );
+
+}
+
+#else
+
+void i64_to_f128M( int64_t a, float128_t *zPtr )
+{
+ uint32_t *zWPtr;
+ uint32_t uiZ96, uiZ64;
+ bool sign;
+ uint64_t absA;
+ uint_fast8_t shiftDist;
+ uint32_t *ptr;
+
+ zWPtr = (uint32_t *) zPtr;
+ uiZ96 = 0;
+ uiZ64 = 0;
+ zWPtr[indexWord( 4, 1 )] = 0;
+ zWPtr[indexWord( 4, 0 )] = 0;
+ if ( a ) {
+ sign = (a < 0);
+ absA = sign ? -(uint64_t) a : (uint64_t) a;
+ shiftDist = softfloat_countLeadingZeros64( absA ) + 17;
+ if ( shiftDist < 32 ) {
+ ptr = zWPtr + indexMultiwordHi( 4, 3 );
+ ptr[indexWord( 3, 2 )] = 0;
+ ptr[indexWord( 3, 1 )] = absA>>32;
+ ptr[indexWord( 3, 0 )] = absA;
+ softfloat_shortShiftLeft96M( ptr, shiftDist, ptr );
+ ptr[indexWordHi( 3 )] =
+ packToF128UI96(
+ sign, 0x404E - shiftDist, ptr[indexWordHi( 3 )] );
+ return;
+ }
+ absA <<= shiftDist - 32;
+ uiZ96 = packToF128UI96( sign, 0x404E - shiftDist, absA>>32 );
+ uiZ64 = absA;
+ }
+ zWPtr[indexWord( 4, 3 )] = uiZ96;
+ zWPtr[indexWord( 4, 2 )] = uiZ64;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/i64_to_f128M.c ****/
+/**** start inlining ../../source/f16_to_ui32.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+uint_fast32_t f16_to_ui32( float16_t a, uint_fast8_t roundingMode, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ uint_fast32_t sig32;
+ int_fast8_t shiftDist;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ frac ? ui32_fromNaN
+ : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig32 = frac;
+ if ( exp ) {
+ sig32 |= 0x0400;
+ shiftDist = exp - 0x19;
+ if ( (0 <= shiftDist) && ! sign ) {
+ return sig32<
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+uint_fast64_t f16_to_ui64( float16_t a, uint_fast8_t roundingMode, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ uint_fast32_t sig32;
+ int_fast8_t shiftDist;
+#ifndef SOFTFLOAT_FAST_INT64
+ uint32_t extSig[3];
+#endif
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ frac ? ui64_fromNaN
+ : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig32 = frac;
+ if ( exp ) {
+ sig32 |= 0x0400;
+ shiftDist = exp - 0x19;
+ if ( (0 <= shiftDist) && ! sign ) {
+ return sig32<>12, (uint_fast64_t) sig32<<52, roundingMode, exact );
+#else
+ extSig[indexWord( 3, 2 )] = 0;
+ extSig[indexWord( 3, 1 )] = sig32>>12;
+ extSig[indexWord( 3, 0 )] = sig32<<20;
+ return softfloat_roundMToUI64( sign, extSig, roundingMode, exact );
+#endif
+
+}
+
+/**** ended inlining ../../source/f16_to_ui64.c ****/
+/**** start inlining ../../source/f16_to_i32.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+int_fast32_t f16_to_i32( float16_t a, uint_fast8_t roundingMode, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ int_fast32_t sig32;
+ int_fast8_t shiftDist;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ frac ? i32_fromNaN
+ : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig32 = frac;
+ if ( exp ) {
+ sig32 |= 0x0400;
+ shiftDist = exp - 0x19;
+ if ( 0 <= shiftDist ) {
+ sig32 <<= shiftDist;
+ return sign ? -sig32 : sig32;
+ }
+ shiftDist = exp - 0x0D;
+ if ( 0 < shiftDist ) sig32 <<= shiftDist;
+ }
+ return
+ softfloat_roundToI32(
+ sign, (uint_fast32_t) sig32, roundingMode, exact );
+
+}
+
+/**** ended inlining ../../source/f16_to_i32.c ****/
+/**** start inlining ../../source/f16_to_i64.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016, 2017 The Regents of the
+University of California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+int_fast64_t f16_to_i64( float16_t a, uint_fast8_t roundingMode, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ int_fast32_t sig32;
+ int_fast8_t shiftDist;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ frac ? i64_fromNaN
+ : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sig32 = frac;
+ if ( exp ) {
+ sig32 |= 0x0400;
+ shiftDist = exp - 0x19;
+ if ( 0 <= shiftDist ) {
+ sig32 <<= shiftDist;
+ return sign ? -sig32 : sig32;
+ }
+ shiftDist = exp - 0x0D;
+ if ( 0 < shiftDist ) sig32 <<= shiftDist;
+ }
+ return
+ softfloat_roundToI32(
+ sign, (uint_fast32_t) sig32, roundingMode, exact );
+
+}
+
+/**** ended inlining ../../source/f16_to_i64.c ****/
+/**** start inlining ../../source/f16_to_ui32_r_minMag.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+uint_fast32_t f16_to_ui32_r_minMag( float16_t a, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ int_fast8_t shiftDist;
+ bool sign;
+ uint_fast32_t alignedSig;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ shiftDist = exp - 0x0F;
+ if ( shiftDist < 0 ) {
+ if ( exact && (exp | frac) ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return 0;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sign = signF16UI( uiA );
+ if ( sign || (exp == 0x1F) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ (exp == 0x1F) && frac ? ui32_fromNaN
+ : sign ? ui32_fromNegOverflow : ui32_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ alignedSig = (uint_fast32_t) (frac | 0x0400)<>10;
+
+}
+
+/**** ended inlining ../../source/f16_to_ui32_r_minMag.c ****/
+/**** start inlining ../../source/f16_to_ui64_r_minMag.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+uint_fast64_t f16_to_ui64_r_minMag( float16_t a, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ int_fast8_t shiftDist;
+ bool sign;
+ uint_fast32_t alignedSig;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ shiftDist = exp - 0x0F;
+ if ( shiftDist < 0 ) {
+ if ( exact && (exp | frac) ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return 0;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sign = signF16UI( uiA );
+ if ( sign || (exp == 0x1F) ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ (exp == 0x1F) && frac ? ui64_fromNaN
+ : sign ? ui64_fromNegOverflow : ui64_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ alignedSig = (uint_fast32_t) (frac | 0x0400)<>10;
+
+}
+
+/**** ended inlining ../../source/f16_to_ui64_r_minMag.c ****/
+/**** start inlining ../../source/f16_to_i32_r_minMag.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+int_fast32_t f16_to_i32_r_minMag( float16_t a, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ int_fast8_t shiftDist;
+ bool sign;
+ int_fast32_t alignedSig;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ shiftDist = exp - 0x0F;
+ if ( shiftDist < 0 ) {
+ if ( exact && (exp | frac) ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return 0;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sign = signF16UI( uiA );
+ if ( exp == 0x1F ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ (exp == 0x1F) && frac ? i32_fromNaN
+ : sign ? i32_fromNegOverflow : i32_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ alignedSig = (int_fast32_t) (frac | 0x0400)<>= 10;
+ return sign ? -alignedSig : alignedSig;
+
+}
+
+/**** ended inlining ../../source/f16_to_i32_r_minMag.c ****/
+/**** start inlining ../../source/f16_to_i64_r_minMag.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+int_fast64_t f16_to_i64_r_minMag( float16_t a, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ int_fast8_t shiftDist;
+ bool sign;
+ int_fast32_t alignedSig;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ shiftDist = exp - 0x0F;
+ if ( shiftDist < 0 ) {
+ if ( exact && (exp | frac) ) {
+ softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ return 0;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ sign = signF16UI( uiA );
+ if ( exp == 0x1F ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ return
+ (exp == 0x1F) && frac ? i64_fromNaN
+ : sign ? i64_fromNegOverflow : i64_fromPosOverflow;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ alignedSig = (int_fast32_t) (frac | 0x0400)<>= 10;
+ return sign ? -alignedSig : alignedSig;
+
+}
+
+/**** ended inlining ../../source/f16_to_i64_r_minMag.c ****/
+/**** start inlining ../../source/f16_to_f32.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float32_t f16_to_f32( float16_t a )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ struct commonNaN commonNaN;
+ uint_fast32_t uiZ;
+ struct exp8_sig16 normExpSig;
+ union ui32_f32 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ if ( frac ) {
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
+ uiZ = softfloat_commonNaNToF32UI( &commonNaN );
+ } else {
+ uiZ = packToF32UI( sign, 0xFF, 0 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! exp ) {
+ if ( ! frac ) {
+ uiZ = packToF32UI( sign, 0, 0 );
+ goto uiZ;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
+ exp = normExpSig.exp - 1;
+ frac = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ = packToF32UI( sign, exp + 0x70, (uint_fast32_t) frac<<13 );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/f16_to_f32.c ****/
+/**** start inlining ../../source/f16_to_f64.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float64_t f16_to_f64( float16_t a )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ struct commonNaN commonNaN;
+ uint_fast64_t uiZ;
+ struct exp8_sig16 normExpSig;
+ union ui64_f64 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ if ( frac ) {
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
+ uiZ = softfloat_commonNaNToF64UI( &commonNaN );
+ } else {
+ uiZ = packToF64UI( sign, 0x7FF, 0 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! exp ) {
+ if ( ! frac ) {
+ uiZ = packToF64UI( sign, 0, 0 );
+ goto uiZ;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
+ exp = normExpSig.exp - 1;
+ frac = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ = packToF64UI( sign, exp + 0x3F0, (uint_fast64_t) frac<<42 );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/f16_to_f64.c ****/
+/**** start inlining ../../source/f16_to_extF80.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+extFloat80_t f16_to_extF80( float16_t a )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ struct commonNaN commonNaN;
+ struct uint128 uiZ;
+ uint_fast16_t uiZ64;
+ uint_fast64_t uiZ0;
+ struct exp8_sig16 normExpSig;
+ union { struct extFloat80M s; extFloat80_t f; } uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ if ( frac ) {
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
+ uiZ = softfloat_commonNaNToExtF80UI( &commonNaN );
+ uiZ64 = uiZ.v64;
+ uiZ0 = uiZ.v0;
+ } else {
+ uiZ64 = packToExtF80UI64( sign, 0x7FFF );
+ uiZ0 = UINT64_C( 0x8000000000000000 );
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! exp ) {
+ if ( ! frac ) {
+ uiZ64 = packToExtF80UI64( sign, 0 );
+ uiZ0 = 0;
+ goto uiZ;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
+ exp = normExpSig.exp;
+ frac = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ64 = packToExtF80UI64( sign, exp + 0x3FF0 );
+ uiZ0 = (uint_fast64_t) (frac | 0x0400)<<53;
+ uiZ:
+ uZ.s.signExp = uiZ64;
+ uZ.s.signif = uiZ0;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/f16_to_extF80.c ****/
+/**** start inlining ../../source/f16_to_extF80M.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+void f16_to_extF80M( float16_t a, extFloat80_t *zPtr )
+{
+
+ *zPtr = f16_to_extF80( a );
+
+}
+
+#else
+
+void f16_to_extF80M( float16_t a, extFloat80_t *zPtr )
+{
+ struct extFloat80M *zSPtr;
+ union ui16_f16 uA;
+ uint16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint16_t frac;
+ struct commonNaN commonNaN;
+ uint_fast16_t uiZ64;
+ uint32_t uiZ32;
+ struct exp8_sig16 normExpSig;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zSPtr = (struct extFloat80M *) zPtr;
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ if ( frac ) {
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
+ softfloat_commonNaNToExtF80M( &commonNaN, zSPtr );
+ return;
+ }
+ uiZ64 = packToExtF80UI64( sign, 0x7FFF );
+ uiZ32 = 0x80000000;
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! exp ) {
+ if ( ! frac ) {
+ uiZ64 = packToExtF80UI64( sign, 0 );
+ uiZ32 = 0;
+ goto uiZ;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
+ exp = normExpSig.exp;
+ frac = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ64 = packToExtF80UI64( sign, exp + 0x3FF0 );
+ uiZ32 = 0x80000000 | (uint32_t) frac<<21;
+ uiZ:
+ zSPtr->signExp = uiZ64;
+ zSPtr->signif = (uint64_t) uiZ32<<32;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/f16_to_extF80M.c ****/
+/**** start inlining ../../source/f16_to_f128.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float128_t f16_to_f128( float16_t a )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint_fast16_t frac;
+ struct commonNaN commonNaN;
+ struct uint128 uiZ;
+ struct exp8_sig16 normExpSig;
+ union ui128_f128 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ if ( frac ) {
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
+ uiZ = softfloat_commonNaNToF128UI( &commonNaN );
+ } else {
+ uiZ.v64 = packToF128UI64( sign, 0x7FFF, 0 );
+ uiZ.v0 = 0;
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! exp ) {
+ if ( ! frac ) {
+ uiZ.v64 = packToF128UI64( sign, 0, 0 );
+ uiZ.v0 = 0;
+ goto uiZ;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
+ exp = normExpSig.exp - 1;
+ frac = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ.v64 = packToF128UI64( sign, exp + 0x3FF0, (uint_fast64_t) frac<<38 );
+ uiZ.v0 = 0;
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/f16_to_f128.c ****/
+/**** start inlining ../../source/f16_to_f128M.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+#ifdef SOFTFLOAT_FAST_INT64
+
+void f16_to_f128M( float16_t a, float128_t *zPtr )
+{
+
+ *zPtr = f16_to_f128( a );
+
+}
+
+#else
+
+void f16_to_f128M( float16_t a, float128_t *zPtr )
+{
+ uint32_t *zWPtr;
+ union ui16_f16 uA;
+ uint16_t uiA;
+ bool sign;
+ int_fast8_t exp;
+ uint16_t frac;
+ struct commonNaN commonNaN;
+ uint32_t uiZ96;
+ struct exp8_sig16 normExpSig;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zWPtr = (uint32_t *) zPtr;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ sign = signF16UI( uiA );
+ exp = expF16UI( uiA );
+ frac = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp == 0x1F ) {
+ if ( frac ) {
+ softfloat_f16UIToCommonNaN( uiA, &commonNaN );
+ softfloat_commonNaNToF128M( &commonNaN, zWPtr );
+ return;
+ }
+ uiZ96 = packToF128UI96( sign, 0x7FFF, 0 );
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! exp ) {
+ if ( ! frac ) {
+ uiZ96 = packToF128UI96( sign, 0, 0 );
+ goto uiZ;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( frac );
+ exp = normExpSig.exp - 1;
+ frac = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ96 = packToF128UI96( sign, exp + 0x3FF0, (uint32_t) frac<<6 );
+ uiZ:
+ zWPtr[indexWord( 4, 3 )] = uiZ96;
+ zWPtr[indexWord( 4, 2 )] = 0;
+ zWPtr[indexWord( 4, 1 )] = 0;
+ zWPtr[indexWord( 4, 0 )] = 0;
+
+}
+
+#endif
+
+/**** ended inlining ../../source/f16_to_f128M.c ****/
+/**** start inlining ../../source/f16_roundToInt.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2017 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t f16_roundToInt( float16_t a, uint_fast8_t roundingMode, bool exact )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ int_fast8_t exp;
+ uint_fast16_t uiZ, lastBitMask, roundBitsMask;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ exp = expF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( exp <= 0xE ) {
+ if ( !(uint16_t) (uiA<<1) ) return a;
+ if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
+ uiZ = uiA & packToF16UI( 1, 0, 0 );
+ switch ( roundingMode ) {
+ case softfloat_round_near_even:
+ if ( !fracF16UI( uiA ) ) break;
+ case softfloat_round_near_maxMag:
+ if ( exp == 0xE ) uiZ |= packToF16UI( 0, 0xF, 0 );
+ break;
+ case softfloat_round_min:
+ if ( uiZ ) uiZ = packToF16UI( 1, 0xF, 0 );
+ break;
+ case softfloat_round_max:
+ if ( !uiZ ) uiZ = packToF16UI( 0, 0xF, 0 );
+ break;
+#ifdef SOFTFLOAT_ROUND_ODD
+ case softfloat_round_odd:
+ uiZ |= packToF16UI( 0, 0xF, 0 );
+ break;
+#endif
+ }
+ goto uiZ;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( 0x19 <= exp ) {
+ if ( (exp == 0x1F) && fracF16UI( uiA ) ) {
+ uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
+ goto uiZ;
+ }
+ return a;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uiZ = uiA;
+ lastBitMask = (uint_fast16_t) 1<<(0x19 - exp);
+ roundBitsMask = lastBitMask - 1;
+ if ( roundingMode == softfloat_round_near_maxMag ) {
+ uiZ += lastBitMask>>1;
+ } else if ( roundingMode == softfloat_round_near_even ) {
+ uiZ += lastBitMask>>1;
+ if ( !(uiZ & roundBitsMask) ) uiZ &= ~lastBitMask;
+ } else if (
+ roundingMode
+ == (signF16UI( uiZ ) ? softfloat_round_min : softfloat_round_max)
+ ) {
+ uiZ += roundBitsMask;
+ }
+ uiZ &= ~roundBitsMask;
+ if ( uiZ != uiA ) {
+#ifdef SOFTFLOAT_ROUND_ODD
+ if ( roundingMode == softfloat_round_odd ) uiZ |= lastBitMask;
+#endif
+ if ( exact ) softfloat_exceptionFlags |= softfloat_flag_inexact;
+ }
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/f16_roundToInt.c ****/
+/**** start inlining ../../source/f16_add.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t f16_add( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
+ float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
+#endif
+
+ uA.f = a;
+ uiA = uA.ui;
+ uB.f = b;
+ uiB = uB.ui;
+#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
+ if ( signF16UI( uiA ^ uiB ) ) {
+ return softfloat_subMagsF16( uiA, uiB );
+ } else {
+ return softfloat_addMagsF16( uiA, uiB );
+ }
+#else
+ magsFuncPtr =
+ signF16UI( uiA ^ uiB ) ? softfloat_subMagsF16 : softfloat_addMagsF16;
+ return (*magsFuncPtr)( uiA, uiB );
+#endif
+
+}
+
+/**** ended inlining ../../source/f16_add.c ****/
+/**** start inlining ../../source/f16_sub.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t f16_sub( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+#if ! defined INLINE_LEVEL || (INLINE_LEVEL < 1)
+ float16_t (*magsFuncPtr)( uint_fast16_t, uint_fast16_t );
+#endif
+
+ uA.f = a;
+ uiA = uA.ui;
+ uB.f = b;
+ uiB = uB.ui;
+#if defined INLINE_LEVEL && (1 <= INLINE_LEVEL)
+ if ( signF16UI( uiA ^ uiB ) ) {
+ return softfloat_addMagsF16( uiA, uiB );
+ } else {
+ return softfloat_subMagsF16( uiA, uiB );
+ }
+#else
+ magsFuncPtr =
+ signF16UI( uiA ^ uiB ) ? softfloat_addMagsF16 : softfloat_subMagsF16;
+ return (*magsFuncPtr)( uiA, uiB );
+#endif
+
+}
+
+/**** ended inlining ../../source/f16_sub.c ****/
+/**** start inlining ../../source/f16_mul.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t f16_mul( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool signA;
+ int_fast8_t expA;
+ uint_fast16_t sigA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+ bool signB;
+ int_fast8_t expB;
+ uint_fast16_t sigB;
+ bool signZ;
+ uint_fast16_t magBits;
+ struct exp8_sig16 normExpSig;
+ int_fast8_t expZ;
+ uint_fast32_t sig32Z;
+ uint_fast16_t sigZ, uiZ;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ signA = signF16UI( uiA );
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ uB.f = b;
+ uiB = uB.ui;
+ signB = signF16UI( uiB );
+ expB = expF16UI( uiB );
+ sigB = fracF16UI( uiB );
+ signZ = signA ^ signB;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x1F ) {
+ if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
+ magBits = expB | sigB;
+ goto infArg;
+ }
+ if ( expB == 0x1F ) {
+ if ( sigB ) goto propagateNaN;
+ magBits = expA | sigA;
+ goto infArg;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) goto zero;
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ if ( ! expB ) {
+ if ( ! sigB ) goto zero;
+ normExpSig = softfloat_normSubnormalF16Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = expA + expB - 0xF;
+ sigA = (sigA | 0x0400)<<4;
+ sigB = (sigB | 0x0400)<<5;
+ sig32Z = (uint_fast32_t) sigA * sigB;
+ sigZ = sig32Z>>16;
+ if ( sig32Z & 0xFFFF ) sigZ |= 1;
+ if ( sigZ < 0x4000 ) {
+ --expZ;
+ sigZ <<= 1;
+ }
+ return softfloat_roundPackToF16( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infArg:
+ if ( ! magBits ) {
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF16UI;
+ } else {
+ uiZ = packToF16UI( signZ, 0x1F, 0 );
+ }
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zero:
+ uiZ = packToF16UI( signZ, 0, 0 );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/f16_mul.c ****/
+/**** start inlining ../../source/f16_mulAdd.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t f16_mulAdd( float16_t a, float16_t b, float16_t c )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+ union ui16_f16 uC;
+ uint_fast16_t uiC;
+
+ uA.f = a;
+ uiA = uA.ui;
+ uB.f = b;
+ uiB = uB.ui;
+ uC.f = c;
+ uiC = uC.ui;
+ return softfloat_mulAddF16( uiA, uiB, uiC, 0 );
+
+}
+
+/**** ended inlining ../../source/f16_mulAdd.c ****/
+/**** start inlining ../../source/f16_div.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+extern const uint16_t softfloat_approxRecip_1k0s[];
+extern const uint16_t softfloat_approxRecip_1k1s[];
+
+float16_t f16_div( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool signA;
+ int_fast8_t expA;
+ uint_fast16_t sigA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+ bool signB;
+ int_fast8_t expB;
+ uint_fast16_t sigB;
+ bool signZ;
+ struct exp8_sig16 normExpSig;
+ int_fast8_t expZ;
+#ifdef SOFTFLOAT_FAST_DIV32TO16
+ uint_fast32_t sig32A;
+ uint_fast16_t sigZ;
+#else
+ int index;
+ uint16_t r0;
+ uint_fast16_t sigZ, rem;
+#endif
+ uint_fast16_t uiZ;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ signA = signF16UI( uiA );
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ uB.f = b;
+ uiB = uB.ui;
+ signB = signF16UI( uiB );
+ expB = expF16UI( uiB );
+ sigB = fracF16UI( uiB );
+ signZ = signA ^ signB;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x1F ) {
+ if ( sigA ) goto propagateNaN;
+ if ( expB == 0x1F ) {
+ if ( sigB ) goto propagateNaN;
+ goto invalid;
+ }
+ goto infinity;
+ }
+ if ( expB == 0x1F ) {
+ if ( sigB ) goto propagateNaN;
+ goto zero;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expB ) {
+ if ( ! sigB ) {
+ if ( ! (expA | sigA) ) goto invalid;
+ softfloat_raiseFlags( softfloat_flag_infinite );
+ goto infinity;
+ }
+ normExpSig = softfloat_normSubnormalF16Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ if ( ! expA ) {
+ if ( ! sigA ) goto zero;
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = expA - expB + 0xE;
+ sigA |= 0x0400;
+ sigB |= 0x0400;
+#ifdef SOFTFLOAT_FAST_DIV32TO16
+ if ( sigA < sigB ) {
+ --expZ;
+ sig32A = (uint_fast32_t) sigA<<15;
+ } else {
+ sig32A = (uint_fast32_t) sigA<<14;
+ }
+ sigZ = sig32A / sigB;
+ if ( ! (sigZ & 7) ) sigZ |= ((uint_fast32_t) sigB * sigZ != sig32A);
+#else
+ if ( sigA < sigB ) {
+ --expZ;
+ sigA <<= 5;
+ } else {
+ sigA <<= 4;
+ }
+ index = sigB>>6 & 0xF;
+ r0 = softfloat_approxRecip_1k0s[index]
+ - (((uint_fast32_t) softfloat_approxRecip_1k1s[index]
+ * (sigB & 0x3F))
+ >>10);
+ sigZ = ((uint_fast32_t) sigA * r0)>>16;
+ rem = (sigA<<10) - sigZ * sigB;
+ sigZ += (rem * (uint_fast32_t) r0)>>26;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ ++sigZ;
+ if ( ! (sigZ & 7) ) {
+ sigZ &= ~1;
+ rem = (sigA<<10) - sigZ * sigB;
+ if ( rem & 0x8000 ) {
+ sigZ -= 2;
+ } else {
+ if ( rem ) sigZ |= 1;
+ }
+ }
+#endif
+ return softfloat_roundPackToF16( signZ, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ invalid:
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF16UI;
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ infinity:
+ uiZ = packToF16UI( signZ, 0x1F, 0 );
+ goto uiZ;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ zero:
+ uiZ = packToF16UI( signZ, 0, 0 );
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/f16_div.c ****/
+/**** start inlining ../../source/f16_rem.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+float16_t f16_rem( float16_t a, float16_t b )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool signA;
+ int_fast8_t expA;
+ uint_fast16_t sigA;
+ union ui16_f16 uB;
+ uint_fast16_t uiB;
+ int_fast8_t expB;
+ uint_fast16_t sigB;
+ struct exp8_sig16 normExpSig;
+ uint16_t rem;
+ int_fast8_t expDiff;
+ uint_fast16_t q;
+ uint32_t recip32, q32;
+ uint16_t altRem, meanRem;
+ bool signRem;
+ uint_fast16_t uiZ;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ signA = signF16UI( uiA );
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ uB.f = b;
+ uiB = uB.ui;
+ expB = expF16UI( uiB );
+ sigB = fracF16UI( uiB );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x1F ) {
+ if ( sigA || ((expB == 0x1F) && sigB) ) goto propagateNaN;
+ goto invalid;
+ }
+ if ( expB == 0x1F ) {
+ if ( sigB ) goto propagateNaN;
+ return a;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expB ) {
+ if ( ! sigB ) goto invalid;
+ normExpSig = softfloat_normSubnormalF16Sig( sigB );
+ expB = normExpSig.exp;
+ sigB = normExpSig.sig;
+ }
+ if ( ! expA ) {
+ if ( ! sigA ) return a;
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ rem = sigA | 0x0400;
+ sigB |= 0x0400;
+ expDiff = expA - expB;
+ if ( expDiff < 1 ) {
+ if ( expDiff < -1 ) return a;
+ sigB <<= 3;
+ if ( expDiff ) {
+ rem <<= 2;
+ q = 0;
+ } else {
+ rem <<= 3;
+ q = (sigB <= rem);
+ if ( q ) rem -= sigB;
+ }
+ } else {
+ recip32 = softfloat_approxRecip32_1( (uint_fast32_t) sigB<<21 );
+ /*--------------------------------------------------------------------
+ | Changing the shift of `rem' here requires also changing the initial
+ | subtraction from `expDiff'.
+ *--------------------------------------------------------------------*/
+ rem <<= 4;
+ expDiff -= 31;
+ /*--------------------------------------------------------------------
+ | The scale of `sigB' affects how many bits are obtained during each
+ | cycle of the loop. Currently this is 29 bits per loop iteration,
+ | which is believed to be the maximum possible.
+ *--------------------------------------------------------------------*/
+ sigB <<= 3;
+ for (;;) {
+ q32 = (rem * (uint_fast64_t) recip32)>>16;
+ if ( expDiff < 0 ) break;
+ rem = -((uint_fast16_t) q32 * sigB);
+ expDiff -= 29;
+ }
+ /*--------------------------------------------------------------------
+ | (`expDiff' cannot be less than -30 here.)
+ *--------------------------------------------------------------------*/
+ q32 >>= ~expDiff & 31;
+ q = q32;
+ rem = (rem<<(expDiff + 30)) - q * sigB;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ do {
+ altRem = rem;
+ ++q;
+ rem -= sigB;
+ } while ( ! (rem & 0x8000) );
+ meanRem = rem + altRem;
+ if ( (meanRem & 0x8000) || (! meanRem && (q & 1)) ) rem = altRem;
+ signRem = signA;
+ if ( 0x8000 <= rem ) {
+ signRem = ! signRem;
+ rem = -rem;
+ }
+ return softfloat_normRoundPackToF16( signRem, expB, rem );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ propagateNaN:
+ uiZ = softfloat_propagateNaNF16UI( uiA, uiB );
+ goto uiZ;
+ invalid:
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF16UI;
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/f16_rem.c ****/
+/**** start inlining ../../source/f16_sqrt.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015, 2016 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include
+/**** skipping file: platform.h ****/
+/**** skipping file: internals.h ****/
+/**** skipping file: specialize.h ****/
+/**** skipping file: softfloat.h ****/
+
+extern const uint16_t softfloat_approxRecipSqrt_1k0s[];
+extern const uint16_t softfloat_approxRecipSqrt_1k1s[];
+
+float16_t f16_sqrt( float16_t a )
+{
+ union ui16_f16 uA;
+ uint_fast16_t uiA;
+ bool signA;
+ int_fast8_t expA;
+ uint_fast16_t sigA, uiZ;
+ struct exp8_sig16 normExpSig;
+ int_fast8_t expZ;
+ int index;
+ uint_fast16_t r0;
+ uint_fast32_t ESqrR0;
+ uint16_t sigma0;
+ uint_fast16_t recipSqrt16, sigZ, shiftedSigZ;
+ uint16_t negRem;
+ union ui16_f16 uZ;
+
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ uA.f = a;
+ uiA = uA.ui;
+ signA = signF16UI( uiA );
+ expA = expF16UI( uiA );
+ sigA = fracF16UI( uiA );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( expA == 0x1F ) {
+ if ( sigA ) {
+ uiZ = softfloat_propagateNaNF16UI( uiA, 0 );
+ goto uiZ;
+ }
+ if ( ! signA ) return a;
+ goto invalid;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( signA ) {
+ if ( ! (expA | sigA) ) return a;
+ goto invalid;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ if ( ! expA ) {
+ if ( ! sigA ) return a;
+ normExpSig = softfloat_normSubnormalF16Sig( sigA );
+ expA = normExpSig.exp;
+ sigA = normExpSig.sig;
+ }
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ expZ = ((expA - 0xF)>>1) + 0xE;
+ expA &= 1;
+ sigA |= 0x0400;
+ index = (sigA>>6 & 0xE) + expA;
+ r0 = softfloat_approxRecipSqrt_1k0s[index]
+ - (((uint_fast32_t) softfloat_approxRecipSqrt_1k1s[index]
+ * (sigA & 0x7F))
+ >>11);
+ ESqrR0 = ((uint_fast32_t) r0 * r0)>>1;
+ if ( expA ) ESqrR0 >>= 1;
+ sigma0 = ~(uint_fast16_t) ((ESqrR0 * sigA)>>16);
+ recipSqrt16 = r0 + (((uint_fast32_t) r0 * sigma0)>>25);
+ if ( ! (recipSqrt16 & 0x8000) ) recipSqrt16 = 0x8000;
+ sigZ = ((uint_fast32_t) (sigA<<5) * recipSqrt16)>>16;
+ if ( expA ) sigZ >>= 1;
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ ++sigZ;
+ if ( ! (sigZ & 7) ) {
+ shiftedSigZ = sigZ>>1;
+ negRem = shiftedSigZ * shiftedSigZ;
+ sigZ &= ~1;
+ if ( negRem & 0x8000 ) {
+ sigZ |= 1;
+ } else {
+ if ( negRem ) --sigZ;
+ }
+ }
+ return softfloat_roundPackToF16( 0, expZ, sigZ );
+ /*------------------------------------------------------------------------
+ *------------------------------------------------------------------------*/
+ invalid:
+ softfloat_raiseFlags( softfloat_flag_invalid );
+ uiZ = defaultNaNF16UI;
+ uiZ:
+ uZ.ui = uiZ;
+ return uZ.f;
+
+}
+
+/**** ended inlining ../../source/f16_sqrt.c ****/
+/**** start inlining ../../source/f16_eq.c ****/
+
+/*============================================================================
+
+This C source file is part of the SoftFloat IEEE Floating-Point Arithmetic
+Package, Release 3e, by John R. Hauser.
+
+Copyright 2011, 2012, 2013, 2014, 2015 The Regents of the University of
+California. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+
+ 1. Redistributions of source code must retain the above copyright notice,
+ this list of conditions, and the following disclaimer.
+
+ 2. Redistributions in binary form must reproduce the above copyright notice,
+ this list of conditions, and the following disclaimer in the documentation
+ and/or other materials provided with the distribution.
+
+ 3. Neither the name of the University nor the names of its contributors may
+ be used to endorse or promote products derived from this software without
+ specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS "AS IS", AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE, ARE
+DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+=============================================================================*/
+
+#include
+#include